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

Unified 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: Follow v8 coding style 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 8d84fdace2562f4f6f834940706f298bfdf481a5..eb1e173def6b9eafa95ba9941eda57d81866aa14 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5726,6 +5726,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
}
+// Returns true if inherited accessors have been copied down
+// to obj from proto's function template.
+static bool IsInheritedApiFunctionOf(JSObject *obj, Object *proto) {
+ Object *constructor = HeapObject::cast(proto)->map()->constructor();
rossberg 2013/12/20 12:54:54 Note that .constructor is a mutable property, so I
+ if (!constructor->IsJSFunction()) return false;
+ JSFunction *constructor_fun = JSFunction::cast(constructor);
+ if (!constructor_fun->shared()->IsApiFunction()) return false;
+ return constructor_fun->shared()
+ ->get_api_func_data()->IsTemplateFor(obj);
+}
+
+
// Find the length of the prototype chain that is to to handled as one. If a
// prototype object is hidden it is to be viewed as part of the the object it
// is prototype for.
@@ -5733,7 +5745,8 @@ static int LocalPrototypeChainLength(JSObject* obj) {
int count = 1;
Object* proto = obj->GetPrototype();
while (proto->IsJSObject() &&
- JSObject::cast(proto)->map()->is_hidden_prototype()) {
+ JSObject::cast(proto)->map()->is_hidden_prototype() &&
+ !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
count++;
proto = JSObject::cast(proto)->GetPrototype();
}
« 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