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

Side by Side Diff: src/api.cc

Issue 1871503002: Lazily compute boundfunction .name and .length if possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4487 matching lines...) Expand 10 before | Expand all | Expand 10 after
4498 void Function::SetName(v8::Local<v8::String> name) { 4498 void Function::SetName(v8::Local<v8::String> name) {
4499 auto self = Utils::OpenHandle(this); 4499 auto self = Utils::OpenHandle(this);
4500 if (!self->IsJSFunction()) return; 4500 if (!self->IsJSFunction()) return;
4501 auto func = i::Handle<i::JSFunction>::cast(self); 4501 auto func = i::Handle<i::JSFunction>::cast(self);
4502 func->shared()->set_name(*Utils::OpenHandle(*name)); 4502 func->shared()->set_name(*Utils::OpenHandle(*name));
4503 } 4503 }
4504 4504
4505 4505
4506 Local<Value> Function::GetName() const { 4506 Local<Value> Function::GetName() const {
4507 auto self = Utils::OpenHandle(this); 4507 auto self = Utils::OpenHandle(this);
4508 i::Isolate* isolate = self->GetIsolate();
4508 if (self->IsJSBoundFunction()) { 4509 if (self->IsJSBoundFunction()) {
4509 auto func = i::Handle<i::JSBoundFunction>::cast(self); 4510 auto func = i::Handle<i::JSBoundFunction>::cast(self);
4510 return Utils::ToLocal(handle(func->name(), func->GetIsolate())); 4511 i::Handle<i::Object> name;
4512 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
4513 i::JSBoundFunction::GetName(isolate, func),
4514 Local<Value>());
4515 return Utils::ToLocal(name);
4511 } 4516 }
4512 if (self->IsJSFunction()) { 4517 if (self->IsJSFunction()) {
4513 auto func = i::Handle<i::JSFunction>::cast(self); 4518 auto func = i::Handle<i::JSFunction>::cast(self);
4514 return Utils::ToLocal(handle(func->shared()->name(), func->GetIsolate())); 4519 return Utils::ToLocal(handle(func->shared()->name(), isolate));
4515 } 4520 }
4516 return ToApiHandle<Primitive>( 4521 return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
4517 self->GetIsolate()->factory()->undefined_value());
4518 } 4522 }
4519 4523
4520 4524
4521 Local<Value> Function::GetInferredName() const { 4525 Local<Value> Function::GetInferredName() const {
4522 auto self = Utils::OpenHandle(this); 4526 auto self = Utils::OpenHandle(this);
4523 if (!self->IsJSFunction()) { 4527 if (!self->IsJSFunction()) {
4524 return ToApiHandle<Primitive>( 4528 return ToApiHandle<Primitive>(
4525 self->GetIsolate()->factory()->undefined_value()); 4529 self->GetIsolate()->factory()->undefined_value());
4526 } 4530 }
4527 auto func = i::Handle<i::JSFunction>::cast(self); 4531 auto func = i::Handle<i::JSFunction>::cast(self);
(...skipping 4254 matching lines...) Expand 10 before | Expand all | Expand 10 after
8782 Address callback_address = 8786 Address callback_address =
8783 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8787 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8784 VMState<EXTERNAL> state(isolate); 8788 VMState<EXTERNAL> state(isolate);
8785 ExternalCallbackScope call_scope(isolate, callback_address); 8789 ExternalCallbackScope call_scope(isolate, callback_address);
8786 callback(info); 8790 callback(info);
8787 } 8791 }
8788 8792
8789 8793
8790 } // namespace internal 8794 } // namespace internal
8791 } // namespace v8 8795 } // namespace v8
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698