bool HValue::IsInteger32Constant() {
- return IsConstant() && HConstant::cast(this)->HasInteger32Value();
+ HValue* value_to_check = IsForceRepresentation()
+ ? HForceRepresentation::cast(this)->value()
+ : this;
+ return value_to_check->IsConstant() &&
+ HConstant::cast(value_to_check)->HasInteger32Value();
}
int32_t HValue::GetInteger32Constant() {
- return HConstant::cast(this)->Integer32Value();
+ HValue* constant_value = IsForceRepresentation()
+ ? HForceRepresentation::cast(this)->value()
+ : this;
+ return HConstant::cast(constant_value)->Integer32Value();
}
DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
- protected:
- virtual int RedefinedOperandIndex() { return 0; }
-
private:
HForceRepresentation(HValue* value, Representation required_representation) {
SetOperandAt(0, value);
static const int kLoopUnfoldLimit = 8;
STATIC_ASSERT(JSArray::kPreallocatedArrayElements <= kLoopUnfoldLimit);
int initial_capacity = -1;
- if (from->ActualValue()->IsConstant() && to->ActualValue()->IsConstant()) {
- HConstant* constant_from = HConstant::cast(from->ActualValue());
- HConstant* constant_to = HConstant::cast(to->ActualValue());
-
- if (constant_from->HasInteger32Value() &&
- constant_from->Integer32Value() == 0 &&
- constant_to->HasInteger32Value() &&
- constant_to->Integer32Value() <= kLoopUnfoldLimit) {
- initial_capacity = constant_to->Integer32Value();
+ if (from->IsInteger32Constant() && to->IsInteger32Constant()) {
+ int constant_from = from->GetInteger32Constant();
+ int constant_to = to->GetInteger32Constant();
+
+ if (constant_from == 0 && constant_to <= kLoopUnfoldLimit) {
+ initial_capacity = constant_to;
}
}