11cb0ef41Sopenharmony_ci// Copyright 2016 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_INTERPRETER_BYTECODE_FLAGS_H_
61cb0ef41Sopenharmony_ci#define V8_INTERPRETER_BYTECODE_FLAGS_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/base/bit-field.h"
91cb0ef41Sopenharmony_ci#include "src/common/globals.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cinamespace v8 {
121cb0ef41Sopenharmony_cinamespace internal {
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci// Forward declarations.
151cb0ef41Sopenharmony_ciclass Literal;
161cb0ef41Sopenharmony_ciclass AstStringConstants;
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cinamespace interpreter {
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciclass CreateArrayLiteralFlags {
211cb0ef41Sopenharmony_ci public:
221cb0ef41Sopenharmony_ci  using FlagsBits = base::BitField8<int, 0, 5>;
231cb0ef41Sopenharmony_ci  using FastCloneSupportedBit = FlagsBits::Next<bool, 1>;
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  static uint8_t Encode(bool use_fast_shallow_clone, int runtime_flags);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci private:
281cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(CreateArrayLiteralFlags);
291cb0ef41Sopenharmony_ci};
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciclass CreateObjectLiteralFlags {
321cb0ef41Sopenharmony_ci public:
331cb0ef41Sopenharmony_ci  using FlagsBits = base::BitField8<int, 0, 5>;
341cb0ef41Sopenharmony_ci  using FastCloneSupportedBit = FlagsBits::Next<bool, 1>;
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  static uint8_t Encode(int runtime_flags, bool fast_clone_supported);
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci private:
391cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(CreateObjectLiteralFlags);
401cb0ef41Sopenharmony_ci};
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciclass CreateClosureFlags {
431cb0ef41Sopenharmony_ci public:
441cb0ef41Sopenharmony_ci  using PretenuredBit = base::BitField8<bool, 0, 1>;
451cb0ef41Sopenharmony_ci  using FastNewClosureBit = PretenuredBit::Next<bool, 1>;
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci  static uint8_t Encode(bool pretenure, bool is_function_scope,
481cb0ef41Sopenharmony_ci                        bool might_always_opt);
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci private:
511cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(CreateClosureFlags);
521cb0ef41Sopenharmony_ci};
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci#define TYPEOF_LITERAL_LIST(V) \
551cb0ef41Sopenharmony_ci  V(Number, number)            \
561cb0ef41Sopenharmony_ci  V(String, string)            \
571cb0ef41Sopenharmony_ci  V(Symbol, symbol)            \
581cb0ef41Sopenharmony_ci  V(Boolean, boolean)          \
591cb0ef41Sopenharmony_ci  V(BigInt, bigint)            \
601cb0ef41Sopenharmony_ci  V(Undefined, undefined)      \
611cb0ef41Sopenharmony_ci  V(Function, function)        \
621cb0ef41Sopenharmony_ci  V(Object, object)            \
631cb0ef41Sopenharmony_ci  V(Other, other)
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ciclass TestTypeOfFlags {
661cb0ef41Sopenharmony_ci public:
671cb0ef41Sopenharmony_ci  enum class LiteralFlag : uint8_t {
681cb0ef41Sopenharmony_ci#define DECLARE_LITERAL_FLAG(name, _) k##name,
691cb0ef41Sopenharmony_ci    TYPEOF_LITERAL_LIST(DECLARE_LITERAL_FLAG)
701cb0ef41Sopenharmony_ci#undef DECLARE_LITERAL_FLAG
711cb0ef41Sopenharmony_ci  };
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ci  static LiteralFlag GetFlagForLiteral(const AstStringConstants* ast_constants,
741cb0ef41Sopenharmony_ci                                       Literal* literal);
751cb0ef41Sopenharmony_ci  static uint8_t Encode(LiteralFlag literal_flag);
761cb0ef41Sopenharmony_ci  static LiteralFlag Decode(uint8_t raw_flag);
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci private:
791cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(TestTypeOfFlags);
801cb0ef41Sopenharmony_ci};
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ciclass StoreLookupSlotFlags {
831cb0ef41Sopenharmony_ci public:
841cb0ef41Sopenharmony_ci  using LanguageModeBit = base::BitField8<LanguageMode, 0, 1>;
851cb0ef41Sopenharmony_ci  using LookupHoistingModeBit = LanguageModeBit::Next<bool, 1>;
861cb0ef41Sopenharmony_ci  STATIC_ASSERT(LanguageModeSize <= LanguageModeBit::kNumValues);
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci  static uint8_t Encode(LanguageMode language_mode,
891cb0ef41Sopenharmony_ci                        LookupHoistingMode lookup_hoisting_mode);
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci private:
921cb0ef41Sopenharmony_ci  DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLookupSlotFlags);
931cb0ef41Sopenharmony_ci};
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ci}  // namespace interpreter
961cb0ef41Sopenharmony_ci}  // namespace internal
971cb0ef41Sopenharmony_ci}  // namespace v8
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci#endif  // V8_INTERPRETER_BYTECODE_FLAGS_H_
100