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" |
11 #include "src/handles-inl.h" | 11 #include "src/handles-inl.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 // ----------------------------------------------------------------------------- | 16 // ----------------------------------------------------------------------------- |
17 // TypeImpl | 17 // TypeImpl |
18 | 18 |
19 template<class Config> | 19 template<class Config> |
20 TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) { | 20 TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) { |
21 TypeImpl* t = static_cast<TypeImpl*>(object); | 21 TypeImpl* t = static_cast<TypeImpl*>(object); |
22 ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() || t->IsRange() || | 22 DCHECK(t->IsBitset() || t->IsClass() || t->IsConstant() || t->IsRange() || |
23 t->IsUnion() || t->IsArray() || t->IsFunction() || t->IsContext()); | 23 t->IsUnion() || t->IsArray() || t->IsFunction() || t->IsContext()); |
24 return t; | 24 return t; |
25 } | 25 } |
26 | 26 |
27 | 27 |
28 // Most precise _current_ type of a value (usually its class). | 28 // Most precise _current_ type of a value (usually its class). |
29 template<class Config> | 29 template<class Config> |
30 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( | 30 typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf( |
31 i::Object* value, Region* region) { | 31 i::Object* value, Region* region) { |
32 if (value->IsSmi() || | 32 if (value->IsSmi() || |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 int ZoneTypeConfig::as_bitset(Type* type) { |
91 ASSERT(is_bitset(type)); | 91 DCHECK(is_bitset(type)); |
92 return static_cast<int>(reinterpret_cast<intptr_t>(type) >> 1); | 92 return static_cast<int>(reinterpret_cast<intptr_t>(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 ASSERT(!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 |
(...skipping 29 matching lines...) Expand all Loading... |
138 Struct* structure = reinterpret_cast<Struct*>( | 138 Struct* structure = reinterpret_cast<Struct*>( |
139 zone->New(sizeof(void*) * (length + 2))); // NOLINT | 139 zone->New(sizeof(void*) * (length + 2))); // NOLINT |
140 structure[0] = reinterpret_cast<void*>(tag); | 140 structure[0] = reinterpret_cast<void*>(tag); |
141 structure[1] = reinterpret_cast<void*>(length); | 141 structure[1] = reinterpret_cast<void*>(length); |
142 return structure; | 142 return structure; |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 // static | 146 // static |
147 void ZoneTypeConfig::struct_shrink(Struct* structure, int length) { | 147 void ZoneTypeConfig::struct_shrink(Struct* structure, int length) { |
148 ASSERT(0 <= length && length <= struct_length(structure)); | 148 DCHECK(0 <= length && length <= struct_length(structure)); |
149 structure[1] = reinterpret_cast<void*>(length); | 149 structure[1] = reinterpret_cast<void*>(length); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 // static | 153 // static |
154 int ZoneTypeConfig::struct_tag(Struct* structure) { | 154 int ZoneTypeConfig::struct_tag(Struct* structure) { |
155 return static_cast<int>(reinterpret_cast<intptr_t>(structure[0])); | 155 return static_cast<int>(reinterpret_cast<intptr_t>(structure[0])); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 // static | 159 // static |
160 int ZoneTypeConfig::struct_length(Struct* structure) { | 160 int ZoneTypeConfig::struct_length(Struct* structure) { |
161 return static_cast<int>(reinterpret_cast<intptr_t>(structure[1])); | 161 return static_cast<int>(reinterpret_cast<intptr_t>(structure[1])); |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 // static | 165 // static |
166 Type* ZoneTypeConfig::struct_get(Struct* structure, int i) { | 166 Type* ZoneTypeConfig::struct_get(Struct* structure, int i) { |
167 ASSERT(0 <= i && i <= struct_length(structure)); | 167 DCHECK(0 <= i && i <= struct_length(structure)); |
168 return static_cast<Type*>(structure[2 + i]); | 168 return static_cast<Type*>(structure[2 + i]); |
169 } | 169 } |
170 | 170 |
171 | 171 |
172 // static | 172 // static |
173 void ZoneTypeConfig::struct_set(Struct* structure, int i, Type* x) { | 173 void ZoneTypeConfig::struct_set(Struct* structure, int i, Type* x) { |
174 ASSERT(0 <= i && i <= struct_length(structure)); | 174 DCHECK(0 <= i && i <= struct_length(structure)); |
175 structure[2 + i] = x; | 175 structure[2 + i] = x; |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 // static | 179 // static |
180 template<class V> | 180 template<class V> |
181 i::Handle<V> ZoneTypeConfig::struct_get_value(Struct* structure, int i) { | 181 i::Handle<V> ZoneTypeConfig::struct_get_value(Struct* structure, int i) { |
182 ASSERT(0 <= i && i <= struct_length(structure)); | 182 DCHECK(0 <= i && i <= struct_length(structure)); |
183 return i::Handle<V>(static_cast<V**>(structure[2 + i])); | 183 return i::Handle<V>(static_cast<V**>(structure[2 + i])); |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 // static | 187 // static |
188 template<class V> | 188 template<class V> |
189 void ZoneTypeConfig::struct_set_value( | 189 void ZoneTypeConfig::struct_set_value( |
190 Struct* structure, int i, i::Handle<V> x) { | 190 Struct* structure, int i, i::Handle<V> x) { |
191 ASSERT(0 <= i && i <= struct_length(structure)); | 191 DCHECK(0 <= i && i <= struct_length(structure)); |
192 structure[2 + i] = x.location(); | 192 structure[2 + i] = x.location(); |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 // ----------------------------------------------------------------------------- | 196 // ----------------------------------------------------------------------------- |
197 // HeapTypeConfig | 197 // HeapTypeConfig |
198 | 198 |
199 // static | 199 // static |
200 template<class T> | 200 template<class T> |
201 i::Handle<T> HeapTypeConfig::handle(T* type) { | 201 i::Handle<T> HeapTypeConfig::handle(T* type) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 // static | 327 // static |
328 template<class V> | 328 template<class V> |
329 void HeapTypeConfig::struct_set_value( | 329 void HeapTypeConfig::struct_set_value( |
330 i::Handle<Struct> structure, int i, i::Handle<V> x) { | 330 i::Handle<Struct> structure, int i, i::Handle<V> x) { |
331 structure->set(i + 1, *x); | 331 structure->set(i + 1, *x); |
332 } | 332 } |
333 | 333 |
334 } } // namespace v8::internal | 334 } } // namespace v8::internal |
335 | 335 |
336 #endif // V8_TYPES_INL_H_ | 336 #endif // V8_TYPES_INL_H_ |
OLD | NEW |