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

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: Ported lithium part to x64 and ARM. Created 9 years, 1 month 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() == isolate()->heap()->fixed_cow_array_map());
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 total_offset = current_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, total_offset), ecx);
4202 LoadHeapObject(source, value_object);
4203 EmitDeepCopy(value_object, result, source, offset);
4204 } else if (value->IsHeapObject()) {
4205 LoadHeapObject(ecx, Handle<HeapObject>::cast(value));
4206 __ mov(FieldOperand(result, total_offset), ecx);
4207 } else {
4208 __ mov(FieldOperand(result, total_offset), Immediate(value));
4209 }
4210 }
4211 }
4212
4213
4214 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
4215 ASSERT(ToRegister(instr->context()).is(esi));
4216 int size = instr->hydrogen()->total_size();
4217
4218 // Allocate all objects that are part of the literal in one big
4219 // allocation. This avoids multiple limit checks.
4220 Label allocated, runtime_allocate;
4221 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
4222 __ jmp(&allocated);
4223
4224 __ bind(&runtime_allocate);
4225 __ push(Immediate(Smi::FromInt(size)));
4226 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4227
4228 __ bind(&allocated);
4229 int offset = 0;
4230 LoadHeapObject(ebx, instr->hydrogen()->boilerplate());
4231 EmitDeepCopy(instr->hydrogen()->boilerplate(), eax, ebx, &offset);
4232 ASSERT_EQ(size, offset);
4233 }
4234
4235
4236 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
4165 ASSERT(ToRegister(instr->context()).is(esi)); 4237 ASSERT(ToRegister(instr->context()).is(esi));
4166 Handle<FixedArray> constant_properties = 4238 Handle<FixedArray> constant_properties =
4167 instr->hydrogen()->constant_properties(); 4239 instr->hydrogen()->constant_properties();
4168 4240
4169 // Setup the parameters to the stub/runtime call. 4241 // Setup the parameters to the stub/runtime call.
4170 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 4242 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
4171 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); 4243 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset));
4172 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); 4244 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index())));
4173 __ push(Immediate(constant_properties)); 4245 __ push(Immediate(constant_properties));
4174 int flags = instr->hydrogen()->fast_elements() 4246 int flags = instr->hydrogen()->fast_elements()
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 this, pointers, Safepoint::kLazyDeopt); 4621 this, pointers, Safepoint::kLazyDeopt);
4550 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4622 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4551 } 4623 }
4552 4624
4553 4625
4554 #undef __ 4626 #undef __
4555 4627
4556 } } // namespace v8::internal 4628 } } // namespace v8::internal
4557 4629
4558 #endif // V8_TARGET_ARCH_IA32 4630 #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