Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/interpreter/interpreter.h

Issue 2803903002: Revert of [snapshot] Move builtins generation into mksnapshot (Closed)
Patch Set: rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/setup-builtins-internal.cc ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_INTERPRETER_INTERPRETER_H_ 5 #ifndef V8_INTERPRETER_INTERPRETER_H_
6 #define V8_INTERPRETER_INTERPRETER_H_ 6 #define V8_INTERPRETER_INTERPRETER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 // Clients of this interface shouldn't depend on lots of interpreter internals. 10 // Clients of this interface shouldn't depend on lots of interpreter internals.
11 // Do not include anything from src/interpreter other than 11 // Do not include anything from src/interpreter other than
12 // src/interpreter/bytecodes.h here! 12 // src/interpreter/bytecodes.h here!
13 #include "src/base/macros.h" 13 #include "src/base/macros.h"
14 #include "src/builtins/builtins.h" 14 #include "src/builtins/builtins.h"
15 #include "src/interpreter/bytecodes.h" 15 #include "src/interpreter/bytecodes.h"
16 #include "src/parsing/token.h" 16 #include "src/parsing/token.h"
17 #include "src/runtime/runtime.h" 17 #include "src/runtime/runtime.h"
18 18
19 namespace v8 { 19 namespace v8 {
20 namespace internal { 20 namespace internal {
21 21
22 class Isolate; 22 class Isolate;
23 class Callable; 23 class Callable;
24 class CompilationInfo; 24 class CompilationInfo;
25 class CompilationJob; 25 class CompilationJob;
26 class SetupIsolateDelegate;
27 26
28 namespace interpreter { 27 namespace interpreter {
29 28
30 class InterpreterAssembler; 29 class InterpreterAssembler;
31 30
32 class Interpreter { 31 class Interpreter {
33 public: 32 public:
34 explicit Interpreter(Isolate* isolate); 33 explicit Interpreter(Isolate* isolate);
35 virtual ~Interpreter() {} 34 virtual ~Interpreter() {}
36 35
36 // Initializes the interpreter dispatch table.
37 void Initialize();
38
37 // Returns the interrupt budget which should be used for the profiler counter. 39 // Returns the interrupt budget which should be used for the profiler counter.
38 static int InterruptBudget(); 40 static int InterruptBudget();
39 41
40 // Creates a compilation job which will generate bytecode for |info|. 42 // Creates a compilation job which will generate bytecode for |info|.
41 static CompilationJob* NewCompilationJob(CompilationInfo* info); 43 static CompilationJob* NewCompilationJob(CompilationInfo* info);
42 44
43 // Return bytecode handler for |bytecode|. 45 // Return bytecode handler for |bytecode|.
44 Code* GetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale); 46 Code* GetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale);
45 47
46 // GC support. 48 // GC support.
47 void IterateDispatchTable(ObjectVisitor* v); 49 void IterateDispatchTable(ObjectVisitor* v);
48 50
49 // Disassembler support (only useful with ENABLE_DISASSEMBLER defined). 51 // Disassembler support (only useful with ENABLE_DISASSEMBLER defined).
50 const char* LookupNameOfBytecodeHandler(Code* code); 52 const char* LookupNameOfBytecodeHandler(Code* code);
51 53
52 V8_EXPORT_PRIVATE Local<v8::Object> GetDispatchCountersObject(); 54 V8_EXPORT_PRIVATE Local<v8::Object> GetDispatchCountersObject();
53 55
54 Address dispatch_table_address() { 56 Address dispatch_table_address() {
55 return reinterpret_cast<Address>(&dispatch_table_[0]); 57 return reinterpret_cast<Address>(&dispatch_table_[0]);
56 } 58 }
57 59
58 Address bytecode_dispatch_counters_table() { 60 Address bytecode_dispatch_counters_table() {
59 return reinterpret_cast<Address>(bytecode_dispatch_counters_table_.get()); 61 return reinterpret_cast<Address>(bytecode_dispatch_counters_table_.get());
60 } 62 }
61 63
62 // TODO(ignition): Tune code size multiplier. 64 // TODO(ignition): Tune code size multiplier.
63 static const int kCodeSizeMultiplier = 24; 65 static const int kCodeSizeMultiplier = 24;
64 66
65 private: 67 private:
66 friend class SetupInterpreter; 68 // In the case of bytecodes that share handler implementations, copy the code
67 friend class v8::internal::SetupIsolateDelegate; 69 // into the bytecode's dispatcher table entry and return true.
70 bool ReuseExistingHandler(Bytecode bytecode, OperandScale operand_scale);
71
72 // Generates handler for given |bytecode| and |operand_scale|
73 // and installs it into the dispatch table.
74 void InstallBytecodeHandler(Isolate* isolate, Bytecode bytecode,
75 OperandScale operand_scale);
68 76
69 uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const; 77 uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const;
70 78
71 // Get dispatch table index of bytecode. 79 // Get dispatch table index of bytecode.
72 static size_t GetDispatchTableIndex(Bytecode bytecode, 80 static size_t GetDispatchTableIndex(Bytecode bytecode,
73 OperandScale operand_scale); 81 OperandScale operand_scale);
74 82
75 bool IsDispatchTableInitialized(); 83 bool IsDispatchTableInitialized();
84 bool ShouldInitializeDispatchTable();
76 85
77 static const int kNumberOfWideVariants = 3; 86 static const int kNumberOfWideVariants = 3;
78 static const int kDispatchTableSize = kNumberOfWideVariants * (kMaxUInt8 + 1); 87 static const int kDispatchTableSize = kNumberOfWideVariants * (kMaxUInt8 + 1);
79 static const int kNumberOfBytecodes = static_cast<int>(Bytecode::kLast) + 1; 88 static const int kNumberOfBytecodes = static_cast<int>(Bytecode::kLast) + 1;
80 89
81 Isolate* isolate_; 90 Isolate* isolate_;
82 Address dispatch_table_[kDispatchTableSize]; 91 Address dispatch_table_[kDispatchTableSize];
83 std::unique_ptr<uintptr_t[]> bytecode_dispatch_counters_table_; 92 std::unique_ptr<uintptr_t[]> bytecode_dispatch_counters_table_;
84 93
85 DISALLOW_COPY_AND_ASSIGN(Interpreter); 94 DISALLOW_COPY_AND_ASSIGN(Interpreter);
86 }; 95 };
87 96
88 } // namespace interpreter 97 } // namespace interpreter
89 } // namespace internal 98 } // namespace internal
90 } // namespace v8 99 } // namespace v8
91 100
92 #endif // V8_INTERPRETER_INTERPRETER_H_ 101 #endif // V8_INTERPRETER_INTERPRETER_H_
OLDNEW
« no previous file with comments | « src/builtins/setup-builtins-internal.cc ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698