OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4143 matching lines...) Loading... | |
4154 FastCloneShallowArrayStub::Mode mode = | 4154 FastCloneShallowArrayStub::Mode mode = |
4155 constant_elements_kind == FAST_DOUBLE_ELEMENTS | 4155 constant_elements_kind == FAST_DOUBLE_ELEMENTS |
4156 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 4156 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
4157 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | 4157 : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
4158 FastCloneShallowArrayStub stub(mode, length); | 4158 FastCloneShallowArrayStub stub(mode, length); |
4159 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4159 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4160 } | 4160 } |
4161 } | 4161 } |
4162 | 4162 |
4163 | 4163 |
4164 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 4164 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
4165 Register result, | |
4166 Register source, | |
4167 int* offset) { | |
4168 ASSERT(!source.is(ecx)); | |
4169 ASSERT(!result.is(ecx)); | |
4170 int current_offset = *offset; | |
4171 | |
4172 if (FLAG_debug_code && !HEAP->InNewSpace(*object)) { | |
4173 __ cmp(source, object); | |
4174 __ Assert(equal, "Unexpected object literal boilerplate"); | |
4175 } | |
4176 | |
4177 // Increase the offset so that subsequent objects end up right after | |
4178 // this one. | |
4179 int size = object->map()->instance_size(); | |
4180 *offset += size; | |
4181 | |
4182 // Copy object header. | |
4183 ASSERT(object->properties()->length() == 0); | |
4184 ASSERT(object->elements()->length() == 0 || | |
4185 object->elements()->map() == HEAP->fixed_cow_array_map()); | |
4186 int inobject_properties = object->map()->inobject_properties(); | |
4187 int header_size = size - inobject_properties * kPointerSize; | |
4188 for (int i = 0; i < header_size; i += kPointerSize) { | |
4189 __ mov(ecx, FieldOperand(source, i)); | |
4190 __ mov(FieldOperand(result, current_offset + i), ecx); | |
4191 } | |
4192 | |
4193 // Copy in-object properties. | |
4194 for (int i = 0; i < inobject_properties; i++) { | |
fschneider
2011/11/22 17:26:16
Can you instead of cloning the original, just stor
Michael Starzinger
2011/11/23 10:55:32
Done.
| |
4195 int in_object_offset = object->GetInObjectPropertyOffset(i); | |
4196 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i)); | |
4197 if (value->IsJSObject()) { | |
4198 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | |
4199 __ push(source); | |
4200 __ mov(source, FieldOperand(source, in_object_offset)); | |
4201 __ lea(ecx, Operand(result, *offset)); | |
fschneider
2011/11/22 17:26:16
Replace the 3 lines above with:
__ LoadHeapObject
Michael Starzinger
2011/11/23 10:55:32
Done. As discussed offline, ecx needs to be loaded
| |
4202 __ mov(FieldOperand(result, current_offset + in_object_offset), ecx); | |
4203 EmitDeepCopy(value_object, result, source, offset); | |
4204 __ pop(source); | |
4205 } else { | |
4206 __ mov(ecx, FieldOperand(source, in_object_offset)); | |
fschneider
2011/11/22 17:26:16
Here you could say:
if (value->IsHeapObject()) {
Michael Starzinger
2011/11/23 10:55:32
Done.
| |
4207 __ mov(FieldOperand(result, current_offset + in_object_offset), ecx); | |
4208 } | |
4209 } | |
4210 } | |
4211 | |
4212 | |
4213 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) { | |
4214 ASSERT(ToRegister(instr->context()).is(esi)); | |
4215 int size = instr->hydrogen()->total_size(); | |
4216 | |
4217 // Allocate all objects that are part of the literal in one big | |
4218 // allocation. This avoids multiple limit checks. | |
4219 Label allocated, runtime_allocate; | |
4220 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT); | |
4221 __ jmp(&allocated); | |
4222 | |
4223 __ bind(&runtime_allocate); | |
4224 __ push(Immediate(Smi::FromInt(size))); | |
4225 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | |
4226 | |
4227 __ bind(&allocated); | |
4228 int offset = 0; | |
4229 int literal_offset = FixedArray::kHeaderSize + | |
4230 instr->hydrogen()->literal_index() * kPointerSize; | |
4231 __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
4232 __ mov(ebx, FieldOperand(ebx, JSFunction::kLiteralsOffset)); | |
4233 __ mov(ebx, FieldOperand(ebx, literal_offset)); | |
fschneider
2011/11/22 17:26:16
You could just load the boilerplace object directl
Michael Starzinger
2011/11/23 10:55:32
Done.
| |
4234 EmitDeepCopy(instr->hydrogen()->boilerplate(), eax, ebx, &offset); | |
4235 ASSERT_EQ(size, offset); | |
4236 } | |
4237 | |
4238 | |
4239 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) { | |
4165 ASSERT(ToRegister(instr->context()).is(esi)); | 4240 ASSERT(ToRegister(instr->context()).is(esi)); |
4166 Handle<FixedArray> constant_properties = | 4241 Handle<FixedArray> constant_properties = |
4167 instr->hydrogen()->constant_properties(); | 4242 instr->hydrogen()->constant_properties(); |
4168 | 4243 |
4169 // Setup the parameters to the stub/runtime call. | 4244 // Setup the parameters to the stub/runtime call. |
4170 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 4245 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
4171 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); | 4246 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); |
4172 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | 4247 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
4173 __ push(Immediate(constant_properties)); | 4248 __ push(Immediate(constant_properties)); |
4174 int flags = instr->hydrogen()->fast_elements() | 4249 int flags = instr->hydrogen()->fast_elements() |
(...skipping 374 matching lines...) Loading... | |
4549 this, pointers, Safepoint::kLazyDeopt); | 4624 this, pointers, Safepoint::kLazyDeopt); |
4550 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4625 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4551 } | 4626 } |
4552 | 4627 |
4553 | 4628 |
4554 #undef __ | 4629 #undef __ |
4555 | 4630 |
4556 } } // namespace v8::internal | 4631 } } // namespace v8::internal |
4557 | 4632 |
4558 #endif // V8_TARGET_ARCH_IA32 | 4633 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |