v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
bytecode-flags-and-tokens.cc
Go to the documentation of this file.
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
6
8#include "src/ast/ast.h"
10
11namespace v8 {
12namespace internal {
13namespace interpreter {
14
15// static
16uint8_t CreateArrayLiteralFlags::Encode(bool use_fast_shallow_clone,
17 int runtime_flags) {
18 uint8_t result = FlagsBits::encode(runtime_flags);
19 result |= FastCloneSupportedBit::encode(use_fast_shallow_clone);
20 return result;
21}
22
23// static
24uint8_t CreateObjectLiteralFlags::Encode(int runtime_flags,
25 bool fast_clone_supported) {
26 uint8_t result = FlagsBits::encode(runtime_flags);
27 result |= FastCloneSupportedBit::encode(fast_clone_supported);
28 return result;
29}
30
31// static
32uint8_t CreateClosureFlags::Encode(bool pretenure, bool is_function_scope,
33 bool might_always_turbofan) {
34 uint8_t result = PretenuredBit::encode(pretenure);
35 if (!might_always_turbofan && !pretenure && is_function_scope) {
37 }
38 return result;
39}
40
41// static
43 const AstStringConstants* ast_constants, Literal* literal) {
44 const AstRawString* raw_literal = literal->AsRawString();
45 if (raw_literal == ast_constants->number_string()) {
46 return LiteralFlag::kNumber;
47 } else if (raw_literal == ast_constants->string_string()) {
48 return LiteralFlag::kString;
49 } else if (raw_literal == ast_constants->symbol_string()) {
50 return LiteralFlag::kSymbol;
51 } else if (raw_literal == ast_constants->boolean_string()) {
52 return LiteralFlag::kBoolean;
53 } else if (raw_literal == ast_constants->bigint_string()) {
54 return LiteralFlag::kBigInt;
55 } else if (raw_literal == ast_constants->undefined_string()) {
56 return LiteralFlag::kUndefined;
57 } else if (raw_literal == ast_constants->function_string()) {
58 return LiteralFlag::kFunction;
59 } else if (raw_literal == ast_constants->object_string()) {
60 return LiteralFlag::kObject;
61 } else {
62 return LiteralFlag::kOther;
63 }
64}
65
66// static
67uint8_t TestTypeOfFlags::Encode(LiteralFlag literal_flag) {
68 return static_cast<uint8_t>(literal_flag);
69}
70
71// static
73 DCHECK_LE(raw_flag, static_cast<uint8_t>(LiteralFlag::kOther));
74 return static_cast<LiteralFlag>(raw_flag);
75}
76
77// static
78const char* TestTypeOfFlags::ToString(LiteralFlag literal_flag) {
79 switch (literal_flag) {
80#define CASE(Name, name) \
81 case LiteralFlag::k##Name: \
82 return #name;
84#undef CASE
85 default:
86 return "<invalid>";
87 }
88}
89
90// static
92 LookupHoistingMode lookup_hoisting_mode) {
94 language_mode == LanguageMode::kSloppy);
95 return LanguageModeBit::encode(language_mode) |
96 LookupHoistingModeBit::encode(static_cast<bool>(lookup_hoisting_mode));
97}
98
99// static
103
104// static
108
109} // namespace interpreter
110} // namespace internal
111} // namespace v8
#define TYPEOF_LITERAL_LIST(V)
static constexpr T decode(U value)
Definition bit-field.h:66
static constexpr U encode(T value)
Definition bit-field.h:55
static uint8_t Encode(bool use_fast_shallow_clone, int runtime_flags)
static uint8_t Encode(bool pretenure, bool is_function_scope, bool might_always_turbofan)
static uint8_t Encode(int runtime_flags, bool fast_clone_supported)
static uint8_t Encode(LanguageMode language_mode, LookupHoistingMode lookup_hoisting_mode)
static uint8_t Encode(LiteralFlag literal_flag)
static LiteralFlag GetFlagForLiteral(const AstStringConstants *ast_constants, Literal *literal)
static LiteralFlag Decode(uint8_t raw_flag)
static const char * ToString(LiteralFlag literal_flag)
ZoneVector< RpoNumber > & result
FunctionLiteral * literal
Definition liveedit.cc:294
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493