[sparkplug] Clean up CodeKind predicates
Baseline code is, like baseline frames, now considered unoptimized, sharing this name with interpreted code. Bug: v8:11420,v8:11429 Change-Id: If1f4a41725dd0d809a4412f5d2f827d19f9628fe Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2713102 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#72959}
This commit is contained in:
parent
9cdff48c4b
commit
9070b2cb86
@ -1261,7 +1261,7 @@ class DiscardBaselineCodeVisitor : public ThreadVisitor {
|
||||
} // namespace
|
||||
|
||||
void Debug::DiscardBaselineCode(SharedFunctionInfo shared) {
|
||||
DCHECK_EQ(shared.GetCode().kind(), CodeKind::BASELINE);
|
||||
DCHECK(shared.HasBaselineData());
|
||||
Isolate* isolate = shared.GetIsolate();
|
||||
DiscardBaselineCodeVisitor visitor(shared);
|
||||
visitor.VisitThread(isolate, isolate->thread_local_top());
|
||||
@ -1274,7 +1274,7 @@ void Debug::DiscardBaselineCode(SharedFunctionInfo shared) {
|
||||
obj = iterator.Next()) {
|
||||
if (obj.IsJSFunction()) {
|
||||
JSFunction fun = JSFunction::cast(obj);
|
||||
if (fun.shared() == shared && fun.code().kind() == CodeKind::BASELINE) {
|
||||
if (fun.shared() == shared && fun.ActiveTierIsBaseline()) {
|
||||
fun.set_code(*trampoline);
|
||||
}
|
||||
}
|
||||
|
@ -1361,7 +1361,6 @@ FrameSummary::JavaScriptFrameSummary::JavaScriptFrameSummary(
|
||||
is_constructor_(is_constructor),
|
||||
parameters_(parameters, isolate) {
|
||||
DCHECK(abstract_code.IsBytecodeArray() ||
|
||||
Code::cast(abstract_code).kind() == CodeKind::BASELINE ||
|
||||
!CodeKindIsOptimizedJSFunction(Code::cast(abstract_code).kind()));
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#ifndef V8_OBJECTS_CODE_KIND_H_
|
||||
#define V8_OBJECTS_CODE_KIND_H_
|
||||
|
||||
#include "src/base/bounds.h"
|
||||
#include "src/base/flags.h"
|
||||
#include "src/flags/flags.h"
|
||||
|
||||
@ -26,8 +27,8 @@ namespace internal {
|
||||
V(JS_TO_JS_FUNCTION) \
|
||||
V(C_WASM_ENTRY) \
|
||||
V(INTERPRETED_FUNCTION) \
|
||||
V(NATIVE_CONTEXT_INDEPENDENT) \
|
||||
V(BASELINE) \
|
||||
V(NATIVE_CONTEXT_INDEPENDENT) \
|
||||
V(TURBOPROP) \
|
||||
V(TURBOFAN)
|
||||
|
||||
@ -38,8 +39,12 @@ enum class CodeKind {
|
||||
};
|
||||
STATIC_ASSERT(CodeKind::INTERPRETED_FUNCTION < CodeKind::TURBOPROP &&
|
||||
CodeKind::INTERPRETED_FUNCTION <
|
||||
CodeKind::NATIVE_CONTEXT_INDEPENDENT);
|
||||
STATIC_ASSERT(CodeKind::TURBOPROP < CodeKind::TURBOFAN &&
|
||||
CodeKind::NATIVE_CONTEXT_INDEPENDENT &&
|
||||
CodeKind::INTERPRETED_FUNCTION < CodeKind::BASELINE);
|
||||
STATIC_ASSERT(CodeKind::BASELINE < CodeKind::TURBOPROP &&
|
||||
CodeKind::BASELINE < CodeKind::NATIVE_CONTEXT_INDEPENDENT);
|
||||
STATIC_ASSERT(CodeKind::BASELINE < CodeKind::TURBOFAN &&
|
||||
CodeKind::TURBOPROP < CodeKind::TURBOFAN &&
|
||||
CodeKind::NATIVE_CONTEXT_INDEPENDENT < CodeKind::TURBOFAN);
|
||||
|
||||
#define V(...) +1
|
||||
@ -54,19 +59,33 @@ inline constexpr bool CodeKindIsInterpretedJSFunction(CodeKind kind) {
|
||||
return kind == CodeKind::INTERPRETED_FUNCTION;
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindIsBaselinedJSFunction(CodeKind kind) {
|
||||
return kind == CodeKind::BASELINE;
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindIsUnoptimizedJSFunction(CodeKind kind) {
|
||||
STATIC_ASSERT(static_cast<int>(CodeKind::INTERPRETED_FUNCTION) + 1 ==
|
||||
static_cast<int>(CodeKind::BASELINE));
|
||||
return base::IsInRange(kind, CodeKind::INTERPRETED_FUNCTION,
|
||||
CodeKind::BASELINE);
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindIsNativeContextIndependentJSFunction(
|
||||
CodeKind kind) {
|
||||
return kind == CodeKind::NATIVE_CONTEXT_INDEPENDENT;
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindIsOptimizedJSFunction(CodeKind kind) {
|
||||
return kind == CodeKind::TURBOFAN ||
|
||||
kind == CodeKind::NATIVE_CONTEXT_INDEPENDENT ||
|
||||
kind == CodeKind::TURBOPROP;
|
||||
STATIC_ASSERT(static_cast<int>(CodeKind::NATIVE_CONTEXT_INDEPENDENT) + 1 ==
|
||||
static_cast<int>(CodeKind::TURBOPROP));
|
||||
STATIC_ASSERT(static_cast<int>(CodeKind::TURBOPROP) + 1 ==
|
||||
static_cast<int>(CodeKind::TURBOFAN));
|
||||
return base::IsInRange(kind, CodeKind::NATIVE_CONTEXT_INDEPENDENT,
|
||||
CodeKind::TURBOFAN);
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindIsJSFunction(CodeKind kind) {
|
||||
return CodeKindIsInterpretedJSFunction(kind) ||
|
||||
return CodeKindIsUnoptimizedJSFunction(kind) ||
|
||||
CodeKindIsOptimizedJSFunction(kind);
|
||||
}
|
||||
|
||||
@ -87,12 +106,11 @@ inline constexpr bool CodeKindCanOSR(CodeKind kind) {
|
||||
|
||||
inline constexpr bool CodeKindIsOptimizedAndCanTierUp(CodeKind kind) {
|
||||
return kind == CodeKind::NATIVE_CONTEXT_INDEPENDENT ||
|
||||
kind == CodeKind::BASELINE ||
|
||||
(!FLAG_turboprop_as_toptier && kind == CodeKind::TURBOPROP);
|
||||
}
|
||||
|
||||
inline constexpr bool CodeKindCanTierUp(CodeKind kind) {
|
||||
return CodeKindIsInterpretedJSFunction(kind) ||
|
||||
return CodeKindIsUnoptimizedJSFunction(kind) ||
|
||||
CodeKindIsOptimizedAndCanTierUp(kind);
|
||||
}
|
||||
|
||||
|
@ -19,28 +19,22 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
CodeKinds JSFunction::GetAttachedCodeKinds() const {
|
||||
CodeKinds result;
|
||||
|
||||
// Note: There's a special case when bytecode has been aged away. After
|
||||
// flushing the bytecode, the JSFunction will still have the interpreter
|
||||
// entry trampoline attached, but the bytecode is no longer available.
|
||||
Code code = this->code(kAcquireLoad);
|
||||
if (code.is_interpreter_trampoline_builtin()) {
|
||||
result |= CodeKindFlag::INTERPRETED_FUNCTION;
|
||||
return CodeKindFlag::INTERPRETED_FUNCTION;
|
||||
}
|
||||
|
||||
const CodeKind kind = code.kind();
|
||||
if (!CodeKindIsOptimizedJSFunction(kind) ||
|
||||
code.marked_for_deoptimization()) {
|
||||
DCHECK_EQ((result & ~kJSFunctionCodeKindsMask), 0);
|
||||
return result;
|
||||
if (!CodeKindIsJSFunction(kind)) return {};
|
||||
|
||||
if (CodeKindIsOptimizedJSFunction(kind) && code.marked_for_deoptimization()) {
|
||||
// Nothing is attached.
|
||||
return {};
|
||||
}
|
||||
|
||||
DCHECK(CodeKindIsOptimizedJSFunction(kind));
|
||||
result |= CodeKindToCodeKindFlag(kind);
|
||||
|
||||
DCHECK_EQ((result & ~kJSFunctionCodeKindsMask), 0);
|
||||
return result;
|
||||
return CodeKindToCodeKindFlag(kind);
|
||||
}
|
||||
|
||||
CodeKinds JSFunction::GetAvailableCodeKinds() const {
|
||||
@ -82,6 +76,11 @@ bool JSFunction::HasAvailableOptimizedCode() const {
|
||||
return (result & kOptimizedJSFunctionCodeKindsMask) != 0;
|
||||
}
|
||||
|
||||
bool JSFunction::HasAttachedCodeKind(CodeKind kind) const {
|
||||
CodeKinds result = GetAttachedCodeKinds();
|
||||
return (result & CodeKindToCodeKindFlag(kind)) != 0;
|
||||
}
|
||||
|
||||
bool JSFunction::HasAvailableCodeKind(CodeKind kind) const {
|
||||
CodeKinds result = GetAvailableCodeKinds();
|
||||
return (result & CodeKindToCodeKindFlag(kind)) != 0;
|
||||
@ -152,9 +151,7 @@ bool JSFunction::ActiveTierIsNCI() const {
|
||||
}
|
||||
|
||||
bool JSFunction::ActiveTierIsBaseline() const {
|
||||
CodeKind highest_tier;
|
||||
if (!HighestTierOf(GetAvailableCodeKinds(), &highest_tier)) return false;
|
||||
return highest_tier == CodeKind::BASELINE;
|
||||
return GetActiveTier() == CodeKind::BASELINE;
|
||||
}
|
||||
|
||||
bool JSFunction::ActiveTierIsIgnitionOrBaseline() const {
|
||||
|
@ -115,6 +115,7 @@ class JSFunction : public JSFunctionOrBoundFunction {
|
||||
V8_EXPORT_PRIVATE bool HasAttachedOptimizedCode() const;
|
||||
bool HasAvailableOptimizedCode() const;
|
||||
|
||||
bool HasAttachedCodeKind(CodeKind kind) const;
|
||||
bool HasAvailableCodeKind(CodeKind kind) const;
|
||||
|
||||
CodeKind GetActiveTier() const;
|
||||
|
@ -621,8 +621,7 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
|
||||
status |= static_cast<int>(OptimizationStatus::kTurboFanned);
|
||||
}
|
||||
}
|
||||
// TODO(v8:11429): Clean up code kind predicates to include Baseline.
|
||||
if (function->code().kind() == CodeKind::BASELINE) {
|
||||
if (function->HasAttachedCodeKind(CodeKind::BASELINE)) {
|
||||
status |= static_cast<int>(OptimizationStatus::kBaseline);
|
||||
}
|
||||
if (function->ActiveTierIsIgnition()) {
|
||||
|
Loading…
Reference in New Issue
Block a user