From 517e15b014cb1a608223ea59606d0682fa5554d5 Mon Sep 17 00:00:00 2001 From: "titzer@chromium.org" Date: Thu, 24 Oct 2013 12:40:34 +0000 Subject: [PATCH] Handle constants in new space on arm by making macro-assembler smarter. BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/30023005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17376 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/full-codegen-arm.cc | 2 +- src/arm/lithium-codegen-arm.cc | 14 +++++++------- src/arm/lithium-codegen-arm.h | 2 -- src/arm/lithium-gap-resolver-arm.cc | 4 ++-- src/arm/macro-assembler-arm.cc | 29 ++++++++++++++--------------- src/arm/macro-assembler-arm.h | 11 ----------- src/arm/stub-cache-arm.cc | 6 +++--- 7 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 34b8921..079bccb 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -1158,7 +1158,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { Handle(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), isolate())); RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); - __ LoadHeapObject(r1, cell); + __ Move(r1, cell); __ mov(r2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); __ str(r2, FieldMemOperand(r1, Cell::kValueOffset)); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index fc7d0fd..a73d6a2 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -388,7 +388,7 @@ Register LCodeGen::EmitLoadRegister(LOperand* op, Register scratch) { Abort(kEmitLoadRegisterUnsupportedDoubleImmediate); } else { ASSERT(r.IsSmiOrTagged()); - __ LoadObject(scratch, literal); + __ Move(scratch, literal); } return scratch; } else if (op->IsStackSlot() || op->IsArgument()) { @@ -704,7 +704,7 @@ void LCodeGen::LoadContextFromDeferred(LOperand* context) { } else if (context->IsConstantOperand()) { HConstant* constant = chunk_->LookupConstant(LConstantOperand::cast(context)); - __ LoadObject(cp, Handle::cast(constant->handle(isolate()))); + __ Move(cp, Handle::cast(constant->handle(isolate()))); } else { UNREACHABLE(); } @@ -1840,7 +1840,7 @@ void LCodeGen::DoConstantE(LConstantE* instr) { void LCodeGen::DoConstantT(LConstantT* instr) { Handle value = instr->value(isolate()); AllowDeferredHandleDereference smi_check; - __ LoadObject(ToRegister(instr->result()), value); + __ Move(ToRegister(instr->result()), value); } @@ -2797,7 +2797,7 @@ void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, // offset to the location of the map check. Register temp = ToRegister(instr->temp()); ASSERT(temp.is(r4)); - __ LoadHeapObject(InstanceofStub::right(), instr->function()); + __ Move(InstanceofStub::right(), instr->function()); static const int kAdditionalDelta = 5; // Make sure that code size is predicable, since we use specific constants // offsets in the code to find embedded values.. @@ -3537,7 +3537,7 @@ void LCodeGen::DoOuterContext(LOuterContext* instr) { void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { ASSERT(ToRegister(instr->context()).is(cp)); __ push(cp); // The context is the first argument. - __ LoadHeapObject(scratch0(), instr->hydrogen()->pairs()); + __ Move(scratch0(), instr->hydrogen()->pairs()); __ push(scratch0()); __ mov(scratch0(), Operand(Smi::FromInt(instr->hydrogen()->flags()))); __ push(scratch0()); @@ -3574,7 +3574,7 @@ void LCodeGen::CallKnownFunction(Handle function, if (can_invoke_directly) { if (r1_state == R1_UNINITIALIZED) { - __ LoadHeapObject(r1, function); + __ Move(r1, function); } // Change context. @@ -5421,7 +5421,7 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { // r2-5 are used as temporaries. int literal_offset = FixedArray::OffsetOfElementAt(instr->hydrogen()->literal_index()); - __ LoadHeapObject(r6, instr->hydrogen()->literals()); + __ Move(r6, instr->hydrogen()->literals()); __ ldr(r1, FieldMemOperand(r6, literal_offset)); __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); __ cmp(r1, ip); diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index b893a9d..a9b85c8 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -246,8 +246,6 @@ class LCodeGen: public LCodeGenBase { CallKind call_kind, R1State r1_state); - void LoadHeapObject(Register result, Handle object); - void RecordSafepointWithLazyDeopt(LInstruction* instr, SafepointMode safepoint_mode); diff --git a/src/arm/lithium-gap-resolver-arm.cc b/src/arm/lithium-gap-resolver-arm.cc index 88ac7a2..0c6b2ad 100644 --- a/src/arm/lithium-gap-resolver-arm.cc +++ b/src/arm/lithium-gap-resolver-arm.cc @@ -252,7 +252,7 @@ void LGapResolver::EmitMove(int index) { if (cgen_->IsInteger32(constant_source)) { __ mov(dst, Operand(cgen_->ToRepresentation(constant_source, r))); } else { - __ LoadObject(dst, cgen_->ToHandle(constant_source)); + __ Move(dst, cgen_->ToHandle(constant_source)); } } else if (destination->IsDoubleRegister()) { DwVfpRegister result = cgen_->ToDoubleRegister(destination); @@ -267,7 +267,7 @@ void LGapResolver::EmitMove(int index) { __ mov(kSavedValueRegister, Operand(cgen_->ToRepresentation(constant_source, r))); } else { - __ LoadObject(kSavedValueRegister, + __ Move(kSavedValueRegister, cgen_->ToHandle(constant_source)); } __ str(kSavedValueRegister, cgen_->ToMemOperand(destination)); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index a149dee..8e187a4 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -233,7 +233,19 @@ void MacroAssembler::Push(Handle handle) { void MacroAssembler::Move(Register dst, Handle value) { - mov(dst, Operand(value)); + AllowDeferredHandleDereference smi_check; + if (value->IsSmi()) { + mov(dst, Operand(value)); + } else { + ASSERT(value->IsHeapObject()); + if (isolate()->heap()->InNewSpace(*value)) { + Handle cell = isolate()->factory()->NewCell(value); + mov(dst, Operand(cell)); + ldr(dst, FieldMemOperand(dst, Cell::kValueOffset)); + } else { + mov(dst, Operand(value)); + } + } } @@ -394,19 +406,6 @@ void MacroAssembler::StoreRoot(Register source, } -void MacroAssembler::LoadHeapObject(Register result, - Handle object) { - AllowDeferredHandleDereference using_raw_address; - if (isolate()->heap()->InNewSpace(*object)) { - Handle cell = isolate()->factory()->NewCell(object); - mov(result, Operand(cell)); - ldr(result, FieldMemOperand(result, Cell::kValueOffset)); - } else { - mov(result, Operand(object)); - } -} - - void MacroAssembler::InNewSpace(Register object, Register scratch, Condition cond, @@ -1285,7 +1284,7 @@ void MacroAssembler::InvokeFunction(Handle function, ASSERT(flag == JUMP_FUNCTION || has_frame()); // Get the function and setup the context. - LoadHeapObject(r1, function); + Move(r1, function); ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); // We call indirectly through the code field in the function to diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index 7cf5d9a..3247144 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -170,17 +170,6 @@ class MacroAssembler: public Assembler { Heap::RootListIndex index, Condition cond = al); - void LoadHeapObject(Register dst, Handle object); - - void LoadObject(Register result, Handle object) { - AllowDeferredHandleDereference heap_object_check; - if (object->IsHeapObject()) { - LoadHeapObject(result, Handle::cast(object)); - } else { - Move(result, object); - } - } - // --------------------------------------------------------------------------- // GC Support diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index a476a42..004e067 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -477,7 +477,7 @@ void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, if (details.type() == CONSTANT) { Handle constant(descriptors->GetValue(descriptor), masm->isolate()); - __ LoadObject(scratch1, constant); + __ Move(scratch1, constant); __ cmp(value_reg, scratch1); __ b(ne, miss_label); } else if (FLAG_track_fields && representation.IsSmi()) { @@ -854,7 +854,7 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, __ str(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize)); // Get the function and setup the context. Handle function = optimization.constant_function(); - __ LoadHeapObject(r5, function); + __ Move(r5, function); __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); __ str(r5, MemOperand(sp, FCA::kCalleeIndex * kPointerSize)); @@ -1414,7 +1414,7 @@ void LoadStubCompiler::GenerateLoadField(Register reg, void LoadStubCompiler::GenerateLoadConstant(Handle value) { // Return the constant value. - __ LoadObject(r0, value); + __ Move(r0, value); __ Ret(); } -- 2.7.4