#include "src/execution/tiering-manager.h"
#include <optional>
#include "src/base/platform/platform.h"
#include "src/baseline/baseline.h"
#include "src/codegen/assembler.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/codegen/pending-optimization-table.h"
#include "src/common/globals.h"
#include "src/diagnostics/code-tracer.h"
#include "src/execution/execution.h"
#include "src/execution/frames-inl.h"
#include "src/flags/flags.h"
#include "src/handles/global-handles.h"
#include "src/init/bootstrapper.h"
#include "src/interpreter/interpreter.h"
#include "src/objects/code-kind.h"
#include "src/objects/code.h"
#include "src/tracing/trace-event.h"
#ifdef V8_ENABLE_SPARKPLUG
#include "src/baseline/baseline-batch-compiler.h"
#endif
namespace v8 {
namespace internal {
#define OPTIMIZATION_REASON_LIST …
enum class OptimizationReason : uint8_t { … };
char const* OptimizationReasonToString(OptimizationReason reason) { … }
#undef OPTIMIZATION_REASON_LIST
std::ostream& operator<<(std::ostream& os, OptimizationReason reason) { … }
class OptimizationDecision { … };
static_assert …;
namespace {
void TraceInOptimizationQueue(Tagged<JSFunction> function,
CodeKind current_code_kind) { … }
void TraceHeuristicOptimizationDisallowed(Tagged<JSFunction> function) { … }
void TraceRecompile(Isolate* isolate, Tagged<JSFunction> function,
OptimizationDecision d) { … }
}
void TraceManualRecompile(Tagged<JSFunction> function, CodeKind code_kind,
ConcurrencyMode concurrency_mode) { … }
void TieringManager::Optimize(Tagged<JSFunction> function,
OptimizationDecision d) { … }
void TieringManager::MarkForTurboFanOptimization(Tagged<JSFunction> function) { … }
namespace {
bool FirstTimeTierUpToSparkplug(Isolate* isolate, Tagged<JSFunction> function) { … }
bool TieringOrTieredUpToOptimizedTier(Tagged<FeedbackVector> vector) { … }
bool TiersUpToMaglev(CodeKind code_kind) { … }
bool TiersUpToMaglev(std::optional<CodeKind> code_kind) { … }
int InterruptBudgetFor(std::optional<CodeKind> code_kind,
TieringState tiering_state,
CachedTieringDecision cached_tiering_decision,
int bytecode_length) { … }
}
int TieringManager::InterruptBudgetFor(
Isolate* isolate, Tagged<JSFunction> function,
std::optional<CodeKind> override_active_tier) { … }
namespace {
void TrySetOsrUrgency(Isolate* isolate, Tagged<JSFunction> function,
int osr_urgency) { … }
void TryIncrementOsrUrgency(Isolate* isolate, Tagged<JSFunction> function) { … }
void TryRequestOsrAtNextOpportunity(Isolate* isolate,
Tagged<JSFunction> function) { … }
}
void TieringManager::RequestOsrAtNextOpportunity(Tagged<JSFunction> function) { … }
void TieringManager::MaybeOptimizeFrame(Tagged<JSFunction> function,
CodeKind current_code_kind) { … }
OptimizationDecision TieringManager::ShouldOptimize(
Tagged<FeedbackVector> feedback_vector, CodeKind current_code_kind) { … }
namespace {
bool ShouldResetInterruptBudgetByICChange(
CachedTieringDecision cached_tiering_decision) { … }
}
void TieringManager::NotifyICChanged(Tagged<FeedbackVector> vector) { … }
TieringManager::OnInterruptTickScope::OnInterruptTickScope() { … }
void TieringManager::OnInterruptTick(DirectHandle<JSFunction> function,
CodeKind code_kind) { … }
}
}