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/ostreams.h" | 7 #include "src/ostreams.h" |
8 #include "src/types-inl.h" | 8 #include "src/types-inl.h" |
9 | 9 |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 // static | 14 // static |
15 template <class T> | 15 HType HType::FromType(Type* type) { |
16 HType HType::FromType(typename T::TypeHandle type) { | 16 if (Type::Any()->Is(type)) return HType::Any(); |
17 if (T::Any()->Is(type)) return HType::Any(); | |
18 if (!type->IsInhabited()) return HType::None(); | 17 if (!type->IsInhabited()) return HType::None(); |
19 if (type->Is(T::SignedSmall())) return HType::Smi(); | 18 if (type->Is(Type::SignedSmall())) return HType::Smi(); |
20 if (type->Is(T::Number())) return HType::TaggedNumber(); | 19 if (type->Is(Type::Number())) return HType::TaggedNumber(); |
21 if (type->Is(T::Null())) return HType::Null(); | 20 if (type->Is(Type::Null())) return HType::Null(); |
22 if (type->Is(T::String())) return HType::String(); | 21 if (type->Is(Type::String())) return HType::String(); |
23 if (type->Is(T::Boolean())) return HType::Boolean(); | 22 if (type->Is(Type::Boolean())) return HType::Boolean(); |
24 if (type->Is(T::Undefined())) return HType::Undefined(); | 23 if (type->Is(Type::Undefined())) return HType::Undefined(); |
25 if (type->Is(T::Object())) return HType::JSObject(); | 24 if (type->Is(Type::Object())) return HType::JSObject(); |
26 if (type->Is(T::Receiver())) return HType::JSReceiver(); | 25 if (type->Is(Type::Receiver())) return HType::JSReceiver(); |
27 return HType::Tagged(); | 26 return HType::Tagged(); |
28 } | 27 } |
29 | 28 |
30 | 29 |
31 // static | 30 // static |
32 template | 31 HType HType::FromFieldType(Handle<FieldType> type, Zone* temp_zone) { |
Benedikt Meurer
2016/01/26 14:22:47
Can we have a TODO here to remember to clean this
Jarin
2016/01/26 14:30:41
As discussed offline, it is not clear what can be
| |
33 HType HType::FromType<Type>(Type* type); | 32 return FromType(type->Convert(temp_zone)); |
34 | 33 } |
35 | |
36 // static | |
37 template | |
38 HType HType::FromType<HeapType>(Handle<HeapType> type); | |
39 | |
40 | 34 |
41 // static | 35 // static |
42 HType HType::FromValue(Handle<Object> value) { | 36 HType HType::FromValue(Handle<Object> value) { |
43 if (value->IsSmi()) return HType::Smi(); | 37 if (value->IsSmi()) return HType::Smi(); |
44 if (value->IsNull()) return HType::Null(); | 38 if (value->IsNull()) return HType::Null(); |
45 if (value->IsHeapNumber()) { | 39 if (value->IsHeapNumber()) { |
46 double n = Handle<v8::internal::HeapNumber>::cast(value)->value(); | 40 double n = Handle<v8::internal::HeapNumber>::cast(value)->value(); |
47 return IsSmiDouble(n) ? HType::Smi() : HType::HeapNumber(); | 41 return IsSmiDouble(n) ? HType::Smi() : HType::HeapNumber(); |
48 } | 42 } |
49 if (value->IsString()) return HType::String(); | 43 if (value->IsString()) return HType::String(); |
(...skipping 15 matching lines...) Expand all Loading... | |
65 return os << #Name; | 59 return os << #Name; |
66 HTYPE_LIST(DEFINE_CASE) | 60 HTYPE_LIST(DEFINE_CASE) |
67 #undef DEFINE_CASE | 61 #undef DEFINE_CASE |
68 } | 62 } |
69 UNREACHABLE(); | 63 UNREACHABLE(); |
70 return os; | 64 return os; |
71 } | 65 } |
72 | 66 |
73 } // namespace internal | 67 } // namespace internal |
74 } // namespace v8 | 68 } // namespace v8 |
OLD | NEW |