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 #ifndef V8_TYPES_INL_H_ | 5 #ifndef V8_TYPES_INL_H_ |
6 #define V8_TYPES_INL_H_ | 6 #define V8_TYPES_INL_H_ |
7 | 7 |
8 #include "src/types.h" | 8 #include "src/types.h" |
9 | 9 |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 | 63 |
64 // static | 64 // static |
65 template<class T> | 65 template<class T> |
66 T* ZoneTypeConfig::cast(Type* type) { | 66 T* ZoneTypeConfig::cast(Type* type) { |
67 return static_cast<T*>(type); | 67 return static_cast<T*>(type); |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 // static | 71 // static |
72 bool ZoneTypeConfig::is_bitset(Type* type) { | 72 bool ZoneTypeConfig::is_bitset(Type* type) { |
73 return reinterpret_cast<intptr_t>(type) & 1; | 73 return reinterpret_cast<uintptr_t>(type) & 1; |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 // static | 77 // static |
78 bool ZoneTypeConfig::is_struct(Type* type, int tag) { | 78 bool ZoneTypeConfig::is_struct(Type* type, int tag) { |
79 return !is_bitset(type) && struct_tag(as_struct(type)) == tag; | 79 return !is_bitset(type) && struct_tag(as_struct(type)) == tag; |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 // static | 83 // static |
84 bool ZoneTypeConfig::is_class(Type* type) { | 84 bool ZoneTypeConfig::is_class(Type* type) { |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 // static | 89 // static |
90 int ZoneTypeConfig::as_bitset(Type* type) { | 90 ZoneTypeConfig::Type::bitset ZoneTypeConfig::as_bitset(Type* type) { |
91 DCHECK(is_bitset(type)); | 91 DCHECK(is_bitset(type)); |
92 return static_cast<int>(reinterpret_cast<intptr_t>(type) >> 1); | 92 return reinterpret_cast<Type::bitset>(type) >> 1; |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 // static | 96 // static |
97 ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) { | 97 ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) { |
98 DCHECK(!is_bitset(type)); | 98 DCHECK(!is_bitset(type)); |
99 return reinterpret_cast<Struct*>(type); | 99 return reinterpret_cast<Struct*>(type); |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 // static | 103 // static |
104 i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) { | 104 i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) { |
105 UNREACHABLE(); | 105 UNREACHABLE(); |
106 return i::Handle<i::Map>(); | 106 return i::Handle<i::Map>(); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 // static | 110 // static |
111 ZoneTypeConfig::Type* ZoneTypeConfig::from_bitset(int bitset) { | 111 ZoneTypeConfig::Type* ZoneTypeConfig::from_bitset(Type::bitset bitset) { |
112 return reinterpret_cast<Type*>((bitset << 1) | 1); | 112 return reinterpret_cast<Type*>((bitset << 1) | 1); |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 // static | 116 // static |
117 ZoneTypeConfig::Type* ZoneTypeConfig::from_bitset(int bitset, Zone* Zone) { | 117 ZoneTypeConfig::Type* ZoneTypeConfig::from_bitset( |
118 Type::bitset bitset, Zone* Zone) { | |
118 return from_bitset(bitset); | 119 return from_bitset(bitset); |
119 } | 120 } |
120 | 121 |
121 | 122 |
122 // static | 123 // static |
123 ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structure) { | 124 ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structure) { |
124 return reinterpret_cast<Type*>(structure); | 125 return reinterpret_cast<Type*>(structure); |
125 } | 126 } |
126 | 127 |
127 | 128 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 } | 223 } |
223 | 224 |
224 | 225 |
225 // static | 226 // static |
226 bool HeapTypeConfig::is_struct(Type* type, int tag) { | 227 bool HeapTypeConfig::is_struct(Type* type, int tag) { |
227 return type->IsFixedArray() && struct_tag(as_struct(type)) == tag; | 228 return type->IsFixedArray() && struct_tag(as_struct(type)) == tag; |
228 } | 229 } |
229 | 230 |
230 | 231 |
231 // static | 232 // static |
232 int HeapTypeConfig::as_bitset(Type* type) { | 233 HeapTypeConfig::Type::bitset HeapTypeConfig::as_bitset(Type* type) { |
233 return i::Smi::cast(type)->value(); | 234 return static_cast<Type::bitset>(i::Smi::cast(type)->value()); |
234 } | 235 } |
235 | 236 |
236 | 237 |
237 // static | 238 // static |
238 i::Handle<i::Map> HeapTypeConfig::as_class(Type* type) { | 239 i::Handle<i::Map> HeapTypeConfig::as_class(Type* type) { |
239 return i::handle(i::Map::cast(type)); | 240 return i::handle(i::Map::cast(type)); |
240 } | 241 } |
241 | 242 |
242 | 243 |
243 // static | 244 // static |
244 i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::as_struct(Type* type) { | 245 i::Handle<HeapTypeConfig::Struct> HeapTypeConfig::as_struct(Type* type) { |
245 return i::handle(Struct::cast(type)); | 246 return i::handle(Struct::cast(type)); |
246 } | 247 } |
247 | 248 |
248 | 249 |
249 // static | 250 // static |
250 HeapTypeConfig::Type* HeapTypeConfig::from_bitset(int bitset) { | 251 HeapTypeConfig::Type* HeapTypeConfig::from_bitset(Type::bitset bitset) { |
251 return Type::cast(i::Smi::FromInt(bitset)); | 252 // TODO(rossberg): This is implementation-defined. How can we avoid it? |
253 return Type::cast(i::Smi::FromInt(static_cast<int>(bitset))); | |
Benedikt Meurer
2014/09/10 04:13:23
Use
Type::cast(i::Smi::FromIntptr(bit_cast<intptr
| |
252 } | 254 } |
253 | 255 |
254 | 256 |
255 // static | 257 // static |
256 i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_bitset( | 258 i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_bitset( |
257 int bitset, Isolate* isolate) { | 259 Type::bitset bitset, Isolate* isolate) { |
258 return i::handle(from_bitset(bitset), isolate); | 260 return i::handle(from_bitset(bitset), isolate); |
259 } | 261 } |
260 | 262 |
261 | 263 |
262 // static | 264 // static |
263 i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_class( | 265 i::Handle<HeapTypeConfig::Type> HeapTypeConfig::from_class( |
264 i::Handle<i::Map> map, Isolate* isolate) { | 266 i::Handle<i::Map> map, Isolate* isolate) { |
265 return i::Handle<Type>::cast(i::Handle<Object>::cast(map)); | 267 return i::Handle<Type>::cast(i::Handle<Object>::cast(map)); |
266 } | 268 } |
267 | 269 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // static | 329 // static |
328 template<class V> | 330 template<class V> |
329 void HeapTypeConfig::struct_set_value( | 331 void HeapTypeConfig::struct_set_value( |
330 i::Handle<Struct> structure, int i, i::Handle<V> x) { | 332 i::Handle<Struct> structure, int i, i::Handle<V> x) { |
331 structure->set(i + 1, *x); | 333 structure->set(i + 1, *x); |
332 } | 334 } |
333 | 335 |
334 } } // namespace v8::internal | 336 } } // namespace v8::internal |
335 | 337 |
336 #endif // V8_TYPES_INL_H_ | 338 #endif // V8_TYPES_INL_H_ |
OLD | NEW |