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

Side by Side Diff: src/arm/lithium-codegen-arm.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/arm/lithium-arm.cc ('k') | src/hydrogen.cc » ('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 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4373 } 4373 }
4374 4374
4375 4375
4376 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 4376 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
4377 Register result, 4377 Register result,
4378 Register source, 4378 Register source,
4379 int* offset) { 4379 int* offset) {
4380 ASSERT(!source.is(r2)); 4380 ASSERT(!source.is(r2));
4381 ASSERT(!result.is(r2)); 4381 ASSERT(!result.is(r2));
4382 4382
4383 // Only elements backing stores for non-COW arrays need to be copied.
4384 Handle<FixedArrayBase> elements(object->elements());
4385 bool has_elements = elements->length() > 0 &&
4386 elements->map() != isolate()->heap()->fixed_cow_array_map();
4387
4383 // Increase the offset so that subsequent objects end up right after 4388 // Increase the offset so that subsequent objects end up right after
4384 // this one. 4389 // this object and its backing store.
4385 int current_offset = *offset; 4390 int object_offset = *offset;
4386 int size = object->map()->instance_size(); 4391 int object_size = object->map()->instance_size();
4387 *offset += size; 4392 int elements_offset = *offset + object_size;
4393 int elements_size = has_elements ? elements->Size() : 0;
4394 *offset += object_size + elements_size;
4388 4395
4389 // Copy object header. 4396 // Copy object header.
4390 ASSERT(object->properties()->length() == 0); 4397 ASSERT(object->properties()->length() == 0);
4391 ASSERT(object->elements()->length() == 0 ||
4392 object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
4393 int inobject_properties = object->map()->inobject_properties(); 4398 int inobject_properties = object->map()->inobject_properties();
4394 int header_size = size - inobject_properties * kPointerSize; 4399 int header_size = object_size - inobject_properties * kPointerSize;
4395 for (int i = 0; i < header_size; i += kPointerSize) { 4400 for (int i = 0; i < header_size; i += kPointerSize) {
4396 __ ldr(r2, FieldMemOperand(source, i)); 4401 if (has_elements && i == JSObject::kElementsOffset) {
4397 __ str(r2, FieldMemOperand(result, current_offset + i)); 4402 __ add(r2, result, Operand(elements_offset));
4403 } else {
4404 __ ldr(r2, FieldMemOperand(source, i));
4405 }
4406 __ str(r2, FieldMemOperand(result, object_offset + i));
4398 } 4407 }
4399 4408
4400 // Copy in-object properties. 4409 // Copy in-object properties.
4401 for (int i = 0; i < inobject_properties; i++) { 4410 for (int i = 0; i < inobject_properties; i++) {
4402 int total_offset = current_offset + object->GetInObjectPropertyOffset(i); 4411 int total_offset = object_offset + object->GetInObjectPropertyOffset(i);
4403 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i)); 4412 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
4404 if (value->IsJSObject()) { 4413 if (value->IsJSObject()) {
4405 Handle<JSObject> value_object = Handle<JSObject>::cast(value); 4414 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4406 __ add(r2, result, Operand(*offset)); 4415 __ add(r2, result, Operand(*offset));
4407 __ str(r2, FieldMemOperand(result, total_offset)); 4416 __ str(r2, FieldMemOperand(result, total_offset));
4408 __ LoadHeapObject(source, value_object); 4417 __ LoadHeapObject(source, value_object);
4409 EmitDeepCopy(value_object, result, source, offset); 4418 EmitDeepCopy(value_object, result, source, offset);
4410 } else if (value->IsHeapObject()) { 4419 } else if (value->IsHeapObject()) {
4411 __ LoadHeapObject(r2, Handle<HeapObject>::cast(value)); 4420 __ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
4412 __ str(r2, FieldMemOperand(result, total_offset)); 4421 __ str(r2, FieldMemOperand(result, total_offset));
4413 } else { 4422 } else {
4414 __ mov(r2, Operand(value)); 4423 __ mov(r2, Operand(value));
4415 __ str(r2, FieldMemOperand(result, total_offset)); 4424 __ str(r2, FieldMemOperand(result, total_offset));
4416 } 4425 }
4417 } 4426 }
4427
4428 // Copy elements backing store header.
4429 ASSERT(!has_elements || elements->IsFixedArray());
4430 if (has_elements) {
4431 __ LoadHeapObject(source, elements);
4432 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) {
4433 __ ldr(r2, FieldMemOperand(source, i));
4434 __ str(r2, FieldMemOperand(result, elements_offset + i));
4435 }
4436 }
4437
4438 // Copy elements backing store content.
4439 ASSERT(!has_elements || elements->IsFixedArray());
4440 int elements_length = has_elements ? elements->length() : 0;
4441 for (int i = 0; i < elements_length; i++) {
4442 int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i);
4443 Handle<Object> value = JSObject::GetElement(object, i);
4444 if (value->IsJSObject()) {
4445 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4446 __ add(r2, result, Operand(*offset));
4447 __ str(r2, FieldMemOperand(result, total_offset));
4448 __ LoadHeapObject(source, value_object);
4449 EmitDeepCopy(value_object, result, source, offset);
4450 } else if (value->IsHeapObject()) {
4451 __ LoadHeapObject(r2, Handle<HeapObject>::cast(value));
4452 __ str(r2, FieldMemOperand(result, total_offset));
4453 } else {
4454 __ mov(r2, Operand(value));
4455 __ str(r2, FieldMemOperand(result, total_offset));
4456 }
4457 }
4418 } 4458 }
4419 4459
4420 4460
4421 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) { 4461 void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
4422 int size = instr->hydrogen()->total_size(); 4462 int size = instr->hydrogen()->total_size();
4423 4463
4424 // Allocate all objects that are part of the literal in one big 4464 // Allocate all objects that are part of the literal in one big
4425 // allocation. This avoids multiple limit checks. 4465 // allocation. This avoids multiple limit checks.
4426 Label allocated, runtime_allocate; 4466 Label allocated, runtime_allocate;
4427 __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); 4467 __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
4428 __ jmp(&allocated); 4468 __ jmp(&allocated);
4429 4469
4430 __ bind(&runtime_allocate); 4470 __ bind(&runtime_allocate);
4431 __ mov(r0, Operand(Smi::FromInt(size))); 4471 __ mov(r0, Operand(Smi::FromInt(size)));
4432 __ push(r0); 4472 __ push(r0);
4433 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); 4473 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4434 4474
4435 __ bind(&allocated); 4475 __ bind(&allocated);
4436 int offset = 0; 4476 int offset = 0;
4437 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate()); 4477 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate());
4438 EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset); 4478 EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset);
4439 ASSERT_EQ(size, offset); 4479 ASSERT_EQ(size, offset);
4440 } 4480 }
4441 4481
4442 4482
4443 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) { 4483 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
4444 Handle<FixedArray> literals(instr->environment()->closure()->literals()); 4484 Handle<FixedArray> literals(instr->environment()->closure()->literals());
4445 Handle<FixedArray> constant_properties = 4485 Handle<FixedArray> constant_properties =
4446 instr->hydrogen()->constant_properties(); 4486 instr->hydrogen()->constant_properties();
4447 4487
4448 // Set up the parameters to the stub/runtime call. 4488 // Set up the parameters to the stub/runtime call.
4449 __ LoadHeapObject(r4, literals); 4489 __ LoadHeapObject(r4, literals);
4450 __ mov(r3, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); 4490 __ mov(r3, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
4451 __ mov(r2, Operand(constant_properties)); 4491 __ mov(r2, Operand(constant_properties));
4452 int flags = instr->hydrogen()->fast_elements() 4492 int flags = instr->hydrogen()->fast_elements()
4453 ? ObjectLiteral::kFastElements 4493 ? ObjectLiteral::kFastElements
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
4808 ASSERT(osr_pc_offset_ == -1); 4848 ASSERT(osr_pc_offset_ == -1);
4809 osr_pc_offset_ = masm()->pc_offset(); 4849 osr_pc_offset_ = masm()->pc_offset();
4810 } 4850 }
4811 4851
4812 4852
4813 4853
4814 4854
4815 #undef __ 4855 #undef __
4816 4856
4817 } } // namespace v8::internal 4857 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698