| 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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 Code::Handle(function.CurrentCode()).Size(), | 1135 Code::Handle(function.CurrentCode()).Size(), |
| 1136 per_compile_timer.TotalElapsedTime()); | 1136 per_compile_timer.TotalElapsedTime()); |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 isolate->debugger()->NotifyCompilation(function); | 1139 isolate->debugger()->NotifyCompilation(function); |
| 1140 | 1140 |
| 1141 if (FLAG_disassemble && FlowGraphPrinter::ShouldPrint(function)) { | 1141 if (FLAG_disassemble && FlowGraphPrinter::ShouldPrint(function)) { |
| 1142 DisassembleCode(function, optimized); | 1142 DisassembleCode(function, optimized); |
| 1143 } else if (FLAG_disassemble_optimized && | 1143 } else if (FLAG_disassemble_optimized && |
| 1144 optimized && | 1144 optimized && |
| 1145 FlowGraphPrinter::ShouldPrint(function)) { | 1145 FlowGraphPrinter::ShouldPrint(function) && |
| 1146 (result == NULL) /* no background compilation*/ ) { |
| 1147 // With background compilation, print when installing the code. |
| 1146 // TODO(fschneider): Print unoptimized code along with the optimized code. | 1148 // TODO(fschneider): Print unoptimized code along with the optimized code. |
| 1147 THR_Print("*** BEGIN CODE\n"); | 1149 THR_Print("*** BEGIN CODE\n"); |
| 1148 DisassembleCode(function, true); | 1150 DisassembleCode(function, true); |
| 1149 THR_Print("*** END CODE\n"); | 1151 THR_Print("*** END CODE\n"); |
| 1150 } | 1152 } |
| 1151 #if defined(DEBUG) | 1153 #if defined(DEBUG) |
| 1152 CheckInliningIntervals(function); | 1154 CheckInliningIntervals(function); |
| 1153 #endif | 1155 #endif |
| 1154 return Error::null(); | 1156 return Error::null(); |
| 1155 } else { | 1157 } else { |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 function ^= code.owner(); | 1862 function ^= code.owner(); |
| 1861 Field& field = Field::Handle(); | 1863 Field& field = Field::Handle(); |
| 1862 // Always execute necessary deoptimizations, even if the result is invalid. | 1864 // Always execute necessary deoptimizations, even if the result is invalid. |
| 1863 for (intptr_t i = 0; i < result.deoptimize_dependent_fields().Length(); | 1865 for (intptr_t i = 0; i < result.deoptimize_dependent_fields().Length(); |
| 1864 i++) { | 1866 i++) { |
| 1865 field ^= result.deoptimize_dependent_fields().At(i); | 1867 field ^= result.deoptimize_dependent_fields().At(i); |
| 1866 field.DeoptimizeDependentCode(); | 1868 field.DeoptimizeDependentCode(); |
| 1867 } | 1869 } |
| 1868 if (result.IsValid()) { | 1870 if (result.IsValid()) { |
| 1869 function.InstallOptimizedCode(result.result_code(), false /* not OSR */); | 1871 function.InstallOptimizedCode(result.result_code(), false /* not OSR */); |
| 1872 if (FLAG_trace_compiler) { |
| 1873 THR_Print("Installing optimized code for %s\n", |
| 1874 function.ToQualifiedCString()); |
| 1875 } |
| 1870 // Install leaf classes and fields dependencies. | 1876 // Install leaf classes and fields dependencies. |
| 1871 Class& cls = Class::Handle(); | 1877 Class& cls = Class::Handle(); |
| 1872 for (intptr_t i = 0; i < result.leaf_classes().Length(); i++) { | 1878 for (intptr_t i = 0; i < result.leaf_classes().Length(); i++) { |
| 1873 cls ^= result.leaf_classes().At(i); | 1879 cls ^= result.leaf_classes().At(i); |
| 1874 cls.RegisterCHACode(code); | 1880 cls.RegisterCHACode(code); |
| 1875 } | 1881 } |
| 1876 for (intptr_t i = 0; i < result.guarded_fields().Length(); i++) { | 1882 for (intptr_t i = 0; i < result.guarded_fields().Length(); i++) { |
| 1877 field ^= result.guarded_fields().At(i); | 1883 field ^= result.guarded_fields().At(i); |
| 1878 field.RegisterDependentCode(code); | 1884 field.RegisterDependentCode(code); |
| 1879 } | 1885 } |
| 1880 } else if (FLAG_trace_compiler) { | 1886 } else if (FLAG_trace_compiler) { |
| 1881 THR_Print("Drop code generated in the background compiler:\n"); | 1887 THR_Print("Drop code generated in the background compiler:\n"); |
| 1882 result.PrintValidity(); | 1888 result.PrintValidity(); |
| 1883 } | 1889 } |
| 1884 if (function.usage_counter() < 0) { | 1890 if (function.usage_counter() < 0) { |
| 1885 // Reset to 0 so that it can be recompiled if needed. | 1891 // Reset to 0 so that it can be recompiled if needed. |
| 1886 function.set_usage_counter(0); | 1892 function.set_usage_counter(0); |
| 1887 } | 1893 } |
| 1894 if (result.IsValid() && |
| 1895 FLAG_disassemble_optimized && |
| 1896 FlowGraphPrinter::ShouldPrint(function)) { |
| 1897 THR_Print("*** BEGIN CODE\n"); |
| 1898 DisassembleCode(function, true); |
| 1899 THR_Print("*** END CODE\n"); |
| 1900 } |
| 1888 } | 1901 } |
| 1889 } | 1902 } |
| 1890 | 1903 |
| 1891 | 1904 |
| 1892 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { | 1905 void BackgroundCompiler::VisitPointers(ObjectPointerVisitor* visitor) { |
| 1893 function_queue_->VisitObjectPointers(visitor); | 1906 function_queue_->VisitObjectPointers(visitor); |
| 1894 result_queue_->VisitObjectPointers(visitor); | 1907 result_queue_->VisitObjectPointers(visitor); |
| 1895 } | 1908 } |
| 1896 | 1909 |
| 1897 | 1910 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 isolate->set_background_compiler(task); | 1965 isolate->set_background_compiler(task); |
| 1953 start_task = true; | 1966 start_task = true; |
| 1954 } | 1967 } |
| 1955 } | 1968 } |
| 1956 if (start_task) { | 1969 if (start_task) { |
| 1957 Dart::thread_pool()->Run(isolate->background_compiler()); | 1970 Dart::thread_pool()->Run(isolate->background_compiler()); |
| 1958 } | 1971 } |
| 1959 } | 1972 } |
| 1960 | 1973 |
| 1961 } // namespace dart | 1974 } // namespace dart |
| OLD | NEW |