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

Side by Side Diff: src/interpreter/bytecode-generator.h

Issue 1378523005: [Interpreter] Add support for global declarations and load/store of global variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_toplevel
Patch Set: Fix test Created 5 years, 2 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/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecode-generator.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_BYTECODE_GENERATOR_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_GENERATOR_H_
6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_ 6 #define V8_INTERPRETER_BYTECODE_GENERATOR_H_
7 7
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/interpreter/bytecode-array-builder.h" 9 #include "src/interpreter/bytecode-array-builder.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace interpreter { 14 namespace interpreter {
15 15
16 class BytecodeGenerator : public AstVisitor { 16 class BytecodeGenerator : public AstVisitor {
17 public: 17 public:
18 BytecodeGenerator(Isolate* isolate, Zone* zone); 18 BytecodeGenerator(Isolate* isolate, Zone* zone);
19 virtual ~BytecodeGenerator(); 19 virtual ~BytecodeGenerator();
20 20
21 Handle<BytecodeArray> MakeBytecode(CompilationInfo* info); 21 Handle<BytecodeArray> MakeBytecode(CompilationInfo* info);
22 22
23 #define DECLARE_VISIT(type) void Visit##type(type* node) override; 23 #define DECLARE_VISIT(type) void Visit##type(type* node) override;
24 AST_NODE_LIST(DECLARE_VISIT) 24 AST_NODE_LIST(DECLARE_VISIT)
25 #undef DECLARE_VISIT 25 #undef DECLARE_VISIT
26 26
27 // Visiting function for declarations list is overridden.
28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override;
29
27 private: 30 private:
28 class ControlScope; 31 class ControlScope;
29 class ControlScopeForIteration; 32 class ControlScopeForIteration;
30 33
31 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 34 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
32 35
33 void VisitArithmeticExpression(BinaryOperation* binop); 36 void VisitArithmeticExpression(BinaryOperation* binop);
34 void VisitPropertyLoad(Register obj, Property* expr); 37 void VisitPropertyLoad(Register obj, Property* expr);
35 void VisitVariableLoad(Variable* variable); 38 void VisitVariableLoad(Variable* variable, FeedbackVectorSlot slot);
39 void VisitVariableAssignment(Variable* variable, FeedbackVectorSlot slot);
36 40
37 // Dispatched from VisitUnaryOperation. 41 // Dispatched from VisitUnaryOperation.
38 void VisitVoid(UnaryOperation* expr); 42 void VisitVoid(UnaryOperation* expr);
39 void VisitTypeOf(UnaryOperation* expr); 43 void VisitTypeOf(UnaryOperation* expr);
40 void VisitNot(UnaryOperation* expr); 44 void VisitNot(UnaryOperation* expr);
41 45
42 inline BytecodeArrayBuilder* builder() { return &builder_; } 46 inline BytecodeArrayBuilder* builder() { return &builder_; }
43 inline Scope* scope() const { return scope_; } 47 inline Scope* scope() const { return scope_; }
44 inline void set_scope(Scope* scope) { scope_ = scope; } 48 inline void set_scope(Scope* scope) { scope_ = scope; }
45 inline ControlScope* control_scope() const { return control_scope_; } 49 inline ControlScope* control_scope() const { return control_scope_; }
46 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; } 50 inline void set_control_scope(ControlScope* scope) { control_scope_ = scope; }
47 inline CompilationInfo* info() const { return info_; } 51 inline CompilationInfo* info() const { return info_; }
48 inline void set_info(CompilationInfo* info) { info_ = info; } 52 inline void set_info(CompilationInfo* info) { info_ = info; }
53 ZoneVector<Handle<Object>>* globals() { return &globals_; }
49 54
50 LanguageMode language_mode() const; 55 LanguageMode language_mode() const;
51 Strength language_mode_strength() const; 56 Strength language_mode_strength() const;
52 int feedback_index(FeedbackVectorSlot slot) const; 57 int feedback_index(FeedbackVectorSlot slot) const;
58 Register current_context() const;
53 59
54 BytecodeArrayBuilder builder_; 60 BytecodeArrayBuilder builder_;
55 CompilationInfo* info_; 61 CompilationInfo* info_;
56 Scope* scope_; 62 Scope* scope_;
63 ZoneVector<Handle<Object>> globals_;
57 ControlScope* control_scope_; 64 ControlScope* control_scope_;
65
66 // TODO(rmcilroy): Encapsulate this in an environment object.
67 Register current_context_;
58 }; 68 };
59 69
60 } // namespace interpreter 70 } // namespace interpreter
61 } // namespace internal 71 } // namespace internal
62 } // namespace v8 72 } // namespace v8
63 73
64 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_ 74 #endif // V8_INTERPRETER_BYTECODE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698