[cleanup] Drop some occurrences of Isolate::Current

Just the low-hanging fruit. There is more to do.

Bug: v8:2487
Change-Id: Ia9afa32797960f6c4c7c4fa0f39c70efc63663e6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1669698
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62397}
This commit is contained in:
Jakob Kummerow 2019-06-21 15:32:50 +02:00 committed by Commit Bot
parent be729136be
commit 881c9b8c05
17 changed files with 86 additions and 103 deletions

View File

@ -676,19 +676,17 @@ StringHttpRequest kSampleRequests[kSampleSize] = {
StringHttpRequest("/", "localhost", "yahoo.com", "firefox")
};
bool ProcessEntries(v8::Platform* platform, HttpRequestProcessor* processor,
int count, StringHttpRequest* reqs) {
bool ProcessEntries(v8::Isolate* isolate, v8::Platform* platform,
HttpRequestProcessor* processor, int count,
StringHttpRequest* reqs) {
for (int i = 0; i < count; i++) {
bool result = processor->Process(&reqs[i]);
while (v8::platform::PumpMessageLoop(platform, Isolate::GetCurrent()))
continue;
while (v8::platform::PumpMessageLoop(platform, isolate)) continue;
if (!result) return false;
}
return true;
}
void PrintMap(map<string, string>* m) {
for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) {
pair<string, string> entry = *i;
@ -727,7 +725,9 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "Error initializing processor.\n");
return 1;
}
if (!ProcessEntries(platform.get(), &processor, kSampleSize, kSampleRequests))
if (!ProcessEntries(isolate, platform.get(), &processor, kSampleSize,
kSampleRequests)) {
return 1;
}
PrintMap(&output);
}

View File

