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/safe_math.h" | 8 #include "src/base/safe_math.h" |
9 #include "src/crankshaft/hydrogen-infer-representation.h" | 9 #include "src/crankshaft/hydrogen-infer-representation.h" |
10 #include "src/double.h" | 10 #include "src/double.h" |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2951 Zone* zone) { | 2951 Zone* zone) { |
2952 HConstant* res = NULL; | 2952 HConstant* res = NULL; |
2953 Handle<Object> handle = this->handle(isolate); | 2953 Handle<Object> handle = this->handle(isolate); |
2954 if (handle->IsBoolean()) { | 2954 if (handle->IsBoolean()) { |
2955 res = handle->BooleanValue() ? | 2955 res = handle->BooleanValue() ? |
2956 new(zone) HConstant(1) : new(zone) HConstant(0); | 2956 new(zone) HConstant(1) : new(zone) HConstant(0); |
2957 } else if (handle->IsUndefined()) { | 2957 } else if (handle->IsUndefined()) { |
2958 res = new (zone) HConstant(std::numeric_limits<double>::quiet_NaN()); | 2958 res = new (zone) HConstant(std::numeric_limits<double>::quiet_NaN()); |
2959 } else if (handle->IsNull()) { | 2959 } else if (handle->IsNull()) { |
2960 res = new(zone) HConstant(0); | 2960 res = new(zone) HConstant(0); |
| 2961 } else if (handle->IsString()) { |
| 2962 res = new(zone) HConstant(String::ToNumber(Handle<String>::cast(handle))); |
2961 } | 2963 } |
2962 return res != NULL ? Just(res) : Nothing<HConstant*>(); | 2964 return res != NULL ? Just(res) : Nothing<HConstant*>(); |
2963 } | 2965 } |
2964 | 2966 |
2965 | 2967 |
2966 std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT | 2968 std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT |
2967 if (HasInteger32Value()) { | 2969 if (HasInteger32Value()) { |
2968 os << int32_value_ << " "; | 2970 os << int32_value_ << " "; |
2969 } else if (HasDoubleValue()) { | 2971 } else if (HasDoubleValue()) { |
2970 os << double_value_ << " "; | 2972 os << double_value_ << " "; |
(...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4655 case HObjectAccess::kExternalMemory: | 4657 case HObjectAccess::kExternalMemory: |
4656 os << "[external-memory]"; | 4658 os << "[external-memory]"; |
4657 break; | 4659 break; |
4658 } | 4660 } |
4659 | 4661 |
4660 return os << "@" << access.offset(); | 4662 return os << "@" << access.offset(); |
4661 } | 4663 } |
4662 | 4664 |
4663 } // namespace internal | 4665 } // namespace internal |
4664 } // namespace v8 | 4666 } // namespace v8 |
OLD | NEW |