| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index 27ed3b5df973d9989eaae15101fe1449d4081de7..434f3ee8f7db110ef4e269d7a452158aff0fc33c 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -3926,7 +3926,73 @@ void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
|
| }
|
|
|
|
|
| -void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
|
| +void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
|
| + Register result,
|
| + Register source,
|
| + int* offset) {
|
| + ASSERT(!source.is(rcx));
|
| + ASSERT(!result.is(rcx));
|
| +
|
| + // Increase the offset so that subsequent objects end up right after
|
| + // this one.
|
| + int current_offset = *offset;
|
| + int size = object->map()->instance_size();
|
| + *offset += size;
|
| +
|
| + // Copy object header.
|
| + ASSERT(object->properties()->length() == 0);
|
| + ASSERT(object->elements()->length() == 0 ||
|
| + object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
|
| + int inobject_properties = object->map()->inobject_properties();
|
| + int header_size = size - inobject_properties * kPointerSize;
|
| + for (int i = 0; i < header_size; i += kPointerSize) {
|
| + __ movq(rcx, FieldOperand(source, i));
|
| + __ movq(FieldOperand(result, current_offset + i), rcx);
|
| + }
|
| +
|
| + // Copy in-object properties.
|
| + for (int i = 0; i < inobject_properties; i++) {
|
| + int total_offset = current_offset + object->GetInObjectPropertyOffset(i);
|
| + Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
|
| + if (value->IsJSObject()) {
|
| + Handle<JSObject> value_object = Handle<JSObject>::cast(value);
|
| + __ lea(rcx, Operand(result, *offset));
|
| + __ movq(FieldOperand(result, total_offset), rcx);
|
| + LoadHeapObject(source, value_object);
|
| + EmitDeepCopy(value_object, result, source, offset);
|
| + } else if (value->IsHeapObject()) {
|
| + LoadHeapObject(rcx, Handle<HeapObject>::cast(value));
|
| + __ movq(FieldOperand(result, total_offset), rcx);
|
| + } else {
|
| + __ movq(rcx, value, RelocInfo::NONE);
|
| + __ movq(FieldOperand(result, total_offset), rcx);
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| +void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
|
| + int size = instr->hydrogen()->total_size();
|
| +
|
| + // Allocate all objects that are part of the literal in one big
|
| + // allocation. This avoids multiple limit checks.
|
| + Label allocated, runtime_allocate;
|
| + __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
|
| + __ jmp(&allocated);
|
| +
|
| + __ bind(&runtime_allocate);
|
| + __ Push(Smi::FromInt(size));
|
| + CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
|
| +
|
| + __ bind(&allocated);
|
| + int offset = 0;
|
| + LoadHeapObject(rbx, instr->hydrogen()->boilerplate());
|
| + EmitDeepCopy(instr->hydrogen()->boilerplate(), rax, rbx, &offset);
|
| + ASSERT_EQ(size, offset);
|
| +}
|
| +
|
| +
|
| +void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
|
| Handle<FixedArray> constant_properties =
|
| instr->hydrogen()->constant_properties();
|
|
|
|
|