| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index 3b01f5761227bdc393e7ad0a755192341f93b288..37582fdb3d8ad785ccc289d18e66eaf8ce2058e4 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -59,6 +59,8 @@ const char* Representation::Mnemonic() const {
|
| case kTagged: return "t";
|
| case kDouble: return "d";
|
| case kInteger32: return "i";
|
| + case kTruncatedInteger32: return "ti";
|
| + case kClampedRoundedUInteger8: return "cri";
|
| case kExternal: return "x";
|
| case kNumRepresentations:
|
| UNREACHABLE();
|
| @@ -727,8 +729,6 @@ void HTypeofIs::PrintDataTo(StringStream* stream) {
|
| void HChange::PrintDataTo(StringStream* stream) {
|
| HUnaryOperation::PrintDataTo(stream);
|
| stream->Add(" %s to %s", from_.Mnemonic(), to().Mnemonic());
|
| -
|
| - if (CanTruncateToInt32()) stream->Add(" truncating-int32");
|
| if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?");
|
| }
|
|
|
| @@ -796,9 +796,11 @@ Range* HConstant::InferRange() {
|
|
|
|
|
| Range* HPhi::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| if (block()->IsLoopHeader()) {
|
| - Range* range = new Range(kMinInt, kMaxInt);
|
| + Range* range = representation().IsClampedRoundedInteger8()
|
| + ? new Range(0, 255)
|
| + : new Range(kMinInt, kMaxInt);
|
| return range;
|
| } else {
|
| Range* range = OperandAt(0)->range()->Copy();
|
| @@ -814,7 +816,7 @@ Range* HPhi::InferRange() {
|
|
|
|
|
| Range* HAdd::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| Range* a = left()->range();
|
| Range* b = right()->range();
|
| Range* res = a->Copy();
|
| @@ -831,7 +833,7 @@ Range* HAdd::InferRange() {
|
|
|
|
|
| Range* HSub::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| Range* a = left()->range();
|
| Range* b = right()->range();
|
| Range* res = a->Copy();
|
| @@ -847,7 +849,7 @@ Range* HSub::InferRange() {
|
|
|
|
|
| Range* HMul::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| Range* a = left()->range();
|
| Range* b = right()->range();
|
| Range* res = a->Copy();
|
| @@ -865,7 +867,7 @@ Range* HMul::InferRange() {
|
|
|
|
|
| Range* HDiv::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| Range* result = new Range();
|
| if (left()->range()->CanBeMinusZero()) {
|
| result->set_can_be_minus_zero(true);
|
| @@ -890,7 +892,7 @@ Range* HDiv::InferRange() {
|
|
|
|
|
| Range* HMod::InferRange() {
|
| - if (representation().IsInteger32()) {
|
| + if (representation().IsInteger()) {
|
| Range* a = left()->range();
|
| Range* result = new Range();
|
| if (a->CanBeMinusZero() || a->CanBeNegative()) {
|
| @@ -1035,7 +1037,9 @@ HConstant::HConstant(Handle<Object> handle, Representation r)
|
|
|
|
|
| HConstant* HConstant::CopyToRepresentation(Representation r) const {
|
| - if (r.IsInteger32() && !has_int32_value_) return NULL;
|
| + if (r.IsInteger() && !has_int32_value_) return NULL;
|
| + if (r.IsClampedRoundedInteger8() &&
|
| + (int32_value_ > 255 || int32_value_ < 0)) return NULL;
|
| if (r.IsDouble() && !has_double_value_) return NULL;
|
| return new HConstant(handle_, r);
|
| }
|
| @@ -1045,7 +1049,15 @@ HConstant* HConstant::CopyToTruncatedInt32() const {
|
| if (!has_double_value_) return NULL;
|
| int32_t truncated = NumberToInt32(*handle_);
|
| return new HConstant(FACTORY->NewNumberFromInt(truncated),
|
| - Representation::Integer32());
|
| + Representation::TruncatedInteger32());
|
| +}
|
| +
|
| +
|
| +HConstant* HConstant::CopyToClampedRoundedUInt8() const {
|
| + if (!has_double_value_) return NULL;
|
| + int32_t clamped_rounded = NumberToClampedUInt8(*handle_);
|
| + return new HConstant(FACTORY->NewNumberFromInt(clamped_rounded),
|
| + Representation::ClampedRoundedUInteger8());
|
| }
|
|
|
|
|
| @@ -1511,14 +1523,14 @@ HType HSar::CalculateInferredType() {
|
| HValue* HUnaryMathOperation::EnsureAndPropagateNotMinusZero(
|
| BitVector* visited) {
|
| visited->Add(id());
|
| - if (representation().IsInteger32() &&
|
| - !value()->representation().IsInteger32()) {
|
| + if (representation().IsInteger() &&
|
| + !value()->representation().IsInteger()) {
|
| if (value()->range() == NULL || value()->range()->CanBeMinusZero()) {
|
| SetFlag(kBailoutOnMinusZero);
|
| }
|
| }
|
| - if (RequiredInputRepresentation(0).IsInteger32() &&
|
| - representation().IsInteger32()) {
|
| + if (RequiredInputRepresentation(0).IsInteger() &&
|
| + representation().IsInteger()) {
|
| return value();
|
| }
|
| return NULL;
|
| @@ -1528,12 +1540,14 @@ HValue* HUnaryMathOperation::EnsureAndPropagateNotMinusZero(
|
|
|
| HValue* HChange::EnsureAndPropagateNotMinusZero(BitVector* visited) {
|
| visited->Add(id());
|
| - if (from().IsInteger32()) return NULL;
|
| - if (CanTruncateToInt32()) return NULL;
|
| + if (from().IsInteger()) return NULL;
|
| + if (to().IsTruncatedInteger32() || to().IsClampedRoundedInteger8()) {
|
| + return NULL;
|
| + }
|
| if (value()->range() == NULL || value()->range()->CanBeMinusZero()) {
|
| SetFlag(kBailoutOnMinusZero);
|
| }
|
| - ASSERT(!from().IsInteger32() || !to().IsInteger32());
|
| + ASSERT(!from().IsInteger() || !to().IsInteger());
|
| return NULL;
|
| }
|
|
|
|
|