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

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: 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 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..89d49fe78cdf73c6da7d600c5ebb66ea37d313a4 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5726,6 +5726,22 @@ 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();
+ if (!constructor->IsJSFunction()) {
jochen (gone - plz use gerrit) 2013/12/17 15:00:53 nit. v8 style is if (...) return false; (in one li
+ return false;
+ }
+ JSFunction *constructor_fun = JSFunction::cast(constructor);
+ if (!constructor_fun->shared()->IsApiFunction()) {
+ return false;
+ }
+ return constructor_fun->shared()->
jochen (gone - plz use gerrit) 2013/12/17 15:00:53 nit the -> should go on the next line
+ 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 +5749,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)) {
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