[compiler] Make is_compiled_scope take an explicit Isolate
This will allow it to take an OffThreadIsolate in the future, without requiring GetIsolate on SharedFunctionInfo. Change-Id: I7db56d5f0587585f829b26e60683c133760d8ff1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2282534 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#68696}
This commit is contained in:
parent
aef551aadd
commit
7281cb1d36
@ -642,7 +642,7 @@ bool IterativelyExecuteAndFinalizeUnoptimizedCompilationJobs(
|
||||
|
||||
if (shared_info.is_identical_to(outer_shared_info)) {
|
||||
// Ensure that the top level function is retained.
|
||||
*is_compiled_scope = shared_info->is_compiled_scope();
|
||||
*is_compiled_scope = shared_info->is_compiled_scope(isolate);
|
||||
DCHECK(is_compiled_scope->is_compiled());
|
||||
}
|
||||
}
|
||||
@ -1496,7 +1496,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate,
|
||||
}
|
||||
|
||||
DCHECK(!isolate->has_pending_exception());
|
||||
DCHECK(shared_info->is_compiled_scope().is_compiled());
|
||||
DCHECK(shared_info->is_compiled_scope(isolate).is_compiled());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1536,7 +1536,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
|
||||
if (!dispatcher->FinishNow(shared_info)) {
|
||||
return FailWithPendingException(isolate, script, &parse_info, flag);
|
||||
}
|
||||
*is_compiled_scope = shared_info->is_compiled_scope();
|
||||
*is_compiled_scope = shared_info->is_compiled_scope(isolate);
|
||||
DCHECK(is_compiled_scope->is_compiled());
|
||||
return true;
|
||||
}
|
||||
@ -1589,7 +1589,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag,
|
||||
Handle<SharedFunctionInfo> shared_info = handle(function->shared(), isolate);
|
||||
|
||||
// Ensure shared function info is compiled.
|
||||
*is_compiled_scope = shared_info->is_compiled_scope();
|
||||
*is_compiled_scope = shared_info->is_compiled_scope(isolate);
|
||||
if (!is_compiled_scope->is_compiled() &&
|
||||
!Compile(shared_info, flag, is_compiled_scope)) {
|
||||
return false;
|
||||
@ -1747,7 +1747,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
|
||||
if (eval_result.has_shared()) {
|
||||
shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate);
|
||||
script = Handle<Script>(Script::cast(shared_info->script()), isolate);
|
||||
is_compiled_scope = shared_info->is_compiled_scope();
|
||||
is_compiled_scope = shared_info->is_compiled_scope(isolate);
|
||||
allow_eval_cache = true;
|
||||
} else {
|
||||
UnoptimizedCompileFlags flags = UnoptimizedCompileFlags::ForToplevelCompile(
|
||||
@ -2322,7 +2322,7 @@ MaybeHandle<SharedFunctionInfo> CompileScriptOnBothBackgroundAndMainThread(
|
||||
|
||||
Handle<SharedFunctionInfo> result;
|
||||
if (maybe_result.ToHandle(&result)) {
|
||||
*is_compiled_scope = result->is_compiled_scope();
|
||||
*is_compiled_scope = result->is_compiled_scope(isolate);
|
||||
}
|
||||
|
||||
return maybe_result;
|
||||
@ -2384,7 +2384,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
|
||||
.ToHandle(&inner_result) &&
|
||||
inner_result->is_compiled()) {
|
||||
// Promote to per-isolate compilation cache.
|
||||
is_compiled_scope = inner_result->is_compiled_scope();
|
||||
is_compiled_scope = inner_result->is_compiled_scope(isolate);
|
||||
DCHECK(is_compiled_scope.is_compiled());
|
||||
compilation_cache->PutScript(source, isolate->native_context(),
|
||||
language_mode, inner_result);
|
||||
@ -2516,7 +2516,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
|
||||
}
|
||||
DCHECK(!wrapped.is_null());
|
||||
} else {
|
||||
is_compiled_scope = wrapped->is_compiled_scope();
|
||||
is_compiled_scope = wrapped->is_compiled_scope(isolate);
|
||||
script = Handle<Script>(Script::cast(wrapped->script()), isolate);
|
||||
}
|
||||
DCHECK(is_compiled_scope.is_compiled());
|
||||
@ -2762,7 +2762,7 @@ bool Compiler::FinalizeOptimizedCompilationJob(OptimizedCompilationJob* job,
|
||||
void Compiler::PostInstantiation(Handle<JSFunction> function) {
|
||||
Isolate* isolate = function->GetIsolate();
|
||||
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
|
||||
|
||||
// If code is compiled to bytecode (i.e., isn't asm.js), then allocate a
|
||||
// feedback and check for optimized code.
|
||||
|
@ -793,7 +793,8 @@ void Coverage::SelectMode(Isolate* isolate, debug::CoverageMode mode) {
|
||||
}
|
||||
|
||||
for (Handle<JSFunction> func : funcs_needing_feedback_vector) {
|
||||
IsCompiledScope is_compiled_scope(func->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
func->shared().is_compiled_scope(isolate));
|
||||
CHECK(is_compiled_scope.is_compiled());
|
||||
JSFunction::EnsureFeedbackVector(func, &is_compiled_scope);
|
||||
}
|
||||
|
@ -1428,7 +1428,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
|
||||
|
||||
bool was_compiled = false;
|
||||
for (const auto& candidate : candidates) {
|
||||
IsCompiledScope is_compiled_scope(candidate->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(candidate->is_compiled_scope(isolate_));
|
||||
if (!is_compiled_scope.is_compiled()) {
|
||||
// Code that cannot be compiled lazily are internal and not debuggable.
|
||||
DCHECK(candidate->allows_lazy_compilation());
|
||||
@ -1533,7 +1533,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
|
||||
shared = finder.Result();
|
||||
if (shared.is_null()) break;
|
||||
// We found it if it's already compiled.
|
||||
is_compiled_scope = shared.is_compiled_scope();
|
||||
is_compiled_scope = shared.is_compiled_scope(isolate_);
|
||||
if (is_compiled_scope.is_compiled()) {
|
||||
Handle<SharedFunctionInfo> shared_handle(shared, isolate_);
|
||||
// If the iteration count is larger than 1, we had to compile the outer
|
||||
@ -1567,7 +1567,7 @@ bool Debug::EnsureBreakInfo(Handle<SharedFunctionInfo> shared) {
|
||||
if (!shared->IsSubjectToDebugging() && !CanBreakAtEntry(shared)) {
|
||||
return false;
|
||||
}
|
||||
IsCompiledScope is_compiled_scope = shared->is_compiled_scope();
|
||||
IsCompiledScope is_compiled_scope = shared->is_compiled_scope(isolate_);
|
||||
if (!is_compiled_scope.is_compiled() &&
|
||||
!Compiler::Compile(shared, Compiler::CLEAR_EXCEPTION,
|
||||
&is_compiled_scope)) {
|
||||
@ -2272,7 +2272,8 @@ bool Debug::PerformSideEffectCheck(Handle<JSFunction> function,
|
||||
Handle<Object> receiver) {
|
||||
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
|
||||
DisallowJavascriptExecution no_js(isolate_);
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(isolate_));
|
||||
if (!function->is_compiled() &&
|
||||
!Compiler::Compile(function, Compiler::KEEP_EXCEPTION,
|
||||
&is_compiled_scope)) {
|
||||
|
@ -1154,7 +1154,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
|
||||
*isolate->factory()->many_closures_cell());
|
||||
if (!js_function->is_compiled()) continue;
|
||||
IsCompiledScope is_compiled_scope(
|
||||
js_function->shared().is_compiled_scope());
|
||||
js_function->shared().is_compiled_scope(isolate));
|
||||
JSFunction::EnsureFeedbackVector(js_function, &is_compiled_scope);
|
||||
}
|
||||
|
||||
@ -1197,7 +1197,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
|
||||
*isolate->factory()->many_closures_cell());
|
||||
if (!js_function->is_compiled()) continue;
|
||||
IsCompiledScope is_compiled_scope(
|
||||
js_function->shared().is_compiled_scope());
|
||||
js_function->shared().is_compiled_scope(isolate));
|
||||
JSFunction::EnsureFeedbackVector(js_function, &is_compiled_scope);
|
||||
}
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ uint32_t CompilationCacheShape::HashForObject(ReadOnlyRoots roots,
|
||||
Smi::cast(val.get(JSRegExp::kFlagsIndex)));
|
||||
}
|
||||
|
||||
InfoCellPair::InfoCellPair(SharedFunctionInfo shared,
|
||||
InfoCellPair::InfoCellPair(Isolate* isolate, SharedFunctionInfo shared,
|
||||
FeedbackCell feedback_cell)
|
||||
: is_compiled_scope_(!shared.is_null() ? shared.is_compiled_scope()
|
||||
: is_compiled_scope_(!shared.is_null() ? shared.is_compiled_scope(isolate)
|
||||
: IsCompiledScope()),
|
||||
shared_(shared),
|
||||
feedback_cell_(feedback_cell) {}
|
||||
|
@ -43,7 +43,8 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> {
|
||||
class InfoCellPair {
|
||||
public:
|
||||
InfoCellPair() = default;
|
||||
inline InfoCellPair(SharedFunctionInfo shared, FeedbackCell feedback_cell);
|
||||
inline InfoCellPair(Isolate* isolate, SharedFunctionInfo shared,
|
||||
FeedbackCell feedback_cell);
|
||||
|
||||
FeedbackCell feedback_cell() const {
|
||||
DCHECK(is_compiled_scope_.is_compiled());
|
||||
|
@ -338,7 +338,7 @@ Handle<FeedbackVector> NewFeedbackVectorForTesting(
|
||||
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array =
|
||||
ClosureFeedbackCellArray::New(isolate, shared);
|
||||
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
|
||||
return FeedbackVector::New(isolate, shared, closure_feedback_cell_array,
|
||||
&is_compiled_scope);
|
||||
}
|
||||
|
@ -5589,7 +5589,7 @@ int JSFunction::CalculateExpectedNofProperties(Isolate* isolate,
|
||||
// The super constructor should be compiled for the number of expected
|
||||
// properties to be available.
|
||||
Handle<SharedFunctionInfo> shared(func->shared(), isolate);
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
|
||||
if (is_compiled_scope.is_compiled() ||
|
||||
Compiler::Compile(func, Compiler::CLEAR_EXCEPTION,
|
||||
&is_compiled_scope)) {
|
||||
|
@ -7226,7 +7226,7 @@ InfoCellPair CompilationCacheTable::LookupEval(
|
||||
if (obj.IsSharedFunctionInfo()) {
|
||||
FeedbackCell feedback_cell =
|
||||
SearchLiteralsMap(*table, index + 2, *native_context);
|
||||
return InfoCellPair(SharedFunctionInfo::cast(obj), feedback_cell);
|
||||
return InfoCellPair(isolate, SharedFunctionInfo::cast(obj), feedback_cell);
|
||||
}
|
||||
return empty_result;
|
||||
}
|
||||
|
@ -414,8 +414,8 @@ bool SharedFunctionInfo::is_compiled() const {
|
||||
!data.IsUncompiledData();
|
||||
}
|
||||
|
||||
IsCompiledScope SharedFunctionInfo::is_compiled_scope() const {
|
||||
return IsCompiledScope(*this, GetIsolate());
|
||||
IsCompiledScope SharedFunctionInfo::is_compiled_scope(Isolate* isolate) const {
|
||||
return IsCompiledScope(*this, isolate);
|
||||
}
|
||||
|
||||
IsCompiledScope::IsCompiledScope(const SharedFunctionInfo shared,
|
||||
|
@ -260,7 +260,7 @@ class SharedFunctionInfo : public HeapObject {
|
||||
// Returns an IsCompiledScope which reports whether the function is compiled,
|
||||
// and if compiled, will avoid the function becoming uncompiled while it is
|
||||
// held.
|
||||
inline IsCompiledScope is_compiled_scope() const;
|
||||
inline IsCompiledScope is_compiled_scope(Isolate* isolate) const;
|
||||
|
||||
// [length]: The function length - usually the number of declared parameters.
|
||||
// Use up to 2^16-2 parameters (16 bits of values, where one is reserved for
|
||||
|
@ -332,7 +332,8 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterrupt) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
|
||||
function->raw_feedback_cell().set_interrupt_budget(FLAG_interrupt_budget);
|
||||
if (!function->has_feedback_vector()) {
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(isolate));
|
||||
JSFunction::EnsureFeedbackVector(function, &is_compiled_scope);
|
||||
// Also initialize the invocation count here. This is only really needed for
|
||||
// OSR. When we OSR functions with lazy feedback allocation we want to have
|
||||
|
@ -269,7 +269,8 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
|
||||
}
|
||||
|
||||
// If function isn't compiled, compile it now.
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(isolate));
|
||||
if (!is_compiled_scope.is_compiled() &&
|
||||
!Compiler::Compile(function, Compiler::CLEAR_EXCEPTION,
|
||||
&is_compiled_scope)) {
|
||||
@ -338,7 +339,8 @@ bool EnsureFeedbackVector(Handle<JSFunction> function) {
|
||||
if (function->has_feedback_vector()) return true;
|
||||
|
||||
// If function isn't compiled, compile it now.
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(function->GetIsolate()));
|
||||
// If the JSFunction isn't compiled but it has a initialized feedback cell
|
||||
// then no need to compile. CompileLazy builtin would handle these cases by
|
||||
// installing the code from SFI. Calling compile here may cause another
|
||||
@ -458,7 +460,8 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
|
||||
function->ShortPrint(scope.file());
|
||||
PrintF(scope.file(), " for non-concurrent optimization]\n");
|
||||
}
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(isolate));
|
||||
JSFunction::EnsureFeedbackVector(function, &is_compiled_scope);
|
||||
function->MarkForOptimization(ConcurrencyMode::kNotConcurrent);
|
||||
|
||||
|
@ -250,7 +250,7 @@ i::Handle<i::JSFunction> Optimize(
|
||||
i::Handle<i::JSFunction> function, i::Zone* zone, i::Isolate* isolate,
|
||||
uint32_t flags, std::unique_ptr<i::compiler::JSHeapBroker>* out_broker) {
|
||||
i::Handle<i::SharedFunctionInfo> shared(function->shared(), isolate);
|
||||
i::IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
i::IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
|
||||
CHECK(is_compiled_scope.is_compiled() ||
|
||||
i::Compiler::Compile(function, i::Compiler::CLEAR_EXCEPTION,
|
||||
&is_compiled_scope));
|
||||
|
@ -117,7 +117,8 @@ class BytecodeGraphTester {
|
||||
.ToLocalChecked());
|
||||
Handle<JSFunction> function =
|
||||
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(isolate_));
|
||||
JSFunction::EnsureFeedbackVector(function, &is_compiled_scope);
|
||||
CHECK(function->shared().HasBytecodeArray());
|
||||
|
||||
|
@ -1247,7 +1247,8 @@ HEAP_TEST(Regress10560) {
|
||||
heap);
|
||||
|
||||
// Allocate feedback vector.
|
||||
IsCompiledScope is_compiled_scope(function->shared().is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(
|
||||
function->shared().is_compiled_scope(i_isolate));
|
||||
JSFunction::EnsureFeedbackVector(function, &is_compiled_scope);
|
||||
|
||||
CHECK(function->has_feedback_vector());
|
||||
|
@ -137,7 +137,7 @@ class InterpreterTester {
|
||||
->Get(context, v8_str(kFunctionName))
|
||||
.ToLocalChecked());
|
||||
function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
|
||||
is_compiled_scope = function->shared().is_compiled_scope();
|
||||
is_compiled_scope = function->shared().is_compiled_scope(isolate_);
|
||||
} else {
|
||||
int arg_count = sizeof...(A);
|
||||
std::string source("(function " + function_name() + "(");
|
||||
@ -148,12 +148,12 @@ class InterpreterTester {
|
||||
function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
||||
*v8::Local<v8::Function>::Cast(CompileRun(source.c_str()))));
|
||||
function->set_code(*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline));
|
||||
is_compiled_scope = function->shared().is_compiled_scope();
|
||||
is_compiled_scope = function->shared().is_compiled_scope(isolate_);
|
||||
}
|
||||
|
||||
if (!bytecode_.is_null()) {
|
||||
function->shared().set_function_data(*bytecode_.ToHandleChecked());
|
||||
is_compiled_scope = function->shared().is_compiled_scope();
|
||||
is_compiled_scope = function->shared().is_compiled_scope(isolate_);
|
||||
}
|
||||
if (HasFeedbackMetadata()) {
|
||||
function->set_raw_feedback_cell(isolate_->heap()->many_closures_cell());
|
||||
|
@ -51,7 +51,7 @@ Handle<FeedbackVector> NewFeedbackVector(Isolate* isolate, Spec* spec) {
|
||||
shared->set_raw_outer_scope_info_or_feedback_metadata(*metadata);
|
||||
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array =
|
||||
ClosureFeedbackCellArray::New(isolate, shared);
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate));
|
||||
return FeedbackVector::New(isolate, shared, closure_feedback_cell_array,
|
||||
&is_compiled_scope);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class JSCallReducerTest : public TypedGraphTest {
|
||||
shared->set_raw_outer_scope_info_or_feedback_metadata(*metadata);
|
||||
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array =
|
||||
ClosureFeedbackCellArray::New(isolate(), shared);
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate()));
|
||||
Handle<FeedbackVector> vector = FeedbackVector::New(
|
||||
isolate(), shared, closure_feedback_cell_array, &is_compiled_scope);
|
||||
FeedbackSource feedback(vector, FeedbackSlot(0));
|
||||
|
@ -39,7 +39,7 @@ class RedundancyEliminationTest : public GraphTest {
|
||||
shared->set_raw_outer_scope_info_or_feedback_metadata(*metadata);
|
||||
Handle<ClosureFeedbackCellArray> closure_feedback_cell_array =
|
||||
ClosureFeedbackCellArray::New(isolate(), shared);
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope());
|
||||
IsCompiledScope is_compiled_scope(shared->is_compiled_scope(isolate()));
|
||||
Handle<FeedbackVector> feedback_vector = FeedbackVector::New(
|
||||
isolate(), shared, closure_feedback_cell_array, &is_compiled_scope);
|
||||
vector_slot_pairs_.push_back(FeedbackSource());
|
||||
|
Loading…
Reference in New Issue
Block a user