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

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

Issue 10008007: Ensure HAllocateObject always allocates in new-space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improved test case to use small objects. Created 8 years, 8 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 | « no previous file | 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 4454 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 // the constructor's prototype changes, but instance size and property 4465 // the constructor's prototype changes, but instance size and property
4466 // counts remain unchanged (if slack tracking finished). 4466 // counts remain unchanged (if slack tracking finished).
4467 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); 4467 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
4468 __ AllocateInNewSpace(instance_size, 4468 __ AllocateInNewSpace(instance_size,
4469 result, 4469 result,
4470 scratch, 4470 scratch,
4471 scratch2, 4471 scratch2,
4472 deferred->entry(), 4472 deferred->entry(),
4473 TAG_OBJECT); 4473 TAG_OBJECT);
4474 4474
4475 __ bind(deferred->exit());
4476 if (FLAG_debug_code) {
4477 Label is_in_new_space;
4478 __ JumpIfInNewSpace(result, scratch, &is_in_new_space);
4479 __ Abort("Allocated object is not in new-space");
4480 __ bind(&is_in_new_space);
4481 }
4482
4475 // Load the initial map. 4483 // Load the initial map.
4476 Register map = scratch; 4484 Register map = scratch;
4477 __ LoadHeapObject(map, constructor); 4485 __ LoadHeapObject(map, constructor);
4478 __ ldr(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset)); 4486 __ ldr(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset));
4479 4487
4480 // Initialize map and fields of the newly allocated object. 4488 // Initialize map and fields of the newly allocated object.
4481 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); 4489 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
4482 __ str(map, FieldMemOperand(result, JSObject::kMapOffset)); 4490 __ str(map, FieldMemOperand(result, JSObject::kMapOffset));
4483 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); 4491 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex);
4484 __ str(scratch, FieldMemOperand(result, JSObject::kElementsOffset)); 4492 __ str(scratch, FieldMemOperand(result, JSObject::kElementsOffset));
4485 __ str(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset)); 4493 __ str(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset));
4486 if (initial_map->inobject_properties() != 0) { 4494 if (initial_map->inobject_properties() != 0) {
4487 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 4495 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
4488 for (int i = 0; i < initial_map->inobject_properties(); i++) { 4496 for (int i = 0; i < initial_map->inobject_properties(); i++) {
4489 int property_offset = JSObject::kHeaderSize + i * kPointerSize; 4497 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
4490 __ str(scratch, FieldMemOperand(result, property_offset)); 4498 __ str(scratch, FieldMemOperand(result, property_offset));
4491 } 4499 }
4492 } 4500 }
4493
4494 __ bind(deferred->exit());
4495 } 4501 }
4496 4502
4497 4503
4498 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { 4504 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
4499 Register result = ToRegister(instr->result()); 4505 Register result = ToRegister(instr->result());
4500 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); 4506 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4507 Handle<Map> initial_map(constructor->initial_map());
4508 int instance_size = initial_map->instance_size();
4501 4509
4502 // TODO(3095996): Get rid of this. For now, we need to make the 4510 // TODO(3095996): Get rid of this. For now, we need to make the
4503 // result register contain a valid pointer because it is already 4511 // result register contain a valid pointer because it is already
4504 // contained in the register pointer map. 4512 // contained in the register pointer map.
4505 __ mov(result, Operand(0)); 4513 __ mov(result, Operand(0));
4506 4514
4507 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); 4515 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters);
4508 __ LoadHeapObject(r0, constructor); 4516 __ mov(r0, Operand(Smi::FromInt(instance_size)));
4509 __ push(r0); 4517 __ push(r0);
4510 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr); 4518 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr);
4511 __ StoreToSafepointRegisterSlot(r0, result); 4519 __ StoreToSafepointRegisterSlot(r0, result);
4512 } 4520 }
4513 4521
4514 4522
4515 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 4523 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
4516 Heap* heap = isolate()->heap(); 4524 Heap* heap = isolate()->heap();
4517 ElementsKind boilerplate_elements_kind = 4525 ElementsKind boilerplate_elements_kind =
4518 instr->hydrogen()->boilerplate_elements_kind(); 4526 instr->hydrogen()->boilerplate_elements_kind();
4519 4527
4520 // Deopt if the array literal boilerplate ElementsKind is of a type different 4528 // Deopt if the array literal boilerplate ElementsKind is of a type different
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
5137 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); 5145 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize));
5138 __ ldr(result, FieldMemOperand(scratch, 5146 __ ldr(result, FieldMemOperand(scratch,
5139 FixedArray::kHeaderSize - kPointerSize)); 5147 FixedArray::kHeaderSize - kPointerSize));
5140 __ bind(&done); 5148 __ bind(&done);
5141 } 5149 }
5142 5150
5143 5151
5144 #undef __ 5152 #undef __
5145 5153
5146 } } // namespace v8::internal 5154 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698