| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/cha.h" | 10 #include "vm/cha.h" |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 static_calls_target_table_.Add( | 534 static_calls_target_table_.Add( |
| 535 Smi::Handle(Smi::New(assembler()->CodeSize()))); | 535 Smi::Handle(Smi::New(assembler()->CodeSize()))); |
| 536 ASSERT(Code::kSCallTableFunctionEntry == 1); | 536 ASSERT(Code::kSCallTableFunctionEntry == 1); |
| 537 static_calls_target_table_.Add(func); | 537 static_calls_target_table_.Add(func); |
| 538 ASSERT(Code::kSCallTableCodeEntry == 2); | 538 ASSERT(Code::kSCallTableCodeEntry == 2); |
| 539 static_calls_target_table_.Add(Code::Handle()); | 539 static_calls_target_table_.Add(Code::Handle()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 | 542 |
| 543 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, | 543 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, |
| 544 intptr_t token_pos, | 544 intptr_t token_pos) { |
| 545 intptr_t input_count) { | |
| 546 ASSERT(is_optimizing()); | 545 ASSERT(is_optimizing()); |
| 547 ASSERT(!intrinsic_mode()); | 546 ASSERT(!intrinsic_mode()); |
| 548 Environment* env = pending_deoptimization_env_->DeepCopy( | |
| 549 isolate(), pending_deoptimization_env_->Length() - input_count); | |
| 550 CompilerDeoptInfo* info = | 547 CompilerDeoptInfo* info = |
| 551 new CompilerDeoptInfo(deopt_id, | 548 new CompilerDeoptInfo(deopt_id, |
| 552 ICData::kDeoptAtCall, | 549 ICData::kDeoptAtCall, |
| 553 env); | 550 pending_deoptimization_env_); |
| 554 info->set_pc_offset(assembler()->CodeSize()); | 551 info->set_pc_offset(assembler()->CodeSize()); |
| 555 deopt_infos_.Add(info); | 552 deopt_infos_.Add(info); |
| 556 } | 553 } |
| 557 | 554 |
| 558 | 555 |
| 559 // This function must be in sync with FlowGraphCompiler::SaveLiveRegisters | 556 // This function must be in sync with FlowGraphCompiler::SaveLiveRegisters |
| 560 // and FlowGraphCompiler::SlowPathEnvironmentFor. | 557 // and FlowGraphCompiler::SlowPathEnvironmentFor. |
| 561 void FlowGraphCompiler::RecordSafepoint(LocationSummary* locs) { | 558 void FlowGraphCompiler::RecordSafepoint(LocationSummary* locs) { |
| 562 if (is_optimizing()) { | 559 if (is_optimizing()) { |
| 563 RegisterSet* registers = locs->live_registers(); | 560 RegisterSet* registers = locs->live_registers(); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 // "Deoptimization" from intrinsic continues here. All deoptimization | 865 // "Deoptimization" from intrinsic continues here. All deoptimization |
| 869 // branches from intrinsic code redirect to here where the slow-path | 866 // branches from intrinsic code redirect to here where the slow-path |
| 870 // (normal function body) starts. | 867 // (normal function body) starts. |
| 871 // This means that there must not be any side-effects in intrinsic code | 868 // This means that there must not be any side-effects in intrinsic code |
| 872 // before any deoptimization point. | 869 // before any deoptimization point. |
| 873 ASSERT(!intrinsic_slow_path_label_.IsBound()); | 870 ASSERT(!intrinsic_slow_path_label_.IsBound()); |
| 874 assembler()->Bind(&intrinsic_slow_path_label_); | 871 assembler()->Bind(&intrinsic_slow_path_label_); |
| 875 } | 872 } |
| 876 | 873 |
| 877 | 874 |
| 878 // Record safe point and deoptimization info if applicable. | |
| 879 void FlowGraphCompiler::RecordCallInfo(intptr_t token_pos, | |
| 880 RawPcDescriptors::Kind kind, | |
| 881 intptr_t deopt_id, | |
| 882 LocationSummary* locs, | |
| 883 intptr_t input_count_adjustment) { | |
| 884 AddCurrentDescriptor(kind, deopt_id, token_pos); | |
| 885 RecordSafepoint(locs); | |
| 886 if (deopt_id != Isolate::kNoDeoptId) { | |
| 887 // Marks either the continuation point in unoptimized code or the | |
| 888 // deoptimization point in optimized code, after call. | |
| 889 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); | |
| 890 if (is_optimizing()) { | |
| 891 AddDeoptIndexAtCall(deopt_id_after, token_pos, input_count_adjustment); | |
| 892 } else { | |
| 893 // Add deoptimization continuation point after the call and before the | |
| 894 // arguments are removed. | |
| 895 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | |
| 896 } | |
| 897 } | |
| 898 } | |
| 899 | |
| 900 | |
| 901 void FlowGraphCompiler::GenerateInstanceCall( | 875 void FlowGraphCompiler::GenerateInstanceCall( |
| 902 intptr_t deopt_id, | 876 intptr_t deopt_id, |
| 903 intptr_t token_pos, | 877 intptr_t token_pos, |
| 904 intptr_t argument_count, | 878 intptr_t argument_count, |
| 905 LocationSummary* locs, | 879 LocationSummary* locs, |
| 906 const ICData& ic_data) { | 880 const ICData& ic_data) { |
| 907 ASSERT(!ic_data.IsNull()); | 881 ASSERT(!ic_data.IsNull()); |
| 908 ASSERT(FLAG_propagate_ic_data || (ic_data.NumberOfUsedChecks() == 0)); | 882 ASSERT(FLAG_propagate_ic_data || (ic_data.NumberOfUsedChecks() == 0)); |
| 909 uword label_address = 0; | 883 uword label_address = 0; |
| 910 StubCode* stub_code = isolate()->stub_code(); | 884 StubCode* stub_code = isolate()->stub_code(); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 threshold = FLAG_optimization_counter_scale * basic_blocks + | 1470 threshold = FLAG_optimization_counter_scale * basic_blocks + |
| 1497 FLAG_min_optimization_counter_threshold; | 1471 FLAG_min_optimization_counter_threshold; |
| 1498 if (threshold > FLAG_optimization_counter_threshold) { | 1472 if (threshold > FLAG_optimization_counter_threshold) { |
| 1499 threshold = FLAG_optimization_counter_threshold; | 1473 threshold = FLAG_optimization_counter_threshold; |
| 1500 } | 1474 } |
| 1501 } | 1475 } |
| 1502 return threshold; | 1476 return threshold; |
| 1503 } | 1477 } |
| 1504 | 1478 |
| 1505 } // namespace dart | 1479 } // namespace dart |
| OLD | NEW |