| Index: src/arm/lithium-codegen-arm.cc
|
| diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
|
| index e8f96e42dc06c019690fd13b1d475413e6f72312..418734d9317bf0e1d1d4e74e666cc7919f8e432f 100644
|
| --- a/src/arm/lithium-codegen-arm.cc
|
| +++ b/src/arm/lithium-codegen-arm.cc
|
| @@ -5722,6 +5722,10 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
|
| DeoptimizeIf(ne, instr->environment());
|
| }
|
|
|
| + int flags = allocation_site_mode == TRACK_ALLOCATION_SITE
|
| + ? ArrayLiteral::kCreateAllocationSiteInfos
|
| + : ArrayLiteral::kNoFlags;
|
| +
|
| // Set up the parameters to the stub/runtime call.
|
| __ LoadHeapObject(r3, literals);
|
| __ mov(r2, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
|
| @@ -5739,9 +5743,13 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
|
| FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length);
|
| CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
|
| } else if (instr->hydrogen()->depth() > 1) {
|
| - CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
|
| + __ mov(r0, Operand(Smi::FromInt(flags)));
|
| + __ push(r0);
|
| + CallRuntime(Runtime::kCreateArrayLiteral, 4, instr);
|
| } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
|
| - CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
|
| + __ mov(r0, Operand(Smi::FromInt(flags)));
|
| + __ push(r0);
|
| + CallRuntime(Runtime::kCreateArrayLiteralShallow, 4, instr);
|
| } else {
|
| FastCloneShallowArrayStub::Mode mode =
|
| boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
|
| @@ -5754,6 +5762,7 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
|
|
|
|
|
| void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| + Handle<JSObject> original_object,
|
| Register result,
|
| Register source,
|
| int* offset,
|
| @@ -5761,11 +5770,13 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| ASSERT(!source.is(r2));
|
| ASSERT(!result.is(r2));
|
|
|
| + // Should we track allocation info for *this* object in the tree?
|
| bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE &&
|
| - object->map()->CanTrackAllocationSite();
|
| + object->ShouldTrackAllocationInfo();
|
|
|
| // Only elements backing stores for non-COW arrays need to be copied.
|
| Handle<FixedArrayBase> elements(object->elements());
|
| + Handle<FixedArrayBase> original_elements(original_object->elements());
|
| bool has_elements = elements->length() > 0 &&
|
| elements->map() != isolate()->heap()->fixed_cow_array_map();
|
|
|
| @@ -5802,11 +5813,14 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| isolate());
|
| if (value->IsJSObject()) {
|
| Handle<JSObject> value_object = Handle<JSObject>::cast(value);
|
| + Handle<JSObject> original_value_object = Handle<JSObject>::cast(
|
| + Handle<Object>(original_object->InObjectPropertyAt(i), isolate()));
|
| +
|
| __ add(r2, result, Operand(*offset));
|
| __ str(r2, FieldMemOperand(result, total_offset));
|
| __ LoadHeapObject(source, value_object);
|
| - EmitDeepCopy(value_object, result, source, offset,
|
| - DONT_TRACK_ALLOCATION_SITE);
|
| + EmitDeepCopy(value_object, original_value_object, result, source,
|
| + offset, mode);
|
| } else if (value->IsHeapObject()) {
|
| __ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
|
| __ str(r2, FieldMemOperand(result, total_offset));
|
| @@ -5820,8 +5834,10 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| if (create_allocation_site_info) {
|
| __ mov(r2, Operand(Handle<Map>(isolate()->heap()->
|
| allocation_site_info_map())));
|
| - __ str(r2, FieldMemOperand(result, object_size));
|
| - __ str(source, FieldMemOperand(result, object_size + kPointerSize));
|
| + __ str(r2, FieldMemOperand(result, object_size + object_offset));
|
| + __ LoadHeapObject(r2, original_object);
|
| + __ str(r2, FieldMemOperand(result,
|
| + object_size + object_offset + kPointerSize));
|
| }
|
|
|
| if (has_elements) {
|
| @@ -5851,16 +5867,22 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| }
|
| } else if (elements->IsFixedArray()) {
|
| Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
|
| + ASSERT(original_object->HasFastObjectElements());
|
| + Handle<FixedArray> original_fast_elements =
|
| + Handle<FixedArray>::cast(original_elements);
|
| for (int i = 0; i < elements_length; i++) {
|
| int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
|
| Handle<Object> value(fast_elements->get(i), isolate());
|
| if (value->IsJSObject()) {
|
| Handle<JSObject> value_object = Handle<JSObject>::cast(value);
|
| + Handle<JSObject> original_value_object = Handle<JSObject>::cast(
|
| + Handle<Object>(original_fast_elements->get(i), isolate()));
|
| __ add(r2, result, Operand(*offset));
|
| __ str(r2, FieldMemOperand(result, total_offset));
|
| __ LoadHeapObject(source, value_object);
|
| - EmitDeepCopy(value_object, result, source, offset,
|
| - DONT_TRACK_ALLOCATION_SITE);
|
| + ASSERT(!value_object.is_identical_to(original_value_object));
|
| + EmitDeepCopy(value_object, original_value_object, result, source,
|
| + offset, mode);
|
| } else if (value->IsHeapObject()) {
|
| __ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
|
| __ str(r2, FieldMemOperand(result, total_offset));
|
| @@ -5876,28 +5898,11 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| }
|
|
|
|
|
| -void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
|
| - int size = instr->hydrogen()->total_size();
|
| - ElementsKind boilerplate_elements_kind =
|
| - instr->hydrogen()->boilerplate()->GetElementsKind();
|
| +void LCodeGen::FastLiteralHelper(LFastLiteral* instr, AllocationSiteMode mode) {
|
| + int size = mode == DONT_TRACK_ALLOCATION_SITE
|
| + ? instr->hydrogen()->size_without_allocation_sites()
|
| + : instr->hydrogen()->total_size();
|
|
|
| - // Deopt if the array literal boilerplate ElementsKind is of a type different
|
| - // than the expected one. The check isn't necessary if the boilerplate has
|
| - // already been converted to TERMINAL_FAST_ELEMENTS_KIND.
|
| - if (CanTransitionToMoreGeneralFastElementsKind(
|
| - boilerplate_elements_kind, true)) {
|
| - __ LoadHeapObject(r1, instr->hydrogen()->boilerplate());
|
| - // Load map into r2.
|
| - __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset));
|
| - // Load the map's "bit field 2".
|
| - __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset));
|
| - // Retrieve elements_kind from bit field 2.
|
| - __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount);
|
| - __ cmp(r2, Operand(boilerplate_elements_kind));
|
| - DeoptimizeIf(ne, instr->environment());
|
| - }
|
| -
|
| - // Allocate all objects that are part of the literal in one big
|
| // allocation. This avoids multiple limit checks.
|
| Label allocated, runtime_allocate;
|
| __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
|
| @@ -5911,12 +5916,40 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
|
| __ bind(&allocated);
|
| int offset = 0;
|
| __ LoadHeapObject(r1, instr->hydrogen()->boilerplate());
|
| - EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset,
|
| + EmitDeepCopy(instr->hydrogen()->boilerplate(),
|
| + instr->hydrogen()->original_boilerplate(),
|
| + r0, r1, &offset,
|
| instr->hydrogen()->allocation_site_mode());
|
| ASSERT_EQ(size, offset);
|
| }
|
|
|
|
|
| +void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
|
| + // TODO(mvstanton): Revisit this heuristic as site info matures.
|
| + // If allocation site mode is on, then we need the ability to turn it off
|
| + // after "awhile." Later, better options should be available, but for
|
| + // now just allow a certain number of gcs to pass.
|
| + if (instr->hydrogen()->allocation_site_mode() == TRACK_ALLOCATION_SITE) {
|
| + // How many gcs have passed?
|
| + const int maxCount = 3;
|
| + ExternalReference gc_count_address =
|
| + ExternalReference::gc_count_address(isolate());
|
| + Label continue_using, done;
|
| + __ mov(r0, Operand(gc_count_address));
|
| + __ ldr(r0, MemOperand(r0));
|
| + __ cmp(r0, Operand(maxCount));
|
| + __ b(lt, &continue_using);
|
| + FastLiteralHelper(instr, DONT_TRACK_ALLOCATION_SITE);
|
| + __ jmp(&done);
|
| + __ bind(&continue_using);
|
| + FastLiteralHelper(instr, TRACK_ALLOCATION_SITE);
|
| + __ bind(&done);
|
| + } else {
|
| + FastLiteralHelper(instr, DONT_TRACK_ALLOCATION_SITE);
|
| + }
|
| +}
|
| +
|
| +
|
| void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
|
| Handle<FixedArray> literals(instr->environment()->closure()->literals());
|
| Handle<FixedArray> constant_properties =
|
| @@ -5929,8 +5962,12 @@ void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
|
| int flags = instr->hydrogen()->fast_elements()
|
| ? ObjectLiteral::kFastElements
|
| : ObjectLiteral::kNoFlags;
|
| - __ mov(r0, Operand(Smi::FromInt(flags)));
|
|
|
| + if (instr->hydrogen()->allocation_site_mode() == TRACK_ALLOCATION_SITE) {
|
| + flags |= ObjectLiteral::kCreateAllocationSiteInfos;
|
| + }
|
| +
|
| + __ mov(r0, Operand(Smi::FromInt(flags)));
|
| // Pick the right runtime function or stub to call.
|
| int properties_count = constant_properties->length() / 2;
|
| if (instr->hydrogen()->depth() > 1) {
|
|
|