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

Side by Side Diff: runtime/vm/code_generator_ia32.h

Issue 8678033: Move more nodes to the optimizing code generator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_CODE_GENERATOR_IA32_H_ 5 #ifndef VM_CODE_GENERATOR_IA32_H_
6 #define VM_CODE_GENERATOR_IA32_H_ 6 #define VM_CODE_GENERATOR_IA32_H_
7 7
8 #ifndef VM_CODE_GENERATOR_H_ 8 #ifndef VM_CODE_GENERATOR_H_
9 #error Do not include code_generator_ia32.h directly; use code_generator.h. 9 #error Do not include code_generator_ia32.h directly; use code_generator.h.
10 #endif 10 #endif
11 11
12 #include "vm/assembler.h" 12 #include "vm/assembler.h"
13 #include "vm/ast.h" 13 #include "vm/ast.h"
14 #include "vm/growable_array.h" 14 #include "vm/growable_array.h"
15 #include "vm/parser.h" 15 #include "vm/parser.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 // Forward Declarations. 19 // Forward Declarations.
20 class Assembler; 20 class Assembler;
21 class AstNode; 21 class AstNode;
22 class CodeGeneratorState; 22 class CodeGenerator;
23 class SourceLabel; 23 class SourceLabel;
24 24
25
26 class CodeGeneratorState : public StackResource {
27 public:
28 explicit CodeGeneratorState(CodeGenerator* codegen);
29 virtual ~CodeGeneratorState();
30
31 CodeGeneratorState* parent() const { return parent_; }
32
33 AstNode* root_node() const { return root_node_; }
34 void set_root_node(AstNode* value) { root_node_ = value; }
35 bool IsRootNode(AstNode* node) const {
36 return root_node_ == node;
37 }
38
39 int loop_level() const { return loop_level_; }
40 void set_loop_level(int loop_level) {
41 loop_level_ = loop_level;
42 }
43
44 int context_level() const { return context_level_; }
45 void set_context_level(int context_level) {
46 context_level_ = context_level;
47 }
48
49 int try_index() const { return current_try_index_; }
50 void set_try_index(int value) {
51 current_try_index_ = value;
52 }
53
54 private:
55 CodeGenerator* codegen_;
56 CodeGeneratorState* parent_;
57 AstNode* root_node_;
58
59 // The loop level reflects the lexical nesting of loop statements, regardless
60 // of the presence of captured variables.
61 int loop_level_;
62
63 // The runtime context level is only incremented when a new context is
64 // allocated and chained to the list of contexts. This occurs when the scopes
65 // at the current loop level contain captured variables.
66 int context_level_;
67
68 // We identify each try block in this function with an unique 'try index'
69 // value.
70 // The 'try index' is used to match the try blocks with the corresponding
71 // catch block (if one exists). The PC descriptors generated for
72 // statements in the try block use this index so that it can be matched
73 // to the appropriate catch block.
74 // The 'try index' value is generated by incrementing the try_index_
75 // variable in the CodeGenerator object.
76 // We store the 'try index' of the block of code that we are
77 // currently generating code for in the current_try_index_ variable.
78 int current_try_index_;
79
80 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeGeneratorState);
81 };
82
83
25 class CodeGenerator : public AstNodeVisitor { 84 class CodeGenerator : public AstNodeVisitor {
26 public: 85 public:
27 CodeGenerator(Assembler* assembler, const ParsedFunction& parsed_function); 86 CodeGenerator(Assembler* assembler, const ParsedFunction& parsed_function);
28 virtual ~CodeGenerator() { } 87 virtual ~CodeGenerator() { }
29 88
30 // Accessors. 89 // Accessors.
31 Assembler* assembler() const { return assembler_; } 90 Assembler* assembler() const { return assembler_; }
32 91
33 const ParsedFunction& parsed_function() const { return parsed_function_; } 92 const ParsedFunction& parsed_function() const { return parsed_function_; }
34 93
(...skipping 21 matching lines...) Expand all
56 static const Array& ArgumentsDescriptor( 115 static const Array& ArgumentsDescriptor(
57 int num_arguments, 116 int num_arguments,
58 const Array& optional_arguments_names); 117 const Array& optional_arguments_names);
59 118
60 virtual bool IsOptimizing() const { 119 virtual bool IsOptimizing() const {
61 return false; 120 return false;
62 } 121 }
63 122
64 virtual void CountBackwardLoop(); 123 virtual void CountBackwardLoop();
65 124
125 void GenerateReturnEpilog();
126
66 private: 127 private:
67 // TODO(srdjan): Remove the friendship once the two compilers are properly 128 // TODO(srdjan): Remove the friendship once the two compilers are properly
68 // structured. 129 // structured.
69 friend class OptimizingCodeGenerator; 130 friend class OptimizingCodeGenerator;
70 131
71 // Forward Declarations. 132 // Forward Declarations.
72 class DescriptorList; 133 class DescriptorList;
73 class HandlerList; 134 class HandlerList;
74 135
75 // Return true if intrinsification was completed and no other code 136 // Return true if intrinsification was completed and no other code
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 HandlerList* exception_handlers_list_; 218 HandlerList* exception_handlers_list_;
158 int try_index_; 219 int try_index_;
159 220
160 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeGenerator); 221 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeGenerator);
161 }; 222 };
162 223
163 224
164 } // namespace dart 225 } // namespace dart
165 226
166 #endif // VM_CODE_GENERATOR_IA32_H_ 227 #endif // VM_CODE_GENERATOR_IA32_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698