11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_OSR_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_OSR_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/zone/zone.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass OptimizedCompilationInfo;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cinamespace compiler {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciclass Frame;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci// Encapsulates logic relating to OSR compilations as well has handles some
201cb0ef41Sopenharmony_ci// details of the frame layout.
211cb0ef41Sopenharmony_ciclass OsrHelper {
221cb0ef41Sopenharmony_ci public:
231cb0ef41Sopenharmony_ci  explicit OsrHelper(OptimizedCompilationInfo* info);
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  // Prepares the frame w.r.t. OSR.
261cb0ef41Sopenharmony_ci  void SetupFrame(Frame* frame);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  // Returns the number of unoptimized frame slots for this OSR.
291cb0ef41Sopenharmony_ci  size_t UnoptimizedFrameSlots() { return stack_slot_count_; }
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  // Returns the environment index of the first stack slot.
321cb0ef41Sopenharmony_ci  static int FirstStackSlotIndex(int parameter_count) {
331cb0ef41Sopenharmony_ci    // TurboFan environments do not contain the context.
341cb0ef41Sopenharmony_ci    return 1 + parameter_count;  // receiver + params
351cb0ef41Sopenharmony_ci  }
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci private:
381cb0ef41Sopenharmony_ci  size_t parameter_count_;
391cb0ef41Sopenharmony_ci  size_t stack_slot_count_;
401cb0ef41Sopenharmony_ci};
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci}  // namespace compiler
431cb0ef41Sopenharmony_ci}  // namespace internal
441cb0ef41Sopenharmony_ci}  // namespace v8
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_OSR_H_
47