[api][cleanup] Use Template::Set with const char* name

Using the Template::Set method which const char name is more ergonomic
and it creates directly an internalized name instead of the normal
string that most users pass in.

Bug: v8:10884
Change-Id: I00c6d49fee9de16b8ebbfe75be4b383831f0d4dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2400980
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69787}
This commit is contained in:
Camillo Bruni 2020-09-09 13:07:28 +02:00 committed by Commit Bot
parent 7c4b930242
commit f2e2809c23
9 changed files with 24 additions and 25 deletions

View File

@ -183,7 +183,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
// Create a template for the global object where we set the
// built-in global functions.
Local<ObjectTemplate> global = ObjectTemplate::New(GetIsolate());
global->Set(String::NewFromUtf8Literal(GetIsolate(), "log"),
global->Set(GetIsolate(), "log",
FunctionTemplate::New(GetIsolate(), LogCallback));
// Each processor gets its own context so different processors don't

View File

@ -196,11 +196,9 @@ void AsyncHooks::Initialize() {
async_hook_ctor.Get(isolate_)->InstanceTemplate());
async_hooks_templ.Get(isolate_)->SetInternalFieldCount(1);
async_hooks_templ.Get(isolate_)->Set(
String::NewFromUtf8Literal(isolate_, "enable"),
FunctionTemplate::New(isolate_, EnableHook));
isolate_, "enable", FunctionTemplate::New(isolate_, EnableHook));
async_hooks_templ.Get(isolate_)->Set(
String::NewFromUtf8Literal(isolate_, "disable"),
FunctionTemplate::New(isolate_, DisableHook));
isolate_, "disable", FunctionTemplate::New(isolate_, DisableHook));
async_id_smb.Reset(isolate_, Private::New(isolate_));
trigger_id_smb.Reset(isolate_, Private::New(isolate_));

View File

@ -4715,8 +4715,8 @@ THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
obj_template->Set(isolate, "7", v8::Integer::New(isolate, 7));
obj_template->Set(isolate, "x", v8::Integer::New(isolate, 42));
obj_template->SetHandler(v8::IndexedPropertyHandlerConfiguration(
nullptr, nullptr, nullptr, nullptr, IndexedPropertyEnumerator));
obj_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
@ -4781,8 +4781,8 @@ THREADED_TEST(GetOwnPropertyNamesWithIndexedInterceptorExceptions_regress4026) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
obj_template->Set(isolate, "7", v8::Integer::New(isolate, 7));
obj_template->Set(isolate, "x", v8::Integer::New(isolate, 42));
// First just try a failing indexed interceptor.
obj_template->SetHandler(v8::IndexedPropertyHandlerConfiguration(
nullptr, nullptr, nullptr, nullptr, IndexedPropertyEnumeratorException));
@ -4827,8 +4827,8 @@ THREADED_TEST(GetOwnPropertyNamesWithNamedInterceptorExceptions_regress4026) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(isolate);
obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7));
obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42));
obj_template->Set(isolate, "7", v8::Integer::New(isolate, 7));
obj_template->Set(isolate, "x", v8::Integer::New(isolate, 42));
// First just try a failing indexed interceptor.
obj_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
nullptr, nullptr, nullptr, nullptr, NamedPropertyEnumeratorException));

View File

