Commit 632f5918 authored by verwaest@chromium.org's avatar verwaest@chromium.org

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

R=jkummerow@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14778 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8fb20868
......@@ -1890,6 +1890,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();
......@@ -1902,9 +1908,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;
......
......@@ -76,6 +76,7 @@ class LCodeGen;
V(CheckMaps) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
......@@ -2387,7 +2388,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;
......@@ -2399,6 +2400,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) {
......
......@@ -5224,6 +5224,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
}
void LCodeGen::DoCheckSmiAndReturn(LCheckSmiAndReturn* instr) {
LOperand* input = instr->value();
__ SmiTst(ToRegister(input));
DeoptimizeIf(ne, instr->environment());
}
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value();
__ SmiTst(ToRegister(input));
......
......@@ -2422,7 +2422,7 @@ class HFixedArrayBaseLength: public HUnaryOperation {
public:
explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
set_type(HType::Smi());
set_representation(Representation::Tagged());
set_representation(Representation::Smi());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnArrayLengths);
}
......@@ -5419,9 +5419,11 @@ class HLoadKeyed
if (IsFastSmiOrObjectElementsKind(elements_kind)) {
if (IsFastSmiElementsKind(elements_kind)) {
set_type(HType::Smi());
set_representation(Representation::Smi());
} else {
set_representation(Representation::Tagged());
}
set_representation(Representation::Tagged());
SetGVNFlag(kDependsOnArrayElements);
} else {
set_representation(Representation::Double());
......
......@@ -5698,6 +5698,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
}
void LCodeGen::DoCheckSmiAndReturn(LCheckSmiAndReturn* instr) {
LOperand* input = instr->value();
__ test(ToOperand(input), Immediate(kSmiTagMask));
DeoptimizeIf(not_zero, instr->environment());
}
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value();
__ test(ToOperand(input), Immediate(kSmiTagMask));
......
......@@ -1910,7 +1910,14 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (from.IsSmi()) {
if (to.IsTagged()) {
LOperand* value = UseRegister(instr->value());
return DefineSameAsFirst(new(zone()) LDummyUse(value));
// For now, always deopt on hole.
if (instr->value()->IsLoadKeyed() &&
HLoadKeyed::cast(instr->value())->UsesMustHandleHole()) {
return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
} else {
return DefineSameAsFirst(new(zone()) LDummyUse(value));
}
}
from = Representation::Tagged();
}
......@@ -1933,9 +1940,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
}
} 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());
if (instr->value()->type().IsSmi()) {
......@@ -2058,13 +2065,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value)));
return AssignEnvironment(new(zone()) LCheckSmi(value));
}
LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) {
LOperand* value = UseAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value)));
return AssignEnvironment(new(zone()) LCheckSmi(value));
}
......
......@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
......@@ -2461,7 +2462,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
};
class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
......@@ -2473,6 +2474,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 LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
public:
explicit LClampDToUint8(LOperand* value) {
......
......@@ -4913,6 +4913,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
}
void LCodeGen::DoCheckSmiAndReturn(LCheckSmiAndReturn* instr) {
LOperand* input = instr->value();
Condition cc = masm()->CheckSmi(ToRegister(input));
DeoptimizeIf(NegateCondition(cc), instr->environment());
}
void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value();
Condition cc = masm()->CheckSmi(ToRegister(input));
......
......@@ -1815,6 +1815,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();
......@@ -1830,9 +1836,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 = UseRegister(instr->value());
......@@ -1937,13 +1943,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value)));
return AssignEnvironment(new(zone()) LCheckSmi(value));
}
LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) {
LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value)));
return AssignEnvironment(new(zone()) LCheckSmi(value));
}
......
......@@ -76,6 +76,7 @@ class LCodeGen;
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
......@@ -2294,7 +2295,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
};
class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
......@@ -2306,6 +2307,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 LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
public:
explicit LClampDToUint8(LOperand* unclamped) {
......
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