Refactored Array, Code to be Objects. Removed Object tagging.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #include "FixedArray.h"
24 static const unsigned kMaxFixedArrayLength = ((INT_MAX - sizeof(FixedArray)) / sizeof(jc::Object *));
27 FixedArray::init(unsigned length)
29 WRITE_FIELD(length, length);
33 FixedArray::New(Zone *zone, unsigned length, Heap::Tenure tenure)
36 if (length >= kMaxFixedArrayLength) {
41 Object *obj = zone->allocate(MapKind_FixedArray, SizeFor(length), tenure);
45 FixedArray *array = FixedArray::cast(obj);
51 ByteArray::init(unsigned length)
53 WRITE_FIELD(length, length);
57 ByteArray::New(Zone *zone, unsigned length, Heap::Tenure tenure)
60 if (length >= kMaxFixedArrayLength) {
65 Object *obj = zone->allocate(MapKind_ByteArray, SizeFor(length), tenure);
69 ByteArray *array = ByteArray::cast(obj);