Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 8640001: Implement crankshaft support for nested object literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Florian Schneider. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...) Expand 10 before | Expand all | Expand 10 after
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
4171 if (FLAG_debug_code) {
4172 LoadHeapObject(ecx, object);
4173 __ cmp(source, ecx);
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 current_offset = *offset;
4180 int size = object->map()->instance_size();
4181 *offset += size;
4182
4183 // Copy object header.
4184 ASSERT(object->properties()->length() == 0);
4185 ASSERT(object->elements()->length() == 0 ||
4186 object->elements()->map() == HEAP->fixed_cow_array_map());
fschneider 2011/11/23 14:27:20 Use isolate()->heap() instead.
Michael Starzinger 2011/11/24 09:51:54 Done.
4187 int inobject_properties = object->map()->inobject_properties();
4188 int header_size = size - inobject_properties * kPointerSize;
4189 for (int i = 0; i < header_size; i += kPointerSize) {
4190 __ mov(ecx, FieldOperand(source, i));
4191 __ mov(FieldOperand(result, current_offset + i), ecx);
4192 }
4193
4194 // Copy in-object properties.
4195 for (int i = 0; i < inobject_properties; i++) {
4196 int in_object_offset = object->GetInObjectPropertyOffset(i);
4197 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
4198 if (value->IsJSObject()) {
4199 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4200 __ lea(ecx, Operand(result, *offset));
4201 __ mov(FieldOperand(result, current_offset + in_object_offset), ecx);
4202 LoadHeapObject(source, value_object);
4203 EmitDeepCopy(value_object, result, source, offset);
4204 } else {
4205 if (value->IsHeapObject()) {
4206 LoadHeapObject(ecx, Handle<HeapObject>::cast(value));
4207 } else {
4208 __ mov(ecx, Immediate(value));
fschneider 2011/11/23 14:27:20 Instead of using ecx, you can use immediate operan
Michael Starzinger 2011/11/24 09:51:54 Done.
4209 }
4210 __ mov(FieldOperand(result, current_offset + in_object_offset), ecx);
fschneider 2011/11/23 14:27:20 Move this into the heap-object case of the if-stat
Michael Starzinger 2011/11/24 09:51:54 Done.
4211 }
4212 }
4213 }
4214
4215
4216 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
4217 ASSERT(ToRegister(instr->context()).is(esi));
4218 int size = instr->hydrogen()->total_size();
4219
4220 // Allocate all objects that are part of the literal in one big
4221 // allocation. This avoids multiple limit checks.
4222 Label allocated, runtime_allocate;
4223 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
4224 __ jmp(&allocated);
4225
4226 __ bind(&runtime_allocate);
4227 __ push(Immediate(Smi::FromInt(size)));
4228 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4229
4230 __ bind(&allocated);
4231 int offset = 0;
4232 LoadHeapObject(ebx, instr->hydrogen()->boilerplate());
4233 EmitDeepCopy(instr->hydrogen()->boilerplate(), eax, ebx, &offset);
4234 ASSERT_EQ(size, offset);
4235 }
4236
4237
4238 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
4165 ASSERT(ToRegister(instr->context()).is(esi)); 4239 ASSERT(ToRegister(instr->context()).is(esi));
4166 Handle<FixedArray> constant_properties = 4240 Handle<FixedArray> constant_properties =
4167 instr->hydrogen()->constant_properties(); 4241 instr->hydrogen()->constant_properties();
4168 4242
4169 // Setup the parameters to the stub/runtime call. 4243 // Setup the parameters to the stub/runtime call.
4170 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 4244 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
4171 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); 4245 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset));
4172 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); 4246 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index())));
4173 __ push(Immediate(constant_properties)); 4247 __ push(Immediate(constant_properties));
4174 int flags = instr->hydrogen()->fast_elements() 4248 int flags = instr->hydrogen()->fast_elements()
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 this, pointers, Safepoint::kLazyDeopt); 4623 this, pointers, Safepoint::kLazyDeopt);
4550 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4624 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4551 } 4625 }
4552 4626
4553 4627
4554 #undef __ 4628 #undef __
4555 4629
4556 } } // namespace v8::internal 4630 } } // namespace v8::internal
4557 4631
4558 #endif // V8_TARGET_ARCH_IA32 4632 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698