tiering-manager.h 2.23 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_EXECUTION_TIERING_MANAGER_H_
#define V8_EXECUTION_TIERING_MANAGER_H_
7

8 9
#include "src/common/assert-scope.h"
#include "src/handles/handles.h"
10
#include "src/utils/allocation.h"
11 12 13 14

namespace v8 {
namespace internal {

15
class BytecodeArray;
16
class Isolate;
17
class UnoptimizedFrame;
18
class JavaScriptFrame;
19
class JSFunction;
20 21
class OptimizationDecision;
enum class CodeKind : uint8_t;
22
enum class OptimizationReason : uint8_t;
23

24 25 26
void TraceManualRecompile(JSFunction function, CodeKind code_kind,
                          ConcurrencyMode concurrency_mode);

27
class TieringManager {
28
 public:
29
  explicit TieringManager(Isolate* isolate) : isolate_(isolate) {}
30

31
  void OnInterruptTick(Handle<JSFunction> function);
32

33 34
  void NotifyICChanged() { any_ic_changed_ = true; }

35 36
  // After this request, the next JumpLoop will perform OSR.
  void RequestOsrAtNextOpportunity(JSFunction function);
37

38 39 40 41 42
  // For use when a JSFunction is available.
  static int InterruptBudgetFor(Isolate* isolate, JSFunction function);
  // For use when no JSFunction is available.
  static int InitialInterruptBudget();

43
 private:
44 45
  // Make the decision whether to optimize the given function, and mark it for
  // optimization if the decision was 'yes'.
46 47
  // This function is also responsible for bumping the OSR urgency.
  void MaybeOptimizeFrame(JSFunction function, UnoptimizedFrame* frame,
48 49
                          CodeKind code_kind);

50 51 52 53
  OptimizationDecision ShouldOptimize(JSFunction function, CodeKind code_kind,
                                      JavaScriptFrame* frame);
  void Optimize(JSFunction function, CodeKind code_kind,
                OptimizationDecision decision);
54
  void Baseline(JSFunction function, OptimizationReason reason);
55

56
  class V8_NODISCARD OnInterruptTickScope final {
57
   public:
58 59
    explicit OnInterruptTickScope(TieringManager* profiler);
    ~OnInterruptTickScope();
60 61

   private:
62
    TieringManager* const profiler_;
63
    DisallowGarbageCollection no_gc;
64 65
  };

66 67
  Isolate* const isolate_;
  bool any_ic_changed_ = false;
68 69
};

70 71
}  // namespace internal
}  // namespace v8
72

73
#endif  // V8_EXECUTION_TIERING_MANAGER_H_