xref: /third_party/node/deps/v8/src/compiler/osr.h (revision 1cb0ef41)
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
10namespace v8 {
11namespace internal {
12
13class OptimizedCompilationInfo;
14
15namespace compiler {
16
17class Frame;
18
19// Encapsulates logic relating to OSR compilations as well has handles some
20// details of the frame layout.
21class 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.
29  size_t UnoptimizedFrameSlots() { return stack_slot_count_; }
30
31  // Returns the environment index of the first stack slot.
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