@ -287,7 +287,7 @@ TEST(CaptureStackTrace) {
v8::HandleScope scope(isolate);
v8::Local<v8::String> origin = v8_str("capture-stack-trace-test");
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("AnalyzeStackInNativeCode"),
templ->Set(isolate, "AnalyzeStackInNativeCode",
v8::FunctionTemplate::New(isolate, AnalyzeStackInNativeCode));
LocalContext context(nullptr, templ);
@ -625,7 +625,7 @@ TEST(SourceURLInStackTrace) {
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(
v8_str("AnalyzeStackOfEvalWithSourceURL"),
isolate, "AnalyzeStackOfEvalWithSourceURL",
v8::FunctionTemplate::New(isolate, AnalyzeStackOfEvalWithSourceURL));
LocalContext context(nullptr, templ);
@ -666,7 +666,7 @@ TEST(ScriptIdInStackTrace) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("AnalyzeScriptIdInStack"),
templ->Set(isolate, "AnalyzeScriptIdInStack",
v8::FunctionTemplate::New(isolate, AnalyzeScriptIdInStack));
LocalContext context(nullptr, templ);
@ -702,7 +702,7 @@ TEST(InlineScriptWithSourceURLInStackTrace) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"),
templ->Set(isolate, "AnalyzeStackOfInlineScriptWithSourceURL",
v8::FunctionTemplate::New(
CcTest::isolate(), AnalyzeStackOfInlineScriptWithSourceURL));
LocalContext context(nullptr, templ);
@ -746,7 +746,7 @@ TEST(DynamicWithSourceURLInStackTrace) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"),
templ->Set(isolate, "AnalyzeStackOfDynamicScriptWithSourceURL",
v8::FunctionTemplate::New(
CcTest::isolate(), AnalyzeStackOfDynamicScriptWithSourceURL));
LocalContext context(nullptr, templ);

View File

@ -817,7 +817,7 @@ TEST(StackAlignmentForSSE2) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->Set(v8_str("do_sse2"),
global_template->Set(isolate, "do_sse2",
v8::FunctionTemplate::New(isolate, DoSSE2));
LocalContext env(nullptr, global_template);

View File

@ -996,7 +996,7 @@ TEST(NativeMethodUninitializedIC) {
v8::Local<v8::Signature> signature =
v8::Signature::New(isolate, func_template);
proto_template->Set(
v8_str("fooMethod"),
isolate, "fooMethod",
v8::FunctionTemplate::New(isolate, &TestApiCallbacks::Callback, data,
signature, 0));
@ -1037,7 +1037,7 @@ TEST(NativeMethodMonomorphicIC) {
v8::Local<v8::Signature> signature =
v8::Signature::New(isolate, func_template);
proto_template->Set(
v8_str("fooMethod"),
isolate, "fooMethod",
v8::FunctionTemplate::New(isolate, &TestApiCallbacks::Callback, data,
signature, 0));

View File

@ -49,7 +49,7 @@ TEST(StackAlignment) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate);
global_template->Set(v8_str("get_stack_pointer"),
global_template->Set(isolate, "get_stack_pointer",
v8::FunctionTemplate::New(isolate, GetStackPointer));
LocalContext env(nullptr, global_template);

View File

@ -45,7 +45,7 @@ class SamplingTestHelper {
instance_ = this;
v8::HandleScope scope(isolate_);
v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_);
global->Set(v8_str("CollectSample"),
global->Set(isolate_, "CollectSample",
v8::FunctionTemplate::New(isolate_, CollectSample));
LocalContext env(isolate_, nullptr, global);
isolate_->SetJitCodeEventHandler(v8::kJitCodeEventDefault,

View File

@ -716,7 +716,8 @@ UNINITIALIZED_TEST(CustomSnapshotDataBlobOverwriteGlobal) {
v8::Local<v8::ObjectTemplate> global_template =
v8::ObjectTemplate::New(isolate1);
global_template->Set(
v8_str("f"), v8::FunctionTemplate::New(isolate1, UnreachableCallback));
isolate1, "f",
v8::FunctionTemplate::New(isolate1, UnreachableCallback));
v8::Local<v8::Context> context =
v8::Context::New(isolate1, nullptr, global_template);
v8::Context::Scope c_scope(context);
@ -3232,7 +3233,7 @@ UNINITIALIZED_TEST(SnapshotCreatorTemplates) {
v8::External::New(isolate, &serialized_static_field);
v8::Local<v8::FunctionTemplate> callback =
v8::FunctionTemplate::New(isolate, SerializedCallback, external);
global_template->Set(v8_str("f"), callback);
global_template->Set(isolate, "f", callback);
v8::Local<v8::Context> context =
v8::Context::New(isolate, no_extension, global_template);
creator.SetDefaultContext(context);
@ -3635,7 +3636,7 @@ UNINITIALIZED_TEST(SnapshotCreatorIncludeGlobalProxy) {
v8::ObjectTemplate::New(isolate);
v8::Local<v8::FunctionTemplate> callback =
v8::FunctionTemplate::New(isolate, SerializedCallback);
global_template->Set(v8_str("f"), callback);
global_template->Set(isolate, "f", callback);
global_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedPropertyGetterForSerialization));
v8::Local<v8::Context> context =
@ -3662,7 +3663,7 @@ UNINITIALIZED_TEST(SnapshotCreatorIncludeGlobalProxy) {
v8::Local<v8::FunctionTemplate> callback =
v8::FunctionTemplate::New(isolate, SerializedCallback);
global_template->SetInternalFieldCount(3);
global_template->Set(v8_str("f"), callback);
global_template->Set(isolate, "f", callback);
global_template->SetHandler(v8::NamedPropertyHandlerConfiguration(
NamedPropertyGetterForSerialization));
global_template->SetAccessor(v8_str("y"), AccessorForSerialization);