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();
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;
V(CheckMaps) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
+ V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
};
-class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
+class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
};
+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) {
}
+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));
public:
explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
set_type(HType::Smi());
- set_representation(Representation::Tagged());
+ set_representation(Representation::Smi());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnArrayLengths);
}
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());
}
+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));
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();
}
}
} 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()) {
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));
}
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
+ V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
};
-class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
+class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
};
+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) {
}
+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));
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();
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());
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));
}
V(CheckNonSmi) \
V(CheckPrototypeMaps) \
V(CheckSmi) \
+ V(CheckSmiAndReturn) \
V(ClampDToUint8) \
V(ClampIToUint8) \
V(ClampTToUint8) \
};
-class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
+class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
public:
explicit LCheckSmi(LOperand* value) {
inputs_[0] = value;
};
+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) {