| 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 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/class_finalizer.h" | 12 #include "vm/class_finalizer.h" |
| 13 #include "vm/code_descriptors.h" |
| 13 #include "vm/dart_entry.h" | 14 #include "vm/dart_entry.h" |
| 14 #include "vm/debugger.h" | 15 #include "vm/debugger.h" |
| 15 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 17 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
| 18 #include "vm/parser.h" | 19 #include "vm/parser.h" |
| 19 #include "vm/resolver.h" | 20 #include "vm/resolver.h" |
| 20 #include "vm/stub_code.h" | 21 #include "vm/stub_code.h" |
| 21 | 22 |
| 22 namespace dart { | 23 namespace dart { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 | 106 |
| 106 CodeGenerator::CodeGenerator(Assembler* assembler, | 107 CodeGenerator::CodeGenerator(Assembler* assembler, |
| 107 const ParsedFunction& parsed_function) | 108 const ParsedFunction& parsed_function) |
| 108 : assembler_(assembler), | 109 : assembler_(assembler), |
| 109 parsed_function_(parsed_function), | 110 parsed_function_(parsed_function), |
| 110 locals_space_size_(-1), | 111 locals_space_size_(-1), |
| 111 state_(NULL), | 112 state_(NULL), |
| 112 pc_descriptors_list_(NULL), | 113 pc_descriptors_list_(NULL), |
| 114 stackmap_builder_(NULL), |
| 113 exception_handlers_list_(NULL), | 115 exception_handlers_list_(NULL), |
| 114 try_index_(CatchClauseNode::kInvalidTryIndex), | 116 try_index_(CatchClauseNode::kInvalidTryIndex), |
| 115 context_level_(0) { | 117 context_level_(0) { |
| 116 ASSERT(assembler_ != NULL); | 118 ASSERT(assembler_ != NULL); |
| 117 ASSERT(parsed_function.node_sequence() != NULL); | 119 ASSERT(parsed_function.node_sequence() != NULL); |
| 118 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); | 120 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); |
| 119 pc_descriptors_list_ = new CodeGenerator::DescriptorList(); | 121 pc_descriptors_list_ = new DescriptorList(); |
| 122 // We do not build any stack maps in the unoptimizing compiler. |
| 120 exception_handlers_list_ = new CodeGenerator::HandlerList(); | 123 exception_handlers_list_ = new CodeGenerator::HandlerList(); |
| 121 } | 124 } |
| 122 | 125 |
| 123 | 126 |
| 124 bool CodeGenerator::IsResultNeeded(AstNode* node) const { | 127 bool CodeGenerator::IsResultNeeded(AstNode* node) const { |
| 125 return !state()->IsRootNode(node); | 128 return !state()->IsRootNode(node); |
| 126 } | 129 } |
| 127 | 130 |
| 128 | 131 |
| 129 // NOTE: First 13 bytes of the code may be patched with a jump instruction. Do | 132 // NOTE: First 13 bytes of the code may be patched with a jump instruction. Do |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 214 |
| 212 void CodeGenerator::FinalizePcDescriptors(const Code& code) { | 215 void CodeGenerator::FinalizePcDescriptors(const Code& code) { |
| 213 ASSERT(pc_descriptors_list_ != NULL); | 216 ASSERT(pc_descriptors_list_ != NULL); |
| 214 const PcDescriptors& descriptors = PcDescriptors::Handle( | 217 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 215 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); | 218 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); |
| 216 descriptors.Verify(parsed_function_.function().is_optimizable()); | 219 descriptors.Verify(parsed_function_.function().is_optimizable()); |
| 217 code.set_pc_descriptors(descriptors); | 220 code.set_pc_descriptors(descriptors); |
| 218 } | 221 } |
| 219 | 222 |
| 220 | 223 |
| 224 void CodeGenerator::FinalizeStackmaps(const Code& code) { |
| 225 if (stackmap_builder_ == NULL) { |
| 226 // The unoptimizing compiler has no stack maps. |
| 227 code.set_stackmaps(Array::Handle()); |
| 228 } else { |
| 229 // Finalize the stack map array and add it to the code object. |
| 230 code.set_stackmaps( |
| 231 Array::Handle(stackmap_builder_->FinalizeStackmaps(code))); |
| 232 } |
| 233 } |
| 234 |
| 235 |
| 221 void CodeGenerator::FinalizeVarDescriptors(const Code& code) { | 236 void CodeGenerator::FinalizeVarDescriptors(const Code& code) { |
| 222 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 237 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
| 223 parsed_function_.node_sequence()->scope()->GetVarDescriptors()); | 238 parsed_function_.node_sequence()->scope()->GetVarDescriptors()); |
| 224 code.set_var_descriptors(var_descs); | 239 code.set_var_descriptors(var_descs); |
| 225 } | 240 } |
| 226 | 241 |
| 227 | 242 |
| 228 void CodeGenerator::FinalizeExceptionHandlers(const Code& code) { | 243 void CodeGenerator::FinalizeExceptionHandlers(const Code& code) { |
| 229 ASSERT(exception_handlers_list_ != NULL); | 244 ASSERT(exception_handlers_list_ != NULL); |
| 230 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 245 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| (...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 const Error& error = Error::Handle( | 2710 const Error& error = Error::Handle( |
| 2696 Parser::FormatError(script, token_index, "Error", format, args)); | 2711 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2697 va_end(args); | 2712 va_end(args); |
| 2698 Isolate::Current()->long_jump_base()->Jump(1, error); | 2713 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2699 UNREACHABLE(); | 2714 UNREACHABLE(); |
| 2700 } | 2715 } |
| 2701 | 2716 |
| 2702 } // namespace dart | 2717 } // namespace dart |
| 2703 | 2718 |
| 2704 #endif // defined TARGET_ARCH_X64 | 2719 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |