| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // LongJump. | 420 // LongJump. |
| 421 { | 421 { |
| 422 CSTAT_TIMER_SCOPE(thread, graphbuilder_timer); | 422 CSTAT_TIMER_SCOPE(thread, graphbuilder_timer); |
| 423 ZoneGrowableArray<const ICData*>* ic_data_array = | 423 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 424 new(zone) ZoneGrowableArray<const ICData*>(); | 424 new(zone) ZoneGrowableArray<const ICData*>(); |
| 425 if (optimized) { | 425 if (optimized) { |
| 426 // Extract type feedback before the graph is built, as the graph | 426 // Extract type feedback before the graph is built, as the graph |
| 427 // builder uses it to attach it to nodes. | 427 // builder uses it to attach it to nodes. |
| 428 ASSERT(function.deoptimization_counter() < | 428 ASSERT(function.deoptimization_counter() < |
| 429 FLAG_deoptimization_counter_threshold); | 429 FLAG_deoptimization_counter_threshold); |
| 430 function.RestoreICDataMap(ic_data_array); | 430 if ((osr_id == Compiler::kNoOSRDeoptId) && |
| 431 FLAG_background_compilation && optimized) { |
| 432 ASSERT(!Thread::Current()->IsMutatorThread()); |
| 433 // This 'freezes' ICData so that it does not change while compiling. |
| 434 function.CopyICDataMap(ic_data_array); |
| 435 } else { |
| 436 ASSERT(Thread::Current()->IsMutatorThread()); |
| 437 function.RestoreICDataMap(ic_data_array); |
| 438 } |
| 431 if (FLAG_print_ic_data_map) { | 439 if (FLAG_print_ic_data_map) { |
| 432 for (intptr_t i = 0; i < ic_data_array->length(); i++) { | 440 for (intptr_t i = 0; i < ic_data_array->length(); i++) { |
| 433 if ((*ic_data_array)[i] != NULL) { | 441 if ((*ic_data_array)[i] != NULL) { |
| 434 THR_Print("%" Pd " ", i); | 442 THR_Print("%" Pd " ", i); |
| 435 FlowGraphPrinter::PrintICData(*(*ic_data_array)[i]); | 443 FlowGraphPrinter::PrintICData(*(*ic_data_array)[i]); |
| 436 } | 444 } |
| 437 } | 445 } |
| 438 } | 446 } |
| 439 } | 447 } |
| 440 | 448 |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 function, | 1538 function, |
| 1531 Compiler::kNoOSRDeoptId, | 1539 Compiler::kNoOSRDeoptId, |
| 1532 &code)); | 1540 &code)); |
| 1533 // TODO(srdjan): We do not expect errors while compiling optimized | 1541 // TODO(srdjan): We do not expect errors while compiling optimized |
| 1534 // code, any errors should have been caught when compiling | 1542 // code, any errors should have been caught when compiling |
| 1535 // unoptimized code. | 1543 // unoptimized code. |
| 1536 // If it still happens mark function as not optimizable. | 1544 // If it still happens mark function as not optimizable. |
| 1537 ASSERT(error.IsNull()); | 1545 ASSERT(error.IsNull()); |
| 1538 temp_function = RemoveFunctionOrNull(); | 1546 temp_function = RemoveFunctionOrNull(); |
| 1539 ASSERT(temp_function.raw() == function.raw()); | 1547 ASSERT(temp_function.raw() == function.raw()); |
| 1540 // Reset to 0 so that it can be recompiled if needed. | |
| 1541 function.set_usage_counter(0); | |
| 1542 function = LastFunctionOrNull(); | 1548 function = LastFunctionOrNull(); |
| 1549 ASSERT(!code.IsNull()); |
| 1543 AddCode(code); | 1550 AddCode(code); |
| 1544 } | 1551 } |
| 1545 } | 1552 } |
| 1546 Thread::ExitIsolateAsHelper(); | 1553 Thread::ExitIsolateAsHelper(); |
| 1547 { | 1554 { |
| 1548 // Wait to be notified when the work queue is not empty. | 1555 // Wait to be notified when the work queue is not empty. |
| 1549 MonitorLocker ml(queue_monitor_); | 1556 MonitorLocker ml(queue_monitor_); |
| 1550 while ((function_queue_length() == 0) && running_) { | 1557 while ((function_queue_length() == 0) && running_) { |
| 1551 ml.Wait(); | 1558 ml.Wait(); |
| 1552 } | 1559 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1568 | 1575 |
| 1569 void BackgroundCompiler::InstallGeneratedCode() { | 1576 void BackgroundCompiler::InstallGeneratedCode() { |
| 1570 MonitorLocker ml(queue_monitor_); | 1577 MonitorLocker ml(queue_monitor_); |
| 1571 CompilationWorkQueue queue(CodesQueue()); | 1578 CompilationWorkQueue queue(CodesQueue()); |
| 1572 Code& code = Code::Handle(); | 1579 Code& code = Code::Handle(); |
| 1573 Object& owner = Object::Handle(); | 1580 Object& owner = Object::Handle(); |
| 1574 for (intptr_t i = 0; i < queue.Length(); i++) { | 1581 for (intptr_t i = 0; i < queue.Length(); i++) { |
| 1575 code = queue.PopBackCode(); | 1582 code = queue.PopBackCode(); |
| 1576 if (code.IsDisabled()) continue; | 1583 if (code.IsDisabled()) continue; |
| 1577 owner = code.owner(); | 1584 owner = code.owner(); |
| 1578 ASSERT(owner.IsFunction()); | 1585 const Function& function = Function::Cast(owner); |
| 1579 Function::Cast(owner).InstallOptimizedCode(code, false /* not OSR */); | 1586 function.InstallOptimizedCode(code, false /* not OSR */); |
| 1587 if (function.usage_counter() < 0) { |
| 1588 // Reset to 0 so that it can be recompiled if needed. |
| 1589 function.set_usage_counter(0); |
| 1590 } |
| 1580 } | 1591 } |
| 1581 } | 1592 } |
| 1582 | 1593 |
| 1583 | 1594 |
| 1584 GrowableObjectArray* BackgroundCompiler::FunctionsQueue() const { | 1595 GrowableObjectArray* BackgroundCompiler::FunctionsQueue() const { |
| 1585 return | 1596 return |
| 1586 &GrowableObjectArray::ZoneHandle(isolate_->compilation_function_queue()); | 1597 &GrowableObjectArray::ZoneHandle(isolate_->compilation_function_queue()); |
| 1587 } | 1598 } |
| 1588 | 1599 |
| 1589 | 1600 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 thread->zone(), GrowableObjectArray::New())); | 1681 thread->zone(), GrowableObjectArray::New())); |
| 1671 start_task = true; | 1682 start_task = true; |
| 1672 } | 1683 } |
| 1673 } | 1684 } |
| 1674 if (start_task) { | 1685 if (start_task) { |
| 1675 Dart::thread_pool()->Run(isolate->background_compiler()); | 1686 Dart::thread_pool()->Run(isolate->background_compiler()); |
| 1676 } | 1687 } |
| 1677 } | 1688 } |
| 1678 | 1689 |
| 1679 } // namespace dart | 1690 } // namespace dart |
| OLD | NEW |