Commit bfc8950e authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[compiler] Fix --stress-concurrent-inlining

.. when concurrent recompilation is disabled by indirect means, e.g.
when --trace-turbo-graph is enabled.

Drive-by: Add an explicit isolate argument to GetOptimizedCode.

Bug: chromium:1204624
Change-Id: Iee4c10e60643473dbbe2b777ea8dbc0bc259282c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2866767Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74349}
parent 4484a80f
...@@ -1150,14 +1150,13 @@ enum class GetOptimizedCodeResultHandling { ...@@ -1150,14 +1150,13 @@ enum class GetOptimizedCodeResultHandling {
}; };
MaybeHandle<Code> GetOptimizedCode( MaybeHandle<Code> GetOptimizedCode(
Handle<JSFunction> function, ConcurrencyMode mode, CodeKind code_kind, Isolate* isolate, Handle<JSFunction> function, ConcurrencyMode mode,
BytecodeOffset osr_offset = BytecodeOffset::None(), CodeKind code_kind, BytecodeOffset osr_offset = BytecodeOffset::None(),
JavaScriptFrame* osr_frame = nullptr, JavaScriptFrame* osr_frame = nullptr,
GetOptimizedCodeResultHandling result_handling = GetOptimizedCodeResultHandling result_handling =
GetOptimizedCodeResultHandling::kDefault) { GetOptimizedCodeResultHandling::kDefault) {
DCHECK(CodeKindIsOptimizedJSFunction(code_kind)); DCHECK(CodeKindIsOptimizedJSFunction(code_kind));
Isolate* isolate = function->GetIsolate();
Handle<SharedFunctionInfo> shared(function->shared(), isolate); Handle<SharedFunctionInfo> shared(function->shared(), isolate);
// Make sure we clear the optimization marker on the function so that we // Make sure we clear the optimization marker on the function so that we
...@@ -1241,13 +1240,16 @@ MaybeHandle<Code> GetOptimizedCode( ...@@ -1241,13 +1240,16 @@ MaybeHandle<Code> GetOptimizedCode(
// addition to non-concurrent compiles to increase coverage in mjsunit tests // addition to non-concurrent compiles to increase coverage in mjsunit tests
// (where most interesting compiles are non-concurrent). The result of the // (where most interesting compiles are non-concurrent). The result of the
// compilation is thrown out. // compilation is thrown out.
void SpawnDuplicateConcurrentJobForStressTesting(Handle<JSFunction> function, void SpawnDuplicateConcurrentJobForStressTesting(Isolate* isolate,
Handle<JSFunction> function,
ConcurrencyMode mode, ConcurrencyMode mode,
CodeKind code_kind) { CodeKind code_kind) {
DCHECK(FLAG_stress_concurrent_inlining && FLAG_concurrent_recompilation && DCHECK(FLAG_stress_concurrent_inlining &&
mode == ConcurrencyMode::kNotConcurrent); isolate->concurrent_recompilation_enabled() &&
USE(GetOptimizedCode(function, ConcurrencyMode::kConcurrent, code_kind, mode == ConcurrencyMode::kNotConcurrent &&
BytecodeOffset::None(), nullptr, isolate->node_observer() == nullptr);
USE(GetOptimizedCode(isolate, function, ConcurrencyMode::kConcurrent,
code_kind, BytecodeOffset::None(), nullptr,
GetOptimizedCodeResultHandling::kDiscardForTesting)); GetOptimizedCodeResultHandling::kDiscardForTesting));
} }
...@@ -1967,15 +1969,16 @@ bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function, ...@@ -1967,15 +1969,16 @@ bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function,
const CodeKind code_kind = CodeKindForTopTier(); const CodeKind code_kind = CodeKindForTopTier();
const ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent; const ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent;
if (FLAG_stress_concurrent_inlining && FLAG_concurrent_recompilation && if (FLAG_stress_concurrent_inlining &&
isolate->concurrent_recompilation_enabled() &&
concurrency_mode == ConcurrencyMode::kNotConcurrent && concurrency_mode == ConcurrencyMode::kNotConcurrent &&
isolate->node_observer() == nullptr) { isolate->node_observer() == nullptr) {
SpawnDuplicateConcurrentJobForStressTesting(function, concurrency_mode, SpawnDuplicateConcurrentJobForStressTesting(isolate, function,
code_kind); concurrency_mode, code_kind);
} }
Handle<Code> maybe_code; Handle<Code> maybe_code;
if (GetOptimizedCode(function, concurrency_mode, code_kind) if (GetOptimizedCode(isolate, function, concurrency_mode, code_kind)
.ToHandle(&maybe_code)) { .ToHandle(&maybe_code)) {
code = maybe_code; code = maybe_code;
} }
...@@ -2072,14 +2075,16 @@ bool Compiler::CompileOptimized(Isolate* isolate, Handle<JSFunction> function, ...@@ -2072,14 +2075,16 @@ bool Compiler::CompileOptimized(Isolate* isolate, Handle<JSFunction> function,
DCHECK(CodeKindIsOptimizedJSFunction(code_kind)); DCHECK(CodeKindIsOptimizedJSFunction(code_kind));
DCHECK(AllowCompilation::IsAllowed(isolate)); DCHECK(AllowCompilation::IsAllowed(isolate));
if (FLAG_stress_concurrent_inlining && FLAG_concurrent_recompilation && if (FLAG_stress_concurrent_inlining &&
isolate->concurrent_recompilation_enabled() &&
mode == ConcurrencyMode::kNotConcurrent && mode == ConcurrencyMode::kNotConcurrent &&
isolate->node_observer() == nullptr) { isolate->node_observer() == nullptr) {
SpawnDuplicateConcurrentJobForStressTesting(function, mode, code_kind); SpawnDuplicateConcurrentJobForStressTesting(isolate, function, mode,
code_kind);
} }
Handle<Code> code; Handle<Code> code;
if (!GetOptimizedCode(function, mode, code_kind).ToHandle(&code)) { if (!GetOptimizedCode(isolate, function, mode, code_kind).ToHandle(&code)) {
// Optimization failed, get the existing code. We could have optimized code // Optimization failed, get the existing code. We could have optimized code
// from a lower tier here. Unoptimized code must exist already if we are // from a lower tier here. Unoptimized code must exist already if we are
// optimizing. // optimizing.
...@@ -3183,12 +3188,13 @@ template Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( ...@@ -3183,12 +3188,13 @@ template Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script, LocalIsolate* isolate); FunctionLiteral* literal, Handle<Script> script, LocalIsolate* isolate);
// static // static
MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function, MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Isolate* isolate,
Handle<JSFunction> function,
BytecodeOffset osr_offset, BytecodeOffset osr_offset,
JavaScriptFrame* osr_frame) { JavaScriptFrame* osr_frame) {
DCHECK(!osr_offset.IsNone()); DCHECK(!osr_offset.IsNone());
DCHECK_NOT_NULL(osr_frame); DCHECK_NOT_NULL(osr_frame);
return GetOptimizedCode(function, ConcurrencyMode::kNotConcurrent, return GetOptimizedCode(isolate, function, ConcurrencyMode::kNotConcurrent,
CodeKindForOSR(), osr_offset, osr_frame); CodeKindForOSR(), osr_offset, osr_frame);
} }
......
...@@ -206,7 +206,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic { ...@@ -206,7 +206,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
// Generate and return optimized code for OSR, or empty handle on failure. // Generate and return optimized code for OSR, or empty handle on failure.
V8_WARN_UNUSED_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR( V8_WARN_UNUSED_RESULT static MaybeHandle<Code> GetOptimizedCodeForOSR(
Handle<JSFunction> function, BytecodeOffset osr_offset, Isolate* isolate, Handle<JSFunction> function, BytecodeOffset osr_offset,
JavaScriptFrame* osr_frame); JavaScriptFrame* osr_frame);
}; };
......
...@@ -311,7 +311,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -311,7 +311,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
PrintF(scope.file(), " at OSR bytecode offset %d]\n", osr_offset.ToInt()); PrintF(scope.file(), " at OSR bytecode offset %d]\n", osr_offset.ToInt());
} }
maybe_result = maybe_result =
Compiler::GetOptimizedCodeForOSR(function, osr_offset, frame); Compiler::GetOptimizedCodeForOSR(isolate, function, osr_offset, frame);
} }
// Check whether we ended up with usable optimized code. // Check whether we ended up with usable optimized code.
......
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