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

Side by Side Diff: src/type-info.h

Issue 8373029: [hydrogen] optimize switch with string clauses (Closed) Base URL: gh:v8/v8@master
Patch Set: last_block != NULL for string cases Created 9 years, 1 month 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 static TypeInfo Unknown() { return TypeInfo(kUnknown); } 58 static TypeInfo Unknown() { return TypeInfo(kUnknown); }
59 // We know it's a primitive type. 59 // We know it's a primitive type.
60 static TypeInfo Primitive() { return TypeInfo(kPrimitive); } 60 static TypeInfo Primitive() { return TypeInfo(kPrimitive); }
61 // We know it's a number of some sort. 61 // We know it's a number of some sort.
62 static TypeInfo Number() { return TypeInfo(kNumber); } 62 static TypeInfo Number() { return TypeInfo(kNumber); }
63 // We know it's a signed 32 bit integer. 63 // We know it's a signed 32 bit integer.
64 static TypeInfo Integer32() { return TypeInfo(kInteger32); } 64 static TypeInfo Integer32() { return TypeInfo(kInteger32); }
65 // We know it's a Smi. 65 // We know it's a Smi.
66 static TypeInfo Smi() { return TypeInfo(kSmi); } 66 static TypeInfo Smi() { return TypeInfo(kSmi); }
67 // We know it's a Symbol.
68 static TypeInfo Symbol() { return TypeInfo(kSymbol); }
67 // We know it's a heap number. 69 // We know it's a heap number.
68 static TypeInfo Double() { return TypeInfo(kDouble); } 70 static TypeInfo Double() { return TypeInfo(kDouble); }
69 // We know it's a string. 71 // We know it's a string.
70 static TypeInfo String() { return TypeInfo(kString); } 72 static TypeInfo String() { return TypeInfo(kString); }
71 // We know it's a non-primitive (object) type. 73 // We know it's a non-primitive (object) type.
72 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } 74 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); }
73 // We haven't started collecting info yet. 75 // We haven't started collecting info yet.
74 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } 76 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); }
75 77
76 int ToInt() { 78 int ToInt() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 inline bool IsNumber() { 132 inline bool IsNumber() {
131 ASSERT(type_ != kUninitialized); 133 ASSERT(type_ != kUninitialized);
132 return ((type_ & kNumber) == kNumber); 134 return ((type_ & kNumber) == kNumber);
133 } 135 }
134 136
135 inline bool IsSmi() { 137 inline bool IsSmi() {
136 ASSERT(type_ != kUninitialized); 138 ASSERT(type_ != kUninitialized);
137 return ((type_ & kSmi) == kSmi); 139 return ((type_ & kSmi) == kSmi);
138 } 140 }
139 141
142 inline bool IsSymbol() {
143 ASSERT(type_ != kUninitialized);
144 return ((type_ & kSymbol) == kSymbol);
145 }
146
140 inline bool IsInteger32() { 147 inline bool IsInteger32() {
141 ASSERT(type_ != kUninitialized); 148 ASSERT(type_ != kUninitialized);
142 return ((type_ & kInteger32) == kInteger32); 149 return ((type_ & kInteger32) == kInteger32);
143 } 150 }
144 151
145 inline bool IsDouble() { 152 inline bool IsDouble() {
146 ASSERT(type_ != kUninitialized); 153 ASSERT(type_ != kUninitialized);
147 return ((type_ & kDouble) == kDouble); 154 return ((type_ & kDouble) == kDouble);
148 } 155 }
149 156
(...skipping 11 matching lines...) Expand all
161 return type_ == kUninitialized; 168 return type_ == kUninitialized;
162 } 169 }
163 170
164 const char* ToString() { 171 const char* ToString() {
165 switch (type_) { 172 switch (type_) {
166 case kUnknown: return "Unknown"; 173 case kUnknown: return "Unknown";
167 case kPrimitive: return "Primitive"; 174 case kPrimitive: return "Primitive";
168 case kNumber: return "Number"; 175 case kNumber: return "Number";
169 case kInteger32: return "Integer32"; 176 case kInteger32: return "Integer32";
170 case kSmi: return "Smi"; 177 case kSmi: return "Smi";
178 case kSymbol: return "Symbol";
171 case kDouble: return "Double"; 179 case kDouble: return "Double";
172 case kString: return "String"; 180 case kString: return "String";
173 case kNonPrimitive: return "Object"; 181 case kNonPrimitive: return "Object";
174 case kUninitialized: return "Uninitialized"; 182 case kUninitialized: return "Uninitialized";
175 } 183 }
176 UNREACHABLE(); 184 UNREACHABLE();
177 return "Unreachable code"; 185 return "Unreachable code";
178 } 186 }
179 187
180 private: 188 private:
181 enum Type { 189 enum Type {
182 kUnknown = 0, // 0000000 190 kUnknown = 0, // 0000000
183 kPrimitive = 0x10, // 0010000 191 kPrimitive = 0x10, // 0010000
184 kNumber = 0x11, // 0010001 192 kNumber = 0x11, // 0010001
185 kInteger32 = 0x13, // 0010011 193 kInteger32 = 0x13, // 0010011
186 kSmi = 0x17, // 0010111 194 kSmi = 0x17, // 0010111
187 kDouble = 0x19, // 0011001 195 kDouble = 0x19, // 0011001
188 kString = 0x30, // 0110000 196 kString = 0x30, // 0110000
197 kSymbol = 0x32, // 0110010
189 kNonPrimitive = 0x40, // 1000000 198 kNonPrimitive = 0x40, // 1000000
190 kUninitialized = 0x7f // 1111111 199 kUninitialized = 0x7f // 1111111
191 }; 200 };
192 explicit inline TypeInfo(Type t) : type_(t) { } 201 explicit inline TypeInfo(Type t) : type_(t) { }
193 202
194 Type type_; 203 Type type_;
195 }; 204 };
196 205
197 206
198 enum StringStubFeedback { 207 enum StringStubFeedback {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 Handle<Context> global_context_; 294 Handle<Context> global_context_;
286 Isolate* isolate_; 295 Isolate* isolate_;
287 Handle<NumberDictionary> dictionary_; 296 Handle<NumberDictionary> dictionary_;
288 297
289 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); 298 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
290 }; 299 };
291 300
292 } } // namespace v8::internal 301 } } // namespace v8::internal
293 302
294 #endif // V8_TYPE_INFO_H_ 303 #endif // V8_TYPE_INFO_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/mips/lithium-mips.cc ('k') | src/type-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698