Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/types-inl.h

Issue 237963016: Revert "Implement structural function and array types" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/types.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "types.h" 8 #include "types.h"
9 9
10 #include "factory.h" 10 #include "factory.h"
11 #include "handles-inl.h" 11 #include "handles-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 // -------------------------------------------------------------------------- //
17 // TypeImpl
18
19 template<class Config>
20 typename TypeImpl<Config>::template Iterator<i::Map>
21 TypeImpl<Config>::Classes() {
22 if (this->IsBitset()) return Iterator<i::Map>();
23 return Iterator<i::Map>(Config::handle(this));
24 }
25
26
27 template<class Config>
28 typename TypeImpl<Config>::template Iterator<i::Object>
29 TypeImpl<Config>::Constants() {
30 if (this->IsBitset()) return Iterator<i::Object>();
31 return Iterator<i::Object>(Config::handle(this));
32 }
33
34
35 template<class Config>
36 TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) {
37 TypeImpl* t = static_cast<TypeImpl*>(object);
38 ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() ||
39 t->IsUnion() || t->IsArray() || t->IsFunction());
40 return t;
41 }
42
43
44 template<class Config> 16 template<class Config>
45 bool TypeImpl<Config>::NowContains(i::Object* value) { 17 bool TypeImpl<Config>::NowContains(i::Object* value) {
46 DisallowHeapAllocation no_allocation; 18 DisallowHeapAllocation no_allocation;
47 if (this->IsAny()) return true; 19 if (this->IsAny()) return true;
48 if (value->IsHeapObject()) { 20 if (value->IsHeapObject()) {
49 i::Map* map = i::HeapObject::cast(value)->map(); 21 i::Map* map = i::HeapObject::cast(value)->map();
50 for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) { 22 for (Iterator<i::Map> it = this->Classes(); !it.Done(); it.Advance()) {
51 if (*it.Current() == map) return true; 23 if (*it.Current() == map) return true;
52 } 24 }
53 } 25 }
54 return this->Contains(value); 26 return this->Contains(value);
55 } 27 }
56 28
57 29
58 // -------------------------------------------------------------------------- //
59 // ZoneTypeConfig
60
61 // static
62 template<class T>
63 T* ZoneTypeConfig::handle(T* type) {
64 return type;
65 }
66
67
68 // static 30 // static
69 template<class T> 31 Type* ZoneTypeConfig::handle(Type* type) {
70 T* ZoneTypeConfig::cast(Type* type) { 32 return type;
71 return static_cast<T*>(type);
72 } 33 }
73 34
74 35
75 // static 36 // static
76 bool ZoneTypeConfig::is_bitset(Type* type) { 37 bool ZoneTypeConfig::is_bitset(Type* type) {
77 return reinterpret_cast<intptr_t>(type) & 1; 38 return reinterpret_cast<intptr_t>(type) & 1;
78 } 39 }
79 40
80 41
81 // static 42 // static
82 bool ZoneTypeConfig::is_struct(Type* type, int tag) { 43 bool ZoneTypeConfig::is_struct(Type* type) {
83 return !is_bitset(type) && struct_tag(as_struct(type)) == tag; 44 return !is_bitset(type);
84 } 45 }
85 46
86 47
87 // static 48 // static
88 bool ZoneTypeConfig::is_class(Type* type) { 49 bool ZoneTypeConfig::is_class(Type* type) {
89 return is_struct(type, Type::StructuralType::kClassTag); 50 return is_struct(type) && struct_tag(as_struct(type)) == Type::kClassTag;
90 } 51 }
91 52
92 53
93 // static 54 // static
94 bool ZoneTypeConfig::is_constant(Type* type) { 55 bool ZoneTypeConfig::is_constant(Type* type) {
95 return is_struct(type, Type::StructuralType::kConstantTag); 56 return is_struct(type) && struct_tag(as_struct(type)) == Type::kConstantTag;
96 } 57 }
97 58
98 59
99 // static 60 // static
100 int ZoneTypeConfig::as_bitset(Type* type) { 61 int ZoneTypeConfig::as_bitset(Type* type) {
101 ASSERT(is_bitset(type)); 62 ASSERT(is_bitset(type));
102 return static_cast<int>(reinterpret_cast<intptr_t>(type) >> 1); 63 return static_cast<int>(reinterpret_cast<intptr_t>(type) >> 1);
103 } 64 }
104 65
105 66
106 // static 67 // static
107 ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) { 68 ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) {
108 ASSERT(!is_bitset(type)); 69 ASSERT(is_struct(type));
109 return reinterpret_cast<Struct*>(type); 70 return reinterpret_cast<Struct*>(type);
110 } 71 }
111 72
112 73
113 // static 74 // static
114 i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) { 75 i::Handle<i::Map> ZoneTypeConfig::as_class(Type* type) {
115 ASSERT(is_class(type)); 76 ASSERT(is_class(type));
116 return i::Handle<i::Map>(static_cast<i::Map**>(as_struct(type)[3])); 77 return i::Handle<i::Map>(static_cast<i::Map**>(as_struct(type)[3]));
117 } 78 }
118 79
(...skipping 20 matching lines...) Expand all
139 100
140 // static 101 // static
141 ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structured) { 102 ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structured) {
142 return reinterpret_cast<Type*>(structured); 103 return reinterpret_cast<Type*>(structured);
143 } 104 }
144 105
145 106
146 // static 107 // static
147 ZoneTypeConfig::Type* ZoneTypeConfig::from_class( 108 ZoneTypeConfig::Type* ZoneTypeConfig::from_class(
148 i::Handle<i::Map> map, int lub, Zone* zone) { 109 i::Handle<i::Map> map, int lub, Zone* zone) {
149 Struct* structured = struct_create(Type::StructuralType::kClassTag, 2, zone); 110 Struct* structured = struct_create(Type::kClassTag, 2, zone);
150 structured[2] = from_bitset(lub); 111 structured[2] = from_bitset(lub);
151 structured[3] = map.location(); 112 structured[3] = map.location();
152 return from_struct(structured); 113 return from_struct(structured);
153 } 114 }
154 115
155 116
156 // static 117 // static
157 ZoneTypeConfig::Type* ZoneTypeConfig::from_constant( 118 ZoneTypeConfig::Type* ZoneTypeConfig::from_constant(
158 i::Handle<i::Object> value, int lub, Zone* zone) { 119 i::Handle<i::Object> value, int lub, Zone* zone) {
159 Struct* structured = 120 Struct* structured = struct_create(Type::kConstantTag, 2, zone);
160 struct_create(Type::StructuralType::kConstantTag, 2, zone);
161 structured[2] = from_bitset(lub); 121 structured[2] = from_bitset(lub);
162 structured[3] = value.location(); 122 structured[3] = value.location();
163 return from_struct(structured); 123 return from_struct(structured);
164 } 124 }
165 125
166 126
167 // static 127 // static
168 ZoneTypeConfig::Struct* ZoneTypeConfig::struct_create( 128 ZoneTypeConfig::Struct* ZoneTypeConfig::struct_create(
169 int tag, int length, Zone* zone) { 129 int tag, int length, Zone* zone) {
170 Struct* structured = reinterpret_cast<Struct*>( 130 Struct* structured = reinterpret_cast<Struct*>(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 structured[2 + i] = type; 167 structured[2 + i] = type;
208 } 168 }
209 169
210 170
211 // static 171 // static
212 int ZoneTypeConfig::lub_bitset(Type* type) { 172 int ZoneTypeConfig::lub_bitset(Type* type) {
213 ASSERT(is_class(type) || is_constant(type)); 173 ASSERT(is_class(type) || is_constant(type));
214 return as_bitset(struct_get(as_struct(type), 0)); 174 return as_bitset(struct_get(as_struct(type), 0));
215 } 175 }
216 176
217
218 // -------------------------------------------------------------------------- // 177 // -------------------------------------------------------------------------- //
219 // HeapTypeConfig
220 178
221 // static 179 // static
222 template<class T> 180 i::Handle<HeapTypeConfig::Type> HeapTypeConfig::handle(Type* type) {
223 i::Handle<T> HeapTypeConfig::handle(T* type) {
224 return i::handle(type, i::HeapObject::cast(type)->GetIsolate()); 181 return i::handle(type, i::HeapObject::cast(type)->GetIsolate());
225 } 182 }
226 183
227 184
228 // static 185 // static
229 template<class T>
230 i::Handle<T> HeapTypeConfig::cast(i::Handle<Type> type) {
231 return i::Handle<T>::cast(type);
232 }
233
234
235 // static
236 bool HeapTypeConfig::is_bitset(Type* type) { 186 bool HeapTypeConfig::is_bitset(Type* type) {
237 return type->IsSmi(); 187 return type->IsSmi();
238 } 188 }
239 189
240 190
241 // static 191 // static
242 bool HeapTypeConfig::is_class(Type* type) { 192 bool HeapTypeConfig::is_class(Type* type) {
243 return type->IsMap(); 193 return type->IsMap();
244 } 194 }
245 195
246 196
247 // static 197 // static
248 bool HeapTypeConfig::is_constant(Type* type) { 198 bool HeapTypeConfig::is_constant(Type* type) {
249 return type->IsBox(); 199 return type->IsBox();
250 } 200 }
251 201
252 202
253 // static 203 // static
254 bool HeapTypeConfig::is_struct(Type* type, int tag) { 204 bool HeapTypeConfig::is_struct(Type* type) {
255 return type->IsFixedArray() && struct_tag(as_struct(type)) == tag; 205 return type->IsFixedArray();
256 } 206 }
257 207
258 208
259 // static 209 // static
260 int HeapTypeConfig::as_bitset(Type* type) { 210 int HeapTypeConfig::as_bitset(Type* type) {
261 return i::Smi::cast(type)->value(); 211 return Smi::cast(type)->value();
262 } 212 }
263 213
264 214
265 // static 215 // static
266 i::Handle<i::Map> HeapTypeConfig::as_class(Type* type) { 216 i::Handle<i::Map> HeapTypeConfig::as_class(Type* type) {
267 return i::handle(i::Map::cast(type)); 217 return i::handle(i::Map::cast(type));
268 } 218 }
269 219
270 220
271 // static 221 // static
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 309
360 310
361 // static 311 // static
362 int HeapTypeConfig::lub_bitset(Type* type) { 312 int HeapTypeConfig::lub_bitset(Type* type) {
363 return 0; // kNone, which causes recomputation. 313 return 0; // kNone, which causes recomputation.
364 } 314 }
365 315
366 } } // namespace v8::internal 316 } } // namespace v8::internal
367 317
368 #endif // V8_TYPES_INL_H_ 318 #endif // V8_TYPES_INL_H_
OLDNEW
« no previous file with comments | « src/types.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698