| 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/crankshaft/hydrogen-instructions.h" | 5 #include "src/crankshaft/hydrogen-instructions.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/ieee754.h" | 8 #include "src/base/ieee754.h" |
| 9 #include "src/base/safe_math.h" | 9 #include "src/base/safe_math.h" |
| 10 #include "src/crankshaft/hydrogen-infer-representation.h" | 10 #include "src/crankshaft/hydrogen-infer-representation.h" |
| (...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2188 bit_field_, | 2188 bit_field_, |
| 2189 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); | 2189 HasMapValue() && Handle<Map>::cast(heap_object)->is_stable()); |
| 2190 } | 2190 } |
| 2191 if (object->IsNumber()) { | 2191 if (object->IsNumber()) { |
| 2192 double n = object->Number(); | 2192 double n = object->Number(); |
| 2193 bool has_int32_value = IsInteger32(n); | 2193 bool has_int32_value = IsInteger32(n); |
| 2194 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); | 2194 bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value); |
| 2195 int32_value_ = DoubleToInt32(n); | 2195 int32_value_ = DoubleToInt32(n); |
| 2196 bit_field_ = HasSmiValueField::update( | 2196 bit_field_ = HasSmiValueField::update( |
| 2197 bit_field_, has_int32_value && Smi::IsValid(int32_value_)); | 2197 bit_field_, has_int32_value && Smi::IsValid(int32_value_)); |
| 2198 double_value_ = n; | 2198 if (std::isnan(n)) { |
| 2199 double_value_ = std::numeric_limits<double>::quiet_NaN(); |
| 2200 } else { |
| 2201 double_value_ = n; |
| 2202 } |
| 2199 bit_field_ = HasDoubleValueField::update(bit_field_, true); | 2203 bit_field_ = HasDoubleValueField::update(bit_field_, true); |
| 2200 } | 2204 } |
| 2201 | 2205 |
| 2202 Initialize(r); | 2206 Initialize(r); |
| 2203 } | 2207 } |
| 2204 | 2208 |
| 2205 | 2209 |
| 2206 HConstant::HConstant(Unique<Object> object, Unique<Map> object_map, | 2210 HConstant::HConstant(Unique<Object> object, Unique<Map> object_map, |
| 2207 bool has_stable_map_value, Representation r, HType type, | 2211 bool has_stable_map_value, Representation r, HType type, |
| 2208 bool is_not_in_new_space, bool boolean_value, | 2212 bool is_not_in_new_space, bool boolean_value, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 int32_value_(integer_value), | 2245 int32_value_(integer_value), |
| 2242 double_value_(FastI2D(integer_value)) { | 2246 double_value_(FastI2D(integer_value)) { |
| 2243 // It's possible to create a constant with a value in Smi-range but stored | 2247 // It's possible to create a constant with a value in Smi-range but stored |
| 2244 // in a (pre-existing) HeapNumber. See crbug.com/349878. | 2248 // in a (pre-existing) HeapNumber. See crbug.com/349878. |
| 2245 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); | 2249 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); |
| 2246 bool is_smi = HasSmiValue() && !could_be_heapobject; | 2250 bool is_smi = HasSmiValue() && !could_be_heapobject; |
| 2247 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); | 2251 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); |
| 2248 Initialize(r); | 2252 Initialize(r); |
| 2249 } | 2253 } |
| 2250 | 2254 |
| 2251 | |
| 2252 HConstant::HConstant(double double_value, Representation r, | 2255 HConstant::HConstant(double double_value, Representation r, |
| 2253 bool is_not_in_new_space, Unique<Object> object) | 2256 bool is_not_in_new_space, Unique<Object> object) |
| 2254 : object_(object), | 2257 : object_(object), |
| 2255 object_map_(Handle<Map>::null()), | 2258 object_map_(Handle<Map>::null()), |
| 2256 bit_field_(HasStableMapValueField::encode(false) | | 2259 bit_field_(HasStableMapValueField::encode(false) | |
| 2257 HasInt32ValueField::encode(IsInteger32(double_value)) | | 2260 HasInt32ValueField::encode(IsInteger32(double_value)) | |
| 2258 HasDoubleValueField::encode(true) | | 2261 HasDoubleValueField::encode(true) | |
| 2259 HasExternalReferenceValueField::encode(false) | | 2262 HasExternalReferenceValueField::encode(false) | |
| 2260 IsNotInNewSpaceField::encode(is_not_in_new_space) | | 2263 IsNotInNewSpaceField::encode(is_not_in_new_space) | |
| 2261 BooleanValueField::encode(double_value != 0 && | 2264 BooleanValueField::encode(double_value != 0 && |
| 2262 !std::isnan(double_value)) | | 2265 !std::isnan(double_value)) | |
| 2263 IsUndetectableField::encode(false) | | 2266 IsUndetectableField::encode(false) | |
| 2264 InstanceTypeField::encode(kUnknownInstanceType)), | 2267 InstanceTypeField::encode(kUnknownInstanceType)), |
| 2265 int32_value_(DoubleToInt32(double_value)), | 2268 int32_value_(DoubleToInt32(double_value)) { |
| 2266 double_value_(double_value) { | |
| 2267 bit_field_ = HasSmiValueField::update( | 2269 bit_field_ = HasSmiValueField::update( |
| 2268 bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_)); | 2270 bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_)); |
| 2269 // It's possible to create a constant with a value in Smi-range but stored | 2271 // It's possible to create a constant with a value in Smi-range but stored |
| 2270 // in a (pre-existing) HeapNumber. See crbug.com/349878. | 2272 // in a (pre-existing) HeapNumber. See crbug.com/349878. |
| 2271 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); | 2273 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); |
| 2272 bool is_smi = HasSmiValue() && !could_be_heapobject; | 2274 bool is_smi = HasSmiValue() && !could_be_heapobject; |
| 2273 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); | 2275 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); |
| 2276 if (std::isnan(double_value)) { |
| 2277 double_value_ = std::numeric_limits<double>::quiet_NaN(); |
| 2278 } else { |
| 2279 double_value_ = double_value; |
| 2280 } |
| 2274 Initialize(r); | 2281 Initialize(r); |
| 2275 } | 2282 } |
| 2276 | 2283 |
| 2277 | 2284 |
| 2278 HConstant::HConstant(ExternalReference reference) | 2285 HConstant::HConstant(ExternalReference reference) |
| 2279 : HTemplateInstruction<0>(HType::Any()), | 2286 : HTemplateInstruction<0>(HType::Any()), |
| 2280 object_(Unique<Object>(Handle<Object>::null())), | 2287 object_(Unique<Object>(Handle<Object>::null())), |
| 2281 object_map_(Handle<Map>::null()), | 2288 object_map_(Handle<Map>::null()), |
| 2282 bit_field_( | 2289 bit_field_( |
| 2283 HasStableMapValueField::encode(false) | | 2290 HasStableMapValueField::encode(false) | |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3282 bool HStoreKeyed::NeedsCanonicalization() { | 3289 bool HStoreKeyed::NeedsCanonicalization() { |
| 3283 switch (value()->opcode()) { | 3290 switch (value()->opcode()) { |
| 3284 case kLoadKeyed: { | 3291 case kLoadKeyed: { |
| 3285 ElementsKind load_kind = HLoadKeyed::cast(value())->elements_kind(); | 3292 ElementsKind load_kind = HLoadKeyed::cast(value())->elements_kind(); |
| 3286 return IsFixedFloatElementsKind(load_kind); | 3293 return IsFixedFloatElementsKind(load_kind); |
| 3287 } | 3294 } |
| 3288 case kChange: { | 3295 case kChange: { |
| 3289 Representation from = HChange::cast(value())->from(); | 3296 Representation from = HChange::cast(value())->from(); |
| 3290 return from.IsTagged() || from.IsHeapObject(); | 3297 return from.IsTagged() || from.IsHeapObject(); |
| 3291 } | 3298 } |
| 3292 case kLoadNamedField: | 3299 case kConstant: |
| 3293 case kPhi: { | 3300 // Double constants are canonicalized upon construction. |
| 3294 // Better safe than sorry... | 3301 return false; |
| 3295 return true; | |
| 3296 } | |
| 3297 default: | 3302 default: |
| 3298 return false; | 3303 return !value()->IsBinaryOperation(); |
| 3299 } | 3304 } |
| 3300 } | 3305 } |
| 3301 | 3306 |
| 3302 | 3307 |
| 3303 #define H_CONSTANT_INT(val) \ | 3308 #define H_CONSTANT_INT(val) \ |
| 3304 HConstant::New(isolate, zone, context, static_cast<int32_t>(val)) | 3309 HConstant::New(isolate, zone, context, static_cast<int32_t>(val)) |
| 3305 #define H_CONSTANT_DOUBLE(val) \ | 3310 #define H_CONSTANT_DOUBLE(val) \ |
| 3306 HConstant::New(isolate, zone, context, static_cast<double>(val)) | 3311 HConstant::New(isolate, zone, context, static_cast<double>(val)) |
| 3307 | 3312 |
| 3308 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ | 3313 #define DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HInstr, op) \ |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4041 case HObjectAccess::kExternalMemory: | 4046 case HObjectAccess::kExternalMemory: |
| 4042 os << "[external-memory]"; | 4047 os << "[external-memory]"; |
| 4043 break; | 4048 break; |
| 4044 } | 4049 } |
| 4045 | 4050 |
| 4046 return os << "@" << access.offset(); | 4051 return os << "@" << access.offset(); |
| 4047 } | 4052 } |
| 4048 | 4053 |
| 4049 } // namespace internal | 4054 } // namespace internal |
| 4050 } // namespace v8 | 4055 } // namespace v8 |
| OLD | NEW |