OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5719 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); | 5719 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, &threw); |
5720 if (threw) return Failure::Exception(); | 5720 if (threw) return Failure::Exception(); |
5721 | 5721 |
5722 // Test again, since cache may have been built by preceding call. | 5722 // Test again, since cache may have been built by preceding call. |
5723 if (object->IsSimpleEnum()) return object->map(); | 5723 if (object->IsSimpleEnum()) return object->map(); |
5724 | 5724 |
5725 return *content; | 5725 return *content; |
5726 } | 5726 } |
5727 | 5727 |
5728 | 5728 |
5729 // Returns true if inherited accessors have been copied down | |
5730 // to obj from proto's function template. | |
5731 static bool IsInheritedApiFunctionOf(JSObject *obj, Object *proto) { | |
5732 Object *constructor = HeapObject::cast(proto)->map()->constructor(); | |
rossberg
2013/12/20 12:54:54
Note that .constructor is a mutable property, so I
| |
5733 if (!constructor->IsJSFunction()) return false; | |
5734 JSFunction *constructor_fun = JSFunction::cast(constructor); | |
5735 if (!constructor_fun->shared()->IsApiFunction()) return false; | |
5736 return constructor_fun->shared() | |
5737 ->get_api_func_data()->IsTemplateFor(obj); | |
5738 } | |
5739 | |
5740 | |
5729 // Find the length of the prototype chain that is to to handled as one. If a | 5741 // Find the length of the prototype chain that is to to handled as one. If a |
5730 // prototype object is hidden it is to be viewed as part of the the object it | 5742 // prototype object is hidden it is to be viewed as part of the the object it |
5731 // is prototype for. | 5743 // is prototype for. |
5732 static int LocalPrototypeChainLength(JSObject* obj) { | 5744 static int LocalPrototypeChainLength(JSObject* obj) { |
5733 int count = 1; | 5745 int count = 1; |
5734 Object* proto = obj->GetPrototype(); | 5746 Object* proto = obj->GetPrototype(); |
5735 while (proto->IsJSObject() && | 5747 while (proto->IsJSObject() && |
5736 JSObject::cast(proto)->map()->is_hidden_prototype()) { | 5748 JSObject::cast(proto)->map()->is_hidden_prototype() && |
5749 !IsInheritedApiFunctionOf(obj, proto)) { | |
dcarney
2013/12/19 19:46:12
filtering here is problematic as there could be pr
sof
2013/12/22 08:39:55
Thanks, the initial version wasn't general enough
| |
5737 count++; | 5750 count++; |
5738 proto = JSObject::cast(proto)->GetPrototype(); | 5751 proto = JSObject::cast(proto)->GetPrototype(); |
5739 } | 5752 } |
5740 return count; | 5753 return count; |
5741 } | 5754 } |
5742 | 5755 |
5743 | 5756 |
5744 // Return the names of the local named properties. | 5757 // Return the names of the local named properties. |
5745 // args[0]: object | 5758 // args[0]: object |
5746 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { | 5759 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { |
(...skipping 9156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14903 // Handle last resort GC and make sure to allow future allocations | 14916 // Handle last resort GC and make sure to allow future allocations |
14904 // to grow the heap without causing GCs (if possible). | 14917 // to grow the heap without causing GCs (if possible). |
14905 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14918 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14906 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14919 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14907 "Runtime::PerformGC"); | 14920 "Runtime::PerformGC"); |
14908 } | 14921 } |
14909 } | 14922 } |
14910 | 14923 |
14911 | 14924 |
14912 } } // namespace v8::internal | 14925 } } // namespace v8::internal |
OLD | NEW |