OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1122 } |
1123 | 1123 |
1124 | 1124 |
1125 EMIT_NATIVE_CODE(CatchBlockEntry, 0) { | 1125 EMIT_NATIVE_CODE(CatchBlockEntry, 0) { |
1126 __ Bind(compiler->GetJumpLabel(this)); | 1126 __ Bind(compiler->GetJumpLabel(this)); |
1127 compiler->AddExceptionHandler(catch_try_index(), | 1127 compiler->AddExceptionHandler(catch_try_index(), |
1128 try_index(), | 1128 try_index(), |
1129 compiler->assembler()->CodeSize(), | 1129 compiler->assembler()->CodeSize(), |
1130 catch_handler_types_, | 1130 catch_handler_types_, |
1131 needs_stacktrace()); | 1131 needs_stacktrace()); |
1132 __ MoveSpecial(-exception_var().index()-1, | 1132 |
1133 Simulator::kExceptionSpecialIndex); | 1133 if (HasParallelMove()) { |
1134 __ MoveSpecial(-stacktrace_var().index()-1, | 1134 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
1135 Simulator::kStacktraceSpecialIndex); | 1135 } |
| 1136 if (compiler->is_optimizing()) { |
| 1137 // In optimized code, variables at the catch block entry reside at the top |
| 1138 // of the allocatable register range. |
| 1139 const intptr_t num_non_copied_params = |
| 1140 compiler->flow_graph().num_non_copied_params(); |
| 1141 const intptr_t exception_reg = kNumberOfCpuRegisters - |
| 1142 (-exception_var().index() + num_non_copied_params); |
| 1143 const intptr_t stacktrace_reg = kNumberOfCpuRegisters - |
| 1144 (-stacktrace_var().index() + num_non_copied_params); |
| 1145 __ MoveSpecial(exception_reg, Simulator::kExceptionSpecialIndex); |
| 1146 __ MoveSpecial(stacktrace_reg, Simulator::kStacktraceSpecialIndex); |
| 1147 } else { |
| 1148 __ MoveSpecial(LocalVarIndex(0, exception_var().index()), |
| 1149 Simulator::kExceptionSpecialIndex); |
| 1150 __ MoveSpecial(LocalVarIndex(0, stacktrace_var().index()), |
| 1151 Simulator::kStacktraceSpecialIndex); |
| 1152 } |
1136 __ SetFrame(compiler->StackSize()); | 1153 __ SetFrame(compiler->StackSize()); |
1137 } | 1154 } |
1138 | 1155 |
1139 | 1156 |
1140 EMIT_NATIVE_CODE(Throw, 0, Location::NoLocation(), LocationSummary::kCall) { | 1157 EMIT_NATIVE_CODE(Throw, 0, Location::NoLocation(), LocationSummary::kCall) { |
1141 __ Throw(0); | 1158 __ Throw(0); |
1142 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, | 1159 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, |
1143 deopt_id(), | 1160 deopt_id(), |
1144 token_pos()); | 1161 token_pos()); |
1145 compiler->RecordAfterCall(this); | 1162 compiler->RecordAfterCall(this); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 if (DeoptIfNull()) { | 1420 if (DeoptIfNull()) { |
1404 __ IfEqNull(value); | 1421 __ IfEqNull(value); |
1405 } else { | 1422 } else { |
1406 __ IfNeNull(value); | 1423 __ IfNeNull(value); |
1407 } | 1424 } |
1408 } else { | 1425 } else { |
1409 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | 1426 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || |
1410 (unary_checks().NumberOfChecks() > 1)); | 1427 (unary_checks().NumberOfChecks() > 1)); |
1411 const intptr_t may_be_smi = | 1428 const intptr_t may_be_smi = |
1412 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; | 1429 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; |
| 1430 bool is_dense_switch = false; |
| 1431 intptr_t cid_mask = 0; |
1413 if (IsDenseSwitch()) { | 1432 if (IsDenseSwitch()) { |
1414 ASSERT(cids_[0] < cids_[cids_.length() - 1]); | 1433 ASSERT(cids_[0] < cids_[cids_.length() - 1]); |
| 1434 cid_mask = ComputeCidMask(); |
| 1435 is_dense_switch = Smi::IsValid(cid_mask); |
| 1436 } |
| 1437 if (is_dense_switch) { |
1415 const intptr_t low_cid = cids_[0]; | 1438 const intptr_t low_cid = cids_[0]; |
1416 const intptr_t cid_mask = ComputeCidMask(); | |
1417 __ CheckDenseSwitch(value, may_be_smi); | 1439 __ CheckDenseSwitch(value, may_be_smi); |
1418 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); | 1440 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); |
1419 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); | 1441 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); |
1420 } else { | 1442 } else { |
1421 GrowableArray<CidTarget> sorted_ic_data; | 1443 GrowableArray<CidTarget> sorted_ic_data; |
1422 FlowGraphCompiler::SortICDataByCount(unary_checks(), | 1444 FlowGraphCompiler::SortICDataByCount(unary_checks(), |
1423 &sorted_ic_data, | 1445 &sorted_ic_data, |
1424 /* drop_smi = */ true); | 1446 /* drop_smi = */ true); |
1425 const intptr_t sorted_length = sorted_ic_data.length(); | 1447 const intptr_t sorted_length = sorted_ic_data.length(); |
1426 if (!Utils::IsUint(8, sorted_length)) { | 1448 if (!Utils::IsUint(8, sorted_length)) { |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 __ IfULe(length, index); | 1912 __ IfULe(length, index); |
1891 compiler->EmitDeopt(deopt_id(), | 1913 compiler->EmitDeopt(deopt_id(), |
1892 ICData::kDeoptCheckArrayBound, | 1914 ICData::kDeoptCheckArrayBound, |
1893 (generalized_ ? ICData::kGeneralized : 0) | | 1915 (generalized_ ? ICData::kGeneralized : 0) | |
1894 (licm_hoisted_ ? ICData::kHoisted : 0)); | 1916 (licm_hoisted_ ? ICData::kHoisted : 0)); |
1895 } | 1917 } |
1896 | 1918 |
1897 } // namespace dart | 1919 } // namespace dart |
1898 | 1920 |
1899 #endif // defined TARGET_ARCH_DBC | 1921 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |