Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index 423d60e5e20c962fd5ab88303a0a2ef91e19df98..6cda851a9685afbe602c389711f14470984a37f4 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -1033,8 +1033,8 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, |
// Handle stepping into constructors if step into is active. |
if (debug->StepInActive()) debug->HandleStepIn(function, true); |
- if (function->has_initial_map()) { |
- if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { |
+ if (original_function->has_initial_map()) { |
+ if (original_function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { |
// The 'Function' function ignores the receiver object when |
// called using 'new' and creates a new JSFunction object that |
// is returned. The receiver object is only used for error |
@@ -1054,24 +1054,12 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, |
// available. |
Compiler::Compile(function, CLEAR_EXCEPTION); |
- Handle<JSObject> result; |
- if (site.is_null()) { |
- result = isolate->factory()->NewJSObject(function); |
- } else { |
- result = isolate->factory()->NewJSObjectWithMemento(function, site); |
- } |
+ JSFunction::EnsureHasInitialMap(function); |
+ Handle<Map> initial_map = |
+ JSFunction::EnsureDerivedHasInitialMap(original_function, function); |
- // Set up the prototoype using original function. |
- // TODO(dslomov): instead of setting the __proto__, |
- // use and cache the correct map. |
- if (*original_function != *function) { |
- 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)); |
- } |
- } |
+ Handle<JSObject> result = |
+ isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); |
isolate->counters()->constructed_objects()->Increment(); |
isolate->counters()->constructed_objects_runtime()->Increment(); |