Chromium Code Reviews| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 optimized_(optimized), | 378 optimized_(optimized), |
| 379 osr_id_(osr_id), | 379 osr_id_(osr_id), |
| 380 thread_(Thread::Current()), | 380 thread_(Thread::Current()), |
| 381 cha_invalidation_gen_at_start_(isolate()->cha_invalidation_gen()), | 381 cha_invalidation_gen_at_start_(isolate()->cha_invalidation_gen()), |
| 382 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), | 382 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), |
| 383 prefix_invalidation_gen_at_start_( | 383 prefix_invalidation_gen_at_start_( |
| 384 isolate()->prefix_invalidation_gen()) { | 384 isolate()->prefix_invalidation_gen()) { |
| 385 } | 385 } |
| 386 | 386 |
| 387 bool Compile(CompilationPipeline* pipeline); | 387 bool Compile(CompilationPipeline* pipeline); |
| 388 uint32_t prefix_invalidation_gen_at_start() const { | |
| 389 return prefix_invalidation_gen_at_start_; | |
| 390 } | |
| 388 | 391 |
| 389 private: | 392 private: |
| 390 ParsedFunction* parsed_function() const { return parsed_function_; } | 393 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 391 bool optimized() const { return optimized_; } | 394 bool optimized() const { return optimized_; } |
| 392 intptr_t osr_id() const { return osr_id_; } | 395 intptr_t osr_id() const { return osr_id_; } |
| 393 Thread* thread() const { return thread_; } | 396 Thread* thread() const { return thread_; } |
| 394 Isolate* isolate() const { return thread_->isolate(); } | 397 Isolate* isolate() const { return thread_->isolate(); } |
| 395 uint32_t cha_invalidation_gen_at_start() const { | 398 uint32_t cha_invalidation_gen_at_start() const { |
| 396 return cha_invalidation_gen_at_start_; | 399 return cha_invalidation_gen_at_start_; |
| 397 } | 400 } |
| 398 uint32_t field_invalidation_gen_at_start() const { | 401 uint32_t field_invalidation_gen_at_start() const { |
| 399 return field_invalidation_gen_at_start_; | 402 return field_invalidation_gen_at_start_; |
| 400 } | 403 } |
| 401 uint32_t prefix_invalidation_gen_at_start() const { | |
| 402 return prefix_invalidation_gen_at_start_; | |
| 403 } | |
| 404 void FinalizeCompilation(Assembler* assembler, | 404 void FinalizeCompilation(Assembler* assembler, |
| 405 FlowGraphCompiler* graph_compiler, | 405 FlowGraphCompiler* graph_compiler, |
| 406 FlowGraph* flow_graph); | 406 FlowGraph* flow_graph); |
| 407 | 407 |
| 408 ParsedFunction* parsed_function_; | 408 ParsedFunction* parsed_function_; |
| 409 const bool optimized_; | 409 const bool optimized_; |
| 410 const intptr_t osr_id_; | 410 const intptr_t osr_id_; |
| 411 Thread* const thread_; | 411 Thread* const thread_; |
| 412 const uint32_t cha_invalidation_gen_at_start_; | 412 const uint32_t cha_invalidation_gen_at_start_; |
| 413 const uint32_t field_invalidation_gen_at_start_; | 413 const uint32_t field_invalidation_gen_at_start_; |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 (optimized ? "optimized " : ""), | 1147 (optimized ? "optimized " : ""), |
| 1148 (Compiler::IsBackgroundCompilation() ? "(background)" : ""), | 1148 (Compiler::IsBackgroundCompilation() ? "(background)" : ""), |
| 1149 function.ToFullyQualifiedCString(), | 1149 function.ToFullyQualifiedCString(), |
| 1150 function.token_pos().ToCString(), | 1150 function.token_pos().ToCString(), |
| 1151 token_size); | 1151 token_size); |
| 1152 } | 1152 } |
| 1153 INC_STAT(thread, num_functions_compiled, 1); | 1153 INC_STAT(thread, num_functions_compiled, 1); |
| 1154 if (optimized) { | 1154 if (optimized) { |
| 1155 INC_STAT(thread, num_functions_optimized, 1); | 1155 INC_STAT(thread, num_functions_optimized, 1); |
| 1156 } | 1156 } |
| 1157 // Makes sure no libraries are loaded during parsing. | |
| 1158 const uint32_t prefix_invalidation_gen_at_start = | |
| 1159 isolate->prefix_invalidation_gen(); | |
| 1157 { | 1160 { |
| 1158 HANDLESCOPE(thread); | 1161 HANDLESCOPE(thread); |
| 1159 const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed); | 1162 const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed); |
| 1160 pipeline->ParseFunction(parsed_function); | 1163 pipeline->ParseFunction(parsed_function); |
| 1161 const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed); | 1164 const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed); |
| 1162 INC_STAT(thread, | 1165 INC_STAT(thread, |
| 1163 num_func_tokens_compiled, | 1166 num_func_tokens_compiled, |
| 1164 num_tokens_after - num_tokens_before); | 1167 num_tokens_after - num_tokens_before); |
| 1165 } | 1168 } |
| 1166 | 1169 |
| 1167 CompileParsedFunctionHelper helper(parsed_function, optimized, osr_id); | 1170 CompileParsedFunctionHelper helper(parsed_function, optimized, osr_id); |
| 1171 if (prefix_invalidation_gen_at_start != | |
| 1172 helper.prefix_invalidation_gen_at_start()) { | |
| 1173 ASSERT(Compiler::IsBackgroundCompilation()); | |
| 1174 // Deferred loading occured while parsing or copying ICData. | |
| 1175 Compiler::AbortBackgroundCompilation(Thread::kNoDeoptId); | |
|
rmacnak
2016/03/24 18:18:19
Add comment here that we need to abort because the
srdjan
2016/03/24 18:22:08
Done.
| |
| 1176 } | |
| 1168 const bool success = helper.Compile(pipeline); | 1177 const bool success = helper.Compile(pipeline); |
| 1169 if (!success) { | 1178 if (!success) { |
| 1170 if (optimized) { | 1179 if (optimized) { |
| 1171 if (Compiler::IsBackgroundCompilation()) { | 1180 if (Compiler::IsBackgroundCompilation()) { |
| 1172 // Try again later, background compilation may abort because of | 1181 // Try again later, background compilation may abort because of |
| 1173 // state change during compilation. | 1182 // state change during compilation. |
| 1174 if (FLAG_trace_compiler) { | 1183 if (FLAG_trace_compiler) { |
| 1175 THR_Print("Aborted background compilation: %s\n", | 1184 THR_Print("Aborted background compilation: %s\n", |
| 1176 function.ToFullyQualifiedCString()); | 1185 function.ToFullyQualifiedCString()); |
| 1177 } | 1186 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1370 ASSERT(!code.is_optimized()); | 1379 ASSERT(!code.is_optimized()); |
| 1371 const Function& function = Function::Handle(code.function()); | 1380 const Function& function = Function::Handle(code.function()); |
| 1372 ParsedFunction* parsed_function = new ParsedFunction( | 1381 ParsedFunction* parsed_function = new ParsedFunction( |
| 1373 Thread::Current(), Function::ZoneHandle(function.raw())); | 1382 Thread::Current(), Function::ZoneHandle(function.raw())); |
| 1374 LocalVarDescriptors& var_descs = | 1383 LocalVarDescriptors& var_descs = |
| 1375 LocalVarDescriptors::Handle(code.var_descriptors()); | 1384 LocalVarDescriptors::Handle(code.var_descriptors()); |
| 1376 ASSERT(var_descs.IsNull()); | 1385 ASSERT(var_descs.IsNull()); |
| 1377 // IsIrregexpFunction have eager var descriptors generation. | 1386 // IsIrregexpFunction have eager var descriptors generation. |
| 1378 ASSERT(!function.IsIrregexpFunction()); | 1387 ASSERT(!function.IsIrregexpFunction()); |
| 1379 // Parser should not produce any errors, therefore no LongJumpScope needed. | 1388 // Parser should not produce any errors, therefore no LongJumpScope needed. |
| 1389 // (exception is background compilation). | |
| 1390 ASSERT(!Compiler::IsBackgroundCompilation()); | |
| 1380 Parser::ParseFunction(parsed_function); | 1391 Parser::ParseFunction(parsed_function); |
| 1381 parsed_function->AllocateVariables(); | 1392 parsed_function->AllocateVariables(); |
| 1382 var_descs = parsed_function->node_sequence()->scope()-> | 1393 var_descs = parsed_function->node_sequence()->scope()-> |
| 1383 GetVarDescriptors(function); | 1394 GetVarDescriptors(function); |
| 1384 ASSERT(!var_descs.IsNull()); | 1395 ASSERT(!var_descs.IsNull()); |
| 1385 code.set_var_descriptors(var_descs); | 1396 code.set_var_descriptors(var_descs); |
| 1386 } | 1397 } |
| 1387 | 1398 |
| 1388 | 1399 |
| 1389 RawError* Compiler::CompileAllFunctions(const Class& cls) { | 1400 RawError* Compiler::CompileAllFunctions(const Class& cls) { |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1896 } | 1907 } |
| 1897 | 1908 |
| 1898 | 1909 |
| 1899 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1910 void BackgroundCompiler::EnsureInit(Thread* thread) { |
| 1900 UNREACHABLE(); | 1911 UNREACHABLE(); |
| 1901 } | 1912 } |
| 1902 | 1913 |
| 1903 #endif // DART_PRECOMPILED_RUNTIME | 1914 #endif // DART_PRECOMPILED_RUNTIME |
| 1904 | 1915 |
| 1905 } // namespace dart | 1916 } // namespace dart |
| OLD | NEW |