• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_COMPILER_OSR_H_
6 #define V8_COMPILER_OSR_H_
7 
8 #include "src/zone/zone.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 class OptimizedCompilationInfo;
14 
15 namespace compiler {
16 
17 class Frame;
18 
19 // Encapsulates logic relating to OSR compilations as well has handles some
20 // details of the frame layout.
21 class OsrHelper {
22  public:
23   explicit OsrHelper(OptimizedCompilationInfo* info);
24 
25   // Prepares the frame w.r.t. OSR.
26   void SetupFrame(Frame* frame);
27 
28   // Returns the number of unoptimized frame slots for this OSR.
UnoptimizedFrameSlots()29   size_t UnoptimizedFrameSlots() { return stack_slot_count_; }
30 
31   // Returns the environment index of the first stack slot.
FirstStackSlotIndex(int parameter_count)32   static int FirstStackSlotIndex(int parameter_count) {
33     // TurboFan environments do not contain the context.
34     return 1 + parameter_count;  // receiver + params
35   }
36 
37  private:
38   size_t parameter_count_;
39   size_t stack_slot_count_;
40 };
41 
42 }  // namespace compiler
43 }  // namespace internal
44 }  // namespace v8
45 
46 #endif  // V8_COMPILER_OSR_H_
47