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

Side by Side Diff: src/types.cc

Issue 18078002: Type handling for special cases and optimization (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 5 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.h ('k') | no next file » | 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (this->is_class()) { 124 if (this->is_class()) {
125 map = *this->as_class(); 125 map = *this->as_class();
126 } else { 126 } else {
127 Handle<v8::internal::Object> value = this->as_constant(); 127 Handle<v8::internal::Object> value = this->as_constant();
128 if (value->IsSmi()) return kSmi; 128 if (value->IsSmi()) return kSmi;
129 map = HeapObject::cast(*value)->map(); 129 map = HeapObject::cast(*value)->map();
130 if (map->instance_type() == ODDBALL_TYPE) { 130 if (map->instance_type() == ODDBALL_TYPE) {
131 if (value->IsUndefined()) return kUndefined; 131 if (value->IsUndefined()) return kUndefined;
132 if (value->IsNull()) return kNull; 132 if (value->IsNull()) return kNull;
133 if (value->IsTrue() || value->IsFalse()) return kBoolean; 133 if (value->IsTrue() || value->IsFalse()) return kBoolean;
134 if (value->IsTheHole()) return kAny;
134 } 135 }
135 } 136 }
136 switch (map->instance_type()) { 137 switch (map->instance_type()) {
137 case STRING_TYPE: 138 case STRING_TYPE:
138 case ASCII_STRING_TYPE: 139 case ASCII_STRING_TYPE:
139 case CONS_STRING_TYPE: 140 case CONS_STRING_TYPE:
140 case CONS_ASCII_STRING_TYPE: 141 case CONS_ASCII_STRING_TYPE:
141 case SLICED_STRING_TYPE: 142 case SLICED_STRING_TYPE:
142 case SLICED_ASCII_STRING_TYPE: 143 case SLICED_ASCII_STRING_TYPE:
143 case EXTERNAL_STRING_TYPE: 144 case EXTERNAL_STRING_TYPE:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // When compiling stub templates, the meta map is used as a place holder 194 // When compiling stub templates, the meta map is used as a place holder
194 // for the actual map with which the template is later instantiated. 195 // for the actual map with which the template is later instantiated.
195 // We treat it as a kind of type variable whose upper bound is Any. 196 // We treat it as a kind of type variable whose upper bound is Any.
196 // TODO(rossberg): for caching of CompareNilIC stubs to work correctly, 197 // TODO(rossberg): for caching of CompareNilIC stubs to work correctly,
197 // we must exclude Undetectable here. This makes no sense, really, 198 // we must exclude Undetectable here. This makes no sense, really,
198 // because it means that the template isn't actually parametric. 199 // because it means that the template isn't actually parametric.
199 // Also, it doesn't apply elsewhere. 8-( 200 // Also, it doesn't apply elsewhere. 8-(
200 // We ought to find a cleaner solution for compiling stubs parameterised 201 // We ought to find a cleaner solution for compiling stubs parameterised
201 // over type or class variables, esp ones with bounds... 202 // over type or class variables, esp ones with bounds...
202 return kDetectable; 203 return kDetectable;
204 case DECLARED_ACCESSOR_INFO_TYPE:
205 case EXECUTABLE_ACCESSOR_INFO_TYPE:
206 case ACCESSOR_PAIR_TYPE:
207 return kInternal;
203 default: 208 default:
204 UNREACHABLE(); 209 UNREACHABLE();
205 return kNone; 210 return kNone;
206 } 211 }
207 } 212 }
208 } 213 }
209 214
210 215
211 // Get the largest bitset subsumed by this type. 216 // Get the largest bitset subsumed by this type.
212 int Type::GlbBitset() { 217 int Type::GlbBitset() {
213 if (this->is_bitset()) { 218 if (this->is_bitset()) {
214 return this->as_bitset(); 219 return this->as_bitset();
215 } else if (this->is_union()) { 220 } else if (this->is_union()) {
216 // All but the first are non-bitsets and thus would yield kNone anyway. 221 // All but the first are non-bitsets and thus would yield kNone anyway.
217 return union_get(this->as_union(), 0)->GlbBitset(); 222 return union_get(this->as_union(), 0)->GlbBitset();
218 } else { 223 } else {
219 return kNone; 224 return kNone;
220 } 225 }
221 } 226 }
222 227
223 228
224 // Check this <= that. 229 // Check this <= that.
225 bool Type::Is(Type* that) { 230 bool Type::IsSlowCase(Type* that) {
226 // Fast path for bitsets. 231 // Fast path for bitsets.
227 if (that->is_bitset()) { 232 if (that->is_bitset()) {
228 return (this->LubBitset() | that->as_bitset()) == that->as_bitset(); 233 return (this->LubBitset() | that->as_bitset()) == that->as_bitset();
229 } 234 }
230 235
231 if (that->is_class()) { 236 if (that->is_class()) {
232 return this->is_class() && *this->as_class() == *that->as_class(); 237 return this->is_class() && *this->as_class() == *that->as_class();
233 } 238 }
234 if (that->is_constant()) { 239 if (that->is_constant()) {
235 return this->is_constant() && *this->as_constant() == *that->as_constant(); 240 return this->is_constant() && *this->as_constant() == *that->as_constant();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 470 }
466 471
467 472
468 Type* Type::Optional(Handle<Type> type) { 473 Type* Type::Optional(Handle<Type> type) {
469 return type->is_bitset() 474 return type->is_bitset()
470 ? from_bitset(type->as_bitset() | kUndefined) 475 ? from_bitset(type->as_bitset() | kUndefined)
471 : Union(type, Undefined()->handle_via_isolate_of(*type)); 476 : Union(type, Undefined()->handle_via_isolate_of(*type));
472 } 477 }
473 478
474 } } // namespace v8::internal 479 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698