| 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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 TimelineDurationScope tds(thread(), | 1042 TimelineDurationScope tds(thread(), |
| 1043 compiler_timeline, | 1043 compiler_timeline, |
| 1044 "CompileGraph"); | 1044 "CompileGraph"); |
| 1045 graph_compiler.CompileGraph(); | 1045 graph_compiler.CompileGraph(); |
| 1046 pipeline->FinalizeCompilation(); | 1046 pipeline->FinalizeCompilation(); |
| 1047 } | 1047 } |
| 1048 { | 1048 { |
| 1049 TimelineDurationScope tds(thread(), | 1049 TimelineDurationScope tds(thread(), |
| 1050 compiler_timeline, | 1050 compiler_timeline, |
| 1051 "FinalizeCompilation"); | 1051 "FinalizeCompilation"); |
| 1052 // This part of compilation must be at a safepoint. | 1052 if (thread()->IsMutatorThread()) { |
| 1053 if (!thread()->IsMutatorThread()) { | 1053 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); |
| 1054 } else { |
| 1055 // This part of compilation must be at a safepoint. |
| 1054 // Stop mutator thread before creating the instruction object and | 1056 // Stop mutator thread before creating the instruction object and |
| 1055 // installing code. | 1057 // installing code. |
| 1056 // Mutator thread may not run code while we are creating the | 1058 // Mutator thread may not run code while we are creating the |
| 1057 // instruction object, since the creation of instruction object | 1059 // instruction object, since the creation of instruction object |
| 1058 // changes code page access permissions (makes them temporary not | 1060 // changes code page access permissions (makes them temporary not |
| 1059 // executable). | 1061 // executable). |
| 1060 isolate()->thread_registry()->SafepointThreads(); | 1062 isolate()->thread_registry()->SafepointThreads(); |
| 1061 } | 1063 { |
| 1062 | 1064 // Do not Garbage collect during this stage and instead allow the |
| 1063 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); | 1065 // heap to grow. |
| 1064 | 1066 NoHeapGrowthControlScope no_growth_control; |
| 1065 if (!thread()->IsMutatorThread()) { | 1067 FinalizeCompilation(&assembler, &graph_compiler, flow_graph); |
| 1066 // Background compilation. | 1068 } |
| 1067 isolate()->thread_registry()->ResumeAllThreads(); | 1069 isolate()->thread_registry()->ResumeAllThreads(); |
| 1070 if (isolate()->heap()->NeedsGarbageCollection()) { |
| 1071 isolate()->heap()->CollectAllGarbage(); |
| 1072 } |
| 1068 } | 1073 } |
| 1069 } | 1074 } |
| 1070 // Mark that this isolate now has compiled code. | 1075 // Mark that this isolate now has compiled code. |
| 1071 isolate()->set_has_compiled_code(true); | 1076 isolate()->set_has_compiled_code(true); |
| 1072 // Exit the loop and the function with the correct result value. | 1077 // Exit the loop and the function with the correct result value. |
| 1073 is_compiled = true; | 1078 is_compiled = true; |
| 1074 done = true; | 1079 done = true; |
| 1075 } else { | 1080 } else { |
| 1076 // We bailed out or we encountered an error. | 1081 // We bailed out or we encountered an error. |
| 1077 const Error& error = Error::Handle( | 1082 const Error& error = Error::Handle( |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 } | 2042 } |
| 2038 | 2043 |
| 2039 | 2044 |
| 2040 void BackgroundCompiler::EnsureInit(Thread* thread) { | 2045 void BackgroundCompiler::EnsureInit(Thread* thread) { |
| 2041 UNREACHABLE(); | 2046 UNREACHABLE(); |
| 2042 } | 2047 } |
| 2043 | 2048 |
| 2044 #endif // DART_PRECOMPILED | 2049 #endif // DART_PRECOMPILED |
| 2045 | 2050 |
| 2046 } // namespace dart | 2051 } // namespace dart |
| OLD | NEW |