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

Unified Diff: src/runtime/runtime-function.cc

Issue 1360403002: Revert of [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months 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 | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-function.cc
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc
index be92d59a64ea9ae8ba62999eb8f0c1796335d452..560016659d6a6cf9998f7b2fd088a365f5eb415e 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -159,7 +159,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
- RUNTIME_ASSERT(fun->IsConstructor());
+ RUNTIME_ASSERT(fun->should_have_prototype());
RETURN_FAILURE_ON_EXCEPTION(isolate,
Accessors::FunctionSetPrototype(fun, value));
return args[0]; // return TOS
@@ -270,10 +270,30 @@
RUNTIME_FUNCTION(Runtime_IsConstructor) {
- SealHandleScope shs(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_CHECKED(Object, object, 0);
- return isolate->heap()->ToBoolean(object->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();
}
@@ -417,10 +437,6 @@
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();
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698