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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 CompileParsedFunctionHelper(ParsedFunction* parsed_function, | 374 CompileParsedFunctionHelper(ParsedFunction* parsed_function, |
| 375 bool optimized, | 375 bool optimized, |
| 376 intptr_t osr_id) | 376 intptr_t osr_id) |
| 377 : parsed_function_(parsed_function), | 377 : parsed_function_(parsed_function), |
| 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 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), | 381 field_invalidation_gen_at_start_(isolate()->field_invalidation_gen()), |
| 382 loading_invalidation_gen_at_start_( | 382 loading_invalidation_gen_at_start_( |
| 383 isolate()->loading_invalidation_gen()) { | 383 isolate()->loading_invalidation_gen()) { |
| 384 if (Compiler::IsBackgroundCompilation()) { | |
| 385 Isolate::Current()->ClearDisablingFieldList(); | |
|
siva
2016/04/12 17:46:45
maybe use 'isolate()' here to avoid another Thread
srdjan
2016/04/12 19:47:18
Done in next CL.
| |
| 386 } | |
| 384 } | 387 } |
| 385 | 388 |
| 386 bool Compile(CompilationPipeline* pipeline); | 389 bool Compile(CompilationPipeline* pipeline); |
| 387 | 390 |
| 388 private: | 391 private: |
| 389 ParsedFunction* parsed_function() const { return parsed_function_; } | 392 ParsedFunction* parsed_function() const { return parsed_function_; } |
| 390 bool optimized() const { return optimized_; } | 393 bool optimized() const { return optimized_; } |
| 391 intptr_t osr_id() const { return osr_id_; } | 394 intptr_t osr_id() const { return osr_id_; } |
| 392 Thread* thread() const { return thread_; } | 395 Thread* thread() const { return thread_; } |
| 393 Isolate* isolate() const { return thread_->isolate(); } | 396 Isolate* isolate() const { return thread_->isolate(); } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 405 const bool optimized_; | 408 const bool optimized_; |
| 406 const intptr_t osr_id_; | 409 const intptr_t osr_id_; |
| 407 Thread* const thread_; | 410 Thread* const thread_; |
| 408 const intptr_t field_invalidation_gen_at_start_; | 411 const intptr_t field_invalidation_gen_at_start_; |
| 409 const intptr_t loading_invalidation_gen_at_start_; | 412 const intptr_t loading_invalidation_gen_at_start_; |
| 410 | 413 |
| 411 DISALLOW_COPY_AND_ASSIGN(CompileParsedFunctionHelper); | 414 DISALLOW_COPY_AND_ASSIGN(CompileParsedFunctionHelper); |
| 412 }; | 415 }; |
| 413 | 416 |
| 414 | 417 |
| 418 // Returns true if any of disabling fields is inside the guarded_fields. | |
| 419 // The number of guarded_fields and disabling-fields is expected to be small | |
| 420 // (less than 5). | |
| 421 static bool CheckDisablingFields( | |
| 422 Thread* thread, | |
| 423 const ZoneGrowableArray<const Field*>& guarded_fields) { | |
| 424 Isolate* isolate = thread->isolate(); | |
| 425 Zone* zone = thread->zone(); | |
| 426 Field& field = Field::Handle(zone, isolate->GetDisablingField()); | |
| 427 while (!field.IsNull()) { | |
| 428 for (intptr_t i = 0; i < guarded_fields.length(); i++) { | |
| 429 if (guarded_fields.At(i)->raw() == field.raw()) { | |
| 430 return true; | |
| 431 } | |
| 432 } | |
| 433 // Get next field. | |
| 434 field = isolate->GetDisablingField(); | |
| 435 } | |
|
siva
2016/04/12 17:46:45
This loop acquires/release lock with every access
srdjan
2016/04/12 19:47:18
Since this occurs only while background compiler i
| |
| 436 return false; | |
| 437 } | |
| 438 | |
| 439 | |
| 415 void CompileParsedFunctionHelper::FinalizeCompilation( | 440 void CompileParsedFunctionHelper::FinalizeCompilation( |
| 416 Assembler* assembler, | 441 Assembler* assembler, |
| 417 FlowGraphCompiler* graph_compiler, | 442 FlowGraphCompiler* graph_compiler, |
| 418 FlowGraph* flow_graph) { | 443 FlowGraph* flow_graph) { |
| 419 ASSERT(!FLAG_precompiled_mode); | 444 ASSERT(!FLAG_precompiled_mode); |
| 420 const Function& function = parsed_function()->function(); | 445 const Function& function = parsed_function()->function(); |
| 421 Zone* const zone = thread()->zone(); | 446 Zone* const zone = thread()->zone(); |
| 422 | 447 |
| 423 CSTAT_TIMER_SCOPE(thread(), codefinalizer_timer); | 448 CSTAT_TIMER_SCOPE(thread(), codefinalizer_timer); |
| 424 // CreateDeoptInfo uses the object pool and needs to be done before | 449 // CreateDeoptInfo uses the object pool and needs to be done before |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 } else { | 517 } else { |
| 493 // Background compilation. | 518 // Background compilation. |
| 494 // Before installing code check generation counts if the code may | 519 // Before installing code check generation counts if the code may |
| 495 // have become invalid. | 520 // have become invalid. |
| 496 const bool trace_compiler = | 521 const bool trace_compiler = |
| 497 FLAG_trace_compiler || FLAG_trace_optimizing_compiler; | 522 FLAG_trace_compiler || FLAG_trace_optimizing_compiler; |
| 498 bool code_is_valid = true; | 523 bool code_is_valid = true; |
| 499 if (!flow_graph->parsed_function().guarded_fields()->is_empty()) { | 524 if (!flow_graph->parsed_function().guarded_fields()->is_empty()) { |
| 500 if (field_invalidation_gen_at_start() != | 525 if (field_invalidation_gen_at_start() != |
| 501 isolate()->field_invalidation_gen()) { | 526 isolate()->field_invalidation_gen()) { |
| 502 code_is_valid = false; | 527 const ZoneGrowableArray<const Field*>& guarded_fields = |
| 503 if (trace_compiler) { | 528 *flow_graph->parsed_function().guarded_fields(); |
| 504 THR_Print("--> FAIL: Field invalidation."); | 529 bool field_conflict = CheckDisablingFields(thread(), guarded_fields); |
| 505 } | 530 if (field_conflict) { |
| 531 code_is_valid = false; | |
| 532 if (trace_compiler) { | |
| 533 THR_Print("--> FAIL: Field invalidation."); | |
| 534 } | |
| 535 } | |
| 506 } | 536 } |
| 507 } | 537 } |
| 508 if (loading_invalidation_gen_at_start() != | 538 if (loading_invalidation_gen_at_start() != |
| 509 isolate()->loading_invalidation_gen()) { | 539 isolate()->loading_invalidation_gen()) { |
| 510 code_is_valid = false; | 540 code_is_valid = false; |
| 511 if (trace_compiler) { | 541 if (trace_compiler) { |
| 512 THR_Print("--> FAIL: Loading invalidation."); | 542 THR_Print("--> FAIL: Loading invalidation."); |
| 513 } | 543 } |
| 514 } | 544 } |
| 515 if (code_is_valid) { | 545 if (code_is_valid) { |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1957 } | 1987 } |
| 1958 | 1988 |
| 1959 | 1989 |
| 1960 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1990 void BackgroundCompiler::EnsureInit(Thread* thread) { |
| 1961 UNREACHABLE(); | 1991 UNREACHABLE(); |
| 1962 } | 1992 } |
| 1963 | 1993 |
| 1964 #endif // DART_PRECOMPILED_RUNTIME | 1994 #endif // DART_PRECOMPILED_RUNTIME |
| 1965 | 1995 |
| 1966 } // namespace dart | 1996 } // namespace dart |
| OLD | NEW |