| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 CodeGenerator; | 22 class CodeGenerator; |
| 23 class DescriptorList; |
| 23 class SourceLabel; | 24 class SourceLabel; |
| 25 class StackmapBuilder; |
| 24 | 26 |
| 25 | 27 |
| 26 class CodeGeneratorState : public StackResource { | 28 class CodeGeneratorState : public StackResource { |
| 27 public: | 29 public: |
| 28 explicit CodeGeneratorState(CodeGenerator* codegen); | 30 explicit CodeGeneratorState(CodeGenerator* codegen); |
| 29 virtual ~CodeGeneratorState(); | 31 virtual ~CodeGeneratorState(); |
| 30 | 32 |
| 31 CodeGeneratorState* parent() const { return parent_; } | 33 CodeGeneratorState* parent() const { return parent_; } |
| 32 | 34 |
| 33 AstNode* root_node() const { return root_node_; } | 35 AstNode* root_node() const { return root_node_; } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 84 |
| 83 CodeGeneratorState* state() const { return state_; } | 85 CodeGeneratorState* state() const { return state_; } |
| 84 void set_state(CodeGeneratorState* state) { state_ = state; } | 86 void set_state(CodeGeneratorState* state) { state_ = state; } |
| 85 | 87 |
| 86 // Add exception handler table to code. | 88 // Add exception handler table to code. |
| 87 void FinalizeExceptionHandlers(const Code& code); | 89 void FinalizeExceptionHandlers(const Code& code); |
| 88 | 90 |
| 89 // Add pc descriptors to code. | 91 // Add pc descriptors to code. |
| 90 void FinalizePcDescriptors(const Code& code); | 92 void FinalizePcDescriptors(const Code& code); |
| 91 | 93 |
| 94 // Add stack maps to code. |
| 95 void FinalizeStackmaps(const Code& code); |
| 96 |
| 92 // Add local variable descriptors to code. | 97 // Add local variable descriptors to code. |
| 93 void FinalizeVarDescriptors(const Code& code); | 98 void FinalizeVarDescriptors(const Code& code); |
| 94 | 99 |
| 95 // Allocate and return an arguments descriptor. | 100 // Allocate and return an arguments descriptor. |
| 96 // Let 'num_names' be the length of 'optional_arguments_names'. | 101 // Let 'num_names' be the length of 'optional_arguments_names'. |
| 97 // Treat the first 'num_arguments - num_names' arguments as positional and | 102 // Treat the first 'num_arguments - num_names' arguments as positional and |
| 98 // treat the following 'num_names' arguments as named optional arguments. | 103 // treat the following 'num_names' arguments as named optional arguments. |
| 99 static const Array& ArgumentsDescriptor( | 104 static const Array& ArgumentsDescriptor( |
| 100 int num_arguments, | 105 int num_arguments, |
| 101 const Array& optional_arguments_names); | 106 const Array& optional_arguments_names); |
| 102 | 107 |
| 103 virtual bool IsOptimizing() const { | 108 virtual bool IsOptimizing() const { |
| 104 return false; | 109 return false; |
| 105 } | 110 } |
| 106 | 111 |
| 107 void GenerateReturnEpilog(ReturnNode* node); | 112 void GenerateReturnEpilog(ReturnNode* node); |
| 108 | 113 |
| 109 // Return true if the VM may optimize functions. | 114 // Return true if the VM may optimize functions. |
| 110 static bool CanOptimize(); | 115 static bool CanOptimize(); |
| 111 | 116 |
| 112 private: | 117 private: |
| 113 // TODO(srdjan): Remove the friendship once the two compilers are properly | 118 // TODO(srdjan): Remove the friendship once the two compilers are properly |
| 114 // structured. | 119 // structured. |
| 115 friend class OptimizingCodeGenerator; | 120 friend class OptimizingCodeGenerator; |
| 116 | 121 |
| 117 // Forward declarations. | 122 // Forward declarations. |
| 118 class DescriptorList; | |
| 119 class HandlerList; | 123 class HandlerList; |
| 120 | 124 |
| 121 // Return true if intrinsification was completed and no other code | 125 // Return true if intrinsification was completed and no other code |
| 122 // needs to be generated. | 126 // needs to be generated. |
| 123 virtual bool TryIntrinsify() { return false; } | 127 virtual bool TryIntrinsify() { return false; } |
| 124 virtual void GeneratePreEntryCode(); | 128 virtual void GeneratePreEntryCode(); |
| 125 void GenerateLegacyEntryCode(); | 129 void GenerateLegacyEntryCode(); |
| 126 void GenerateEntryCode(); | 130 void GenerateEntryCode(); |
| 127 void GenerateLoadVariable(Register dst, const LocalVariable& local); | 131 void GenerateLoadVariable(Register dst, const LocalVariable& local); |
| 128 void GeneratePushVariable(const LocalVariable& variable, Register scratch); | 132 void GeneratePushVariable(const LocalVariable& variable, Register scratch); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 intptr_t token_index); | 207 intptr_t token_index); |
| 204 | 208 |
| 205 void set_context_level(intptr_t value) { context_level_ = value; } | 209 void set_context_level(intptr_t value) { context_level_ = value; } |
| 206 intptr_t context_level() const { return context_level_; } | 210 intptr_t context_level() const { return context_level_; } |
| 207 | 211 |
| 208 Assembler* assembler_; | 212 Assembler* assembler_; |
| 209 const ParsedFunction& parsed_function_; | 213 const ParsedFunction& parsed_function_; |
| 210 intptr_t locals_space_size_; | 214 intptr_t locals_space_size_; |
| 211 CodeGeneratorState* state_; | 215 CodeGeneratorState* state_; |
| 212 DescriptorList* pc_descriptors_list_; | 216 DescriptorList* pc_descriptors_list_; |
| 217 StackmapBuilder* stackmap_builder_; |
| 213 HandlerList* exception_handlers_list_; | 218 HandlerList* exception_handlers_list_; |
| 214 int try_index_; | 219 int try_index_; |
| 215 // The runtime context level is only incremented when a new context is | 220 // The runtime context level is only incremented when a new context is |
| 216 // allocated and chained to the list of contexts. | 221 // allocated and chained to the list of contexts. |
| 217 intptr_t context_level_; | 222 intptr_t context_level_; |
| 218 | 223 |
| 219 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeGenerator); | 224 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeGenerator); |
| 220 }; | 225 }; |
| 221 | 226 |
| 222 } // namespace dart | 227 } // namespace dart |
| 223 | 228 |
| 224 #endif // VM_CODE_GENERATOR_IA32_H_ | 229 #endif // VM_CODE_GENERATOR_IA32_H_ |
| OLD | NEW |