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

Side by Side Diff: src/types.h

Issue 17589013: Introduce Unsigned32 and RegExp types (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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/ic.cc ('k') | src/types.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 30 matching lines...) Expand all
41 // obvious primitive types and some predefined unions, the type language also 41 // obvious primitive types and some predefined unions, the type language also
42 // can express class types (a.k.a. specific maps) and singleton types (i.e., 42 // can express class types (a.k.a. specific maps) and singleton types (i.e.,
43 // concrete constants). 43 // concrete constants).
44 // 44 //
45 // The following equations and inequations hold: 45 // The following equations and inequations hold:
46 // 46 //
47 // None <= T 47 // None <= T
48 // T <= Any 48 // T <= Any
49 // 49 //
50 // Oddball = Boolean \/ Null \/ Undefined 50 // Oddball = Boolean \/ Null \/ Undefined
51 // Number = Integer32 \/ Double 51 // Number = Signed32 \/ Unsigned32 \/ Double
52 // Integer31 < Integer32 52 // Smi < Signed32
Jakob Kummerow 2013/06/24 15:12:11 strictly speaking: Smi <= Signed32 (as well as Sig
rossberg 2013/06/25 06:21:51 Good point.
53 // Name = String \/ Symbol 53 // Name = String \/ Symbol
54 // UniqueName = InternalizedString \/ Symbol 54 // UniqueName = InternalizedString \/ Symbol
55 // InternalizedString < String 55 // InternalizedString < String
56 // 56 //
57 // Allocated = Receiver \/ Number \/ Name 57 // Allocated = Receiver \/ Number \/ Name
58 // Detectable = Allocated - Undetectable 58 // Detectable = Allocated - Undetectable
59 // Undetectable < Object 59 // Undetectable < Object
60 // Receiver = Object \/ Proxy 60 // Receiver = Object \/ Proxy
61 // Array < Object 61 // Array < Object
62 // Function < Object 62 // Function < Object
63 // RegExp < Object
63 // 64 //
64 // Class(map) < T iff instance_type(map) < T 65 // Class(map) < T iff instance_type(map) < T
65 // Constant(x) < T iff instance_type(map(x)) < T 66 // Constant(x) < T iff instance_type(map(x)) < T
66 // 67 //
67 // Note that Constant(x) < Class(map(x)) does _not_ hold, since x's map can 68 // Note that Constant(x) < Class(map(x)) does _not_ hold, since x's map can
68 // change! (Its instance type cannot, however.) 69 // change! (Its instance type cannot, however.)
69 // TODO(rossberg): the latter is not currently true for proxies, because of fix, 70 // TODO(rossberg): the latter is not currently true for proxies, because of fix,
70 // but will hold once we implement direct proxies. 71 // but will hold once we implement direct proxies.
71 // 72 //
72 // There are two main functions for testing types: 73 // There are two main functions for testing types:
(...skipping 24 matching lines...) Expand all
97 static Type* Any() { return from_bitset(kAny); } 98 static Type* Any() { return from_bitset(kAny); }
98 static Type* Allocated() { return from_bitset(kAllocated); } 99 static Type* Allocated() { return from_bitset(kAllocated); }
99 static Type* Detectable() { return from_bitset(kDetectable); } 100 static Type* Detectable() { return from_bitset(kDetectable); }
100 101
101 static Type* Oddball() { return from_bitset(kOddball); } 102 static Type* Oddball() { return from_bitset(kOddball); }
102 static Type* Boolean() { return from_bitset(kBoolean); } 103 static Type* Boolean() { return from_bitset(kBoolean); }
103 static Type* Null() { return from_bitset(kNull); } 104 static Type* Null() { return from_bitset(kNull); }
104 static Type* Undefined() { return from_bitset(kUndefined); } 105 static Type* Undefined() { return from_bitset(kUndefined); }
105 106
106 static Type* Number() { return from_bitset(kNumber); } 107 static Type* Number() { return from_bitset(kNumber); }
107 static Type* Integer31() { return from_bitset(kInteger31); } 108 static Type* Smi() { return from_bitset(kSmi); }
108 static Type* Integer32() { return from_bitset(kInteger32); } 109 static Type* Signed32() { return from_bitset(kSigned32); }
110 static Type* Unsigned32() { return from_bitset(kUnsigned32); }
109 static Type* Double() { return from_bitset(kDouble); } 111 static Type* Double() { return from_bitset(kDouble); }
112 static Type* NumberOrString() { return from_bitset(kNumberOrString); }
110 113
111 static Type* Name() { return from_bitset(kName); } 114 static Type* Name() { return from_bitset(kName); }
112 static Type* UniqueName() { return from_bitset(kUniqueName); } 115 static Type* UniqueName() { return from_bitset(kUniqueName); }
113 static Type* String() { return from_bitset(kString); } 116 static Type* String() { return from_bitset(kString); }
114 static Type* InternalizedString() { return from_bitset(kInternalizedString); } 117 static Type* InternalizedString() { return from_bitset(kInternalizedString); }
115 static Type* Symbol() { return from_bitset(kSymbol); } 118 static Type* Symbol() { return from_bitset(kSymbol); }
116 119
117 static Type* Receiver() { return from_bitset(kReceiver); } 120 static Type* Receiver() { return from_bitset(kReceiver); }
118 static Type* Object() { return from_bitset(kObject); } 121 static Type* Object() { return from_bitset(kObject); }
119 static Type* Undetectable() { return from_bitset(kUndetectable); } 122 static Type* Undetectable() { return from_bitset(kUndetectable); }
120 static Type* Array() { return from_bitset(kArray); } 123 static Type* Array() { return from_bitset(kArray); }
121 static Type* Function() { return from_bitset(kFunction); } 124 static Type* Function() { return from_bitset(kFunction); }
125 static Type* RegExp() { return from_bitset(kRegExp); }
122 static Type* Proxy() { return from_bitset(kProxy); } 126 static Type* Proxy() { return from_bitset(kProxy); }
123 127
124 static Type* Class(Handle<Map> map) { return from_handle(map); } 128 static Type* Class(Handle<Map> map) { return from_handle(map); }
125 static Type* Constant(Handle<HeapObject> value) { 129 static Type* Constant(Handle<HeapObject> value) {
126 return Constant(value, value->GetIsolate()); 130 return Constant(value, value->GetIsolate());
127 } 131 }
128 static Type* Constant(Handle<v8::internal::Object> value, Isolate* isolate) { 132 static Type* Constant(Handle<v8::internal::Object> value, Isolate* isolate) {
129 return from_handle(isolate->factory()->NewBox(value)); 133 return from_handle(isolate->factory()->NewBox(value));
130 } 134 }
131 135
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // A union is a fixed array containing types. Invariants: 185 // A union is a fixed array containing types. Invariants:
182 // - its length is at least 2 186 // - its length is at least 2
183 // - at most one field is a bitset, and it must go into index 0 187 // - at most one field is a bitset, and it must go into index 0
184 // - no field is a union 188 // - no field is a union
185 typedef FixedArray Unioned; 189 typedef FixedArray Unioned;
186 190
187 enum { 191 enum {
188 kNull = 1 << 0, 192 kNull = 1 << 0,
189 kUndefined = 1 << 1, 193 kUndefined = 1 << 1,
190 kBoolean = 1 << 2, 194 kBoolean = 1 << 2,
191 kInteger31 = 1 << 3, 195 kSmi = 1 << 3,
192 kOtherInteger = 1 << 4, 196 kOtherSigned32 = 1 << 4,
193 kDouble = 1 << 5, 197 kUnsigned32 = 1 << 5,
194 kSymbol = 1 << 6, 198 kDouble = 1 << 6,
195 kInternalizedString = 1 << 7, 199 kSymbol = 1 << 7,
196 kOtherString = 1 << 8, 200 kInternalizedString = 1 << 8,
197 kUndetectable = 1 << 9, 201 kOtherString = 1 << 9,
198 kArray = 1 << 10, 202 kUndetectable = 1 << 10,
199 kFunction = 1 << 11, 203 kArray = 1 << 11,
200 kOtherObject = 1 << 12, 204 kFunction = 1 << 12,
201 kProxy = 1 << 13, 205 kRegExp = 1 << 13,
206 kOtherObject = 1 << 14,
207 kProxy = 1 << 15,
202 208
203 kOddball = kBoolean | kNull | kUndefined, 209 kOddball = kBoolean | kNull | kUndefined,
204 kInteger32 = kInteger31 | kOtherInteger, 210 kSigned32 = kSmi | kOtherSigned32,
205 kNumber = kInteger32 | kDouble, 211 kNumber = kSigned32 | kUnsigned32 | kDouble,
206 kString = kInternalizedString | kOtherString, 212 kString = kInternalizedString | kOtherString,
207 kUniqueName = kSymbol | kInternalizedString, 213 kUniqueName = kSymbol | kInternalizedString,
208 kName = kSymbol | kString, 214 kName = kSymbol | kString,
209 kObject = kUndetectable | kArray | kFunction | kOtherObject, 215 kNumberOrString = kNumber | kString,
216 kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject,
210 kReceiver = kObject | kProxy, 217 kReceiver = kObject | kProxy,
211 kAllocated = kDouble | kName | kReceiver, 218 kAllocated = kDouble | kName | kReceiver,
212 kAny = kOddball | kNumber | kAllocated, 219 kAny = kOddball | kNumber | kAllocated,
213 kDetectable = kAllocated - kUndetectable, 220 kDetectable = kAllocated - kUndetectable,
214 kNone = 0 221 kNone = 0
215 }; 222 };
216 223
217 bool is_bitset() { return this->IsSmi(); } 224 bool is_bitset() { return this->IsSmi(); }
218 bool is_class() { return this->IsMap(); } 225 bool is_class() { return this->IsMap(); }
219 bool is_constant() { return this->IsBox(); } 226 bool is_constant() { return this->IsBox(); }
(...skipping 30 matching lines...) Expand all
250 int GlbBitset(); // greatest lower bound that's a bitset 257 int GlbBitset(); // greatest lower bound that's a bitset
251 bool InUnion(Handle<Unioned> unioned, int current_size); 258 bool InUnion(Handle<Unioned> unioned, int current_size);
252 int ExtendUnion(Handle<Unioned> unioned, int current_size); 259 int ExtendUnion(Handle<Unioned> unioned, int current_size);
253 int ExtendIntersection( 260 int ExtendIntersection(
254 Handle<Unioned> unioned, Handle<Type> type, int current_size); 261 Handle<Unioned> unioned, Handle<Type> type, int current_size);
255 }; 262 };
256 263
257 } } // namespace v8::internal 264 } } // namespace v8::internal
258 265
259 #endif // V8_TYPES_H_ 266 #endif // V8_TYPES_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698