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

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

Issue 851163007: Implement IsConstructor() abstract operation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: All raw pointers converted to handles Created 5 years, 11 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.h ('k') | test/mjsunit/harmony/array-from.js » ('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 608cc9548423a34543b739c6a6d85e0571200579..62d5513e542782ed8b4d285d1130556e9789f0a1 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -326,6 +326,34 @@ 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();
+}
+
+
RUNTIME_FUNCTION(Runtime_SetInlineBuiltinFlag) {
SealHandleScope shs(isolate);
RUNTIME_ASSERT(args.length() == 1);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/harmony/array-from.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698