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

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

Issue 8745012: MIPS: Implement crankshaft support for nested object literals. (Closed)
Patch Set: 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
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.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 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after
4232 FastCloneShallowArrayStub::Mode mode = 4232 FastCloneShallowArrayStub::Mode mode =
4233 constant_elements_kind == FAST_DOUBLE_ELEMENTS 4233 constant_elements_kind == FAST_DOUBLE_ELEMENTS
4234 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 4234 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
4235 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 4235 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
4236 FastCloneShallowArrayStub stub(mode, length); 4236 FastCloneShallowArrayStub stub(mode, length);
4237 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4237 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4238 } 4238 }
4239 } 4239 }
4240 4240
4241 4241
4242 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { 4242 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
4243 Register result,
4244 Register source,
4245 int* offset) {
4246 ASSERT(!source.is(a2));
4247 ASSERT(!result.is(a2));
4248
4249 // Increase the offset so that subsequent objects end up right after
4250 // this one.
4251 int current_offset = *offset;
4252 int size = object->map()->instance_size();
4253 *offset += size;
4254
4255 // Copy object header.
4256 ASSERT(object->properties()->length() == 0);
4257 ASSERT(object->elements()->length() == 0 ||
4258 object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
4259 int inobject_properties = object->map()->inobject_properties();
4260 int header_size = size - inobject_properties * kPointerSize;
4261 for (int i = 0; i < header_size; i += kPointerSize) {
4262 __ lw(a2, FieldMemOperand(source, i));
4263 __ sw(a2, FieldMemOperand(result, current_offset + i));
4264 }
4265
4266 // Copy in-object properties.
4267 for (int i = 0; i < inobject_properties; i++) {
4268 int total_offset = current_offset + object->GetInObjectPropertyOffset(i);
4269 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
4270 if (value->IsJSObject()) {
4271 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4272 __ Addu(a2, result, Operand(*offset));
4273 __ sw(a2, FieldMemOperand(result, total_offset));
4274 LoadHeapObject(source, value_object);
4275 EmitDeepCopy(value_object, result, source, offset);
4276 } else if (value->IsHeapObject()) {
4277 LoadHeapObject(a2, Handle<HeapObject>::cast(value));
4278 __ sw(a2, FieldMemOperand(result, total_offset));
4279 } else {
4280 __ li(a2, Operand(value));
4281 __ sw(a2, FieldMemOperand(result, total_offset));
4282 }
4283 }
4284 }
4285
4286
4287 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
4288 int size = instr->hydrogen()->total_size();
4289
4290 // Allocate all objects that are part of the literal in one big
4291 // allocation. This avoids multiple limit checks.
4292 Label allocated, runtime_allocate;
4293 __ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
4294 __ jmp(&allocated);
4295
4296 __ bind(&runtime_allocate);
4297 __ li(a0, Operand(Smi::FromInt(size)));
4298 __ push(a0);
4299 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4300
4301 __ bind(&allocated);
4302 int offset = 0;
4303 LoadHeapObject(a1, instr->hydrogen()->boilerplate());
4304 EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset);
4305 ASSERT_EQ(size, offset);
4306 }
4307
4308
4309 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
4243 ASSERT(ToRegister(instr->result()).is(v0)); 4310 ASSERT(ToRegister(instr->result()).is(v0));
4244 __ lw(t0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 4311 __ lw(t0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
4245 __ lw(t0, FieldMemOperand(t0, JSFunction::kLiteralsOffset)); 4312 __ lw(t0, FieldMemOperand(t0, JSFunction::kLiteralsOffset));
4246 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); 4313 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
4247 __ li(a2, Operand(instr->hydrogen()->constant_properties())); 4314 __ li(a2, Operand(instr->hydrogen()->constant_properties()));
4248 __ li(a1, Operand(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0))); 4315 __ li(a1, Operand(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0)));
4249 __ Push(t0, a3, a2, a1); 4316 __ Push(t0, a3, a2, a1);
4250 4317
4251 // Pick the right runtime function to call. 4318 // Pick the right runtime function to call.
4252 if (instr->hydrogen()->depth() > 1) { 4319 if (instr->hydrogen()->depth() > 1) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4631 ASSERT(!environment->HasBeenRegistered()); 4698 ASSERT(!environment->HasBeenRegistered());
4632 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4699 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4633 ASSERT(osr_pc_offset_ == -1); 4700 ASSERT(osr_pc_offset_ == -1);
4634 osr_pc_offset_ = masm()->pc_offset(); 4701 osr_pc_offset_ = masm()->pc_offset();
4635 } 4702 }
4636 4703
4637 4704
4638 #undef __ 4705 #undef __
4639 4706
4640 } } // namespace v8::internal 4707 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698