@ -49,8 +49,6 @@ static const char* NameForNativeContextIntrinsicIndex(uint32_t idx) {
return "UnknownIntrinsicIndex";
}
void AstNode::Print() { Print(Isolate::Current()); }
void AstNode::Print(Isolate* isolate) {
AllowHandleDereference allow_deref;
AstPrinter::PrintOut(isolate, this);

View File

@ -147,7 +147,6 @@ class AstNode: public ZoneObject {
int position() const { return position_; }
#ifdef DEBUG
void Print();
void Print(Isolate* isolate);
#endif // DEBUG

View File

@ -1927,7 +1927,7 @@ static void PrintNonErrorsMessageCallback(Local<Message> message,
auto ToCString = [](const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
};
Isolate* isolate = Isolate::GetCurrent();
Isolate* isolate = message->GetIsolate();
v8::String::Utf8Value msg(isolate, message->Get());
const char* msg_string = ToCString(msg);
// Print (filename):(line number): (message).

View File

@ -600,14 +600,11 @@ RUNTIME_FUNCTION(Runtime_GetUndetectable) {
}
static void call_as_function(const v8::FunctionCallbackInfo<v8::Value>& args) {
double v1 = args[0]
->NumberValue(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToChecked();
double v2 = args[1]
->NumberValue(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToChecked();
args.GetReturnValue().Set(
v8::Number::New(v8::Isolate::GetCurrent(), v1 - v2));
double v1 =
args[0]->NumberValue(args.GetIsolate()->GetCurrentContext()).ToChecked();
double v2 =
args[1]->NumberValue(args.GetIsolate()->GetCurrentContext()).ToChecked();
args.GetReturnValue().Set(v8::Number::New(args.GetIsolate(), v1 - v2));
}
// Returns a callable object. The object returns the difference of its two

View File

@ -464,7 +464,7 @@ bool WriteExpectationsFile(const std::vector<std::string>& snippet_list,
void PrintMessage(v8::Local<v8::Message> message, v8::Local<v8::Value>) {
std::cerr << "INFO: "
<< *v8::String::Utf8Value(v8::Isolate::GetCurrent(), message->Get())
<< *v8::String::Utf8Value(message->GetIsolate(), message->Get())
<< '\n';
}

View File

@ -8847,17 +8847,16 @@ TEST(ApiUncaughtException) {
static const char* script_resource_name = "ExceptionInNativeScript.js";
static void ExceptionInNativeScriptTestListener(v8::Local<v8::Message> message,
v8::Local<Value>) {
v8::Isolate* isolate = message->GetIsolate();
v8::Local<v8::Value> name_val = message->GetScriptOrigin().ResourceName();
CHECK(!name_val.IsEmpty() && name_val->IsString());
v8::String::Utf8Value name(v8::Isolate::GetCurrent(),
v8::String::Utf8Value name(isolate,
message->GetScriptOrigin().ResourceName());
CHECK_EQ(0, strcmp(script_resource_name, *name));
v8::Local<v8::Context> context =
v8::Isolate::GetCurrent()->GetCurrentContext();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
CHECK_EQ(3, message->GetLineNumber(context).FromJust());
v8::String::Utf8Value source_line(
v8::Isolate::GetCurrent(),
message->GetSourceLine(context).ToLocalChecked());
isolate, message->GetSourceLine(context).ToLocalChecked());
CHECK_EQ(0, strcmp(" new o.foo();", *source_line));
}
@ -12711,9 +12710,9 @@ TEST(ObjectProtoToStringES6) {
Local<v8::Symbol> valueSymbol = v8_symbol("TestSymbol");
Local<v8::Function> valueFunction =
CompileRun("(function fn() {})").As<v8::Function>();
Local<v8::Object> valueObject = v8::Object::New(v8::Isolate::GetCurrent());
Local<v8::Primitive> valueNull = v8::Null(v8::Isolate::GetCurrent());
Local<v8::Primitive> valueUndef = v8::Undefined(v8::Isolate::GetCurrent());
Local<v8::Object> valueObject = v8::Object::New(isolate);
Local<v8::Primitive> valueNull = v8::Null(isolate);
Local<v8::Primitive> valueUndef = v8::Undefined(isolate);
#define TEST_TOSTRINGTAG(type, tagValue, expected) \
do { \
@ -18309,9 +18308,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
}
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(isolate1);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1);
v8::Local<v8::Context>::New(isolate1, context1);
v8::Context::Scope context_scope(context);
ExpectString("function f() { return foo; }; f()", "isolate 1");
}

View File

@ -26,7 +26,7 @@ namespace {
static Handle<JSFunction> GetFunction(const char* name) {
v8::MaybeLocal<v8::Value> v8_f = CcTest::global()->Get(
v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str(name));
CcTest::isolate()->GetCurrentContext(), v8_str(name));
Handle<JSFunction> f =
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*v8_f.ToLocalChecked()));
return f;

View File

@ -2671,7 +2671,7 @@ TEST(ArrayGrowLeftTrim) {
}
TEST(TrackHeapAllocationsWithInlining) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -2705,7 +2705,7 @@ TEST(TrackHeapAllocationsWithoutInlining) {
// Disable inlining
i::FLAG_max_inlined_bytecode_size = 0;
i::FLAG_max_inlined_bytecode_size_small = 0;
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -2752,7 +2752,7 @@ static const char* inline_heap_allocation_source =
TEST(TrackBumpPointerAllocations) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -2807,7 +2807,7 @@ TEST(TrackBumpPointerAllocations) {
TEST(TrackV8ApiAllocation) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3474,7 +3474,7 @@ static const char* simple_sampling_heap_profiler_script =
"foo();";
TEST(SamplingHeapProfiler) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3557,7 +3557,7 @@ TEST(SamplingHeapProfiler) {
}
TEST(SamplingHeapProfilerRateAgnosticEstimates) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3639,7 +3639,7 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) {
}
TEST(SamplingHeapProfilerApiAllocation) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3662,7 +3662,7 @@ TEST(SamplingHeapProfilerApiAllocation) {
}
TEST(SamplingHeapProfilerApiSamples) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3707,7 +3707,7 @@ TEST(SamplingHeapProfilerApiSamples) {
}
TEST(SamplingHeapProfilerLeftTrimming) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3742,7 +3742,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
return;
}
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3807,7 +3807,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
}
TEST(SamplingHeapProfilerLargeInterval) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@ -3845,7 +3845,7 @@ TEST(HeapSnapshotPrototypeNotJSReceiver) {
TEST(SamplingHeapProfilerSampleDuringDeopt) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::HandleScope scope(CcTest::isolate());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();

View File

@ -28,8 +28,7 @@ static Handle<T> OpenHandle(v8::Local<v8::Value> value) {
static inline v8::Local<v8::Value> Run(v8::Local<v8::Script> script) {
v8::Local<v8::Value> result;
if (script->Run(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToLocal(&result)) {
if (script->Run(CcTest::isolate()->GetCurrentContext()).ToLocal(&result)) {
return result;
}
return v8::Local<v8::Value>();

View File

@ -58,7 +58,6 @@ class DeoptimizeCodeThread : public v8::base::Thread {
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
CHECK_EQ(isolate_, v8::Isolate::GetCurrent());
// This code triggers deoptimization of some function that will be
// used in a different thread.
CompileRun(source_);
@ -73,7 +72,7 @@ class DeoptimizeCodeThread : public v8::base::Thread {
};
void UnlockForDeoptimization(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = args.GetIsolate();
// Gets the pointer to the thread that will trigger the deoptimization of the
// code.
DeoptimizeCodeThread* deoptimizer =
@ -94,7 +93,7 @@ void UnlockForDeoptimization(const v8::FunctionCallbackInfo<v8::Value>& args) {
void UnlockForDeoptimizationIfReady(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = args.GetIsolate();
bool* ready_to_deoptimize = reinterpret_cast<bool*>(isolate->GetData(1));
if (*ready_to_deoptimize) {
// The test should enter here only once, so put the flag back to false.
@ -297,7 +296,6 @@ class KangarooThread : public v8::base::Thread {
{
v8::Locker locker(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
CHECK_EQ(isolate_, v8::Isolate::GetCurrent());
v8::HandleScope scope(isolate_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
@ -338,7 +336,6 @@ TEST(KangarooIsolates) {
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
CHECK_EQ(isolate, v8::Isolate::GetCurrent());
CompileRun("function getValue() { return 30; }");
thread1.reset(new KangarooThread(isolate, context));
}
@ -416,7 +413,6 @@ class IsolateLockingThreadWithLocalContext : public JoinableThread {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
LocalContext local_context(isolate_);
CHECK_EQ(isolate_, v8::Isolate::GetCurrent());
CalcFibAndCheck(local_context.local());
}
private:

View File

@ -624,14 +624,12 @@ TEST(ProfileNodeScriptId) {
v8::Local<v8::Script> script_a =
v8_compile(v8_str("function a() { startProfiling(); }\n"));
script_a->Run(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToLocalChecked();
script_a->Run(env).ToLocalChecked();
v8::Local<v8::Script> script_b =
v8_compile(v8_str("function b() { a(); }\n"
"b();\n"
"stopProfiling();\n"));
script_b->Run(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToLocalChecked();
script_b->Run(env).ToLocalChecked();
CHECK_EQ(1, iprofiler->GetProfilesCount());
const v8::CpuProfile* profile = i::ProfilerExtension::last_profile;
const v8::CpuProfileNode* current = profile->GetTopDownRoot();

View File

@ -1260,8 +1260,8 @@ UNINITIALIZED_TEST(CustomSnapshotDataBlobOutdatedContextWithOverflow) {
v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr, global);
v8::Context::Scope c_scope(context);
v8::Local<v8::Value> result = CompileRun(source2);
v8::Maybe<bool> compare = v8_str("42")->Equals(
v8::Isolate::GetCurrent()->GetCurrentContext(), result);
v8::Maybe<bool> compare =
v8_str("42")->Equals(isolate->GetCurrentContext(), result);
CHECK(compare.FromJust());
}
isolate->Dispose();
@ -1929,10 +1929,10 @@ TEST(CodeSerializerThreeBigStrings) {
v8::Maybe<int32_t> result =
CompileRun("(a + b).length")
->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
->Int32Value(CcTest::isolate()->GetCurrentContext());
CHECK_EQ(length_of_a + length_of_b, result.FromJust());
result = CompileRun("(b + c).length")
->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext());
->Int32Value(CcTest::isolate()->GetCurrentContext());
CHECK_EQ(length_of_b + length_of_c, result.FromJust());
Heap* heap = isolate->heap();
v8::Local<v8::String> result_str =

View File

@ -345,7 +345,7 @@ TEST(TerminateAndReenterFromThreadItself) {
isolate, TerminateCurrentThread, ReenterAfterTermination);
v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(!isolate->IsExecutionTerminating());
// Create script strings upfront as it won't work when terminating.
reenter_script_1.Reset(isolate, v8_str(
"function f() {"
@ -377,7 +377,7 @@ TEST(TerminateAndReenterFromThreadItselfWithOuterTryCatch) {
isolate, TerminateCurrentThread, ReenterAfterTermination);
v8::Local<v8::Context> context = v8::Context::New(isolate, nullptr, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(!isolate->IsExecutionTerminating());
// Create script strings upfront as it won't work when terminating.
reenter_script_1.Reset(isolate, v8_str("function f() {"
" var term = true;"
@ -411,25 +411,25 @@ TEST(TerminateAndReenterFromThreadItselfWithOuterTryCatch) {
}
void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch(args.GetIsolate());
CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
v8::MaybeLocal<v8::Value> result =
CompileRun(args.GetIsolate()->GetCurrentContext(),
"var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"
"fail();");
v8::Isolate* isolate = args.GetIsolate();
v8::TryCatch try_catch(isolate);
CHECK(!isolate->IsExecutionTerminating());
v8::MaybeLocal<v8::Value> result = CompileRun(isolate->GetCurrentContext(),
"var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"
"fail();");
CHECK(result.IsEmpty());
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(isolate->IsExecutionTerminating());
CHECK(try_catch.HasTerminated());
CcTest::isolate()->CancelTerminateExecution();
CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
isolate->CancelTerminateExecution();
CHECK(!isolate->IsExecutionTerminating());
}
@ -467,7 +467,7 @@ void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Function::New(isolate->GetCurrentContext(), MicrotaskShouldNotRun)
.ToLocalChecked());
CompileRun("terminate(); while (true) { }");
CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(isolate->IsExecutionTerminating());
}
@ -782,10 +782,10 @@ TEST(TerminationInInnerTryCall) {
CompileRun("inner_try_call_terminate()");
CHECK(try_catch.HasTerminated());
}
v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value(
v8::Isolate::GetCurrent()->GetCurrentContext());
v8::Maybe<int32_t> result =
CompileRun("2 + 2")->Int32Value(isolate->GetCurrentContext());
CHECK_EQ(4, result.FromJust());
CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
CHECK(!isolate->IsExecutionTerminating());
}
@ -816,8 +816,8 @@ TEST(TerminateAndTryCall) {
CHECK(isolate->IsExecutionTerminating());
}
// V8 then recovers.
v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value(
v8::Isolate::GetCurrent()->GetCurrentContext());
v8::Maybe<int32_t> result =
CompileRun("2 + 2")->Int32Value(isolate->GetCurrentContext());
CHECK_EQ(4, result.FromJust());
CHECK(!isolate->IsExecutionTerminating());
}

View File

@ -17,7 +17,7 @@ namespace internal {
void TestArrayBufferViewContents(LocalContext& env, bool should_use_buffer) {
v8::Local<v8::Object> obj_a = v8::Local<v8::Object>::Cast(
env->Global()
->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), v8_str("a"))
->Get(env->GetIsolate()->GetCurrentContext(), v8_str("a"))
.ToLocalChecked());
CHECK(obj_a->IsArrayBufferView());
v8::Local<v8::ArrayBufferView> array_buffer_view =

View File

@ -61,9 +61,8 @@ enum RegExpBuiltin {
REGEXP_BUILTINS(CASE)
#undef CASE
v8::Local<v8::String> v8_str(const char* s) {
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), s,
v8::NewStringType::kNormal)
v8::Local<v8::String> v8_str(v8::Isolate* isolate, const char* s) {
return v8::String::NewFromUtf8(isolate, s, v8::NewStringType::kNormal)
.ToLocalChecked();
}
@ -71,7 +70,7 @@ v8::MaybeLocal<v8::Value> CompileRun(v8::Local<v8::Context> context,
const char* source) {
v8::Local<v8::Script> script;
v8::MaybeLocal<v8::Script> maybe_script =
v8::Script::Compile(context, v8_str(source));
v8::Script::Compile(context, v8_str(context->GetIsolate(), source));
if (!maybe_script.ToLocal(&script)) return v8::MaybeLocal<v8::Value>();
return script->Run(context);

View File

@ -260,7 +260,7 @@ void IsolateData::DumpAsyncTaskStacksStateForTest() {
// static
int IsolateData::HandleMessage(v8::Local<v8::Message> message,
v8::Local<v8::Value> exception) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = message->GetIsolate();
v8::Local<v8::Context> context = isolate->GetEnteredOrMicrotaskContext();
if (context.IsEmpty()) return 0;
v8_inspector::V8Inspector* inspector =
@ -304,7 +304,7 @@ void IsolateData::MessageHandler(v8::Local<v8::Message> message,
// static
void IsolateData::PromiseRejectHandler(v8::PromiseRejectMessage data) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = data.GetPromise()->GetIsolate();
v8::Local<v8::Context> context = isolate->GetEnteredOrMicrotaskContext();
if (context.IsEmpty()) return;
v8::Local<v8::Promise> promise = data.GetPromise();
@ -370,12 +370,11 @@ std::vector<int> IsolateData::GetSessionIds(int context_group_id) {
}
bool IsolateData::formatAccessorsAsProperties(v8::Local<v8::Value> object) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Context> context = isolate()->GetCurrentContext();
v8::Local<v8::Private> shouldFormatAccessorsPrivate = v8::Private::ForApi(
isolate, v8::String::NewFromUtf8(isolate, "allowAccessorFormatting",
v8::NewStringType::kNormal)
.ToLocalChecked());
isolate(), v8::String::NewFromUtf8(isolate(), "allowAccessorFormatting",
v8::NewStringType::kNormal)
.ToLocalChecked());
CHECK(object->IsObject());
return object.As<v8::Object>()
->HasPrivate(context, shouldFormatAccessorsPrivate)
@ -383,11 +382,10 @@ bool IsolateData::formatAccessorsAsProperties(v8::Local<v8::Value> object) {
}
bool IsolateData::isInspectableHeapObject(v8::Local<v8::Object> object) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Context> context = isolate()->GetCurrentContext();
v8::MicrotasksScope microtasks_scope(
isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
return !object->HasPrivate(context, not_inspectable_private_.Get(isolate))
isolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
return !object->HasPrivate(context, not_inspectable_private_.Get(isolate()))
.FromMaybe(false);
}
@ -455,7 +453,7 @@ void IsolateData::maxAsyncCallStackDepthChanged(int depth) {
}
void IsolateData::SetResourceNamePrefix(v8::Local<v8::String> prefix) {
resource_name_prefix_.Reset(v8::Isolate::GetCurrent(), prefix);
resource_name_prefix_.Reset(isolate(), prefix);
}
namespace {
@ -475,10 +473,10 @@ class StringBufferImpl : public v8_inspector::StringBuffer {
std::unique_ptr<v8_inspector::StringBuffer> IsolateData::resourceNameToUrl(
const v8_inspector::StringView& resourceName) {
if (resource_name_prefix_.IsEmpty()) return nullptr;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::String> name = ToString(isolate, resourceName);
v8::Local<v8::String> prefix = resource_name_prefix_.Get(isolate);
v8::Local<v8::String> url = v8::String::Concat(isolate, prefix, name);
return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(isolate, url));
v8::HandleScope handle_scope(isolate());
v8::Local<v8::String> name = ToString(isolate(), resourceName);
v8::Local<v8::String> prefix = resource_name_prefix_.Get(isolate());
v8::Local<v8::String> url = v8::String::Concat(isolate(), prefix, name);
return std::unique_ptr<StringBufferImpl>(
new StringBufferImpl(isolate(), url));
}