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

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

Issue 9403018: Implement fast literal support in Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Daniel Clifford. Created 8 years, 10 months 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-ia32.cc ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 4254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4265 } 4265 }
4266 4266
4267 4267
4268 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 4268 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
4269 Register result, 4269 Register result,
4270 Register source, 4270 Register source,
4271 int* offset) { 4271 int* offset) {
4272 ASSERT(!source.is(a2)); 4272 ASSERT(!source.is(a2));
4273 ASSERT(!result.is(a2)); 4273 ASSERT(!result.is(a2));
4274 4274
4275 // Only elements backing stores for non-COW arrays need to be copied.
4276 Handle<FixedArrayBase> elements(object->elements());
4277 bool has_elements = elements->length() > 0 &&
4278 elements->map() != isolate()->heap()->fixed_cow_array_map();
4279
4275 // Increase the offset so that subsequent objects end up right after 4280 // Increase the offset so that subsequent objects end up right after
4276 // this one. 4281 // this object and its backing store.
4277 int current_offset = *offset; 4282 int object_offset = *offset;
4278 int size = object->map()->instance_size(); 4283 int object_size = object->map()->instance_size();
4279 *offset += size; 4284 int elements_offset = *offset + object_size;
4285 int elements_size = has_elements ? elements->Size() : 0;
4286 *offset += object_size + elements_size;
4280 4287
4281 // Copy object header. 4288 // Copy object header.
4282 ASSERT(object->properties()->length() == 0); 4289 ASSERT(object->properties()->length() == 0);
4283 ASSERT(object->elements()->length() == 0 ||
4284 object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
4285 int inobject_properties = object->map()->inobject_properties(); 4290 int inobject_properties = object->map()->inobject_properties();
4286 int header_size = size - inobject_properties * kPointerSize; 4291 int header_size = object_size - inobject_properties * kPointerSize;
4287 for (int i = 0; i < header_size; i += kPointerSize) { 4292 for (int i = 0; i < header_size; i += kPointerSize) {
4288 __ lw(a2, FieldMemOperand(source, i)); 4293 if (has_elements && i == JSObject::kElementsOffset) {
4289 __ sw(a2, FieldMemOperand(result, current_offset + i)); 4294 __ Addu(a2, result, Operand(elements_offset));
4295 } else {
4296 __ lw(a2, FieldMemOperand(source, i));
4297 }
4298 __ sw(a2, FieldMemOperand(result, object_offset + i));
4290 } 4299 }
4291 4300
4292 // Copy in-object properties. 4301 // Copy in-object properties.
4293 for (int i = 0; i < inobject_properties; i++) { 4302 for (int i = 0; i < inobject_properties; i++) {
4294 int total_offset = current_offset + object->GetInObjectPropertyOffset(i); 4303 int total_offset = object_offset + object->GetInObjectPropertyOffset(i);
4295 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i)); 4304 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
4296 if (value->IsJSObject()) { 4305 if (value->IsJSObject()) {
4297 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 4306 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4298 __ Addu(a2, result, Operand(*offset)); 4307 __ Addu(a2, result, Operand(*offset));
4299 __ sw(a2, FieldMemOperand(result, total_offset)); 4308 __ sw(a2, FieldMemOperand(result, total_offset));
4300 __ LoadHeapObject(source, value_object); 4309 __ LoadHeapObject(source, value_object);
4301 EmitDeepCopy(value_object, result, source, offset); 4310 EmitDeepCopy(value_object, result, source, offset);
4302 } else if (value->IsHeapObject()) { 4311 } else if (value->IsHeapObject()) {
4303 __ LoadHeapObject(a2, Handle<HeapObject>::cast(value)); 4312 __ LoadHeapObject(a2, Handle<HeapObject>::cast(value));
4304 __ sw(a2, FieldMemOperand(result, total_offset)); 4313 __ sw(a2, FieldMemOperand(result, total_offset));
4305 } else { 4314 } else {
4306 __ li(a2, Operand(value)); 4315 __ li(a2, Operand(value));
4307 __ sw(a2, FieldMemOperand(result, total_offset)); 4316 __ sw(a2, FieldMemOperand(result, total_offset));
4308 } 4317 }
4309 } 4318 }
4319
4320
4321 // Copy elements backing store header.
4322 ASSERT(!has_elements || elements->IsFixedArray());
4323 if (has_elements) {
4324 __ LoadHeapObject(source, elements);
4325 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) {
4326 __ lw(a2, FieldMemOperand(source, i));
4327 __ sw(a2, FieldMemOperand(result, elements_offset + i));
4328 }
4329 }
4330
4331 // Copy elements backing store content.
4332 ASSERT(!has_elements || elements->IsFixedArray());
4333 int elements_length = has_elements ? elements->length() : 0;
4334 for (int i = 0; i < elements_length; i++) {
4335 int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
4336 Handle<Object> value = JSObject::GetElement(object, i);
4337 if (value->IsJSObject()) {
4338 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4339 __ Addu(a2, result, Operand(*offset));
4340 __ sw(a2, FieldMemOperand(result, total_offset));
4341 __ LoadHeapObject(source, value_object);
4342 EmitDeepCopy(value_object, result, source, offset);
4343 } else if (value->IsHeapObject()) {
4344 __ LoadHeapObject(a2, Handle<HeapObject>::cast(value));
4345 __ sw(a2, FieldMemOperand(result, total_offset));
4346 } else {
4347 __ li(a2, Operand(value));
4348 __ sw(a2, FieldMemOperand(result, total_offset));
4349 }
4350 }
4310 } 4351 }
4311 4352
4312 4353
4313 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) { 4354 void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
4314 int size = instr->hydrogen()->total_size(); 4355 int size = instr->hydrogen()->total_size();
4315 4356
4316 // Allocate all objects that are part of the literal in one big 4357 // Allocate all objects that are part of the literal in one big
4317 // allocation. This avoids multiple limit checks. 4358 // allocation. This avoids multiple limit checks.
4318 Label allocated, runtime_allocate; 4359 Label allocated, runtime_allocate;
4319 __ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT); 4360 __ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
4320 __ jmp(&allocated); 4361 __ jmp(&allocated);
4321 4362
4322 __ bind(&runtime_allocate); 4363 __ bind(&runtime_allocate);
4323 __ li(a0, Operand(Smi::FromInt(size))); 4364 __ li(a0, Operand(Smi::FromInt(size)));
4324 __ push(a0); 4365 __ push(a0);
4325 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); 4366 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4326 4367
4327 __ bind(&allocated); 4368 __ bind(&allocated);
4328 int offset = 0; 4369 int offset = 0;
4329 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate()); 4370 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate());
4330 EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset); 4371 EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset);
4331 ASSERT_EQ(size, offset); 4372 ASSERT_EQ(size, offset);
4332 } 4373 }
4333 4374
4334 4375
4335 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) { 4376 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
4336 ASSERT(ToRegister(instr->result()).is(v0)); 4377 ASSERT(ToRegister(instr->result()).is(v0));
4337 Handle<FixedArray> literals(instr->environment()->closure()->literals()); 4378 Handle<FixedArray> literals(instr->environment()->closure()->literals());
4338 Handle<FixedArray> constant_properties = 4379 Handle<FixedArray> constant_properties =
4339 instr->hydrogen()->constant_properties(); 4380 instr->hydrogen()->constant_properties();
4340 4381
4341 // Set up the parameters to the stub/runtime call. 4382 // Set up the parameters to the stub/runtime call.
4342 __ LoadHeapObject(t0, literals); 4383 __ LoadHeapObject(t0, literals);
4343 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); 4384 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
4344 __ li(a2, Operand(constant_properties)); 4385 __ li(a2, Operand(constant_properties));
4345 int flags = instr->hydrogen()->fast_elements() 4386 int flags = instr->hydrogen()->fast_elements()
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 ASSERT(!environment->HasBeenRegistered()); 4777 ASSERT(!environment->HasBeenRegistered());
4737 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4778 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4738 ASSERT(osr_pc_offset_ == -1); 4779 ASSERT(osr_pc_offset_ == -1);
4739 osr_pc_offset_ = masm()->pc_offset(); 4780 osr_pc_offset_ = masm()->pc_offset();
4740 } 4781 }
4741 4782
4742 4783
4743 #undef __ 4784 #undef __
4744 4785
4745 } } // namespace v8::internal 4786 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698