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

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

Issue 1542963002: [runtime] Introduce dedicated JSBoundFunction to represent bound functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@FunctionConstructor
Patch Set: [arm64] Poke does not preserve flags with --debug-code. Created 5 years 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') | src/runtime/runtime-function.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 3d6f02f2ea1050b7b8ca08f88a45bc5f4800e8cb..d94c75fa0e135cf11f4d9fe1cd270124eeb891d5 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -150,33 +150,29 @@ static MaybeHandle<JSArray> GetIteratorInternalProperties(
MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
Handle<Object> object) {
Factory* factory = isolate->factory();
- if (object->IsJSFunction()) {
- Handle<JSFunction> function = Handle<JSFunction>::cast(object);
- if (function->shared()->bound()) {
- RUNTIME_ASSERT_HANDLIFIED(function->function_bindings()->IsFixedArray(),
- JSArray);
-
- Handle<BindingsArray> bindings(function->function_bindings());
-
- Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
- Handle<String> target =
- factory->NewStringFromAsciiChecked("[[TargetFunction]]");
- result->set(0, *target);
- result->set(1, bindings->bound_function());
-
- Handle<String> bound_this =
- factory->NewStringFromAsciiChecked("[[BoundThis]]");
- result->set(2, *bound_this);
- result->set(3, bindings->bound_this());
-
- Handle<String> bound_args =
- factory->NewStringFromAsciiChecked("[[BoundArgs]]");
- result->set(4, *bound_args);
- Handle<JSArray> arguments_array =
- BindingsArray::CreateBoundArguments(bindings);
- result->set(5, *arguments_array);
- return factory->NewJSArrayWithElements(result);
- }
+ if (object->IsJSBoundFunction()) {
+ Handle<JSBoundFunction> function = Handle<JSBoundFunction>::cast(object);
+
+ Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
+ Handle<String> target =
+ factory->NewStringFromAsciiChecked("[[TargetFunction]]");
+ result->set(0, *target);
+ result->set(1, function->bound_target_function());
+
+ Handle<String> bound_this =
+ factory->NewStringFromAsciiChecked("[[BoundThis]]");
+ result->set(2, *bound_this);
+ result->set(3, function->bound_this());
+
+ Handle<String> bound_args =
+ factory->NewStringFromAsciiChecked("[[BoundArgs]]");
+ result->set(4, *bound_args);
+ Handle<FixedArray> bound_arguments =
+ factory->CopyFixedArray(handle(function->bound_arguments(), isolate));
+ Handle<JSArray> arguments_array =
+ factory->NewJSArrayWithElements(bound_arguments);
+ result->set(5, *arguments_array);
+ return factory->NewJSArrayWithElements(result);
} else if (object->IsJSMapIterator()) {
Handle<JSMapIterator> iterator = Handle<JSMapIterator>::cast(object);
return GetIteratorInternalProperties(isolate, iterator);
@@ -873,15 +869,18 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) {
RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
+ DCHECK_EQ(1, args.length());
// Check arguments.
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
// Count the visible scopes.
int n = 0;
- for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) {
- n++;
+ if (function->IsJSFunction()) {
+ for (ScopeIterator it(isolate, Handle<JSFunction>::cast(function));
+ !it.Done(); it.Next()) {
+ n++;
+ }
}
return Smi::FromInt(n);
@@ -1468,19 +1467,27 @@ RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) {
RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) {
SealHandleScope shs(isolate);
- DCHECK(args.length() == 1);
+ DCHECK_EQ(1, args.length());
- CONVERT_ARG_CHECKED(JSFunction, f, 0);
- return f->shared()->inferred_name();
+ CONVERT_ARG_CHECKED(Object, f, 0);
+ if (f->IsJSFunction()) {
+ return JSFunction::cast(f)->shared()->inferred_name();
+ }
+ return isolate->heap()->empty_string();
}
RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) {
HandleScope scope(isolate);
- DCHECK(args.length() == 1);
+ DCHECK_EQ(1, args.length());
+
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0);
- Handle<Object> name = JSFunction::GetDebugName(f);
+ if (function->IsJSBoundFunction()) {
+ return Handle<JSBoundFunction>::cast(function)->name();
+ }
+ Handle<Object> name =
+ JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
return *name;
}
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698