| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 | 104 |
| 104 CodeGenerator::CodeGenerator(Assembler* assembler, | 105 CodeGenerator::CodeGenerator(Assembler* assembler, |
| 105 const ParsedFunction& parsed_function) | 106 const ParsedFunction& parsed_function) |
| 106 : assembler_(assembler), | 107 : assembler_(assembler), |
| 107 parsed_function_(parsed_function), | 108 parsed_function_(parsed_function), |
| 108 locals_space_size_(-1), | 109 locals_space_size_(-1), |
| 109 state_(NULL), | 110 state_(NULL), |
| 110 pc_descriptors_list_(NULL), | 111 pc_descriptors_list_(NULL), |
| 112 stackmap_builder_(NULL), |
| 111 exception_handlers_list_(NULL), | 113 exception_handlers_list_(NULL), |
| 112 try_index_(CatchClauseNode::kInvalidTryIndex), | 114 try_index_(CatchClauseNode::kInvalidTryIndex), |
| 113 context_level_(0) { | 115 context_level_(0) { |
| 114 ASSERT(assembler_ != NULL); | 116 ASSERT(assembler_ != NULL); |
| 115 ASSERT(parsed_function.node_sequence() != NULL); | 117 ASSERT(parsed_function.node_sequence() != NULL); |
| 116 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); | 118 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); |
| 117 pc_descriptors_list_ = new CodeGenerator::DescriptorList(); | 119 pc_descriptors_list_ = new DescriptorList(); |
| 120 // We do not build any stack maps in the unoptimizing compiler. |
| 118 exception_handlers_list_ = new CodeGenerator::HandlerList(); | 121 exception_handlers_list_ = new CodeGenerator::HandlerList(); |
| 119 } | 122 } |
| 120 | 123 |
| 121 | 124 |
| 122 bool CodeGenerator::IsResultNeeded(AstNode* node) const { | 125 bool CodeGenerator::IsResultNeeded(AstNode* node) const { |
| 123 return !state()->IsRootNode(node); | 126 return !state()->IsRootNode(node); |
| 124 } | 127 } |
| 125 | 128 |
| 126 | 129 |
| 127 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do | 130 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 210 |
| 208 void CodeGenerator::FinalizePcDescriptors(const Code& code) { | 211 void CodeGenerator::FinalizePcDescriptors(const Code& code) { |
| 209 ASSERT(pc_descriptors_list_ != NULL); | 212 ASSERT(pc_descriptors_list_ != NULL); |
| 210 const PcDescriptors& descriptors = PcDescriptors::Handle( | 213 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 211 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); | 214 pc_descriptors_list_->FinalizePcDescriptors(code.EntryPoint())); |
| 212 descriptors.Verify(parsed_function_.function().is_optimizable()); | 215 descriptors.Verify(parsed_function_.function().is_optimizable()); |
| 213 code.set_pc_descriptors(descriptors); | 216 code.set_pc_descriptors(descriptors); |
| 214 } | 217 } |
| 215 | 218 |
| 216 | 219 |
| 220 void CodeGenerator::FinalizeStackmaps(const Code& code) { |
| 221 if (stackmap_builder_ == NULL) { |
| 222 // The unoptimizing compiler has no stack maps. |
| 223 code.set_stackmaps(Array::Handle()); |
| 224 } else { |
| 225 // Finalize the stack map array and add it to the code object. |
| 226 code.set_stackmaps( |
| 227 Array::Handle(stackmap_builder_->FinalizeStackmaps(code))); |
| 228 } |
| 229 } |
| 230 |
| 231 |
| 217 void CodeGenerator::FinalizeVarDescriptors(const Code& code) { | 232 void CodeGenerator::FinalizeVarDescriptors(const Code& code) { |
| 218 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 233 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
| 219 parsed_function_.node_sequence()->scope()->GetVarDescriptors()); | 234 parsed_function_.node_sequence()->scope()->GetVarDescriptors()); |
| 220 code.set_var_descriptors(var_descs); | 235 code.set_var_descriptors(var_descs); |
| 221 } | 236 } |
| 222 | 237 |
| 223 | 238 |
| 224 void CodeGenerator::FinalizeExceptionHandlers(const Code& code) { | 239 void CodeGenerator::FinalizeExceptionHandlers(const Code& code) { |
| 225 ASSERT(exception_handlers_list_ != NULL); | 240 ASSERT(exception_handlers_list_ != NULL); |
| 226 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 241 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| (...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2687 const Error& error = Error::Handle( | 2702 const Error& error = Error::Handle( |
| 2688 Parser::FormatError(script, token_index, "Error", format, args)); | 2703 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2689 va_end(args); | 2704 va_end(args); |
| 2690 Isolate::Current()->long_jump_base()->Jump(1, error); | 2705 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2691 UNREACHABLE(); | 2706 UNREACHABLE(); |
| 2692 } | 2707 } |
| 2693 | 2708 |
| 2694 } // namespace dart | 2709 } // namespace dart |
| 2695 | 2710 |
| 2696 #endif // defined TARGET_ARCH_IA32 | 2711 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |