| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/property-descriptor.h" | 5 #include "src/property-descriptor.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" |
| 7 #include "src/factory.h" | 8 #include "src/factory.h" |
| 8 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 9 #include "src/lookup.h" | 10 #include "src/lookup.h" |
| 10 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
| 11 | 12 |
| 12 namespace v8 { | 13 namespace v8 { |
| 13 namespace internal { | 14 namespace internal { |
| 14 | 15 |
| 15 // Helper function for ToPropertyDescriptor. Comments describe steps for | 16 // Helper function for ToPropertyDescriptor. Comments describe steps for |
| 16 // "enumerable", other properties are handled the same way. | 17 // "enumerable", other properties are handled the same way. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 36 // objects: nothing on the prototype chain, just own fast data properties. | 37 // objects: nothing on the prototype chain, just own fast data properties. |
| 37 // Must not have observable side effects, because the slow path will restart | 38 // Must not have observable side effects, because the slow path will restart |
| 38 // the entire conversion! | 39 // the entire conversion! |
| 39 bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj, | 40 bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj, |
| 40 PropertyDescriptor* desc) { | 41 PropertyDescriptor* desc) { |
| 41 if (!obj->IsJSObject()) return false; | 42 if (!obj->IsJSObject()) return false; |
| 42 Map* map = Handle<JSObject>::cast(obj)->map(); | 43 Map* map = Handle<JSObject>::cast(obj)->map(); |
| 43 if (map->instance_type() != JS_OBJECT_TYPE) return false; | 44 if (map->instance_type() != JS_OBJECT_TYPE) return false; |
| 44 if (map->is_access_check_needed()) return false; | 45 if (map->is_access_check_needed()) return false; |
| 45 if (map->prototype() != *isolate->initial_object_prototype()) return false; | 46 if (map->prototype() != *isolate->initial_object_prototype()) return false; |
| 47 // During bootstrapping, the object_function_prototype_map hasn't been |
| 48 // set up yet. |
| 49 if (isolate->bootstrapper()->IsActive()) return false; |
| 46 if (JSObject::cast(map->prototype())->map() != | 50 if (JSObject::cast(map->prototype())->map() != |
| 47 isolate->native_context()->object_function_prototype_map()) { | 51 isolate->native_context()->object_function_prototype_map()) { |
| 48 return false; | 52 return false; |
| 49 } | 53 } |
| 50 // TODO(jkummerow): support dictionary properties? | 54 // TODO(jkummerow): support dictionary properties? |
| 51 if (map->is_dictionary_map()) return false; | 55 if (map->is_dictionary_map()) return false; |
| 52 Handle<DescriptorArray> descs = | 56 Handle<DescriptorArray> descs = |
| 53 Handle<DescriptorArray>(map->instance_descriptors()); | 57 Handle<DescriptorArray>(map->instance_descriptors()); |
| 54 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 58 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
| 55 PropertyDetails details = descs->GetDetails(i); | 59 PropertyDetails details = descs->GetDetails(i); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // throw a TypeError exception. | 207 // throw a TypeError exception. |
| 204 if ((desc->has_get() || desc->has_set()) && | 208 if ((desc->has_get() || desc->has_set()) && |
| 205 (desc->has_value() || desc->has_writable())) { | 209 (desc->has_value() || desc->has_writable())) { |
| 206 isolate->Throw(*isolate->factory()->NewTypeError( | 210 isolate->Throw(*isolate->factory()->NewTypeError( |
| 207 MessageTemplate::kValueAndAccessor, obj)); | 211 MessageTemplate::kValueAndAccessor, obj)); |
| 208 return false; | 212 return false; |
| 209 } | 213 } |
| 210 } | 214 } |
| 211 } else { | 215 } else { |
| 212 DCHECK(obj->IsJSProxy()); | 216 DCHECK(obj->IsJSProxy()); |
| 213 UNIMPLEMENTED(); | 217 // Having an UNIMPLEMENTED() here would upset ClusterFuzz, because |
| 218 // --harmony-proxies makes it possible to reach this branch. |
| 219 isolate->Throw( |
| 220 *isolate->factory()->NewTypeError(MessageTemplate::kUnsupported)); |
| 221 return false; |
| 214 } | 222 } |
| 215 // 23. Return desc. | 223 // 23. Return desc. |
| 216 return true; | 224 return true; |
| 217 } | 225 } |
| 218 | 226 |
| 219 | 227 |
| 220 } // namespace internal | 228 } // namespace internal |
| 221 } // namespace v8 | 229 } // namespace v8 |
| OLD | NEW |