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

Side by Side Diff: src/types.cc

Issue 25722002: More precise type lub for numbers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 2 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 | « no previous file | 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 return bitset; 122 return bitset;
123 } else { 123 } else {
124 Map* map = NULL; 124 Map* map = NULL;
125 if (this->is_class()) { 125 if (this->is_class()) {
126 map = *this->as_class(); 126 map = *this->as_class();
127 } else { 127 } else {
128 Handle<v8::internal::Object> value = this->as_constant(); 128 Handle<v8::internal::Object> value = this->as_constant();
129 if (value->IsSmi()) return kSmi; 129 if (value->IsSmi()) return kSmi;
130 map = HeapObject::cast(*value)->map(); 130 map = HeapObject::cast(*value)->map();
131 if (map->instance_type() == HEAP_NUMBER_TYPE) {
132 int32_t i;
133 uint32_t u;
134 if (value->ToInt32(&i)) return Smi::IsValid(i) ? kSmi : kOtherSigned32;
135 if (value->ToUint32(&u)) return kUnsigned32;
136 return kDouble;
137 }
131 if (map->instance_type() == ODDBALL_TYPE) { 138 if (map->instance_type() == ODDBALL_TYPE) {
132 if (value->IsUndefined()) return kUndefined; 139 if (value->IsUndefined()) return kUndefined;
133 if (value->IsNull()) return kNull; 140 if (value->IsNull()) return kNull;
134 if (value->IsTrue() || value->IsFalse()) return kBoolean; 141 if (value->IsTrue() || value->IsFalse()) return kBoolean;
135 if (value->IsTheHole()) return kAny; 142 if (value->IsTheHole()) return kAny; // TODO(rossberg): kNone?
136 } 143 }
137 } 144 }
138 switch (map->instance_type()) { 145 switch (map->instance_type()) {
139 case STRING_TYPE: 146 case STRING_TYPE:
140 case ASCII_STRING_TYPE: 147 case ASCII_STRING_TYPE:
141 case CONS_STRING_TYPE: 148 case CONS_STRING_TYPE:
142 case CONS_ASCII_STRING_TYPE: 149 case CONS_ASCII_STRING_TYPE:
143 case SLICED_STRING_TYPE: 150 case SLICED_STRING_TYPE:
144 case SLICED_ASCII_STRING_TYPE: 151 case SLICED_ASCII_STRING_TYPE:
145 case EXTERNAL_STRING_TYPE: 152 case EXTERNAL_STRING_TYPE:
146 case EXTERNAL_ASCII_STRING_TYPE: 153 case EXTERNAL_ASCII_STRING_TYPE:
147 case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: 154 case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
148 case SHORT_EXTERNAL_STRING_TYPE: 155 case SHORT_EXTERNAL_STRING_TYPE:
149 case SHORT_EXTERNAL_ASCII_STRING_TYPE: 156 case SHORT_EXTERNAL_ASCII_STRING_TYPE:
150 case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: 157 case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
151 case INTERNALIZED_STRING_TYPE: 158 case INTERNALIZED_STRING_TYPE:
152 case ASCII_INTERNALIZED_STRING_TYPE: 159 case ASCII_INTERNALIZED_STRING_TYPE:
153 case CONS_INTERNALIZED_STRING_TYPE: 160 case CONS_INTERNALIZED_STRING_TYPE:
154 case CONS_ASCII_INTERNALIZED_STRING_TYPE: 161 case CONS_ASCII_INTERNALIZED_STRING_TYPE:
155 case EXTERNAL_INTERNALIZED_STRING_TYPE: 162 case EXTERNAL_INTERNALIZED_STRING_TYPE:
156 case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: 163 case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
157 case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: 164 case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
158 case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: 165 case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE:
159 case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: 166 case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE:
160 case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: 167 case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
161 return kString; 168 return kString;
162 case SYMBOL_TYPE: 169 case SYMBOL_TYPE:
163 return kSymbol; 170 return kSymbol;
164 case ODDBALL_TYPE: 171 case ODDBALL_TYPE:
165 return kOddball;
166 case HEAP_NUMBER_TYPE: 172 case HEAP_NUMBER_TYPE:
167 return kDouble; 173 UNREACHABLE();
168 case JS_VALUE_TYPE: 174 case JS_VALUE_TYPE:
169 case JS_DATE_TYPE: 175 case JS_DATE_TYPE:
170 case JS_OBJECT_TYPE: 176 case JS_OBJECT_TYPE:
171 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: 177 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
172 case JS_GENERATOR_OBJECT_TYPE: 178 case JS_GENERATOR_OBJECT_TYPE:
173 case JS_MODULE_TYPE: 179 case JS_MODULE_TYPE:
174 case JS_GLOBAL_OBJECT_TYPE: 180 case JS_GLOBAL_OBJECT_TYPE:
175 case JS_BUILTINS_OBJECT_TYPE: 181 case JS_BUILTINS_OBJECT_TYPE:
176 case JS_GLOBAL_PROXY_TYPE: 182 case JS_GLOBAL_PROXY_TYPE:
177 case JS_ARRAY_BUFFER_TYPE: 183 case JS_ARRAY_BUFFER_TYPE:
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (i > 0) PrintF(out, ","); 535 if (i > 0) PrintF(out, ",");
530 type_i->TypePrint(out); 536 type_i->TypePrint(out);
531 } 537 }
532 PrintF(out, "}"); 538 PrintF(out, "}");
533 } 539 }
534 } 540 }
535 #endif 541 #endif
536 542
537 543
538 } } // namespace v8::internal 544 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698