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

Unified Diff: src/api.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/accessors.cc ('k') | src/api-natives.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 93ea6a4c028be4b3a9d540be5ab8c9ad8ce018a2..8ff302f8d82702fa40c471082186a28ed91c8e90 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4412,13 +4412,16 @@ void Function::SetName(v8::Local<v8::String> name) {
Local<Value> Function::GetName() const {
auto self = Utils::OpenHandle(this);
- if (!self->IsJSFunction()) {
- return ToApiHandle<Primitive>(
- self->GetIsolate()->factory()->undefined_value());
+ if (self->IsJSBoundFunction()) {
+ auto func = i::Handle<i::JSBoundFunction>::cast(self);
+ return Utils::ToLocal(handle(func->name(), func->GetIsolate()));
}
- auto func = i::Handle<i::JSFunction>::cast(self);
- return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name(),
- func->GetIsolate()));
+ if (self->IsJSFunction()) {
+ auto func = i::Handle<i::JSFunction>::cast(self);
+ return Utils::ToLocal(handle(func->shared()->name(), func->GetIsolate()));
+ }
+ return ToApiHandle<Primitive>(
+ self->GetIsolate()->factory()->undefined_value());
}
@@ -4537,18 +4540,13 @@ int Function::ScriptId() const {
Local<v8::Value> Function::GetBoundFunction() const {
auto self = Utils::OpenHandle(this);
- if (!self->IsJSFunction()) {
- return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate()));
+ if (self->IsJSBoundFunction()) {
+ auto bound_function = i::Handle<i::JSBoundFunction>::cast(self);
+ auto bound_target_function = i::handle(
+ bound_function->bound_target_function(), bound_function->GetIsolate());
+ return Utils::CallableToLocal(bound_target_function);
}
- auto func = i::Handle<i::JSFunction>::cast(self);
- if (!func->shared()->bound()) {
- return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate()));
- }
- i::Handle<i::BindingsArray> bound_args = i::Handle<i::BindingsArray>(
- i::BindingsArray::cast(func->function_bindings()));
- i::Handle<i::Object> original(bound_args->bound_function(),
- func->GetIsolate());
- return Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(original));
+ return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate()));
}
« no previous file with comments | « src/accessors.cc ('k') | src/api-natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698