Index: src/runtime/runtime-function.cc |
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc |
index 560016659d6a6cf9998f7b2fd088a365f5eb415e..be92d59a64ea9ae8ba62999eb8f0c1796335d452 100644 |
--- a/src/runtime/runtime-function.cc |
+++ b/src/runtime/runtime-function.cc |
@@ -159,7 +159,7 @@ RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { |
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
- RUNTIME_ASSERT(fun->should_have_prototype()); |
+ RUNTIME_ASSERT(fun->IsConstructor()); |
RETURN_FAILURE_ON_EXCEPTION(isolate, |
Accessors::FunctionSetPrototype(fun, value)); |
return args[0]; // return TOS |
@@ -270,30 +270,10 @@ RUNTIME_FUNCTION(Runtime_SetNativeFlag) { |
RUNTIME_FUNCTION(Runtime_IsConstructor) { |
- HandleScope handles(isolate); |
- RUNTIME_ASSERT(args.length() == 1); |
- |
- CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
- |
- // TODO(caitp): implement this in a better/simpler way, allow inlining via TF |
- if (object->IsJSFunction()) { |
- Handle<JSFunction> func = Handle<JSFunction>::cast(object); |
- bool should_have_prototype = func->should_have_prototype(); |
- if (func->shared()->bound()) { |
- Handle<FixedArray> bound_args = |
- Handle<FixedArray>(FixedArray::cast(func->function_bindings())); |
- Handle<Object> bound_function( |
- JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)), |
- isolate); |
- if (bound_function->IsJSFunction()) { |
- Handle<JSFunction> bound = Handle<JSFunction>::cast(bound_function); |
- DCHECK(!bound->shared()->bound()); |
- should_have_prototype = bound->should_have_prototype(); |
- } |
- } |
- return isolate->heap()->ToBoolean(should_have_prototype); |
- } |
- return isolate->heap()->false_value(); |
+ SealHandleScope shs(isolate); |
+ DCHECK_EQ(1, args.length()); |
+ CONVERT_ARG_CHECKED(Object, object, 0); |
+ return isolate->heap()->ToBoolean(object->IsConstructor()); |
} |
@@ -437,6 +417,10 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { |
bound_function_map = Map::TransitionToPrototype(bound_function_map, proto, |
REGULAR_PROTOTYPE); |
} |
+ if (bound_function_map->is_constructor() != bindee->IsConstructor()) { |
+ bound_function_map = Map::Copy(bound_function_map, "IsConstructor"); |
+ bound_function_map->set_is_constructor(bindee->IsConstructor()); |
+ } |
JSObject::MigrateToMap(bound_function, bound_function_map); |
Handle<String> length_string = isolate->factory()->length_string(); |