Commit 900a0012 authored by danno@chromium.org's avatar danno@chromium.org

Improve register allocation for Lithium representation changes on ARM

BUG=none
TEST=none

Review URL: https://chromiumcodereview.appspot.com/9207006
Patch from Martyn Capewell <m.m.capewell@googlemail.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10538 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1c254fb5
...@@ -1631,11 +1631,11 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1631,11 +1631,11 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
return AssignEnvironment(DefineAsRegister(res)); return AssignEnvironment(DefineAsRegister(res));
} else { } else {
ASSERT(to.IsInteger32()); ASSERT(to.IsInteger32());
LOperand* value = UseRegister(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
bool needs_check = !instr->value()->type().IsSmi(); bool needs_check = !instr->value()->type().IsSmi();
LInstruction* res = NULL; LInstruction* res = NULL;
if (!needs_check) { if (!needs_check) {
res = DefineSameAsFirst(new LSmiUntag(value, needs_check)); res = DefineAsRegister(new LSmiUntag(value, needs_check));
} else { } else {
LOperand* temp1 = TempRegister(); LOperand* temp1 = TempRegister();
LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister()
...@@ -1671,12 +1671,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1671,12 +1671,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
} else if (from.IsInteger32()) { } else if (from.IsInteger32()) {
if (to.IsTagged()) { if (to.IsTagged()) {
HValue* val = instr->value(); HValue* val = instr->value();
LOperand* value = UseRegister(val); LOperand* value = UseRegisterAtStart(val);
if (val->HasRange() && val->range()->IsInSmiRange()) { if (val->HasRange() && val->range()->IsInSmiRange()) {
return DefineSameAsFirst(new LSmiTag(value)); return DefineAsRegister(new LSmiTag(value));
} else { } else {
LNumberTagI* result = new LNumberTagI(value); LNumberTagI* result = new LNumberTagI(value);
return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
} }
} else { } else {
ASSERT(to.IsDouble()); ASSERT(to.IsDouble());
......
...@@ -3796,12 +3796,11 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) { ...@@ -3796,12 +3796,11 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
LNumberTagI* instr_; LNumberTagI* instr_;
}; };
LOperand* input = instr->InputAt(0); Register src = ToRegister(instr->InputAt(0));
ASSERT(input->IsRegister() && input->Equals(instr->result())); Register dst = ToRegister(instr->result());
Register reg = ToRegister(input);
DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr); DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr);
__ SmiTag(reg, SetCC); __ SmiTag(dst, src, SetCC);
__ b(vs, deferred->entry()); __ b(vs, deferred->entry());
__ bind(deferred->exit()); __ bind(deferred->exit());
} }
...@@ -3809,7 +3808,8 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) { ...@@ -3809,7 +3808,8 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) {
Label slow; Label slow;
Register reg = ToRegister(instr->InputAt(0)); Register src = ToRegister(instr->InputAt(0));
Register dst = ToRegister(instr->result());
DoubleRegister dbl_scratch = double_scratch0(); DoubleRegister dbl_scratch = double_scratch0();
SwVfpRegister flt_scratch = dbl_scratch.low(); SwVfpRegister flt_scratch = dbl_scratch.low();
...@@ -3820,14 +3820,16 @@ void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { ...@@ -3820,14 +3820,16 @@ void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) {
// disagree. Try to allocate a heap number in new space and store // disagree. Try to allocate a heap number in new space and store
// the value in there. If that fails, call the runtime system. // the value in there. If that fails, call the runtime system.
Label done; Label done;
__ SmiUntag(reg); if (dst.is(src)) {
__ eor(reg, reg, Operand(0x80000000)); __ SmiUntag(src, dst);
__ vmov(flt_scratch, reg); __ eor(src, src, Operand(0x80000000));
}
__ vmov(flt_scratch, src);
__ vcvt_f64_s32(dbl_scratch, flt_scratch); __ vcvt_f64_s32(dbl_scratch, flt_scratch);
if (FLAG_inline_new) { if (FLAG_inline_new) {
__ LoadRoot(r6, Heap::kHeapNumberMapRootIndex); __ LoadRoot(r6, Heap::kHeapNumberMapRootIndex);
__ AllocateHeapNumber(r5, r3, r4, r6, &slow); __ AllocateHeapNumber(r5, r3, r4, r6, &slow);
if (!reg.is(r5)) __ mov(reg, r5); __ Move(dst, r5);
__ b(&done); __ b(&done);
} }
...@@ -3838,16 +3840,17 @@ void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { ...@@ -3838,16 +3840,17 @@ void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) {
// register is stored, as this register is in the pointer map, but contains an // register is stored, as this register is in the pointer map, but contains an
// integer value. // integer value.
__ mov(ip, Operand(0)); __ mov(ip, Operand(0));
__ StoreToSafepointRegisterSlot(ip, reg); __ StoreToSafepointRegisterSlot(ip, src);
__ StoreToSafepointRegisterSlot(ip, dst);
CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr); CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr);
if (!reg.is(r0)) __ mov(reg, r0); __ Move(dst, r0);
// Done. Put the value in dbl_scratch into the value of the allocated heap // Done. Put the value in dbl_scratch into the value of the allocated heap
// number. // number.
__ bind(&done); __ bind(&done);
__ sub(ip, reg, Operand(kHeapObjectTag)); __ sub(ip, dst, Operand(kHeapObjectTag));
__ vstr(dbl_scratch, ip, HeapNumber::kValueOffset); __ vstr(dbl_scratch, ip, HeapNumber::kValueOffset);
__ StoreToSafepointRegisterSlot(reg, reg); __ StoreToSafepointRegisterSlot(dst, dst);
} }
...@@ -3895,23 +3898,21 @@ void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) { ...@@ -3895,23 +3898,21 @@ void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) {
void LCodeGen::DoSmiTag(LSmiTag* instr) { void LCodeGen::DoSmiTag(LSmiTag* instr) {
LOperand* input = instr->InputAt(0);
ASSERT(input->IsRegister() && input->Equals(instr->result()));
ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow)); ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow));
__ SmiTag(ToRegister(input)); __ SmiTag(ToRegister(instr->result()), ToRegister(instr->InputAt(0)));
} }
void LCodeGen::DoSmiUntag(LSmiUntag* instr) { void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
LOperand* input = instr->InputAt(0); Register input = ToRegister(instr->InputAt(0));
ASSERT(input->IsRegister() && input->Equals(instr->result())); Register result = ToRegister(instr->result());
if (instr->needs_check()) { if (instr->needs_check()) {
STATIC_ASSERT(kHeapObjectTag == 1); STATIC_ASSERT(kHeapObjectTag == 1);
// If the input is a HeapObject, SmiUntag will set the carry flag. // If the input is a HeapObject, SmiUntag will set the carry flag.
__ SmiUntag(ToRegister(input), SetCC); __ SmiUntag(result, input, SetCC);
DeoptimizeIf(cs, instr->environment()); DeoptimizeIf(cs, instr->environment());
} else { } else {
__ SmiUntag(ToRegister(input)); __ SmiUntag(result, input);
} }
} }
...@@ -3967,10 +3968,9 @@ void LCodeGen::EmitNumberUntagD(Register input_reg, ...@@ -3967,10 +3968,9 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
// Smi to double register conversion // Smi to double register conversion
__ bind(&load_smi); __ bind(&load_smi);
__ SmiUntag(input_reg); // Untag smi before converting to float. __ SmiUntag(scratch, input_reg); // Untag smi before converting to float.
__ vmov(flt_scratch, input_reg); __ vmov(flt_scratch, scratch);
__ vcvt_f64_s32(result_reg, flt_scratch); __ vcvt_f64_s32(result_reg, flt_scratch);
__ SmiTag(input_reg); // Retag smi.
__ bind(&done); __ bind(&done);
} }
......
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