OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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-types.h" | 5 #include "src/crankshaft/hydrogen-types.h" |
6 | 6 |
7 #include "src/field-type.h" | 7 #include "src/field-type.h" |
8 #include "src/handles-inl.h" | 8 #include "src/handles-inl.h" |
9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 | 29 |
30 // static | 30 // static |
31 HType HType::FromFieldType(Handle<FieldType> type, Zone* temp_zone) { | 31 HType HType::FromFieldType(Handle<FieldType> type, Zone* temp_zone) { |
32 return FromType(type->Convert(temp_zone)); | 32 return FromType(type->Convert(temp_zone)); |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 HType HType::FromValue(Handle<Object> value) { | 36 HType HType::FromValue(Handle<Object> value) { |
37 if (value->IsSmi()) return HType::Smi(); | 37 Object* raw_value = *value; |
38 if (value->IsNull()) return HType::Null(); | 38 if (raw_value->IsSmi()) return HType::Smi(); |
39 if (value->IsHeapNumber()) { | 39 DCHECK(raw_value->IsHeapObject()); |
| 40 Isolate* isolate = HeapObject::cast(*value)->GetIsolate(); |
| 41 if (raw_value->IsNull()) return HType::Null(); |
| 42 if (raw_value->IsHeapNumber()) { |
40 double n = Handle<v8::internal::HeapNumber>::cast(value)->value(); | 43 double n = Handle<v8::internal::HeapNumber>::cast(value)->value(); |
41 return IsSmiDouble(n) ? HType::Smi() : HType::HeapNumber(); | 44 return IsSmiDouble(n) ? HType::Smi() : HType::HeapNumber(); |
42 } | 45 } |
43 if (value->IsString()) return HType::String(); | 46 if (raw_value->IsString()) return HType::String(); |
44 if (value->IsBoolean()) return HType::Boolean(); | 47 if (raw_value->IsBoolean()) return HType::Boolean(); |
45 if (value->IsUndefined()) return HType::Undefined(); | 48 if (raw_value->IsUndefined(isolate)) return HType::Undefined(); |
46 if (value->IsJSArray()) { | 49 if (raw_value->IsJSArray()) { |
47 DCHECK(!value->IsUndetectable()); | 50 DCHECK(!raw_value->IsUndetectable()); |
48 return HType::JSArray(); | 51 return HType::JSArray(); |
49 } | 52 } |
50 if (value->IsJSObject() && !value->IsUndetectable()) { | 53 if (raw_value->IsJSObject() && !raw_value->IsUndetectable()) { |
51 return HType::JSObject(); | 54 return HType::JSObject(); |
52 } | 55 } |
53 DCHECK(value->IsHeapObject()); | |
54 return HType::HeapObject(); | 56 return HType::HeapObject(); |
55 } | 57 } |
56 | 58 |
57 | 59 |
58 std::ostream& operator<<(std::ostream& os, const HType& t) { | 60 std::ostream& operator<<(std::ostream& os, const HType& t) { |
59 // Note: The c1visualizer syntax for locals allows only a sequence of the | 61 // Note: The c1visualizer syntax for locals allows only a sequence of the |
60 // following characters: A-Za-z0-9_-|: | 62 // following characters: A-Za-z0-9_-|: |
61 switch (t.kind_) { | 63 switch (t.kind_) { |
62 #define DEFINE_CASE(Name, mask) \ | 64 #define DEFINE_CASE(Name, mask) \ |
63 case HType::k##Name: \ | 65 case HType::k##Name: \ |
64 return os << #Name; | 66 return os << #Name; |
65 HTYPE_LIST(DEFINE_CASE) | 67 HTYPE_LIST(DEFINE_CASE) |
66 #undef DEFINE_CASE | 68 #undef DEFINE_CASE |
67 } | 69 } |
68 UNREACHABLE(); | 70 UNREACHABLE(); |
69 return os; | 71 return os; |
70 } | 72 } |
71 | 73 |
72 } // namespace internal | 74 } // namespace internal |
73 } // namespace v8 | 75 } // namespace v8 |
OLD | NEW |