Kaido Kert | f309f9a | 2021-04-30 12:09:15 -0700 | [diff] [blame] | 1 | // Copyright 2016 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_INTERPRETER_BYTECODE_FLAGS_H_ |
| 6 | #define V8_INTERPRETER_BYTECODE_FLAGS_H_ |
| 7 | |
| 8 | #include "src/base/bit-field.h" |
| 9 | #include "src/common/globals.h" |
| 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
| 14 | // Forward declarations. |
| 15 | class Literal; |
| 16 | class AstStringConstants; |
| 17 | |
| 18 | namespace interpreter { |
| 19 | |
| 20 | class CreateArrayLiteralFlags { |
| 21 | public: |
| 22 | using FlagsBits = base::BitField8<int, 0, 5>; |
| 23 | using FastCloneSupportedBit = FlagsBits::Next<bool, 1>; |
| 24 | |
| 25 | static uint8_t Encode(bool use_fast_shallow_clone, int runtime_flags); |
| 26 | |
| 27 | private: |
| 28 | DISALLOW_IMPLICIT_CONSTRUCTORS(CreateArrayLiteralFlags); |
| 29 | }; |
| 30 | |
| 31 | class CreateObjectLiteralFlags { |
| 32 | public: |
| 33 | using FlagsBits = base::BitField8<int, 0, 5>; |
| 34 | using FastCloneSupportedBit = FlagsBits::Next<bool, 1>; |
| 35 | |
| 36 | static uint8_t Encode(int runtime_flags, bool fast_clone_supported); |
| 37 | |
| 38 | private: |
| 39 | DISALLOW_IMPLICIT_CONSTRUCTORS(CreateObjectLiteralFlags); |
| 40 | }; |
| 41 | |
| 42 | class CreateClosureFlags { |
| 43 | public: |
| 44 | using PretenuredBit = base::BitField8<bool, 0, 1>; |
| 45 | using FastNewClosureBit = PretenuredBit::Next<bool, 1>; |
| 46 | |
| 47 | static uint8_t Encode(bool pretenure, bool is_function_scope, |
| 48 | bool might_always_opt); |
| 49 | |
| 50 | private: |
| 51 | DISALLOW_IMPLICIT_CONSTRUCTORS(CreateClosureFlags); |
| 52 | }; |
| 53 | |
| 54 | #define TYPEOF_LITERAL_LIST(V) \ |
| 55 | V(Number, number) \ |
| 56 | V(String, string) \ |
| 57 | V(Symbol, symbol) \ |
| 58 | V(Boolean, boolean) \ |
| 59 | V(BigInt, bigint) \ |
| 60 | V(Undefined, undefined) \ |
| 61 | V(Function, function) \ |
| 62 | V(Object, object) \ |
| 63 | V(Other, other) |
| 64 | |
| 65 | class TestTypeOfFlags { |
| 66 | public: |
| 67 | enum class LiteralFlag : uint8_t { |
| 68 | #define DECLARE_LITERAL_FLAG(name, _) k##name, |
| 69 | TYPEOF_LITERAL_LIST(DECLARE_LITERAL_FLAG) |
| 70 | #undef DECLARE_LITERAL_FLAG |
| 71 | }; |
| 72 | |
| 73 | static LiteralFlag GetFlagForLiteral(const AstStringConstants* ast_constants, |
| 74 | Literal* literal); |
| 75 | static uint8_t Encode(LiteralFlag literal_flag); |
| 76 | static LiteralFlag Decode(uint8_t raw_flag); |
| 77 | |
| 78 | private: |
| 79 | DISALLOW_IMPLICIT_CONSTRUCTORS(TestTypeOfFlags); |
| 80 | }; |
| 81 | |
| 82 | class StoreLookupSlotFlags { |
| 83 | public: |
| 84 | using LanguageModeBit = base::BitField8<LanguageMode, 0, 1>; |
| 85 | using LookupHoistingModeBit = LanguageModeBit::Next<bool, 1>; |
| 86 | STATIC_ASSERT(LanguageModeSize <= LanguageModeBit::kNumValues); |
| 87 | |
| 88 | static uint8_t Encode(LanguageMode language_mode, |
| 89 | LookupHoistingMode lookup_hoisting_mode); |
| 90 | |
| 91 | private: |
| 92 | DISALLOW_IMPLICIT_CONSTRUCTORS(StoreLookupSlotFlags); |
| 93 | }; |
| 94 | |
| 95 | } // namespace interpreter |
| 96 | } // namespace internal |
| 97 | } // namespace v8 |
| 98 | |
| 99 | #endif // V8_INTERPRETER_BYTECODE_FLAGS_H_ |