Commit 1bd48322 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix uses of V8_DEPRECATE_SOON methods in v8

Change many uses of deprecated methods returning Locals to use the
MaybeLocal versions.

Also fix uses of Utf8Length to use the Isolate versions.

Bug: v8:7754
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ib89df12e6cc5ca50296d21b2bb51a3f3ed065dd4
Reviewed-on: https://chromium-review.googlesource.com/1142779Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54550}
parent 88643ae3
......@@ -182,10 +182,12 @@ void AsyncHooks::Initialize() {
async_hook_ctor.Get(isolate_)->InstanceTemplate());
async_hooks_templ.Get(isolate_)->SetInternalFieldCount(1);
async_hooks_templ.Get(isolate_)->Set(
String::NewFromUtf8(isolate_, "enable"),
String::NewFromUtf8(isolate_, "enable", v8::NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate_, EnableHook));
async_hooks_templ.Get(isolate_)->Set(
String::NewFromUtf8(isolate_, "disable"),
String::NewFromUtf8(isolate_, "disable", v8::NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate_, DisableHook));
async_id_smb.Reset(isolate_, Private::New(isolate_));
......@@ -215,10 +217,9 @@ void AsyncHooks::PromiseHookDispatch(PromiseHookType type,
try_catch.SetVerbose(true);
Local<Value> rcv = Undefined(hooks->isolate_);
Local<Context> context = hooks->isolate_->GetCurrentContext();
Local<Value> async_id =
promise
->GetPrivate(hooks->isolate_->GetCurrentContext(),
hooks->async_id_smb.Get(hooks->isolate_))
promise->GetPrivate(context, hooks->async_id_smb.Get(hooks->isolate_))
.ToLocalChecked();
Local<Value> args[1] = {async_id};
......@@ -231,23 +232,24 @@ void AsyncHooks::PromiseHookDispatch(PromiseHookType type,
NewStringType::kNormal)
.ToLocalChecked(),
promise
->GetPrivate(hooks->isolate_->GetCurrentContext(),
hooks->trigger_id_smb.Get(hooks->isolate_))
->GetPrivate(context, hooks->trigger_id_smb.Get(hooks->isolate_))
.ToLocalChecked(),
promise};
wrap->init_function()->Call(rcv, 4, initArgs);
wrap->init_function()->Call(context, rcv, 4, initArgs).ToLocalChecked();
}
} else if (type == PromiseHookType::kBefore) {
if (!wrap->before_function().IsEmpty()) {
wrap->before_function()->Call(rcv, 1, args);
wrap->before_function()->Call(context, rcv, 1, args).ToLocalChecked();
}
} else if (type == PromiseHookType::kAfter) {
if (!wrap->after_function().IsEmpty()) {
wrap->after_function()->Call(rcv, 1, args);
wrap->after_function()->Call(context, rcv, 1, args).ToLocalChecked();
}
} else if (type == PromiseHookType::kResolve) {
if (!wrap->promiseResolve_function().IsEmpty()) {
wrap->promiseResolve_function()->Call(rcv, 1, args);
wrap->promiseResolve_function()
->Call(context, rcv, 1, args)
.ToLocalChecked();
}
}
......
......@@ -38,7 +38,7 @@ class MaybeUtf8 {
}
} else {
Local<v8::String> local = Utils::ToLocal(string);
len = local->Utf8Length();
len = local->Utf8Length(reinterpret_cast<v8::Isolate*>(isolate));
AllocateSufficientSpace(len);
if (len > 0) {
local->WriteUtf8(reinterpret_cast<char*>(buf_));
......
......@@ -118,13 +118,11 @@ class V8ValueStringBuilder {
!value->IsNativeError() && !value->IsRegExp()) {
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Local<v8::String> stringValue;
if (object->ObjectProtoToString(m_isolate->GetCurrentContext())
.ToLocal(&stringValue))
if (object->ObjectProtoToString(m_context).ToLocal(&stringValue))
return append(stringValue);
}
v8::Local<v8::String> stringValue;
if (!value->ToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue))
return false;
if (!value->ToString(m_context).ToLocal(&stringValue)) return false;
return append(stringValue);
}
......@@ -160,7 +158,9 @@ class V8ValueStringBuilder {
}
bool append(v8::Local<v8::BigInt> bigint) {
bool result = append(bigint->ToString());
v8::Local<v8::String> bigint_string;
if (!bigint->ToString(m_context).ToLocal(&bigint_string)) return false;
bool result = append(bigint_string);
if (m_tryCatch.HasCaught()) return false;
m_builder.append('n');
return result;
......
......@@ -1736,7 +1736,8 @@ THREADED_TEST(StringObject) {
Local<v8::String> the_string = as_boxed->ValueOf();
CHECK(!the_string.IsEmpty());
ExpectObject("\"test\"", the_string);
v8::Local<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
v8::Local<v8::Value> new_boxed_string =
v8::StringObject::New(CcTest::isolate(), the_string);
CHECK(new_boxed_string->IsStringObject());
as_boxed = new_boxed_string.As<v8::StringObject>();
the_string = as_boxed->ValueOf();
......@@ -10639,8 +10640,8 @@ THREADED_TEST(ObjectGetOwnPropertyNames) {
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> value =
v8::Local<v8::Object>::Cast(v8::StringObject::New(v8_str("test")));
v8::Local<v8::Object> value = v8::Local<v8::Object>::Cast(
v8::StringObject::New(CcTest::isolate(), v8_str("test")));
v8::Local<v8::Array> properties;
CHECK(value
......@@ -24915,8 +24916,12 @@ TEST(ResolvedPromiseReFulfill) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo");
v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar");
v8::Local<v8::String> value1 =
v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal)
.ToLocalChecked();
v8::Local<v8::String> value2 =
v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal)
.ToLocalChecked();
v8::Local<v8::Promise::Resolver> resolver =
v8::Promise::Resolver::New(context.local()).ToLocalChecked();
......@@ -24942,8 +24947,12 @@ TEST(RejectedPromiseReFulfill) {
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo");
v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar");
v8::Local<v8::String> value1 =
v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal)
.ToLocalChecked();
v8::Local<v8::String> value2 =
v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal)
.ToLocalChecked();
v8::Local<v8::Promise::Resolver> resolver =
v8::Promise::Resolver::New(context.local()).ToLocalChecked();
......
......@@ -289,6 +289,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
LocalContext env;
v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
......@@ -307,7 +308,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(result->BooleanValue());
CHECK(result->BooleanValue(context).ToChecked());
}
{
......@@ -317,7 +318,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(!result->BooleanValue());
CHECK(!result->BooleanValue(context).ToChecked());
}
{
......@@ -327,7 +328,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(result->BooleanValue());
CHECK(result->BooleanValue(context).ToChecked());
}
}
......@@ -337,6 +338,7 @@ TEST(BuiltinsTrace) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
LocalContext env;
v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
......@@ -360,7 +362,7 @@ TEST(BuiltinsTrace) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(!result->BooleanValue());
CHECK(!result->BooleanValue(context).ToChecked());
CHECK_EQ(0, GET_TRACE_OBJECTS_LIST->size());
}
......@@ -368,7 +370,6 @@ TEST(BuiltinsTrace) {
{
v8::Local<v8::String> category = v8_str("v8-cat");
v8::Local<v8::String> name = v8_str("name");
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> data = v8::Object::New(isolate);
data->Set(context, v8_str("foo"), v8_str("bar")).FromJust();
v8::Local<v8::Value> argv[] = {
......@@ -380,7 +381,7 @@ TEST(BuiltinsTrace) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(result->BooleanValue());
CHECK(result->BooleanValue(context).ToChecked());
CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(123, GET_TRACE_OBJECT(0)->id);
......@@ -393,7 +394,6 @@ TEST(BuiltinsTrace) {
{
v8::Local<v8::String> category = v8_str("v8-cat\u20ac");
v8::Local<v8::String> name = v8_str("name\u20ac");
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> data = v8::Object::New(isolate);
data->Set(context, v8_str("foo"), v8_str("bar")).FromJust();
v8::Local<v8::Value> argv[] = {
......@@ -405,7 +405,7 @@ TEST(BuiltinsTrace) {
.ToLocalChecked()
.As<v8::Boolean>();
CHECK(result->BooleanValue());
CHECK(result->BooleanValue(context).ToChecked());
CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size());
CHECK_EQ(123, GET_TRACE_OBJECT(1)->id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment