From 44cd1b467c4342eee545df060c2d3012046f4723 Mon Sep 17 00:00:00 2001 From: "palfia@homejinni.com" Date: Thu, 11 Apr 2013 00:52:22 +0000 Subject: [PATCH] MIPS: Build fast literals in hydrogen. Port r14211 (8d6dfcb6) BUG= Review URL: https://codereview.chromium.org/14108003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14220 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/lithium-codegen-mips.cc | 164 --------------------------------------- src/mips/lithium-mips.cc | 5 -- src/mips/lithium-mips.h | 8 -- 3 files changed, 177 deletions(-) diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index b6f9998..c647121 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -5430,170 +5430,6 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { } -void LCodeGen::EmitDeepCopy(Handle object, - Register result, - Register source, - int* offset, - AllocationSiteMode mode) { - ASSERT(!source.is(a2)); - ASSERT(!result.is(a2)); - - bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && - object->map()->CanTrackAllocationSite(); - - // Only elements backing stores for non-COW arrays need to be copied. - Handle elements(object->elements()); - bool has_elements = elements->length() > 0 && - elements->map() != isolate()->heap()->fixed_cow_array_map(); - - // Increase the offset so that subsequent objects end up right after - // this object and its backing store. - int object_offset = *offset; - int object_size = object->map()->instance_size(); - int elements_size = has_elements ? elements->Size() : 0; - int elements_offset = *offset + object_size; - if (create_allocation_site_info) { - elements_offset += AllocationSiteInfo::kSize; - *offset += AllocationSiteInfo::kSize; - } - - *offset += object_size + elements_size; - - // Copy object header. - ASSERT(object->properties()->length() == 0); - int inobject_properties = object->map()->inobject_properties(); - int header_size = object_size - inobject_properties * kPointerSize; - for (int i = 0; i < header_size; i += kPointerSize) { - if (has_elements && i == JSObject::kElementsOffset) { - __ Addu(a2, result, Operand(elements_offset)); - } else { - __ lw(a2, FieldMemOperand(source, i)); - } - __ sw(a2, FieldMemOperand(result, object_offset + i)); - } - - // Copy in-object properties. - for (int i = 0; i < inobject_properties; i++) { - int total_offset = object_offset + object->GetInObjectPropertyOffset(i); - Handle value = Handle(object->InObjectPropertyAt(i), - isolate()); - if (value->IsJSObject()) { - Handle value_object = Handle::cast(value); - __ Addu(a2, result, Operand(*offset)); - __ sw(a2, FieldMemOperand(result, total_offset)); - __ LoadHeapObject(source, value_object); - EmitDeepCopy(value_object, result, source, offset, - DONT_TRACK_ALLOCATION_SITE); - } else if (value->IsHeapObject()) { - __ LoadHeapObject(a2, Handle::cast(value)); - __ sw(a2, FieldMemOperand(result, total_offset)); - } else { - __ li(a2, Operand(value)); - __ sw(a2, FieldMemOperand(result, total_offset)); - } - } - - // Build Allocation Site Info if desired - if (create_allocation_site_info) { - __ li(a2, Operand(Handle(isolate()->heap()-> - allocation_site_info_map()))); - __ sw(a2, FieldMemOperand(result, object_size)); - __ sw(source, FieldMemOperand(result, object_size + kPointerSize)); - } - - if (has_elements) { - // Copy elements backing store header. - __ LoadHeapObject(source, elements); - for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) { - __ lw(a2, FieldMemOperand(source, i)); - __ sw(a2, FieldMemOperand(result, elements_offset + i)); - } - - // Copy elements backing store content. - int elements_length = has_elements ? elements->length() : 0; - if (elements->IsFixedDoubleArray()) { - Handle double_array = - Handle::cast(elements); - for (int i = 0; i < elements_length; i++) { - int64_t value = double_array->get_representation(i); - // We only support little endian mode... - int32_t value_low = static_cast(value & 0xFFFFFFFF); - int32_t value_high = static_cast(value >> 32); - int total_offset = - elements_offset + FixedDoubleArray::OffsetOfElementAt(i); - __ li(a2, Operand(value_low)); - __ sw(a2, FieldMemOperand(result, total_offset)); - __ li(a2, Operand(value_high)); - __ sw(a2, FieldMemOperand(result, total_offset + 4)); - } - } else if (elements->IsFixedArray()) { - Handle fast_elements = Handle::cast(elements); - for (int i = 0; i < elements_length; i++) { - int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i); - Handle value(fast_elements->get(i), isolate()); - if (value->IsJSObject()) { - Handle value_object = Handle::cast(value); - __ Addu(a2, result, Operand(*offset)); - __ sw(a2, FieldMemOperand(result, total_offset)); - __ LoadHeapObject(source, value_object); - EmitDeepCopy(value_object, result, source, offset, - DONT_TRACK_ALLOCATION_SITE); - } else if (value->IsHeapObject()) { - __ LoadHeapObject(a2, Handle::cast(value)); - __ sw(a2, FieldMemOperand(result, total_offset)); - } else { - __ li(a2, Operand(value)); - __ sw(a2, FieldMemOperand(result, total_offset)); - } - } - } else { - UNREACHABLE(); - } - } -} - - -void LCodeGen::DoFastLiteral(LFastLiteral* instr) { - int size = instr->hydrogen()->total_size(); - ElementsKind boilerplate_elements_kind = - instr->hydrogen()->boilerplate()->GetElementsKind(); - - // 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(a1, instr->hydrogen()->boilerplate()); - // Load map into a2. - __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset)); - // Load the map's "bit field 2". - __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset)); - // Retrieve elements_kind from bit field 2. - __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount); - DeoptimizeIf(ne, instr->environment(), a2, - Operand(boilerplate_elements_kind)); - } - - // Allocate all objects that are part of the literal in one big - // allocation. This avoids multiple limit checks. - Label allocated, runtime_allocate; - __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT); - __ jmp(&allocated); - - __ bind(&runtime_allocate); - __ li(a0, Operand(Smi::FromInt(size))); - __ push(a0); - CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); - - __ bind(&allocated); - int offset = 0; - __ LoadHeapObject(a1, instr->hydrogen()->boilerplate()); - EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset, - instr->hydrogen()->allocation_site_mode()); - ASSERT_EQ(size, offset); -} - - void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { ASSERT(ToRegister(instr->result()).is(v0)); Handle literals(instr->environment()->closure()->literals()); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index afe658b..14ccfd4 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -2217,11 +2217,6 @@ LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { } -LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) { - return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, v0), instr); -} - - LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { return MarkAsCall(DefineFixed(new(zone()) LArrayLiteral, v0), instr); } diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 8d8cb58..59e9769 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -97,7 +97,6 @@ class LCodeGen; V(DoubleToI) \ V(DummyUse) \ V(ElementsKind) \ - V(FastLiteral) \ V(FixedArrayBaseLength) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ @@ -2300,13 +2299,6 @@ class LAllocate: public LTemplateInstruction<1, 2, 2> { }; -class LFastLiteral: public LTemplateInstruction<1, 0, 0> { - public: - DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal") - DECLARE_HYDROGEN_ACCESSOR(FastLiteral) -}; - - class LArrayLiteral: public LTemplateInstruction<1, 0, 0> { public: DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal") -- 2.7.4