OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/double.h" | 8 #include "src/double.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/hydrogen-infer-representation.h" | 10 #include "src/hydrogen-infer-representation.h" |
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2676 static bool IsInteger32(double value) { | 2676 static bool IsInteger32(double value) { |
2677 if (value >= std::numeric_limits<int32_t>::min() && | 2677 if (value >= std::numeric_limits<int32_t>::min() && |
2678 value <= std::numeric_limits<int32_t>::max()) { | 2678 value <= std::numeric_limits<int32_t>::max()) { |
2679 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); | 2679 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); |
2680 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value); | 2680 return bit_cast<int64_t>(roundtrip_value) == bit_cast<int64_t>(value); |
2681 } | 2681 } |
2682 return false; | 2682 return false; |
2683 } | 2683 } |
2684 | 2684 |
2685 | 2685 |
2686 HConstant::HConstant(Special special) | |
2687 : HTemplateInstruction<0>(HType::TaggedNumber()), | |
2688 object_(Handle<Object>::null()), | |
2689 object_map_(Handle<Map>::null()), | |
2690 bit_field_(HasDoubleValueField::encode(true) | | |
2691 InstanceTypeField::encode(kUnknownInstanceType)), | |
2692 int32_value_(0) { | |
2693 DCHECK_EQ(kHoleNaN, special); | |
2694 std::memcpy(&double_value_, &kHoleNanInt64, sizeof(double_value_)); | |
2695 Initialize(Representation::Double()); | |
2696 } | |
2697 | |
2698 | |
2686 HConstant::HConstant(Handle<Object> object, Representation r) | 2699 HConstant::HConstant(Handle<Object> object, Representation r) |
2687 : HTemplateInstruction<0>(HType::FromValue(object)), | 2700 : HTemplateInstruction<0>(HType::FromValue(object)), |
2688 object_(Unique<Object>::CreateUninitialized(object)), | 2701 object_(Unique<Object>::CreateUninitialized(object)), |
2689 object_map_(Handle<Map>::null()), | 2702 object_map_(Handle<Map>::null()), |
2690 bit_field_(HasStableMapValueField::encode(false) | | 2703 bit_field_(HasStableMapValueField::encode(false) | |
2691 HasSmiValueField::encode(false) | | 2704 HasSmiValueField::encode(false) | |
2692 HasInt32ValueField::encode(false) | | 2705 HasInt32ValueField::encode(false) | |
2693 HasDoubleValueField::encode(false) | | 2706 HasDoubleValueField::encode(false) | |
2694 HasExternalReferenceValueField::encode(false) | | 2707 HasExternalReferenceValueField::encode(false) | |
2695 IsNotInNewSpaceField::encode(true) | | 2708 IsNotInNewSpaceField::encode(true) | |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4033 // constant-offset-from-key * kPointerSize) | 4046 // constant-offset-from-key * kPointerSize) |
4034 v8::base::internal::CheckedNumeric<uint32_t> addition_result = base_offset_; | 4047 v8::base::internal::CheckedNumeric<uint32_t> addition_result = base_offset_; |
4035 addition_result += increase_by_value; | 4048 addition_result += increase_by_value; |
4036 if (!addition_result.IsValid()) return false; | 4049 if (!addition_result.IsValid()) return false; |
4037 base_offset_ = addition_result.ValueOrDie(); | 4050 base_offset_ = addition_result.ValueOrDie(); |
4038 return true; | 4051 return true; |
4039 } | 4052 } |
4040 | 4053 |
4041 | 4054 |
4042 bool HStoreKeyed::NeedsCanonicalization() { | 4055 bool HStoreKeyed::NeedsCanonicalization() { |
4043 // If value is an integer or smi or comes from the result of a keyed load or | 4056 switch (value()->opcode()) { |
Vyacheslav Egorov (Google)
2015/01/22 02:52:20
This check should account for heap number fields (
Benedikt Meurer
2015/01/22 06:11:15
Fixed, thanks.
| |
4044 // constant then it is either be a non-hole value or in the case of a constant | 4057 case kLoadKeyed: { |
4045 // the hole is only being stored explicitly: no need for canonicalization. | 4058 ElementsKind load_kind = HLoadKeyed::cast(value())->elements_kind(); |
4046 // | 4059 return IsExternalFloatOrDoubleElementsKind(load_kind) || |
4047 // The exception to that is keyed loads from external float or double arrays: | 4060 IsFixedFloatElementsKind(load_kind); |
4048 // these can load arbitrary representation of NaN. | 4061 } |
4049 | 4062 case kChange: { |
4050 if (value()->IsConstant()) { | 4063 Representation from = HChange::cast(value())->from(); |
4051 return false; | 4064 return from.IsTagged() || from.IsHeapObject(); |
4065 } | |
4066 case kPhi: | |
4067 // Better safe than sorry... | |
4068 return true; | |
4069 default: | |
4070 return false; | |
4052 } | 4071 } |
4053 | |
4054 if (value()->IsLoadKeyed()) { | |
4055 return IsExternalFloatOrDoubleElementsKind( | |
4056 HLoadKeyed::cast(value())->elements_kind()); | |
4057 } | |
4058 | |
4059 if (value()->IsChange()) { | |
4060 if (HChange::cast(value())->from().IsSmiOrInteger32()) { | |
4061 return false; | |
4062 } | |
4063 if (HChange::cast(value())->value()->type().IsSmi()) { | |
4064 return false; | |
4065 } | |
4066 } | |
4067 return true; | |
4068 } | 4072 } |
4069 | 4073 |
4070 | 4074 |
4071 #define H_CONSTANT_INT(val) \ | 4075 #define H_CONSTANT_INT(val) \ |
4072 HConstant::New(zone, context, static_cast<int32_t>(val)) | 4076 HConstant::New(zone, context, static_cast<int32_t>(val)) |
4073 #define H_CONSTANT_DOUBLE(val) \ | 4077 #define H_CONSTANT_DOUBLE(val) \ |
4074 HConstant::New(zone, context, static_cast<double>(val)) | 4078 HConstant::New(zone, context, static_cast<double>(val)) |
4075 | 4079 |
4076 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ | 4080 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ |
4077 HInstruction* HInstr::New( \ | 4081 HInstruction* HInstr::New( \ |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4817 break; | 4821 break; |
4818 case HObjectAccess::kExternalMemory: | 4822 case HObjectAccess::kExternalMemory: |
4819 os << "[external-memory]"; | 4823 os << "[external-memory]"; |
4820 break; | 4824 break; |
4821 } | 4825 } |
4822 | 4826 |
4823 return os << "@" << access.offset(); | 4827 return os << "@" << access.offset(); |
4824 } | 4828 } |
4825 | 4829 |
4826 } } // namespace v8::internal | 4830 } } // namespace v8::internal |
OLD | NEW |