Commit 29090926 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Update the gap resolver to support Smi constants.

R=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/15664005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14850 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ff2a76b5
......@@ -539,6 +539,12 @@ int LCodeGen::ToInteger32(LConstantOperand* op) const {
}
Smi* LCodeGen::ToSmi(LConstantOperand* op) const {
HConstant* constant = chunk_->LookupConstant(op);
return Smi::FromInt(constant->Integer32Value());
}
double LCodeGen::ToDouble(LConstantOperand* op) const {
HConstant* constant = chunk_->LookupConstant(op);
ASSERT(constant->HasDoubleValue());
......
......@@ -119,6 +119,7 @@ class LCodeGen BASE_EMBEDDED {
SwVfpRegister flt_scratch,
DwVfpRegister dbl_scratch);
int ToInteger32(LConstantOperand* op) const;
Smi* ToSmi(LConstantOperand* op) const;
double ToDouble(LConstantOperand* op) const;
Operand ToOperand(LOperand* op);
MemOperand ToMemOperand(LOperand* op) const;
......
......@@ -248,7 +248,9 @@ void LGapResolver::EmitMove(int index) {
LConstantOperand* constant_source = LConstantOperand::cast(source);
if (destination->IsRegister()) {
Register dst = cgen_->ToRegister(destination);
if (cgen_->IsInteger32(constant_source)) {
if (cgen_->IsSmi(constant_source)) {
__ mov(dst, Operand(cgen_->ToSmi(constant_source)));
} else if (cgen_->IsInteger32(constant_source)) {
__ mov(dst, Operand(cgen_->ToInteger32(constant_source)));
} else {
__ LoadObject(dst, cgen_->ToHandle(constant_source));
......@@ -256,7 +258,9 @@ void LGapResolver::EmitMove(int index) {
} else {
ASSERT(destination->IsStackSlot());
ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone.
if (cgen_->IsInteger32(constant_source)) {
if (cgen_->IsSmi(constant_source)) {
__ mov(kSavedValueRegister, Operand(cgen_->ToSmi(constant_source)));
} else if (cgen_->IsInteger32(constant_source)) {
__ mov(kSavedValueRegister,
Operand(cgen_->ToInteger32(constant_source)));
} else {
......
......@@ -115,6 +115,9 @@ class LCodeGen BASE_EMBEDDED {
Immediate ToInteger32Immediate(LOperand* op) const {
return Immediate(ToInteger32(LConstantOperand::cast(op)));
}
Immediate ToSmiImmediate(LOperand* op) const {
return Immediate(Smi::FromInt(ToInteger32(LConstantOperand::cast(op))));
}
// Support for non-sse2 (x87) floating point stack handling.
// These functions maintain the depth of the stack (either 0 or 1)
......
......@@ -306,7 +306,9 @@ void LGapResolver::EmitMove(int index) {
LConstantOperand* constant_source = LConstantOperand::cast(source);
if (destination->IsRegister()) {
Register dst = cgen_->ToRegister(destination);
if (cgen_->IsInteger32(constant_source)) {
if (cgen_->IsSmi(constant_source)) {
__ Set(dst, cgen_->ToSmiImmediate(constant_source));
} else if (cgen_->IsInteger32(constant_source)) {
__ Set(dst, cgen_->ToInteger32Immediate(constant_source));
} else {
__ LoadObject(dst, cgen_->ToHandle(constant_source));
......@@ -314,7 +316,9 @@ void LGapResolver::EmitMove(int index) {
} else {
ASSERT(destination->IsStackSlot());
Operand dst = cgen_->ToOperand(destination);
if (cgen_->IsInteger32(constant_source)) {
if (cgen_->IsSmi(constant_source)) {
__ Set(dst, cgen_->ToSmiImmediate(constant_source));
} else if (cgen_->IsInteger32(constant_source)) {
__ Set(dst, cgen_->ToInteger32Immediate(constant_source));
} else {
Register tmp = EnsureTempRegister();
......
......@@ -453,6 +453,12 @@ int LCodeGen::ToInteger32(LConstantOperand* op) const {
}
Smi* LCodeGen::ToSmi(LConstantOperand* op) const {
HConstant* constant = chunk_->LookupConstant(op);
return Smi::FromInt(constant->Integer32Value());
}
double LCodeGen::ToDouble(LConstantOperand* op) const {
HConstant* constant = chunk_->LookupConstant(op);
ASSERT(constant->HasDoubleValue());
......
......@@ -106,6 +106,7 @@ class LCodeGen BASE_EMBEDDED {
bool IsInteger32Constant(LConstantOperand* op) const;
bool IsSmiConstant(LConstantOperand* op) const;
int ToInteger32(LConstantOperand* op) const;
Smi* ToSmi(LConstantOperand* op) const;
double ToDouble(LConstantOperand* op) const;
bool IsTaggedConstant(LConstantOperand* op) const;
Handle<Object> ToHandle(LConstantOperand* op) const;
......
......@@ -195,7 +195,9 @@ void LGapResolver::EmitMove(int index) {
LConstantOperand* constant_source = LConstantOperand::cast(source);
if (destination->IsRegister()) {
Register dst = cgen_->ToRegister(destination);
if (cgen_->IsInteger32Constant(constant_source)) {
if (cgen_->IsSmiConstant(constant_source)) {
__ Move(dst, cgen_->ToSmi(constant_source));
} else if (cgen_->IsInteger32Constant(constant_source)) {
__ movl(dst, Immediate(cgen_->ToInteger32(constant_source)));
} else {
__ LoadObject(dst, cgen_->ToHandle(constant_source));
......@@ -203,7 +205,9 @@ void LGapResolver::EmitMove(int index) {
} else {
ASSERT(destination->IsStackSlot());
Operand dst = cgen_->ToOperand(destination);
if (cgen_->IsInteger32Constant(constant_source)) {
if (cgen_->IsSmiConstant(constant_source)) {
__ Move(dst, cgen_->ToSmi(constant_source));
} else if (cgen_->IsInteger32Constant(constant_source)) {
// Zero top 32 bits of a 64 bit spill slot that holds a 32 bit untagged
// value.
__ movq(dst, Immediate(cgen_->ToInteger32(constant_source)));
......
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