Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index bde3021df16653280c3576aa15552c39764d6bda..b97073e42702da4179feffd02989624bf64aef06 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -1245,10 +1245,6 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, |
Handle<Object> constructor, |
Handle<Object> original_constructor, |
Handle<AllocationSite> site) { |
- // TODO(dslomov): implement prototype rewiring. |
- // The check below is a sanity check. |
- CHECK(*constructor == *original_constructor); |
- |
// If the constructor isn't a proper function we throw a type error. |
if (!constructor->IsJSFunction()) { |
Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); |
@@ -1258,8 +1254,13 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, |
Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
+ CHECK(original_constructor->IsJSFunction()); |
+ Handle<JSFunction> original_function = |
+ Handle<JSFunction>::cast(original_constructor); |
+ |
+ |
// If function should not have prototype, construction is not allowed. In this |
- // case generated code bailouts here, since function has no initial_map. |
+ // case generated code: bailouts here, since function has no initial_map. |
if (!function->should_have_prototype() && !function->shared()->bound()) { |
Vector<Handle<Object> > arguments = HandleVector(&constructor, 1); |
THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
@@ -1300,6 +1301,15 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, |
result = isolate->factory()->NewJSObjectWithMemento(function, site); |
} |
+ if (*original_function != *function) { |
arv (Not doing code reviews)
2015/02/09 17:44:39
Is this is to set up the prototype from the NewTar
Dmitry Lomov (no reviews)
2015/02/10 19:22:15
Done.
|
+ if (original_function->has_instance_prototype()) { |
+ Handle<Object> prototype = |
+ handle(original_function->instance_prototype(), isolate); |
+ RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, JSObject::SetPrototype(result, prototype, false)); |
+ } |
+ } |
+ |
isolate->counters()->constructed_objects()->Increment(); |
isolate->counters()->constructed_objects_runtime()->Increment(); |