• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_RUNTIME_PROFILER_H_
6 #define V8_RUNTIME_PROFILER_H_
7 
8 #include "src/allocation.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 class Isolate;
14 class JavaScriptFrame;
15 class JSFunction;
16 enum class OptimizationReason : uint8_t;
17 
18 class RuntimeProfiler {
19  public:
20   explicit RuntimeProfiler(Isolate* isolate);
21 
22   void MarkCandidatesForOptimization();
23 
NotifyICChanged()24   void NotifyICChanged() { any_ic_changed_ = true; }
25 
26   void AttemptOnStackReplacement(JavaScriptFrame* frame,
27                                  int nesting_levels = 1);
28 
29  private:
30   void MaybeOptimizeFullCodegen(JSFunction* function, JavaScriptFrame* frame,
31                                 int frame_count);
32   void MaybeBaselineIgnition(JSFunction* function, JavaScriptFrame* frame);
33   void MaybeOptimizeIgnition(JSFunction* function, JavaScriptFrame* frame);
34   // Potentially attempts OSR from ignition and returns whether no other
35   // optimization attempts should be made.
36   bool MaybeOSRIgnition(JSFunction* function, JavaScriptFrame* frame);
37   OptimizationReason ShouldOptimizeIgnition(JSFunction* function,
38                                             JavaScriptFrame* frame);
39   void Optimize(JSFunction* function, OptimizationReason reason);
40   void Baseline(JSFunction* function, OptimizationReason reason);
41 
42   Isolate* isolate_;
43   bool any_ic_changed_;
44 };
45 
46 }  // namespace internal
47 }  // namespace v8
48 
49 #endif  // V8_RUNTIME_PROFILER_H_
50