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

Side by Side Diff: src/runtime.cc

Issue 116533003: Avoid duplication of a hidden & inherited prototype's properties. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Reuploaded Created 7 years 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
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
5733 if (!constructor->IsJSFunction()) {
jochen (gone - plz use gerrit) 2013/12/17 15:00:53 nit. v8 style is if (...) return false; (in one li
5734 return false;
5735 }
5736 JSFunction *constructor_fun = JSFunction::cast(constructor);
5737 if (!constructor_fun->shared()->IsApiFunction()) {
5738 return false;
5739 }
5740 return constructor_fun->shared()->
jochen (gone - plz use gerrit) 2013/12/17 15:00:53 nit the -> should go on the next line
5741 get_api_func_data()->IsTemplateFor(obj);
5742 }
5743
5744
5729 // Find the length of the prototype chain that is to to handled as one. If a 5745 // 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 5746 // prototype object is hidden it is to be viewed as part of the the object it
5731 // is prototype for. 5747 // is prototype for.
5732 static int LocalPrototypeChainLength(JSObject* obj) { 5748 static int LocalPrototypeChainLength(JSObject* obj) {
5733 int count = 1; 5749 int count = 1;
5734 Object* proto = obj->GetPrototype(); 5750 Object* proto = obj->GetPrototype();
5735 while (proto->IsJSObject() && 5751 while (proto->IsJSObject() &&
5736 JSObject::cast(proto)->map()->is_hidden_prototype()) { 5752 JSObject::cast(proto)->map()->is_hidden_prototype() &&
5753 !IsInheritedApiFunctionOf(obj, proto)) {
5737 count++; 5754 count++;
5738 proto = JSObject::cast(proto)->GetPrototype(); 5755 proto = JSObject::cast(proto)->GetPrototype();
5739 } 5756 }
5740 return count; 5757 return count;
5741 } 5758 }
5742 5759
5743 5760
5744 // Return the names of the local named properties. 5761 // Return the names of the local named properties.
5745 // args[0]: object 5762 // args[0]: object
5746 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { 5763 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
(...skipping 9156 matching lines...) Expand 10 before | Expand all | Expand 10 after
14903 // Handle last resort GC and make sure to allow future allocations 14920 // Handle last resort GC and make sure to allow future allocations
14904 // to grow the heap without causing GCs (if possible). 14921 // to grow the heap without causing GCs (if possible).
14905 isolate->counters()->gc_last_resort_from_js()->Increment(); 14922 isolate->counters()->gc_last_resort_from_js()->Increment();
14906 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14923 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14907 "Runtime::PerformGC"); 14924 "Runtime::PerformGC");
14908 } 14925 }
14909 } 14926 }
14910 14927
14911 14928
14912 } } // namespace v8::internal 14929 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698