return i::Handle<i::FixedArray>();
}
int new_size = i::Max(index, data->length() << 1) + 1;
- data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size);
+ data = i::FixedArray::CopySize(data, new_size);
env->set_embedder_data(*data);
return data;
}
int length = deoptimizations_.length();
if (length == 0) return;
Handle<DeoptimizationInputData> data =
- factory()->NewDeoptimizationInputData(length, TENURED);
+ DeoptimizationInputData::New(isolate(), length, TENURED);
Handle<ByteArray> translations =
translations_.CreateByteArray(isolate()->factory());
if (length == 0) return;
Handle<DeoptimizationInputData> data =
- factory()->NewDeoptimizationInputData(length, TENURED);
+ DeoptimizationInputData::New(isolate(), length, TENURED);
Handle<ByteArray> translations =
translations_.CreateByteArray(isolate()->factory());
}
-Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
- int deopt_entry_count,
- PretenureFlag pretenure) {
- ASSERT(deopt_entry_count > 0);
- CALL_HEAP_FUNCTION(isolate(),
- DeoptimizationInputData::Allocate(isolate(),
- deopt_entry_count,
- pretenure),
- DeoptimizationInputData);
-}
-
-
-Handle<DeoptimizationOutputData> Factory::NewDeoptimizationOutputData(
- int deopt_entry_count,
- PretenureFlag pretenure) {
- ASSERT(deopt_entry_count > 0);
- CALL_HEAP_FUNCTION(isolate(),
- DeoptimizationOutputData::Allocate(isolate(),
- deopt_entry_count,
- pretenure),
- DeoptimizationOutputData);
-}
-
-
Handle<AccessorPair> Factory::NewAccessorPair() {
Handle<AccessorPair> accessors =
Handle<AccessorPair>::cast(NewStruct(ACCESSOR_PAIR_TYPE));
}
-Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
- CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray);
+Handle<FixedArray> Factory::CopyFixedArrayWithMap(Handle<FixedArray> array,
+ Handle<Map> map) {
+ CALL_HEAP_FUNCTION(isolate(),
+ isolate()->heap()->CopyFixedArrayWithMap(*array, *map),
+ FixedArray);
}
-Handle<FixedArray> Factory::CopyAndTenureFixedCOWArray(
- Handle<FixedArray> array) {
- ASSERT(isolate()->heap()->InNewSpace(*array));
+Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
CALL_HEAP_FUNCTION(isolate(),
- isolate()->heap()->CopyAndTenureFixedCOWArray(*array),
+ isolate()->heap()->CopyFixedArray(*array),
FixedArray);
}
-Handle<FixedArray> Factory::CopySizeFixedArray(Handle<FixedArray> array,
- int new_length,
- PretenureFlag pretenure) {
+Handle<FixedArray> Factory::CopyAndTenureFixedCOWArray(
+ Handle<FixedArray> array) {
+ ASSERT(isolate()->heap()->InNewSpace(*array));
CALL_HEAP_FUNCTION(isolate(),
- array->CopySize(new_length, pretenure),
+ isolate()->heap()->CopyAndTenureFixedCOWArray(*array),
FixedArray);
}
Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
Handle<FixedDoubleArray> array) {
- CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedDoubleArray);
+ CALL_HEAP_FUNCTION(isolate(),
+ isolate()->heap()->CopyFixedDoubleArray(*array),
+ FixedDoubleArray);
}
Handle<ConstantPoolArray> Factory::CopyConstantPoolArray(
Handle<ConstantPoolArray> array) {
- CALL_HEAP_FUNCTION(isolate(), array->Copy(), ConstantPoolArray);
+ CALL_HEAP_FUNCTION(isolate(),
+ isolate()->heap()->CopyConstantPoolArray(*array),
+ ConstantPoolArray);
}
Handle<OrderedHashSet> NewOrderedHashSet();
Handle<OrderedHashMap> NewOrderedHashMap();
- Handle<DeoptimizationInputData> NewDeoptimizationInputData(
- int deopt_entry_count,
- PretenureFlag pretenure);
- Handle<DeoptimizationOutputData> NewDeoptimizationOutputData(
- int deopt_entry_count,
- PretenureFlag pretenure);
-
// Create a new boxed value.
Handle<Box> NewBox(Handle<Object> value);
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
+ Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
+ Handle<Map> map);
+
Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
// This method expects a COW array in new space, and creates a copy
// of it in old space.
Handle<FixedArray> CopyAndTenureFixedCOWArray(Handle<FixedArray> array);
- Handle<FixedArray> CopySizeFixedArray(Handle<FixedArray> array,
- int new_length,
- PretenureFlag pretenure = NOT_TENURED);
-
Handle<FixedDoubleArray> CopyFixedDoubleArray(
Handle<FixedDoubleArray> array);
ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty());
if (!info_->HasDeoptimizationSupport()) return;
int length = bailout_entries_.length();
- Handle<DeoptimizationOutputData> data = isolate()->factory()->
- NewDeoptimizationOutputData(length, TENURED);
+ Handle<DeoptimizationOutputData> data =
+ DeoptimizationOutputData::New(isolate(), length, TENURED);
for (int i = 0; i < length; i++) {
data->SetAstId(i, bailout_entries_[i].id);
data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state));
int length = deoptimizations_.length();
if (length == 0) return;
Handle<DeoptimizationInputData> data =
- factory()->NewDeoptimizationInputData(length, TENURED);
+ DeoptimizationInputData::New(isolate(), length, TENURED);
Handle<ByteArray> translations =
translations_.CreateByteArray(isolate()->factory());
int new_unused = transition->unused_property_fields();
int new_size = old_storage->length() + new_unused + 1;
- Handle<FixedArray> new_storage = isolate->factory()->CopySizeFixedArray(
- old_storage, new_size);
+ Handle<FixedArray> new_storage = FixedArray::CopySize(old_storage, new_size);
Handle<Object> to_store = value;
int length = deoptimizations_.length();
if (length == 0) return;
Handle<DeoptimizationInputData> data =
- factory()->NewDeoptimizationInputData(length, TENURED);
+ DeoptimizationInputData::New(isolate(), length, TENURED);
Handle<ByteArray> translations =
translations_.CreateByteArray(isolate()->factory());
}
-MaybeObject* JSObject::EnsureWritableFastElements() {
- ASSERT(HasFastSmiOrObjectElements());
- FixedArray* elems = FixedArray::cast(elements());
- Isolate* isolate = GetIsolate();
- if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
- Object* writable_elems;
- { MaybeObject* maybe_writable_elems = isolate->heap()->CopyFixedArrayWithMap(
- elems, isolate->heap()->fixed_array_map());
- if (!maybe_writable_elems->ToObject(&writable_elems)) {
- return maybe_writable_elems;
- }
- }
- set_elements(FixedArray::cast(writable_elems));
- isolate->counters()->cow_arrays_converted()->Increment();
- return writable_elems;
-}
-
-
NameDictionary* JSObject::property_dictionary() {
ASSERT(!HasFastProperties());
return NameDictionary::cast(properties());
}
-MaybeObject* FixedArray::Copy() {
- if (length() == 0) return this;
- return GetHeap()->CopyFixedArray(this);
-}
-
-
-MaybeObject* FixedDoubleArray::Copy() {
- if (length() == 0) return this;
- return GetHeap()->CopyFixedDoubleArray(this);
-}
-
-
-MaybeObject* ConstantPoolArray::Copy() {
- if (length() == 0) return this;
- return GetHeap()->CopyConstantPoolArray(this);
-}
-
-
Handle<Object> TypeFeedbackInfo::UninitializedSentinel(Isolate* isolate) {
return isolate->factory()->uninitialized_symbol();
}
Handle<FixedArray> JSObject::EnsureWritableFastElements(
Handle<JSObject> object) {
- CALL_HEAP_FUNCTION(object->GetIsolate(),
- object->EnsureWritableFastElements(),
- FixedArray);
+ ASSERT(object->HasFastSmiOrObjectElements());
+ Isolate* isolate = object->GetIsolate();
+ Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate);
+ if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
+ Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap(
+ elems, isolate->factory()->fixed_array_map());
+ object->set_elements(*writable_elems);
+ isolate->counters()->cow_arrays_converted()->Increment();
+ return writable_elems;
}
}
-MaybeObject* FixedArray::CopySize(int new_length, PretenureFlag pretenure) {
- Heap* heap = GetHeap();
- if (new_length == 0) return heap->empty_fixed_array();
- Object* obj;
- { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length, pretenure);
- if (!maybe_obj->ToObject(&obj)) return maybe_obj;
- }
- FixedArray* result = FixedArray::cast(obj);
+Handle<FixedArray> FixedArray::CopySize(
+ Handle<FixedArray> array, int new_length, PretenureFlag pretenure) {
+ Isolate* isolate = array->GetIsolate();
+ if (new_length == 0) return isolate->factory()->empty_fixed_array();
+ Handle<FixedArray> result =
+ isolate->factory()->NewFixedArray(new_length, pretenure);
// Copy the content
DisallowHeapAllocation no_gc;
- int len = length();
+ int len = array->length();
if (new_length < len) len = new_length;
// We are taking the map from the old fixed array so the map is sure to
// be an immortal immutable object.
- result->set_map_no_write_barrier(map());
+ result->set_map_no_write_barrier(array->map());
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
for (int i = 0; i < len; i++) {
- result->set(i, get(i), mode);
+ result->set(i, array->get(i), mode);
}
return result;
}
-Handle<FixedArray> FixedArray::CopySize(
- Handle<FixedArray> array, int new_length, PretenureFlag pretenure) {
- Isolate* isolate = array->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- array->CopySize(new_length, pretenure),
- FixedArray);
-}
-
-
void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) {
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc);
}
-MaybeObject* DeoptimizationInputData::Allocate(Isolate* isolate,
- int deopt_entry_count,
- PretenureFlag pretenure) {
+Handle<DeoptimizationInputData> DeoptimizationInputData::New(
+ Isolate* isolate,
+ int deopt_entry_count,
+ PretenureFlag pretenure) {
ASSERT(deopt_entry_count > 0);
- return isolate->heap()->AllocateFixedArray(LengthFor(deopt_entry_count),
- pretenure);
+ return Handle<DeoptimizationInputData>::cast(
+ isolate->factory()->NewFixedArray(
+ LengthFor(deopt_entry_count), pretenure));
}
-MaybeObject* DeoptimizationOutputData::Allocate(Isolate* isolate,
- int number_of_deopt_points,
- PretenureFlag pretenure) {
- if (number_of_deopt_points == 0) return isolate->heap()->empty_fixed_array();
- return isolate->heap()->AllocateFixedArray(
- LengthOfFixedArray(number_of_deopt_points), pretenure);
+Handle<DeoptimizationOutputData> DeoptimizationOutputData::New(
+ Isolate* isolate,
+ int number_of_deopt_points,
+ PretenureFlag pretenure) {
+ Handle<FixedArray> result;
+ if (number_of_deopt_points == 0) {
+ result = isolate->factory()->empty_fixed_array();
+ } else {
+ result = isolate->factory()->NewFixedArray(
+ LengthOfFixedArray(number_of_deopt_points), pretenure);
+ }
+ return Handle<DeoptimizationOutputData>::cast(result);
}
Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value);
ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*native_context, osr_ast_id));
old_length = old_code_map->length();
- new_code_map = isolate->factory()->CopySizeFixedArray(
+ new_code_map = FixedArray::CopySize(
old_code_map, old_length + kEntryLength);
// Zap the old map for the sake of the heap verifier.
if (Heap::ShouldZapGarbage()) {
if (capacity > kMaxCachedPrototypeTransitions) return map;
// Grow array by factor 2 over and above what we need.
- Factory* factory = map->GetIsolate()->factory();
- cache = factory->CopySizeFixedArray(cache, transitions * 2 * step + header);
+ cache = FixedArray::CopySize(cache, transitions * 2 * step + header);
SetPrototypeTransitions(map, cache);
}
if (entries->object_at(i) == *object) return entries;
}
if (entries->length() < kCodesStartIndex + number_of_entries + 1) {
- Factory* factory = entries->GetIsolate()->factory();
int capacity = kCodesStartIndex + number_of_entries + 1;
if (capacity > 5) capacity = capacity * 5 / 4;
Handle<DependentCode> new_entries = Handle<DependentCode>::cast(
- factory->CopySizeFixedArray(entries, capacity, TENURED));
+ FixedArray::CopySize(entries, capacity, TENURED));
// The number of codes can change after GC.
starts.Recompute(*entries);
start = starts.at(group);
inline bool HasSpecificClassOf(String* name);
- MUST_USE_RESULT MaybeObject* ToObject(Isolate* isolate); // ECMA-262 9.9.
bool BooleanValue(); // ECMA-262 9.2.
// Convert to a JSObject if needed.
// Requires: HasFastElements().
static Handle<FixedArray> EnsureWritableFastElements(
Handle<JSObject> object);
- MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
// Collects elements starting at index 0.
// Undefined values are placed after non-undefined values.
Handle<JSObject> object,
int capacity,
int length);
- MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength(
- int capacity,
- int length);
// Lookup interceptors are used for handling properties controlled by host
// objects.
// Shrink length and insert filler objects.
void Shrink(int length);
- // Copy operations.
- MUST_USE_RESULT inline MaybeObject* Copy();
- MUST_USE_RESULT MaybeObject* CopySize(int new_length,
- PretenureFlag pretenure = NOT_TENURED);
+ // Copy operation.
static Handle<FixedArray> CopySize(Handle<FixedArray> array,
int new_length,
PretenureFlag pretenure = NOT_TENURED);
// Checking for the hole.
inline bool is_the_hole(int index);
- // Copy operations
- MUST_USE_RESULT inline MaybeObject* Copy();
-
// Garbage collection support.
inline static int SizeFor(int length) {
return kHeaderSize + length * kDoubleSize;
int number_of_heap_ptr_entries,
int number_of_int32_entries);
- // Copy operations
- MUST_USE_RESULT inline MaybeObject* Copy();
-
// Garbage collection support.
inline static int SizeFor(int number_of_int64_entries,
int number_of_code_ptr_entries,
}
// Allocates a DeoptimizationInputData.
- MUST_USE_RESULT static MaybeObject* Allocate(Isolate* isolate,
- int deopt_entry_count,
- PretenureFlag pretenure);
+ static Handle<DeoptimizationInputData> New(Isolate* isolate,
+ int deopt_entry_count,
+ PretenureFlag pretenure);
// Casting.
static inline DeoptimizationInputData* cast(Object* obj);
}
// Allocates a DeoptimizationOutputData.
- MUST_USE_RESULT static MaybeObject* Allocate(Isolate* isolate,
- int number_of_deopt_points,
- PretenureFlag pretenure);
+ static Handle<DeoptimizationOutputData> New(Isolate* isolate,
+ int number_of_deopt_points,
+ PretenureFlag pretenure);
// Casting.
static inline DeoptimizationOutputData* cast(Object* obj);
int length = deoptimizations_.length();
if (length == 0) return;
Handle<DeoptimizationInputData> data =
- factory()->NewDeoptimizationInputData(length, TENURED);
+ DeoptimizationInputData::New(isolate(), length, TENURED);
Handle<ByteArray> translations =
translations_.CreateByteArray(isolate()->factory());