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) { ...@@ -1890,6 +1890,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (from.IsSmi()) { if (from.IsSmi()) {
if (to.IsTagged()) { if (to.IsTagged()) {
LOperand* value = UseRegister(instr->value()); 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)); return DefineSameAsFirst(new(zone()) LDummyUse(value));
} }
from = Representation::Tagged(); from = Representation::Tagged();
...@@ -1902,9 +1908,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1902,9 +1908,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
return AssignEnvironment(DefineAsRegister(res)); return AssignEnvironment(DefineAsRegister(res));
} else if (to.IsSmi()) { } else if (to.IsSmi()) {
HValue* val = instr->value(); HValue* val = instr->value();
LOperand* value = UseRegisterAtStart(val); LOperand* value = UseRegister(val);
return AssignEnvironment( return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmi(value))); DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
} else { } else {
ASSERT(to.IsInteger32()); ASSERT(to.IsInteger32());
LOperand* value = NULL; LOperand* value = NULL;
......
...@@ -76,6 +76,7 @@ class LCodeGen; ...@@ -76,6 +76,7 @@ class LCodeGen;
V(CheckMaps) \ V(CheckMaps) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \ V(ClampDToUint8) \
V(ClampIToUint8) \ V(ClampIToUint8) \
V(ClampTToUint8) \ V(ClampTToUint8) \
...@@ -2387,7 +2388,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> { ...@@ -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: public:
explicit LCheckSmi(LOperand* value) { explicit LCheckSmi(LOperand* value) {
inputs_[0] = value; inputs_[0] = value;
...@@ -2399,6 +2400,18 @@ class LCheckSmi: public LTemplateInstruction<1, 1, 0> { ...@@ -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> { class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
public: public:
explicit LCheckNonSmi(LOperand* value) { explicit LCheckNonSmi(LOperand* value) {
......
...@@ -5224,6 +5224,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { ...@@ -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) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value(); LOperand* input = instr->value();
__ SmiTst(ToRegister(input)); __ SmiTst(ToRegister(input));
......
...@@ -2422,7 +2422,7 @@ class HFixedArrayBaseLength: public HUnaryOperation { ...@@ -2422,7 +2422,7 @@ class HFixedArrayBaseLength: public HUnaryOperation {
public: public:
explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
set_type(HType::Smi()); set_type(HType::Smi());
set_representation(Representation::Tagged()); set_representation(Representation::Smi());
SetFlag(kUseGVN); SetFlag(kUseGVN);
SetGVNFlag(kDependsOnArrayLengths); SetGVNFlag(kDependsOnArrayLengths);
} }
...@@ -5419,9 +5419,11 @@ class HLoadKeyed ...@@ -5419,9 +5419,11 @@ class HLoadKeyed
if (IsFastSmiOrObjectElementsKind(elements_kind)) { if (IsFastSmiOrObjectElementsKind(elements_kind)) {
if (IsFastSmiElementsKind(elements_kind)) { if (IsFastSmiElementsKind(elements_kind)) {
set_type(HType::Smi()); set_type(HType::Smi());
set_representation(Representation::Smi());
} else {
set_representation(Representation::Tagged());
} }
set_representation(Representation::Tagged());
SetGVNFlag(kDependsOnArrayElements); SetGVNFlag(kDependsOnArrayElements);
} else { } else {
set_representation(Representation::Double()); set_representation(Representation::Double());
......
...@@ -5698,6 +5698,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { ...@@ -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) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value(); LOperand* input = instr->value();
__ test(ToOperand(input), Immediate(kSmiTagMask)); __ test(ToOperand(input), Immediate(kSmiTagMask));
......
...@@ -1910,7 +1910,14 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1910,7 +1910,14 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (from.IsSmi()) { if (from.IsSmi()) {
if (to.IsTagged()) { if (to.IsTagged()) {
LOperand* value = UseRegister(instr->value()); 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(); from = Representation::Tagged();
} }
...@@ -1933,9 +1940,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1933,9 +1940,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
} }
} else if (to.IsSmi()) { } else if (to.IsSmi()) {
HValue* val = instr->value(); HValue* val = instr->value();
LOperand* value = UseRegisterAtStart(val); LOperand* value = UseRegister(val);
return AssignEnvironment( return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmi(value))); DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
} else { } else {
ASSERT(to.IsInteger32()); ASSERT(to.IsInteger32());
if (instr->value()->type().IsSmi()) { if (instr->value()->type().IsSmi()) {
...@@ -2058,13 +2065,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { ...@@ -2058,13 +2065,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseAtStart(instr->value()); LOperand* value = UseAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); return AssignEnvironment(new(zone()) LCheckSmi(value));
} }
LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) { LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) {
LOperand* value = UseAtStart(instr->value()); LOperand* value = UseAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); return AssignEnvironment(new(zone()) LCheckSmi(value));
} }
......
...@@ -70,6 +70,7 @@ class LCodeGen; ...@@ -70,6 +70,7 @@ class LCodeGen;
V(CheckNonSmi) \ V(CheckNonSmi) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \ V(ClampDToUint8) \
V(ClampIToUint8) \ V(ClampIToUint8) \
V(ClampTToUint8) \ V(ClampTToUint8) \
...@@ -2461,7 +2462,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { ...@@ -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: public:
explicit LCheckSmi(LOperand* value) { explicit LCheckSmi(LOperand* value) {
inputs_[0] = value; inputs_[0] = value;
...@@ -2473,6 +2474,18 @@ class LCheckSmi: public LTemplateInstruction<1, 1, 0> { ...@@ -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> { class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
public: public:
explicit LClampDToUint8(LOperand* value) { explicit LClampDToUint8(LOperand* value) {
......
...@@ -4913,6 +4913,13 @@ void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { ...@@ -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) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
LOperand* input = instr->value(); LOperand* input = instr->value();
Condition cc = masm()->CheckSmi(ToRegister(input)); Condition cc = masm()->CheckSmi(ToRegister(input));
......
...@@ -1815,6 +1815,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1815,6 +1815,12 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (from.IsSmi()) { if (from.IsSmi()) {
if (to.IsTagged()) { if (to.IsTagged()) {
LOperand* value = UseRegister(instr->value()); 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)); return DefineSameAsFirst(new(zone()) LDummyUse(value));
} }
from = Representation::Tagged(); from = Representation::Tagged();
...@@ -1830,9 +1836,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1830,9 +1836,9 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
return AssignEnvironment(DefineAsRegister(res)); return AssignEnvironment(DefineAsRegister(res));
} else if (to.IsSmi()) { } else if (to.IsSmi()) {
HValue* val = instr->value(); HValue* val = instr->value();
LOperand* value = UseRegisterAtStart(val); LOperand* value = UseRegister(val);
return AssignEnvironment( return AssignEnvironment(
DefineSameAsFirst(new(zone()) LCheckSmi(value))); DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value)));
} else { } else {
ASSERT(to.IsInteger32()); ASSERT(to.IsInteger32());
LOperand* value = UseRegister(instr->value()); LOperand* value = UseRegister(instr->value());
...@@ -1937,13 +1943,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { ...@@ -1937,13 +1943,13 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); return AssignEnvironment(new(zone()) LCheckSmi(value));
} }
LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) { LInstruction* LChunkBuilder::DoCheckSmiOrInt32(HCheckSmiOrInt32* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); return AssignEnvironment(new(zone()) LCheckSmi(value));
} }
......
...@@ -76,6 +76,7 @@ class LCodeGen; ...@@ -76,6 +76,7 @@ class LCodeGen;
V(CheckNonSmi) \ V(CheckNonSmi) \
V(CheckPrototypeMaps) \ V(CheckPrototypeMaps) \
V(CheckSmi) \ V(CheckSmi) \
V(CheckSmiAndReturn) \
V(ClampDToUint8) \ V(ClampDToUint8) \
V(ClampIToUint8) \ V(ClampIToUint8) \
V(ClampTToUint8) \ V(ClampTToUint8) \
...@@ -2294,7 +2295,7 @@ class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> { ...@@ -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: public:
explicit LCheckSmi(LOperand* value) { explicit LCheckSmi(LOperand* value) {
inputs_[0] = value; inputs_[0] = value;
...@@ -2306,6 +2307,18 @@ class LCheckSmi: public LTemplateInstruction<1, 1, 0> { ...@@ -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> { class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
public: public:
explicit LClampDToUint8(LOperand* unclamped) { 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