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/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| 11 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/debugger.h" | 13 #include "vm/debugger.h" |
| 14 #include "vm/deopt_instructions.h" | 14 #include "vm/deopt_instructions.h" |
| 15 #include "vm/exceptions.h" | 15 #include "vm/exceptions.h" |
| 16 #include "vm/intermediate_language.h" | 16 #include "vm/intermediate_language.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/message.h" | 18 #include "vm/message.h" |
| 19 #include "vm/message_handler.h" | 19 #include "vm/message_handler.h" |
| 20 #include "vm/parser.h" | 20 #include "vm/parser.h" |
| 21 #include "vm/resolver.h" | 21 #include "vm/resolver.h" |
| 22 #include "vm/runtime_entry.h" | 22 #include "vm/runtime_entry.h" |
| 23 #include "vm/stack_frame.h" | 23 #include "vm/stack_frame.h" |
| 24 #include "vm/symbols.h" | 24 #include "vm/symbols.h" |
| 25 #include "vm/verifier.h" | 25 #include "vm/verifier.h" |
| 26 | 26 |
| 27 namespace dart { | 27 namespace dart { |
| 28 | 28 |
| 29 DEFINE_FLAG(bool, deoptimize_alot, false, | |
| 30 "Deoptimizes all live frames at runtime and native entries."); | |
|
siva
2012/08/30 01:37:30
Deoptimizes all live frames when we are about to r
srdjan
2012/08/30 17:16:16
Done, removed reference to runtime.
| |
| 29 DEFINE_FLAG(bool, inline_cache, true, "Enable inline caches"); | 31 DEFINE_FLAG(bool, inline_cache, true, "Enable inline caches"); |
| 30 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); | 32 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); |
| 31 DEFINE_FLAG(bool, trace_ic, false, "Trace IC handling"); | 33 DEFINE_FLAG(bool, trace_ic, false, "Trace IC handling"); |
| 32 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); | 34 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); |
| 33 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls"); | 35 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls"); |
| 34 DEFINE_FLAG(int, optimization_counter_threshold, 2000, | 36 DEFINE_FLAG(int, optimization_counter_threshold, 2000, |
| 35 "Function's usage-counter value before it is optimized, -1 means never"); | 37 "Function's usage-counter value before it is optimized, -1 means never"); |
| 36 DECLARE_FLAG(bool, enable_type_checks); | 38 DECLARE_FLAG(bool, enable_type_checks); |
| 37 DECLARE_FLAG(bool, trace_type_checks); | 39 DECLARE_FLAG(bool, trace_type_checks); |
| 38 DECLARE_FLAG(bool, report_usage_count); | 40 DECLARE_FLAG(bool, report_usage_count); |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 *deopt_index = descriptors.DeoptIndex(i); | 1390 *deopt_index = descriptors.DeoptIndex(i); |
| 1389 return; | 1391 return; |
| 1390 } | 1392 } |
| 1391 } | 1393 } |
| 1392 *deopt_id = Isolate::kNoDeoptId; | 1394 *deopt_id = Isolate::kNoDeoptId; |
| 1393 *deopt_reason = kDeoptUnknown; | 1395 *deopt_reason = kDeoptUnknown; |
| 1394 *deopt_index = -1; | 1396 *deopt_index = -1; |
| 1395 } | 1397 } |
| 1396 | 1398 |
| 1397 | 1399 |
| 1400 // Currently checks only that all optimized frames have kDeoptIndex | |
| 1401 // and unoptimized code has the kDeoptAfter. | |
| 1402 void DeoptimizeAll() { | |
| 1403 DartFrameIterator iterator; | |
| 1404 StackFrame* frame = iterator.NextFrame(); | |
|
siva
2012/08/30 01:37:30
Code& optimized_code = Code::Handle();
Function& f
srdjan
2012/08/30 17:16:16
Done.
| |
| 1405 while (frame != NULL) { | |
| 1406 const Code& optimized_code = Code::Handle(frame->LookupDartCode()); | |
|
siva
2012/08/30 01:37:30
optimized_code = frame->LookupDartCode();
srdjan
2012/08/30 17:16:16
Done.
| |
| 1407 if (optimized_code.is_optimized()) { | |
| 1408 intptr_t deopt_id, deopt_reason, deopt_index; | |
| 1409 GetDeoptIxDescrAtPc(optimized_code, frame->pc(), | |
| 1410 &deopt_id, &deopt_reason, &deopt_index); | |
| 1411 ASSERT(deopt_id != Isolate::kNoDeoptId); | |
| 1412 const Function& function = Function::Handle(optimized_code.function()); | |
|
siva
2012/08/30 01:37:30
function = optimized_code.function();
unoptimized_
srdjan
2012/08/30 17:16:16
Done.
| |
| 1413 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); | |
| 1414 ASSERT(!unoptimized_code.IsNull()); | |
| 1415 uword continue_at_pc = | |
| 1416 unoptimized_code.GetDeoptAfterPcAtDeoptId(deopt_id); | |
| 1417 ASSERT(continue_at_pc != 0); | |
|
siva
2012/08/30 01:37:30
Maybe also assert that
continue_at_pc > unoptimize
srdjan
2012/08/30 17:16:16
This check belongs in GetDeoptAfterPcAtDeoptId. Ad
| |
| 1418 } | |
| 1419 frame = iterator.NextFrame(); | |
| 1420 } | |
| 1421 } | |
| 1422 | |
| 1398 | 1423 |
| 1399 // Copy saved registers into the isolate buffer. | 1424 // Copy saved registers into the isolate buffer. |
| 1400 static void CopySavedRegisters(intptr_t* saved_registers_address) { | 1425 static void CopySavedRegisters(intptr_t* saved_registers_address) { |
| 1401 intptr_t* registers_copy = new intptr_t[kNumberOfCpuRegisters]; | 1426 intptr_t* registers_copy = new intptr_t[kNumberOfCpuRegisters]; |
| 1402 ASSERT(registers_copy != NULL); | 1427 ASSERT(registers_copy != NULL); |
| 1403 ASSERT(saved_registers_address != NULL); | 1428 ASSERT(saved_registers_address != NULL); |
| 1404 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { | 1429 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { |
| 1405 registers_copy[i] = *saved_registers_address; | 1430 registers_copy[i] = *saved_registers_address; |
| 1406 saved_registers_address++; | 1431 saved_registers_address++; |
| 1407 } | 1432 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1556 ASSERT(!optimized_code.IsNull() && optimized_code.is_optimized()); | 1581 ASSERT(!optimized_code.IsNull() && optimized_code.is_optimized()); |
| 1557 ASSERT(!unoptimized_code.IsNull() && !unoptimized_code.is_optimized()); | 1582 ASSERT(!unoptimized_code.IsNull() && !unoptimized_code.is_optimized()); |
| 1558 | 1583 |
| 1559 intptr_t* frame_copy = isolate->deopt_frame_copy(); | 1584 intptr_t* frame_copy = isolate->deopt_frame_copy(); |
| 1560 intptr_t* registers_copy = isolate->deopt_registers_copy(); | 1585 intptr_t* registers_copy = isolate->deopt_registers_copy(); |
| 1561 | 1586 |
| 1562 intptr_t deopt_id, deopt_reason, deopt_index; | 1587 intptr_t deopt_id, deopt_reason, deopt_index; |
| 1563 GetDeoptIxDescrAtPc(optimized_code, caller_frame->pc(), | 1588 GetDeoptIxDescrAtPc(optimized_code, caller_frame->pc(), |
| 1564 &deopt_id, &deopt_reason, &deopt_index); | 1589 &deopt_id, &deopt_reason, &deopt_index); |
| 1565 ASSERT(deopt_id != Isolate::kNoDeoptId); | 1590 ASSERT(deopt_id != Isolate::kNoDeoptId); |
| 1566 uword continue_at_pc = unoptimized_code.GetDeoptPcAtDeoptId(deopt_id); | 1591 uword continue_at_pc = unoptimized_code.GetDeoptBeforePcAtDeoptId(deopt_id); |
|
siva
2012/08/30 01:37:30
I am a little confused I thought unoptimized_code
srdjan
2012/08/30 17:16:16
DeoptBefore an DeoptAfter are continuation points
| |
| 1567 if (FLAG_trace_deopt) { | 1592 if (FLAG_trace_deopt) { |
| 1568 OS::Print(" -> continue at 0x%x\n", continue_at_pc); | 1593 OS::Print(" -> continue at 0x%x\n", continue_at_pc); |
| 1569 // TODO(srdjan): If we could allow GC, we could print the line where | 1594 // TODO(srdjan): If we could allow GC, we could print the line where |
| 1570 // deoptimization occured. | 1595 // deoptimization occured. |
| 1571 } | 1596 } |
| 1572 const Array& deopt_info_array = | 1597 const Array& deopt_info_array = |
| 1573 Array::Handle(optimized_code.deopt_info_array()); | 1598 Array::Handle(optimized_code.deopt_info_array()); |
| 1574 ASSERT(!deopt_info_array.IsNull()); | 1599 ASSERT(!deopt_info_array.IsNull()); |
| 1575 DeoptInfo& deopt_info = DeoptInfo::Handle(); | 1600 DeoptInfo& deopt_info = DeoptInfo::Handle(); |
| 1576 deopt_info ^= deopt_info_array.At(deopt_index); | 1601 deopt_info ^= deopt_info_array.At(deopt_index); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1607 function.set_usage_counter(0); | 1632 function.set_usage_counter(0); |
| 1608 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 1633 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
| 1609 | 1634 |
| 1610 if (function.HasOptimizedCode()) { | 1635 if (function.HasOptimizedCode()) { |
| 1611 function.SwitchToUnoptimizedCode(); | 1636 function.SwitchToUnoptimizedCode(); |
| 1612 } | 1637 } |
| 1613 } | 1638 } |
| 1614 END_LEAF_RUNTIME_ENTRY | 1639 END_LEAF_RUNTIME_ENTRY |
| 1615 | 1640 |
| 1616 } // namespace dart | 1641 } // namespace dart |
| OLD | NEW |