Commit 87ab8ab1 authored by palfia@homejinni.com's avatar palfia@homejinni.com

MIPS: Allow direct allocation in old pointer space.

Port r13940 (a39765e7)

BUG=

Review URL: https://codereview.chromium.org/12413026

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13979 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 859a7154
...@@ -128,12 +128,8 @@ static void AllocateEmptyJSArray(MacroAssembler* masm, ...@@ -128,12 +128,8 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
if (initial_capacity > 0) { if (initial_capacity > 0) {
size += FixedArray::SizeFor(initial_capacity); size += FixedArray::SizeFor(initial_capacity);
} }
__ AllocateInNewSpace(size, __ Allocate(size, result, scratch2, scratch3, gc_required, TAG_OBJECT);
result,
scratch2,
scratch3,
gc_required,
TAG_OBJECT);
// Allocated the JSArray. Now initialize the fields except for the elements // Allocated the JSArray. Now initialize the fields except for the elements
// array. // array.
// result: JSObject // result: JSObject
...@@ -665,12 +661,12 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { ...@@ -665,12 +661,12 @@ void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
// ----------------------------------- // -----------------------------------
Label gc_required; Label gc_required;
__ AllocateInNewSpace(JSValue::kSize, __ Allocate(JSValue::kSize,
v0, // Result. v0, // Result.
a3, // Scratch. a3, // Scratch.
t0, // Scratch. t0, // Scratch.
&gc_required, &gc_required,
TAG_OBJECT); TAG_OBJECT);
// Initialising the String Object. // Initialising the String Object.
Register map = a3; Register map = a3;
......
...@@ -168,12 +168,7 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) { ...@@ -168,12 +168,7 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
__ pop(a3); __ pop(a3);
// Attempt to allocate new JSFunction in new space. // Attempt to allocate new JSFunction in new space.
__ AllocateInNewSpace(JSFunction::kSize, __ Allocate(JSFunction::kSize, v0, a1, a2, &gc, TAG_OBJECT);
v0,
a1,
a2,
&gc,
TAG_OBJECT);
__ IncrementCounter(counters->fast_new_closure_total(), 1, t2, t3); __ IncrementCounter(counters->fast_new_closure_total(), 1, t2, t3);
...@@ -300,12 +295,7 @@ void FastNewContextStub::Generate(MacroAssembler* masm) { ...@@ -300,12 +295,7 @@ void FastNewContextStub::Generate(MacroAssembler* masm) {
int length = slots_ + Context::MIN_CONTEXT_SLOTS; int length = slots_ + Context::MIN_CONTEXT_SLOTS;
// Attempt to allocate the context in new space. // Attempt to allocate the context in new space.
__ AllocateInNewSpace(FixedArray::SizeFor(length), __ Allocate(FixedArray::SizeFor(length), v0, a1, a2, &gc, TAG_OBJECT);
v0,
a1,
a2,
&gc,
TAG_OBJECT);
// Load the function from the stack. // Load the function from the stack.
__ lw(a3, MemOperand(sp, 0)); __ lw(a3, MemOperand(sp, 0));
...@@ -349,8 +339,7 @@ void FastNewBlockContextStub::Generate(MacroAssembler* masm) { ...@@ -349,8 +339,7 @@ void FastNewBlockContextStub::Generate(MacroAssembler* masm) {
// Try to allocate the context in new space. // Try to allocate the context in new space.
Label gc; Label gc;
int length = slots_ + Context::MIN_CONTEXT_SLOTS; int length = slots_ + Context::MIN_CONTEXT_SLOTS;
__ AllocateInNewSpace(FixedArray::SizeFor(length), __ Allocate(FixedArray::SizeFor(length), v0, a1, a2, &gc, TAG_OBJECT);
v0, a1, a2, &gc, TAG_OBJECT);
// Load the function from the stack. // Load the function from the stack.
__ lw(a3, MemOperand(sp, 0)); __ lw(a3, MemOperand(sp, 0));
...@@ -429,12 +418,7 @@ static void GenerateFastCloneShallowArrayCommon( ...@@ -429,12 +418,7 @@ static void GenerateFastCloneShallowArrayCommon(
// Allocate both the JS array and the elements array in one big // Allocate both the JS array and the elements array in one big
// allocation. This avoids multiple limit checks. // allocation. This avoids multiple limit checks.
__ AllocateInNewSpace(size, __ Allocate(size, v0, a1, a2, fail, TAG_OBJECT);
v0,
a1,
a2,
fail,
TAG_OBJECT);
if (allocation_site_mode == TRACK_ALLOCATION_SITE) { if (allocation_site_mode == TRACK_ALLOCATION_SITE) {
__ li(a2, Operand(Handle<Map>(masm->isolate()->heap()-> __ li(a2, Operand(Handle<Map>(masm->isolate()->heap()->
......
...@@ -1553,7 +1553,7 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { ...@@ -1553,7 +1553,7 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
__ bind(&materialized); __ bind(&materialized);
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
Label allocated, runtime_allocate; Label allocated, runtime_allocate;
__ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT); __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
__ jmp(&allocated); __ jmp(&allocated);
__ bind(&runtime_allocate); __ bind(&runtime_allocate);
......
...@@ -5255,12 +5255,8 @@ void LCodeGen::DoAllocateObject(LAllocateObject* instr) { ...@@ -5255,12 +5255,8 @@ void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
// the constructor's prototype changes, but instance size and property // the constructor's prototype changes, but instance size and property
// counts remain unchanged (if slack tracking finished). // counts remain unchanged (if slack tracking finished).
ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
__ AllocateInNewSpace(instance_size, __ Allocate(instance_size, result, scratch, scratch2, deferred->entry(),
result, TAG_OBJECT);
scratch,
scratch2,
deferred->entry(),
TAG_OBJECT);
__ bind(deferred->exit()); __ bind(deferred->exit());
if (FLAG_debug_code) { if (FLAG_debug_code) {
...@@ -5335,12 +5331,10 @@ void LCodeGen::DoAllocate(LAllocate* instr) { ...@@ -5335,12 +5331,10 @@ void LCodeGen::DoAllocate(LAllocate* instr) {
} }
if (instr->size()->IsConstantOperand()) { if (instr->size()->IsConstantOperand()) {
int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
__ AllocateInNewSpace(size, if (instr->hydrogen()->CanAllocateInOldPointerSpace()) {
result, flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_POINTER_SPACE);
scratch, }
scratch2, __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags);
deferred->entry(),
flags);
} else { } else {
Register size = ToRegister(instr->size()); Register size = ToRegister(instr->size());
__ AllocateInNewSpace(size, __ AllocateInNewSpace(size,
...@@ -5575,7 +5569,7 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) { ...@@ -5575,7 +5569,7 @@ void LCodeGen::DoFastLiteral(LFastLiteral* instr) {
// Allocate all objects that are part of the literal in one big // Allocate all objects that are part of the literal in one big
// allocation. This avoids multiple limit checks. // allocation. This avoids multiple limit checks.
Label allocated, runtime_allocate; Label allocated, runtime_allocate;
__ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT); __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
__ jmp(&allocated); __ jmp(&allocated);
__ bind(&runtime_allocate); __ bind(&runtime_allocate);
...@@ -5658,7 +5652,7 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { ...@@ -5658,7 +5652,7 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
Label allocated, runtime_allocate; Label allocated, runtime_allocate;
__ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT); __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
__ jmp(&allocated); __ jmp(&allocated);
__ bind(&runtime_allocate); __ bind(&runtime_allocate);
......
...@@ -2912,12 +2912,12 @@ void MacroAssembler::ThrowUncatchable(Register value) { ...@@ -2912,12 +2912,12 @@ void MacroAssembler::ThrowUncatchable(Register value) {
} }
void MacroAssembler::AllocateInNewSpace(int object_size, void MacroAssembler::Allocate(int object_size,
Register result, Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required, Label* gc_required,
AllocationFlags flags) { AllocationFlags flags) {
if (!FLAG_inline_new) { if (!FLAG_inline_new) {
if (emit_debug_code()) { if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure. // Trash the registers to simulate an allocation failure.
...@@ -2945,20 +2945,21 @@ void MacroAssembler::AllocateInNewSpace(int object_size, ...@@ -2945,20 +2945,21 @@ void MacroAssembler::AllocateInNewSpace(int object_size,
// Check relative positions of allocation top and limit addresses. // Check relative positions of allocation top and limit addresses.
// ARM adds additional checks to make sure the ldm instruction can be // ARM adds additional checks to make sure the ldm instruction can be
// used. On MIPS we don't have ldm so we don't need additional checks either. // used. On MIPS we don't have ldm so we don't need additional checks either.
ExternalReference new_space_allocation_top = ExternalReference allocation_top =
ExternalReference::new_space_allocation_top_address(isolate()); AllocationUtils::GetAllocationTopReference(isolate(), flags);
ExternalReference new_space_allocation_limit = ExternalReference allocation_limit =
ExternalReference::new_space_allocation_limit_address(isolate()); AllocationUtils::GetAllocationLimitReference(isolate(), flags);
intptr_t top = intptr_t top =
reinterpret_cast<intptr_t>(new_space_allocation_top.address()); reinterpret_cast<intptr_t>(allocation_top.address());
intptr_t limit = intptr_t limit =
reinterpret_cast<intptr_t>(new_space_allocation_limit.address()); reinterpret_cast<intptr_t>(allocation_limit.address());
ASSERT((limit - top) == kPointerSize); ASSERT((limit - top) == kPointerSize);
// Set up allocation top address and object size registers. // Set up allocation top address and object size registers.
Register topaddr = scratch1; Register topaddr = scratch1;
Register obj_size_reg = scratch2; Register obj_size_reg = scratch2;
li(topaddr, Operand(new_space_allocation_top)); li(topaddr, Operand(allocation_top));
li(obj_size_reg, Operand(object_size)); li(obj_size_reg, Operand(object_size));
// This code stores a temporary value in t9. // This code stores a temporary value in t9.
...@@ -2997,6 +2998,7 @@ void MacroAssembler::AllocateInNewSpace(Register object_size, ...@@ -2997,6 +2998,7 @@ void MacroAssembler::AllocateInNewSpace(Register object_size,
Register scratch2, Register scratch2,
Label* gc_required, Label* gc_required,
AllocationFlags flags) { AllocationFlags flags) {
ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
if (!FLAG_inline_new) { if (!FLAG_inline_new) {
if (emit_debug_code()) { if (emit_debug_code()) {
// Trash the registers to simulate an allocation failure. // Trash the registers to simulate an allocation failure.
...@@ -3159,12 +3161,8 @@ void MacroAssembler::AllocateTwoByteConsString(Register result, ...@@ -3159,12 +3161,8 @@ void MacroAssembler::AllocateTwoByteConsString(Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required) { Label* gc_required) {
AllocateInNewSpace(ConsString::kSize, Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
result, TAG_OBJECT);
scratch1,
scratch2,
gc_required,
TAG_OBJECT);
InitializeNewString(result, InitializeNewString(result,
length, length,
Heap::kConsStringMapRootIndex, Heap::kConsStringMapRootIndex,
...@@ -3178,12 +3176,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, ...@@ -3178,12 +3176,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required) { Label* gc_required) {
AllocateInNewSpace(ConsString::kSize, Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
result, TAG_OBJECT);
scratch1,
scratch2,
gc_required,
TAG_OBJECT);
InitializeNewString(result, InitializeNewString(result,
length, length,
Heap::kConsAsciiStringMapRootIndex, Heap::kConsAsciiStringMapRootIndex,
...@@ -3197,12 +3191,8 @@ void MacroAssembler::AllocateTwoByteSlicedString(Register result, ...@@ -3197,12 +3191,8 @@ void MacroAssembler::AllocateTwoByteSlicedString(Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required) { Label* gc_required) {
AllocateInNewSpace(SlicedString::kSize, Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
result, TAG_OBJECT);
scratch1,
scratch2,
gc_required,
TAG_OBJECT);
InitializeNewString(result, InitializeNewString(result,
length, length,
...@@ -3217,12 +3207,8 @@ void MacroAssembler::AllocateAsciiSlicedString(Register result, ...@@ -3217,12 +3207,8 @@ void MacroAssembler::AllocateAsciiSlicedString(Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required) { Label* gc_required) {
AllocateInNewSpace(SlicedString::kSize, Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
result, TAG_OBJECT);
scratch1,
scratch2,
gc_required,
TAG_OBJECT);
InitializeNewString(result, InitializeNewString(result,
length, length,
...@@ -3242,13 +3228,8 @@ void MacroAssembler::AllocateHeapNumber(Register result, ...@@ -3242,13 +3228,8 @@ void MacroAssembler::AllocateHeapNumber(Register result,
TaggingMode tagging_mode) { TaggingMode tagging_mode) {
// Allocate an object in the heap for the heap number and tag it as a heap // Allocate an object in the heap for the heap number and tag it as a heap
// object. // object.
AllocateInNewSpace(HeapNumber::kSize, Allocate(HeapNumber::kSize, result, scratch1, scratch2, need_gc,
result, tagging_mode == TAG_RESULT ? TAG_OBJECT : NO_ALLOCATION_FLAGS);
scratch1,
scratch2,
need_gc,
tagging_mode == TAG_RESULT ? TAG_OBJECT :
NO_ALLOCATION_FLAGS);
// Store heap number map in the allocated object. // Store heap number map in the allocated object.
AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
......
...@@ -477,19 +477,20 @@ class MacroAssembler: public Assembler { ...@@ -477,19 +477,20 @@ class MacroAssembler: public Assembler {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Allocation support. // Allocation support.
// Allocate an object in new space. The object_size is specified // Allocate an object in new space or old pointer space. The object_size is
// either in bytes or in words if the allocation flag SIZE_IN_WORDS // specified either in bytes or in words if the allocation flag SIZE_IN_WORDS
// is passed. If the new space is exhausted control continues at the // is passed. If the space is exhausted control continues at the gc_required
// gc_required label. The allocated object is returned in result. If // label. The allocated object is returned in result. If the flag
// the flag tag_allocated_object is true the result is tagged as as // tag_allocated_object is true the result is tagged as as a heap object.
// a heap object. All registers are clobbered also when control // All registers are clobbered also when control continues at the gc_required
// continues at the gc_required label. // label.
void AllocateInNewSpace(int object_size, void Allocate(int object_size,
Register result, Register result,
Register scratch1, Register scratch1,
Register scratch2, Register scratch2,
Label* gc_required, Label* gc_required,
AllocationFlags flags); AllocationFlags flags);
void AllocateInNewSpace(Register object_size, void AllocateInNewSpace(Register object_size,
Register result, Register result,
Register scratch1, Register scratch1,
......
...@@ -3731,8 +3731,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement( ...@@ -3731,8 +3731,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(
__ Branch(&check_capacity, ne, elements_reg, Operand(at)); __ Branch(&check_capacity, ne, elements_reg, Operand(at));
int size = FixedArray::SizeFor(JSArray::kPreallocatedArrayElements); int size = FixedArray::SizeFor(JSArray::kPreallocatedArrayElements);
__ AllocateInNewSpace(size, elements_reg, scratch, scratch2, &slow, __ Allocate(size, elements_reg, scratch, scratch2, &slow, TAG_OBJECT);
TAG_OBJECT);
__ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex); __ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex);
__ sw(scratch, FieldMemOperand(elements_reg, JSObject::kMapOffset)); __ sw(scratch, FieldMemOperand(elements_reg, JSObject::kMapOffset));
...@@ -3882,8 +3881,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( ...@@ -3882,8 +3881,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
__ Branch(&check_capacity, ne, elements_reg, Operand(at)); __ Branch(&check_capacity, ne, elements_reg, Operand(at));
int size = FixedDoubleArray::SizeFor(JSArray::kPreallocatedArrayElements); int size = FixedDoubleArray::SizeFor(JSArray::kPreallocatedArrayElements);
__ AllocateInNewSpace(size, elements_reg, scratch1, scratch2, &slow, __ Allocate(size, elements_reg, scratch1, scratch2, &slow, TAG_OBJECT);
TAG_OBJECT);
// Initialize the new FixedDoubleArray. // Initialize the new FixedDoubleArray.
__ LoadRoot(scratch1, Heap::kFixedDoubleArrayMapRootIndex); __ LoadRoot(scratch1, Heap::kFixedDoubleArrayMapRootIndex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment