| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index 6da6774aa8e87302bdd2a03a9f4f31f88d8216e7..39d59582beec3d1ba57cad734dc5713e5bdda976 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -1255,8 +1255,15 @@ static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
|
|
|
|
|
| HValue* HAdd::Canonicalize() {
|
| - if (IsIdentityOperation(left(), right(), 0)) return left();
|
| - if (IsIdentityOperation(right(), left(), 0)) return right();
|
| + // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0
|
| + if (IsIdentityOperation(left(), right(), 0) &&
|
| + !left()->representation().IsDouble()) { // Left could be -0.
|
| + return left();
|
| + }
|
| + if (IsIdentityOperation(right(), left(), 0) &&
|
| + !left()->representation().IsDouble()) { // Right could be -0.
|
| + return right();
|
| + }
|
| return this;
|
| }
|
|
|
| @@ -2849,8 +2856,17 @@ Range* HShl::InferRange(Zone* zone) {
|
|
|
|
|
| Range* HLoadNamedField::InferRange(Zone* zone) {
|
| - if (access().representation().IsByte()) {
|
| - return new(zone) Range(0, 255);
|
| + if (access().representation().IsInteger8()) {
|
| + return new(zone) Range(kMinInt8, kMaxInt8);
|
| + }
|
| + if (access().representation().IsUInteger8()) {
|
| + return new(zone) Range(kMinUInt8, kMaxUInt8);
|
| + }
|
| + if (access().representation().IsInteger16()) {
|
| + return new(zone) Range(kMinInt16, kMaxInt16);
|
| + }
|
| + if (access().representation().IsUInteger16()) {
|
| + return new(zone) Range(kMinUInt16, kMaxUInt16);
|
| }
|
| if (access().IsStringLength()) {
|
| return new(zone) Range(0, String::kMaxLength);
|
| @@ -2861,16 +2877,15 @@ Range* HLoadNamedField::InferRange(Zone* zone) {
|
|
|
| Range* HLoadKeyed::InferRange(Zone* zone) {
|
| switch (elements_kind()) {
|
| - case EXTERNAL_PIXEL_ELEMENTS:
|
| - return new(zone) Range(0, 255);
|
| case EXTERNAL_BYTE_ELEMENTS:
|
| - return new(zone) Range(-128, 127);
|
| + return new(zone) Range(kMinInt8, kMaxInt8);
|
| case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
|
| - return new(zone) Range(0, 255);
|
| + case EXTERNAL_PIXEL_ELEMENTS:
|
| + return new(zone) Range(kMinUInt8, kMaxUInt8);
|
| case EXTERNAL_SHORT_ELEMENTS:
|
| - return new(zone) Range(-32768, 32767);
|
| + return new(zone) Range(kMinInt16, kMaxInt16);
|
| case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
|
| - return new(zone) Range(0, 65535);
|
| + return new(zone) Range(kMinUInt16, kMaxUInt16);
|
| default:
|
| return HValue::InferRange(zone);
|
| }
|
| @@ -2929,6 +2944,24 @@ void HCompareHoleAndBranch::InferRepresentation(
|
| }
|
|
|
|
|
| +bool HCompareMinusZeroAndBranch::KnownSuccessorBlock(HBasicBlock** block) {
|
| + if (value()->representation().IsSmiOrInteger32()) {
|
| + // A Smi or Integer32 cannot contain minus zero.
|
| + *block = SecondSuccessor();
|
| + return true;
|
| + }
|
| + *block = NULL;
|
| + return false;
|
| +}
|
| +
|
| +
|
| +void HCompareMinusZeroAndBranch::InferRepresentation(
|
| + HInferRepresentationPhase* h_infer) {
|
| + ChangeRepresentation(value()->representation());
|
| +}
|
| +
|
| +
|
| +
|
| void HGoto::PrintDataTo(StringStream* stream) {
|
| stream->Add("B%d", SuccessorAt(0)->block_id());
|
| }
|
| @@ -3984,6 +4017,26 @@ HInstruction* HShr::New(
|
| }
|
|
|
|
|
| +HInstruction* HSeqStringGetChar::New(Zone* zone,
|
| + HValue* context,
|
| + String::Encoding encoding,
|
| + HValue* string,
|
| + HValue* index) {
|
| + if (FLAG_fold_constants && string->IsConstant() && index->IsConstant()) {
|
| + HConstant* c_string = HConstant::cast(string);
|
| + HConstant* c_index = HConstant::cast(index);
|
| + if (c_string->HasStringValue() && c_index->HasInteger32Value()) {
|
| + Handle<String> s = c_string->StringValue();
|
| + int32_t i = c_index->Integer32Value();
|
| + ASSERT_LE(0, i);
|
| + ASSERT_LT(i, s->length());
|
| + return H_CONSTANT_INT(s->Get(i));
|
| + }
|
| + }
|
| + return new(zone) HSeqStringGetChar(encoding, string, index);
|
| +}
|
| +
|
| +
|
| #undef H_CONSTANT_INT
|
| #undef H_CONSTANT_DOUBLE
|
|
|
|
|