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