MIPS: Tag length of FixedArrayBase and smi-array[x] as smi representation

Port r14778 (c7fdf61b)

BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14786 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
palfia@homejinni.com 2013-05-24 01:09:23 +00:00
parent 31080249c0
commit 4b0f9cd4f1
3 changed files with 29 additions and 3 deletions

View File

@ -4958,6 +4958,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
}
void LCodeGen::DoCheckSmiAndReturn(LCheckSmiAndReturn* instr) {
LOperand* input = instr->value();
__ And(at, ToRegister(input), Operand(kSmiTagMask));
DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg));
}
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value();
__ And(at, ToRegister(input), Operand(kSmiTagMask));

View File

@ -1763,6 +1763,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (from.IsSmi()) {
if (to.IsTagged()) {
LOperand* value = UseRegister(instr->value());
// For now, always deopt on hole.
if (instr->value()->IsLoadKeyed() &&
HLoadKeyed::cast(instr->value())->UsesMustHandleHole()) {
return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
}
return DefineSameAsFirst(new(zone()) LDummyUse(value));
}
from = Representation::Tagged();
@ -1775,9 +1781,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
return AssignEnvironment(DefineAsRegister(res));
} else if (to.IsSmi()) {
HValue* val = instr->value();
LOperand* value = UseRegisterAtStart(val);
LOperand* value = UseRegister(val);
return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmi(value)));
DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
} else {
ASSERT(to.IsInteger32());
LOperand* value = NULL;

View File

@ -76,6 +76,7 @@ class LCodeGen;
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
@ -2328,7 +2329,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
};
class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
@ -2340,6 +2341,18 @@ class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
};
class LCheckSmiAndReturn: public LTemplateInstruction<1, 1, 0> {
public:
explicit LCheckSmiAndReturn(LOperand* value) {
inputs_[0] = value;
}
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(CheckSmiAndReturn, "check-smi-and-return")
};
class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckNonSmi(LOperand* value) {