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

Side by Side 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: arm port. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 4519 matching lines...) Expand 10 before | Expand all | Expand 10 after
4530 if (!func->shared()->script()->IsScript()) { 4530 if (!func->shared()->script()->IsScript()) {
4531 return v8::UnboundScript::kNoScriptId; 4531 return v8::UnboundScript::kNoScriptId;
4532 } 4532 }
4533 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4533 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4534 return script->id(); 4534 return script->id();
4535 } 4535 }
4536 4536
4537 4537
4538 Local<v8::Value> Function::GetBoundFunction() const { 4538 Local<v8::Value> Function::GetBoundFunction() const {
4539 auto self = Utils::OpenHandle(this); 4539 auto self = Utils::OpenHandle(this);
4540 if (!self->IsJSFunction()) { 4540 if (self->IsJSBoundFunction()) {
4541 return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate())); 4541 auto bound_function = i::Handle<i::JSBoundFunction>::cast(self);
4542 auto bound_target_function = i::handle(
4543 bound_function->bound_target_function(), bound_function->GetIsolate());
4544 return Utils::CallableToLocal(bound_target_function);
4542 } 4545 }
4543 auto func = i::Handle<i::JSFunction>::cast(self); 4546 return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate()));
4544 if (!func->shared()->bound()) {
4545 return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate()));
4546 }
4547 i::Handle<i::BindingsArray> bound_args = i::Handle<i::BindingsArray>(
4548 i::BindingsArray::cast(func->function_bindings()));
4549 i::Handle<i::Object> original(bound_args->bound_function(),
4550 func->GetIsolate());
4551 return Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(original));
4552 } 4547 }
4553 4548
4554 4549
4555 int Name::GetIdentityHash() { 4550 int Name::GetIdentityHash() {
4556 auto self = Utils::OpenHandle(this); 4551 auto self = Utils::OpenHandle(this);
4557 return static_cast<int>(self->Hash()); 4552 return static_cast<int>(self->Hash());
4558 } 4553 }
4559 4554
4560 4555
4561 int String::Length() const { 4556 int String::Length() const {
(...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after
8539 Address callback_address = 8534 Address callback_address =
8540 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8535 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8541 VMState<EXTERNAL> state(isolate); 8536 VMState<EXTERNAL> state(isolate);
8542 ExternalCallbackScope call_scope(isolate, callback_address); 8537 ExternalCallbackScope call_scope(isolate, callback_address);
8543 callback(info); 8538 callback(info);
8544 } 8539 }
8545 8540
8546 8541
8547 } // namespace internal 8542 } // namespace internal
8548 } // namespace v8 8543 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/api-natives.cc » ('j') | src/objects-debug.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698