OLD | NEW |
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 double num = HeapNumber::cast(this)->value(); | 196 double num = HeapNumber::cast(this)->value(); |
197 if (num >= 0 && FastUI2D(FastD2UI(num)) == num) { | 197 if (num >= 0 && FastUI2D(FastD2UI(num)) == num) { |
198 *value = FastD2UI(num); | 198 *value = FastD2UI(num); |
199 return true; | 199 return true; |
200 } | 200 } |
201 } | 201 } |
202 return false; | 202 return false; |
203 } | 203 } |
204 | 204 |
205 | 205 |
| 206 bool FunctionTemplateInfo::IsTemplateFor(Object* object) { |
| 207 if (!object->IsHeapObject()) return false; |
| 208 return IsTemplateFor(HeapObject::cast(object)->map()); |
| 209 } |
| 210 |
| 211 |
| 212 bool FunctionTemplateInfo::IsTemplateFor(Map* map) { |
| 213 // There is a constraint on the object; check. |
| 214 if (!map->IsJSObjectMap()) return false; |
| 215 // Fetch the constructor function of the object. |
| 216 Object* cons_obj = map->constructor(); |
| 217 if (!cons_obj->IsJSFunction()) return false; |
| 218 JSFunction* fun = JSFunction::cast(cons_obj); |
| 219 // Iterate through the chain of inheriting function templates to |
| 220 // see if the required one occurs. |
| 221 for (Object* type = fun->shared()->function_data(); |
| 222 type->IsFunctionTemplateInfo(); |
| 223 type = FunctionTemplateInfo::cast(type)->parent_template()) { |
| 224 if (type == this) return true; |
| 225 } |
| 226 // Didn't find the required type in the inheritance chain. |
| 227 return false; |
| 228 } |
| 229 |
| 230 |
206 template<typename To> | 231 template<typename To> |
207 static inline To* CheckedCast(void *from) { | 232 static inline To* CheckedCast(void *from) { |
208 uintptr_t temp = reinterpret_cast<uintptr_t>(from); | 233 uintptr_t temp = reinterpret_cast<uintptr_t>(from); |
209 ASSERT(temp % sizeof(To) == 0); | 234 ASSERT(temp % sizeof(To) == 0); |
210 return reinterpret_cast<To*>(temp); | 235 return reinterpret_cast<To*>(temp); |
211 } | 236 } |
212 | 237 |
213 | 238 |
214 static MaybeObject* PerformCompare(const BitmaskCompareDescriptor& descriptor, | 239 static MaybeObject* PerformCompare(const BitmaskCompareDescriptor& descriptor, |
215 char* ptr, | 240 char* ptr, |
(...skipping 16432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16648 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16673 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16649 static const char* error_messages_[] = { | 16674 static const char* error_messages_[] = { |
16650 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16675 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16651 }; | 16676 }; |
16652 #undef ERROR_MESSAGES_TEXTS | 16677 #undef ERROR_MESSAGES_TEXTS |
16653 return error_messages_[reason]; | 16678 return error_messages_[reason]; |
16654 } | 16679 } |
16655 | 16680 |
16656 | 16681 |
16657 } } // namespace v8::internal | 16682 } } // namespace v8::internal |
OLD | NEW |