Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index bdfa23cde59d32626192b08ec182f5e2784550e6..a306e88b04716c9e96b229aa573f7d4b7cf4ae25 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -10189,6 +10189,10 @@ void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) { |
Handle<Object> prototype; |
if (function->has_instance_prototype()) { |
prototype = handle(function->instance_prototype(), isolate); |
+ for (Handle<Object> p = prototype; !p->IsNull() && !p->IsJSProxy(); |
+ p = Object::GetPrototype(isolate, p)) { |
+ JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(p)); |
+ } |
} else { |
prototype = isolate->factory()->NewFunctionPrototype(function); |
} |