| 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 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 if (loading_invalidation_gen_at_start() != | 609 if (loading_invalidation_gen_at_start() != |
| 610 isolate()->loading_invalidation_gen()) { | 610 isolate()->loading_invalidation_gen()) { |
| 611 code_is_valid = false; | 611 code_is_valid = false; |
| 612 if (trace_compiler) { | 612 if (trace_compiler) { |
| 613 THR_Print("--> FAIL: Loading invalidation."); | 613 THR_Print("--> FAIL: Loading invalidation."); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 if (!thread()->cha()->IsConsistentWithCurrentHierarchy()) { |
| 617 code_is_valid = false; |
| 618 if (trace_compiler) { |
| 619 THR_Print("--> FAIL: Class hierarchy has new subclasses."); |
| 620 } |
| 621 } |
| 622 |
| 616 // Setting breakpoints at runtime could make a function non-optimizable. | 623 // Setting breakpoints at runtime could make a function non-optimizable. |
| 617 if (code_is_valid && Compiler::CanOptimizeFunction(thread(), function)) { | 624 if (code_is_valid && Compiler::CanOptimizeFunction(thread(), function)) { |
| 618 const bool is_osr = osr_id() != Compiler::kNoOSRDeoptId; | 625 const bool is_osr = osr_id() != Compiler::kNoOSRDeoptId; |
| 619 ASSERT(!is_osr); // OSR is not compiled in background. | 626 ASSERT(!is_osr); // OSR is not compiled in background. |
| 620 function.InstallOptimizedCode(code, is_osr); | 627 function.InstallOptimizedCode(code, is_osr); |
| 621 code_was_installed = true; | 628 code_was_installed = true; |
| 622 } | 629 } |
| 623 if (function.usage_counter() < 0) { | 630 if (function.usage_counter() < 0) { |
| 624 // Reset to 0 so that it can be recompiled if needed. | 631 // Reset to 0 so that it can be recompiled if needed. |
| 625 if (code_is_valid) { | 632 if (code_is_valid) { |
| 626 function.set_usage_counter(0); | 633 function.set_usage_counter(0); |
| 627 } else { | 634 } else { |
| 628 // Trigger another optimization pass soon. | 635 // Trigger another optimization pass soon. |
| 629 function.set_usage_counter(FLAG_optimization_counter_threshold - 100); | 636 function.set_usage_counter(FLAG_optimization_counter_threshold - 100); |
| 630 } | 637 } |
| 631 } | 638 } |
| 632 } | 639 } |
| 633 | 640 |
| 634 if (code_was_installed) { | 641 if (code_was_installed) { |
| 635 // Register code with the classes it depends on because of CHA and | 642 // The generated code was compiled under certain assumptions about |
| 636 // fields it depends on because of store guards, unless we cannot | 643 // class hierarchy and field types. Register these dependencies |
| 637 // deopt. | 644 // to ensure that the code will be deoptimized if they are violated. |
| 638 for (intptr_t i = 0; | 645 thread()->cha()->RegisterDependencies(code); |
| 639 i < thread()->cha()->leaf_classes().length(); | 646 |
| 640 ++i) { | |
| 641 thread()->cha()->leaf_classes()[i]->RegisterCHACode(code); | |
| 642 } | |
| 643 const ZoneGrowableArray<const Field*>& guarded_fields = | 647 const ZoneGrowableArray<const Field*>& guarded_fields = |
| 644 *flow_graph->parsed_function().guarded_fields(); | 648 *flow_graph->parsed_function().guarded_fields(); |
| 645 for (intptr_t i = 0; i < guarded_fields.length(); i++) { | 649 for (intptr_t i = 0; i < guarded_fields.length(); i++) { |
| 646 const Field* field = guarded_fields[i]; | 650 const Field* field = guarded_fields[i]; |
| 647 field->RegisterDependentCode(code); | 651 field->RegisterDependentCode(code); |
| 648 } | 652 } |
| 649 } | 653 } |
| 650 } else { // not optimized. | 654 } else { // not optimized. |
| 651 if (function.ic_data_array() == Array::null()) { | 655 if (function.ic_data_array() == Array::null()) { |
| 652 function.SaveICDataMap( | 656 function.SaveICDataMap( |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 | 2185 |
| 2182 | 2186 |
| 2183 bool BackgroundCompiler::IsDisabled() { | 2187 bool BackgroundCompiler::IsDisabled() { |
| 2184 UNREACHABLE(); | 2188 UNREACHABLE(); |
| 2185 return true; | 2189 return true; |
| 2186 } | 2190 } |
| 2187 | 2191 |
| 2188 #endif // DART_PRECOMPILED_RUNTIME | 2192 #endif // DART_PRECOMPILED_RUNTIME |
| 2189 | 2193 |
| 2190 } // namespace dart | 2194 } // namespace dart |
| OLD | NEW |