v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
interpreter.h
Go to the documentation of this file.
1// Copyright 2015 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_INTERPRETER_H_
6#define V8_INTERPRETER_INTERPRETER_H_
7
8#include <memory>
9
10// Clients of this interface shouldn't depend on lots of interpreter internals.
11// Do not include anything from src/interpreter other than
12// src/interpreter/bytecodes.h here!
13#include "src/base/macros.h"
16
17namespace v8 {
18namespace internal {
19
20class AccountingAllocator;
21class BytecodeArray;
22class Callable;
23class UnoptimizedCompilationJob;
24class FunctionLiteral;
25class IgnitionStatisticsTester;
26class Isolate;
27class LocalIsolate;
28class ParseInfo;
29class RootVisitor;
30class SetupIsolateDelegate;
31template <typename>
32class ZoneVector;
33
34namespace interpreter {
35
36class InterpreterAssembler;
37
39 public:
40 explicit Interpreter(Isolate* isolate);
41 virtual ~Interpreter() = default;
42 Interpreter(const Interpreter&) = delete;
44
45 // Creates a compilation job which will generate bytecode for |literal|.
46 // Additionally, if |eager_inner_literals| is not null, adds any eagerly
47 // compilable inner FunctionLiterals to this list.
48 static std::unique_ptr<UnoptimizedCompilationJob> NewCompilationJob(
49 ParseInfo* parse_info, FunctionLiteral* literal, Handle<Script> script,
50 AccountingAllocator* allocator,
51 std::vector<FunctionLiteral*>* eager_inner_literals,
52 LocalIsolate* local_isolate);
53
54 // Creates a compilation job which will generate source positions for
55 // |literal| and when finalized, store the result into |existing_bytecode|.
56 static std::unique_ptr<UnoptimizedCompilationJob>
59 Handle<BytecodeArray> existing_bytecode,
60 AccountingAllocator* allocator,
61 LocalIsolate* local_isolate);
62
63 // If the bytecode handler for |bytecode| and |operand_scale| has not yet
64 // been loaded, deserialize it. Then return the handler.
66 OperandScale operand_scale);
67
68 // Set the bytecode handler for |bytecode| and |operand_scale|.
69 void SetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale,
70 Tagged<Code> handler);
71
73
74 void ForEachBytecode(const std::function<void(Bytecode, OperandScale)>& f);
75
76 void Initialize();
77
78 bool IsDispatchTableInitialized() const;
79
81 return reinterpret_cast<Address>(&dispatch_table_[0]);
82 }
83
87
92
93 private:
94 friend class SetupInterpreter;
97
100 Bytecode to) const;
101
102 // Get dispatch table index of bytecode.
103 static size_t GetDispatchTableIndex(Bytecode bytecode,
104 OperandScale operand_scale);
105
108 static const int kNumberOfBytecodes = static_cast<int>(Bytecode::kLast) + 1;
109
112 std::unique_ptr<uintptr_t[]> bytecode_dispatch_counters_table_;
114};
115
116#ifdef V8_IGNITION_DISPATCH_COUNTING
117#define V8_IGNITION_DISPATCH_COUNTING_BOOL true
118#else
119#define V8_IGNITION_DISPATCH_COUNTING_BOOL false
120#endif
121
122} // namespace interpreter
123} // namespace internal
124} // namespace v8
125
126#endif // V8_INTERPRETER_INTERPRETER_H_
static std::unique_ptr< UnoptimizedCompilationJob > NewSourcePositionCollectionJob(ParseInfo *parse_info, FunctionLiteral *literal, Handle< BytecodeArray > existing_bytecode, AccountingAllocator *allocator, LocalIsolate *local_isolate)
V8_EXPORT_PRIVATE void InitDispatchCounters()
void ForEachBytecode(const std::function< void(Bytecode, OperandScale)> &f)
void SetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale, Tagged< Code > handler)
static size_t GetDispatchTableIndex(Bytecode bytecode, OperandScale operand_scale)
Address address_of_interpreter_entry_trampoline_instruction_start() const
Definition interpreter.h:88
V8_EXPORT_PRIVATE DirectHandle< JSObject > GetDispatchCountersObject()
Address dispatch_table_[kDispatchTableSize]
static std::unique_ptr< UnoptimizedCompilationJob > NewCompilationJob(ParseInfo *parse_info, FunctionLiteral *literal, Handle< Script > script, AccountingAllocator *allocator, std::vector< FunctionLiteral * > *eager_inner_literals, LocalIsolate *local_isolate)
friend class v8::internal::IgnitionStatisticsTester
Definition interpreter.h:96
Interpreter(const Interpreter &)=delete
std::unique_ptr< uintptr_t[]> bytecode_dispatch_counters_table_
V8_EXPORT_PRIVATE Tagged< Code > GetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale)
Interpreter & operator=(const Interpreter &)=delete
V8_EXPORT_PRIVATE uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const
FunctionLiteral * literal
Definition liveedit.cc:294
constexpr int kMaxUInt8
Definition globals.h:378
#define V8_EXPORT_PRIVATE
Definition macros.h:460