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/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/code_index_table.h" | 10 #include "vm/code_index_table.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (FLAG_use_new_compiler) { | 135 if (FLAG_use_new_compiler) { |
136 ASSERT(!optimized); | 136 ASSERT(!optimized); |
137 LongJump* old_base = isolate->long_jump_base(); | 137 LongJump* old_base = isolate->long_jump_base(); |
138 LongJump bailout_jump; | 138 LongJump bailout_jump; |
139 isolate->set_long_jump_base(&bailout_jump); | 139 isolate->set_long_jump_base(&bailout_jump); |
140 if (setjmp(*bailout_jump.Set()) == 0) { | 140 if (setjmp(*bailout_jump.Set()) == 0) { |
141 FlowGraphBuilder graph_builder(parsed_function); | 141 FlowGraphBuilder graph_builder(parsed_function); |
142 graph_builder.BuildGraph(); | 142 graph_builder.BuildGraph(); |
143 | 143 |
144 Assembler assembler; | 144 Assembler assembler; |
145 FlowGraphCompiler graph_compiler(&assembler, | 145 // The non-optimizing compiler compiles blocks in reverse postorder, |
146 parsed_function, | 146 // because it is a 'natural' order for the human reader of the |
147 graph_builder.blocks()); | 147 // generated code. |
| 148 intptr_t length = graph_builder.postorder_block_entries().length(); |
| 149 GrowableArray<BlockEntryInstr*> block_order(length); |
| 150 for (intptr_t i = length - 1; i >= 0; --i) { |
| 151 block_order.Add(graph_builder.postorder_block_entries()[i]); |
| 152 } |
| 153 FlowGraphCompiler graph_compiler(&assembler, parsed_function, |
| 154 block_order); |
148 graph_compiler.CompileGraph(); | 155 graph_compiler.CompileGraph(); |
149 const Code& code = | 156 const Code& code = |
150 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); | 157 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); |
151 code.set_is_optimized(false); | 158 code.set_is_optimized(false); |
152 graph_compiler.FinalizePcDescriptors(code); | 159 graph_compiler.FinalizePcDescriptors(code); |
153 graph_compiler.FinalizeVarDescriptors(code); | 160 graph_compiler.FinalizeVarDescriptors(code); |
154 graph_compiler.FinalizeExceptionHandlers(code); | 161 graph_compiler.FinalizeExceptionHandlers(code); |
155 function.set_unoptimized_code(code); | 162 function.set_unoptimized_code(code); |
156 function.SetCode(code); | 163 function.SetCode(code); |
157 ASSERT(CodePatcher::CodeIsPatchable(code)); | 164 ASSERT(CodePatcher::CodeIsPatchable(code)); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } else { | 403 } else { |
397 result = isolate->object_store()->sticky_error(); | 404 result = isolate->object_store()->sticky_error(); |
398 isolate->object_store()->clear_sticky_error(); | 405 isolate->object_store()->clear_sticky_error(); |
399 } | 406 } |
400 isolate->set_long_jump_base(base); | 407 isolate->set_long_jump_base(base); |
401 return result.raw(); | 408 return result.raw(); |
402 } | 409 } |
403 | 410 |
404 | 411 |
405 } // namespace dart | 412 } // namespace dart |
OLD | NEW |