| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual void FinalizeCompilation(FlowGraph* flow_graph) { | 99 virtual void FinalizeCompilation(FlowGraph* flow_graph) { |
| 100 if ((field_map_ != NULL) && | 100 if ((field_map_ != NULL) && |
| 101 flow_graph->function().IsGenerativeConstructor()) { | 101 flow_graph->function().IsGenerativeConstructor()) { |
| 102 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator(); | 102 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator(); |
| 103 !block_it.Done(); block_it.Advance()) { | 103 !block_it.Done(); block_it.Advance()) { |
| 104 ForwardInstructionIterator it(block_it.Current()); | 104 ForwardInstructionIterator it(block_it.Current()); |
| 105 for (; !it.Done(); it.Advance()) { | 105 for (; !it.Done(); it.Advance()) { |
| 106 StoreInstanceFieldInstr* store = it.Current()->AsStoreInstanceField(); | 106 StoreInstanceFieldInstr* store = it.Current()->AsStoreInstanceField(); |
| 107 if (store != NULL) { | 107 if (store != NULL) { |
| 108 if (!store->field().IsNull() && store->field().is_final()) { | 108 if (!store->field().IsNull() && store->field().is_final()) { |
| 109 #ifndef PRODUCT |
| 109 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 110 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 110 THR_Print("Found store to %s <- %s\n", | 111 THR_Print("Found store to %s <- %s\n", |
| 111 store->field().ToCString(), | 112 store->field().ToCString(), |
| 112 store->value()->Type()->ToCString()); | 113 store->value()->Type()->ToCString()); |
| 113 } | 114 } |
| 115 #endif // !PRODUCT |
| 114 FieldTypePair* entry = field_map_->Lookup(&store->field()); | 116 FieldTypePair* entry = field_map_->Lookup(&store->field()); |
| 115 if (entry == NULL) { | 117 if (entry == NULL) { |
| 116 field_map_->Insert(FieldTypePair( | 118 field_map_->Insert(FieldTypePair( |
| 117 &Field::Handle(zone_, store->field().raw()), // Re-wrap. | 119 &Field::Handle(zone_, store->field().raw()), // Re-wrap. |
| 118 store->value()->Type()->ToCid())); | 120 store->value()->Type()->ToCid())); |
| 121 #ifndef PRODUCT |
| 119 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 122 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 120 THR_Print(" initial type = %s\n", | 123 THR_Print(" initial type = %s\n", |
| 121 store->value()->Type()->ToCString()); | 124 store->value()->Type()->ToCString()); |
| 122 } | 125 } |
| 126 #endif // !PRODUCT |
| 123 continue; | 127 continue; |
| 124 } | 128 } |
| 125 CompileType type = CompileType::FromCid(entry->cid_); | 129 CompileType type = CompileType::FromCid(entry->cid_); |
| 130 #ifndef PRODUCT |
| 126 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 131 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 127 THR_Print(" old type = %s\n", type.ToCString()); | 132 THR_Print(" old type = %s\n", type.ToCString()); |
| 128 } | 133 } |
| 134 #endif // !PRODUCT |
| 129 type.Union(store->value()->Type()); | 135 type.Union(store->value()->Type()); |
| 136 #ifndef PRODUCT |
| 130 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 137 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 131 THR_Print(" new type = %s\n", type.ToCString()); | 138 THR_Print(" new type = %s\n", type.ToCString()); |
| 132 } | 139 } |
| 140 #endif // !PRODUCT |
| 133 entry->cid_ = type.ToCid(); | 141 entry->cid_ = type.ToCid(); |
| 134 } | 142 } |
| 135 } | 143 } |
| 136 } | 144 } |
| 137 } | 145 } |
| 138 } | 146 } |
| 139 | 147 |
| 140 CompileType result_type = CompileType::None(); | 148 CompileType result_type = CompileType::None(); |
| 141 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator(); | 149 for (BlockIterator block_it = flow_graph->reverse_postorder_iterator(); |
| 142 !block_it.Done(); block_it.Advance()) { | 150 !block_it.Done(); block_it.Advance()) { |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 DartPrecompilationPipeline pipeline(zone); | 1227 DartPrecompilationPipeline pipeline(zone); |
| 1220 PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL, | 1228 PrecompileParsedFunctionHelper helper(/* precompiler = */ NULL, |
| 1221 parsed_function, | 1229 parsed_function, |
| 1222 /* optimized = */ true); | 1230 /* optimized = */ true); |
| 1223 bool success = helper.Compile(&pipeline); | 1231 bool success = helper.Compile(&pipeline); |
| 1224 ASSERT(success); | 1232 ASSERT(success); |
| 1225 | 1233 |
| 1226 if (compute_type && field.is_final()) { | 1234 if (compute_type && field.is_final()) { |
| 1227 intptr_t result_cid = pipeline.result_type().ToCid(); | 1235 intptr_t result_cid = pipeline.result_type().ToCid(); |
| 1228 if (result_cid != kDynamicCid) { | 1236 if (result_cid != kDynamicCid) { |
| 1237 #ifndef PRODUCT |
| 1229 if (FLAG_trace_precompiler && FLAG_support_il_printer) { | 1238 if (FLAG_trace_precompiler && FLAG_support_il_printer) { |
| 1230 THR_Print("Setting guarded_cid of %s to %s\n", field.ToCString(), | 1239 THR_Print("Setting guarded_cid of %s to %s\n", field.ToCString(), |
| 1231 pipeline.result_type().ToCString()); | 1240 pipeline.result_type().ToCString()); |
| 1232 } | 1241 } |
| 1242 #endif // !PRODUCT |
| 1233 field.set_guarded_cid(result_cid); | 1243 field.set_guarded_cid(result_cid); |
| 1234 } | 1244 } |
| 1235 } | 1245 } |
| 1236 | 1246 |
| 1237 if ((FLAG_disassemble || FLAG_disassemble_optimized) && | 1247 if ((FLAG_disassemble || FLAG_disassemble_optimized) && |
| 1238 FlowGraphPrinter::ShouldPrint(parsed_function->function())) { | 1248 FlowGraphPrinter::ShouldPrint(parsed_function->function())) { |
| 1239 Disassembler::DisassembleCode(parsed_function->function(), | 1249 Disassembler::DisassembleCode(parsed_function->function(), |
| 1240 /* optimized = */ true); | 1250 /* optimized = */ true); |
| 1241 } | 1251 } |
| 1242 return parsed_function->function().raw(); | 1252 return parsed_function->function().raw(); |
| (...skipping 2414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3657 | 3667 |
| 3658 ASSERT(FLAG_precompiled_mode); | 3668 ASSERT(FLAG_precompiled_mode); |
| 3659 const bool optimized = function.IsOptimizable(); // False for natives. | 3669 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3660 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3670 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3661 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3671 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3662 } | 3672 } |
| 3663 | 3673 |
| 3664 #endif // DART_PRECOMPILER | 3674 #endif // DART_PRECOMPILER |
| 3665 | 3675 |
| 3666 } // namespace dart | 3676 } // namespace dart |
| OLD | NEW |