Commit b9b2c456 authored by plind44@gmail.com's avatar plind44@gmail.com

MIPS: Handle constants in new space by making macro-assembler smarter.

Port r17376 (9af4f51)

BUG=
R=plind44@gmail.com

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

Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17463 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0400bc45
...@@ -1162,7 +1162,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -1162,7 +1162,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker),
isolate())); isolate()));
RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell);
__ LoadHeapObject(a1, cell); __ li(a1, cell);
__ li(a2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); __ li(a2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
__ sw(a2, FieldMemOperand(a1, Cell::kValueOffset)); __ sw(a2, FieldMemOperand(a1, Cell::kValueOffset));
......
...@@ -366,7 +366,7 @@ Register LCodeGen::EmitLoadRegister(LOperand* op, Register scratch) { ...@@ -366,7 +366,7 @@ Register LCodeGen::EmitLoadRegister(LOperand* op, Register scratch) {
Abort(kEmitLoadRegisterUnsupportedDoubleImmediate); Abort(kEmitLoadRegisterUnsupportedDoubleImmediate);
} else { } else {
ASSERT(r.IsSmiOrTagged()); ASSERT(r.IsSmiOrTagged());
__ LoadObject(scratch, literal); __ li(scratch, literal);
} }
return scratch; return scratch;
} else if (op->IsStackSlot() || op->IsArgument()) { } else if (op->IsStackSlot() || op->IsArgument()) {
...@@ -668,7 +668,7 @@ void LCodeGen::LoadContextFromDeferred(LOperand* context) { ...@@ -668,7 +668,7 @@ void LCodeGen::LoadContextFromDeferred(LOperand* context) {
} else if (context->IsConstantOperand()) { } else if (context->IsConstantOperand()) {
HConstant* constant = HConstant* constant =
chunk_->LookupConstant(LConstantOperand::cast(context)); chunk_->LookupConstant(LConstantOperand::cast(context));
__ LoadObject(cp, Handle<Object>::cast(constant->handle(isolate()))); __ li(cp, Handle<Object>::cast(constant->handle(isolate())));
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
...@@ -1647,7 +1647,7 @@ void LCodeGen::DoConstantE(LConstantE* instr) { ...@@ -1647,7 +1647,7 @@ void LCodeGen::DoConstantE(LConstantE* instr) {
void LCodeGen::DoConstantT(LConstantT* instr) { void LCodeGen::DoConstantT(LConstantT* instr) {
Handle<Object> value = instr->value(isolate()); Handle<Object> value = instr->value(isolate());
AllowDeferredHandleDereference smi_check; AllowDeferredHandleDereference smi_check;
__ LoadObject(ToRegister(instr->result()), value); __ li(ToRegister(instr->result()), value);
} }
...@@ -2651,7 +2651,7 @@ void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, ...@@ -2651,7 +2651,7 @@ void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
// offset to the location of the map check. // offset to the location of the map check.
Register temp = ToRegister(instr->temp()); Register temp = ToRegister(instr->temp());
ASSERT(temp.is(t0)); ASSERT(temp.is(t0));
__ LoadHeapObject(InstanceofStub::right(), instr->function()); __ li(InstanceofStub::right(), instr->function());
static const int kAdditionalDelta = 7; static const int kAdditionalDelta = 7;
int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta; int delta = masm_->InstructionsGeneratedSince(map_check) + kAdditionalDelta;
Label before_push_delta; Label before_push_delta;
...@@ -3403,7 +3403,7 @@ void LCodeGen::DoOuterContext(LOuterContext* instr) { ...@@ -3403,7 +3403,7 @@ void LCodeGen::DoOuterContext(LOuterContext* instr) {
void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
ASSERT(ToRegister(instr->context()).is(cp)); ASSERT(ToRegister(instr->context()).is(cp));
__ LoadHeapObject(scratch0(), instr->hydrogen()->pairs()); __ li(scratch0(), instr->hydrogen()->pairs());
__ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags()))); __ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
// The context is the first argument. // The context is the first argument.
__ Push(cp, scratch0(), scratch1()); __ Push(cp, scratch0(), scratch1());
...@@ -3440,7 +3440,7 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function, ...@@ -3440,7 +3440,7 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
if (can_invoke_directly) { if (can_invoke_directly) {
if (a1_state == A1_UNINITIALIZED) { if (a1_state == A1_UNINITIALIZED) {
__ LoadHeapObject(a1, function); __ li(a1, function);
} }
// Change context. // Change context.
...@@ -5374,7 +5374,7 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { ...@@ -5374,7 +5374,7 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
// a2 and t0-t2 are used as temporaries. // a2 and t0-t2 are used as temporaries.
int literal_offset = int literal_offset =
FixedArray::OffsetOfElementAt(instr->hydrogen()->literal_index()); FixedArray::OffsetOfElementAt(instr->hydrogen()->literal_index());
__ LoadHeapObject(t3, instr->hydrogen()->literals()); __ li(t3, instr->hydrogen()->literals());
__ lw(a1, FieldMemOperand(t3, literal_offset)); __ lw(a1, FieldMemOperand(t3, literal_offset));
__ LoadRoot(at, Heap::kUndefinedValueRootIndex); __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
__ Branch(&materialized, ne, a1, Operand(at)); __ Branch(&materialized, ne, a1, Operand(at));
......
...@@ -242,8 +242,6 @@ class LCodeGen: public LCodeGenBase { ...@@ -242,8 +242,6 @@ class LCodeGen: public LCodeGenBase {
CallKind call_kind, CallKind call_kind,
A1State a1_state); A1State a1_state);
void LoadHeapObject(Register result, Handle<HeapObject> object);
void RecordSafepointWithLazyDeopt(LInstruction* instr, void RecordSafepointWithLazyDeopt(LInstruction* instr,
SafepointMode safepoint_mode); SafepointMode safepoint_mode);
......
...@@ -256,7 +256,7 @@ void LGapResolver::EmitMove(int index) { ...@@ -256,7 +256,7 @@ void LGapResolver::EmitMove(int index) {
if (cgen_->IsInteger32(constant_source)) { if (cgen_->IsInteger32(constant_source)) {
__ li(dst, Operand(cgen_->ToRepresentation(constant_source, r))); __ li(dst, Operand(cgen_->ToRepresentation(constant_source, r)));
} else { } else {
__ LoadObject(dst, cgen_->ToHandle(constant_source)); __ li(dst, cgen_->ToHandle(constant_source));
} }
} else if (destination->IsDoubleRegister()) { } else if (destination->IsDoubleRegister()) {
DoubleRegister result = cgen_->ToDoubleRegister(destination); DoubleRegister result = cgen_->ToDoubleRegister(destination);
...@@ -271,8 +271,7 @@ void LGapResolver::EmitMove(int index) { ...@@ -271,8 +271,7 @@ void LGapResolver::EmitMove(int index) {
__ li(kLithiumScratchReg, __ li(kLithiumScratchReg,
Operand(cgen_->ToRepresentation(constant_source, r))); Operand(cgen_->ToRepresentation(constant_source, r)));
} else { } else {
__ LoadObject(kLithiumScratchReg, __ li(kLithiumScratchReg, cgen_->ToHandle(constant_source));
cgen_->ToHandle(constant_source));
} }
__ sw(kLithiumScratchReg, cgen_->ToMemOperand(destination)); __ sw(kLithiumScratchReg, cgen_->ToMemOperand(destination));
} }
......
...@@ -83,19 +83,6 @@ void MacroAssembler::StoreRoot(Register source, ...@@ -83,19 +83,6 @@ void MacroAssembler::StoreRoot(Register source,
} }
void MacroAssembler::LoadHeapObject(Register result,
Handle<HeapObject> object) {
AllowDeferredHandleDereference using_raw_address;
if (isolate()->heap()->InNewSpace(*object)) {
Handle<Cell> cell = isolate()->factory()->NewCell(object);
li(result, Operand(cell));
lw(result, FieldMemOperand(result, Cell::kValueOffset));
} else {
li(result, Operand(object));
}
}
// Push and pop all registers that can hold pointers. // Push and pop all registers that can hold pointers.
void MacroAssembler::PushSafepointRegisters() { void MacroAssembler::PushSafepointRegisters() {
// Safepoints expect a block of kNumSafepointRegisters values on the // Safepoints expect a block of kNumSafepointRegisters values on the
...@@ -768,6 +755,23 @@ void MacroAssembler::Ror(Register rd, Register rs, const Operand& rt) { ...@@ -768,6 +755,23 @@ void MacroAssembler::Ror(Register rd, Register rs, const Operand& rt) {
//------------Pseudo-instructions------------- //------------Pseudo-instructions-------------
void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) {
AllowDeferredHandleDereference smi_check;
if (value->IsSmi()) {
li(dst, Operand(value), mode);
} else {
ASSERT(value->IsHeapObject());
if (isolate()->heap()->InNewSpace(*value)) {
Handle<Cell> cell = isolate()->factory()->NewCell(value);
li(dst, Operand(cell));
lw(dst, FieldMemOperand(dst, Cell::kValueOffset));
} else {
li(dst, Operand(value));
}
}
}
void MacroAssembler::li(Register rd, Operand j, LiFlags mode) { void MacroAssembler::li(Register rd, Operand j, LiFlags mode) {
ASSERT(!j.is_reg()); ASSERT(!j.is_reg());
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
...@@ -3697,7 +3701,7 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function, ...@@ -3697,7 +3701,7 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
ASSERT(flag == JUMP_FUNCTION || has_frame()); ASSERT(flag == JUMP_FUNCTION || has_frame());
// Get the function and setup the context. // Get the function and setup the context.
LoadHeapObject(a1, function); li(a1, function);
lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// We call indirectly through the code field in the function to // We call indirectly through the code field in the function to
......
...@@ -293,17 +293,6 @@ class MacroAssembler: public Assembler { ...@@ -293,17 +293,6 @@ class MacroAssembler: public Assembler {
Heap::RootListIndex index, Heap::RootListIndex index,
Condition cond, Register src1, const Operand& src2); Condition cond, Register src1, const Operand& src2);
void LoadHeapObject(Register dst, Handle<HeapObject> object);
void LoadObject(Register result, Handle<Object> object) {
AllowDeferredHandleDereference heap_object_check;
if (object->IsHeapObject()) {
LoadHeapObject(result, Handle<HeapObject>::cast(object));
} else {
li(result, object);
}
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// GC Support // GC Support
...@@ -620,10 +609,7 @@ class MacroAssembler: public Assembler { ...@@ -620,10 +609,7 @@ class MacroAssembler: public Assembler {
inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) { inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) {
li(rd, Operand(j), mode); li(rd, Operand(j), mode);
} }
inline void li(Register dst, Handle<Object> value, void li(Register dst, Handle<Object> value, LiFlags mode = OPTIMIZE_SIZE);
LiFlags mode = OPTIMIZE_SIZE) {
li(dst, Operand(value), mode);
}
// Push multiple registers on the stack. // Push multiple registers on the stack.
// Registers are saved in numerical order, with higher numbered registers // Registers are saved in numerical order, with higher numbered registers
......
...@@ -461,7 +461,7 @@ void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, ...@@ -461,7 +461,7 @@ void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm,
if (details.type() == CONSTANT) { if (details.type() == CONSTANT) {
Handle<Object> constant(descriptors->GetValue(descriptor), masm->isolate()); Handle<Object> constant(descriptors->GetValue(descriptor), masm->isolate());
__ LoadObject(scratch1, constant); __ li(scratch1, constant);
__ Branch(miss_label, ne, value_reg, Operand(scratch1)); __ Branch(miss_label, ne, value_reg, Operand(scratch1));
} else if (FLAG_track_fields && representation.IsSmi()) { } else if (FLAG_track_fields && representation.IsSmi()) {
__ JumpIfNotSmi(value_reg, miss_label); __ JumpIfNotSmi(value_reg, miss_label);
...@@ -837,7 +837,7 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -837,7 +837,7 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
__ sw(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize)); __ sw(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize));
// Get the function and setup the context. // Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function(); Handle<JSFunction> function = optimization.constant_function();
__ LoadHeapObject(t1, function); __ li(t1, function);
__ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset)); __ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset));
__ sw(t1, MemOperand(sp, FCA::kCalleeIndex * kPointerSize)); __ sw(t1, MemOperand(sp, FCA::kCalleeIndex * kPointerSize));
...@@ -1376,7 +1376,7 @@ void LoadStubCompiler::GenerateLoadField(Register reg, ...@@ -1376,7 +1376,7 @@ void LoadStubCompiler::GenerateLoadField(Register reg,
void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value. // Return the constant value.
__ LoadObject(v0, value); __ li(v0, value);
__ Ret(); __ Ret();
} }
......
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