Commit ef503f07 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Revert "[Compile] Ensure we don't access the native context during bytecode finalization."

This reverts commit 9cde8808.

Reason for revert:
https://ci.chromium.org/p/v8/builders/luci.v8.ci/Linux%20V8%20FYI%20Release%20(NVIDIA)/3086

Original change's description:
> [Compile] Ensure we don't access the native context during bytecode finalization.
> 
> Resets the isolate's context to nullptr in debug builds during bytecode finalization
> to ensure that we don't rely on the native context during context independent
> unoptimized compilation.
> 
> BUG=chromium:898076, v8:8041
> 
> Change-Id: Ifaa5006a7a3d31d7fbd535ebb63f8889c75526c4
> Reviewed-on: https://chromium-review.googlesource.com/c/1297961
> Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#56979}

TBR=rmcilroy@chromium.org,mstarzinger@chromium.org,leszeks@chromium.org

Change-Id: I363bc9db3f4b89e46ecdaf41c101f7fc1145a325
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:898076, v8:8041
Reviewed-on: https://chromium-review.googlesource.com/c/1299247Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57007}
parent d5f3e225
......@@ -504,9 +504,6 @@ bool FinalizeUnoptimizedCode(
UnoptimizedCompilationJobList* inner_function_jobs) {
DCHECK(AllowCompilation::IsAllowed(isolate));
// TODO(rmcilroy): Clear native context in debug once AsmJS generates doesn't
// rely on accessing native context during finalization.
// Allocate scope infos for the literal.
DeclarationScope::AllocateScopeInfos(parse_info, isolate);
......
......@@ -923,12 +923,6 @@ BytecodeGenerator::BytecodeGenerator(
Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
Isolate* isolate, Handle<Script> script) {
DCHECK(ThreadId::Current().Equals(isolate->thread_id()));
#ifdef DEBUG
// Unoptimized compilation should be context-independent. Verify that we don't
// access the native context by nulling it out during finalization.
SaveContext save(isolate);
isolate->set_context(nullptr);
#endif
AllocateDeferredConstants(isolate, script);
......
......@@ -42,14 +42,15 @@ const char* ProfilerExtension::kSource =
v8::Local<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<v8::String> name) {
if (name->StrictEquals(v8_str(isolate, "startProfiling"))) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (name->Equals(context, v8_str(isolate, "startProfiling")).FromJust()) {
return v8::FunctionTemplate::New(isolate,
ProfilerExtension::StartProfiling);
}
if (name->StrictEquals(v8_str(isolate, "stopProfiling"))) {
if (name->Equals(context, v8_str(isolate, "stopProfiling")).FromJust()) {
return v8::FunctionTemplate::New(isolate, ProfilerExtension::StopProfiling);
}
if (name->StrictEquals(v8_str(isolate, "collectSample"))) {
if (name->Equals(context, v8_str(isolate, "collectSample")).FromJust()) {
return v8::FunctionTemplate::New(isolate, ProfilerExtension::CollectSample);
}
UNREACHABLE();
......
......@@ -7728,13 +7728,15 @@ static int lookup_count = 0;
v8::Local<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<String> name) {
lookup_count++;
if (name->StrictEquals(v8_str("A"))) {
if (name->Equals(isolate->GetCurrentContext(), v8_str("A")).FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 8));
} else if (name->StrictEquals(v8_str("B"))) {
} else if (name->Equals(isolate->GetCurrentContext(), v8_str("B"))
.FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 7));
} else if (name->StrictEquals(v8_str("C"))) {
} else if (name->Equals(isolate->GetCurrentContext(), v8_str("C"))
.FromJust()) {
return v8::FunctionTemplate::New(isolate, CallFun,
v8::Integer::New(isolate, 6));
} else {
......
......@@ -43,24 +43,29 @@ const char* TraceExtension::kSource =
v8::Local<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Local<v8::String> name) {
if (name->StrictEquals(
v8::String::NewFromUtf8(isolate, "trace", v8::NewStringType::kNormal)
.ToLocalChecked())) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
if (name->Equals(context, v8::String::NewFromUtf8(isolate, "trace",
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, TraceExtension::Trace);
} else if (name->StrictEquals(
v8::String::NewFromUtf8(isolate, "js_trace",
v8::NewStringType::kNormal)
.ToLocalChecked())) {
} else if (name->Equals(context,
v8::String::NewFromUtf8(isolate, "js_trace",
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace);
} else if (name->StrictEquals(
v8::String::NewFromUtf8(isolate, "js_entry_sp",
v8::NewStringType::kNormal)
.ToLocalChecked())) {
} else if (name->Equals(context,
v8::String::NewFromUtf8(isolate, "js_entry_sp",
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP);
} else if (name->StrictEquals(
v8::String::NewFromUtf8(isolate, "js_entry_sp_level2",
v8::NewStringType::kNormal)
.ToLocalChecked())) {
} else if (name->Equals(context,
v8::String::NewFromUtf8(isolate, "js_entry_sp_level2",
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromJust()) {
return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2);
}
UNREACHABLE();
......
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