Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: runtime/vm/intermediate_language_dbc.cc

Issue 2388093003: VM: Make optimized try-catch work in DBC. (Closed)
Patch Set: new test file Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1112 }
1113 1113
1114 1114
1115 EMIT_NATIVE_CODE(CatchBlockEntry, 0) { 1115 EMIT_NATIVE_CODE(CatchBlockEntry, 0) {
1116 __ Bind(compiler->GetJumpLabel(this)); 1116 __ Bind(compiler->GetJumpLabel(this));
1117 compiler->AddExceptionHandler(catch_try_index(), 1117 compiler->AddExceptionHandler(catch_try_index(),
1118 try_index(), 1118 try_index(),
1119 compiler->assembler()->CodeSize(), 1119 compiler->assembler()->CodeSize(),
1120 catch_handler_types_, 1120 catch_handler_types_,
1121 needs_stacktrace()); 1121 needs_stacktrace());
1122 __ MoveSpecial(-exception_var().index()-1, 1122
1123 Simulator::kExceptionSpecialIndex); 1123 if (HasParallelMove()) {
1124 __ MoveSpecial(-stacktrace_var().index()-1, 1124 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
1125 Simulator::kStacktraceSpecialIndex); 1125 }
1126 if (compiler->is_optimizing()) {
1127 // In optimized code, variables at the catch block entry reside at the top
1128 // of the allocatable register range.
1129 const intptr_t num_non_copied_params =
1130 compiler->flow_graph().num_non_copied_params();
1131 const intptr_t exception_reg = kNumberOfCpuRegisters -
1132 (-exception_var().index() + num_non_copied_params);
1133 const intptr_t stacktrace_reg = kNumberOfCpuRegisters -
1134 (-stacktrace_var().index() + num_non_copied_params);
1135 __ MoveSpecial(exception_reg, Simulator::kExceptionSpecialIndex);
1136 __ MoveSpecial(stacktrace_reg, Simulator::kStacktraceSpecialIndex);
1137 } else {
1138 __ MoveSpecial(LocalVarIndex(0, exception_var().index()),
1139 Simulator::kExceptionSpecialIndex);
1140 __ MoveSpecial(LocalVarIndex(0, stacktrace_var().index()),
1141 Simulator::kStacktraceSpecialIndex);
1142 }
1126 __ SetFrame(compiler->StackSize()); 1143 __ SetFrame(compiler->StackSize());
1127 } 1144 }
1128 1145
1129 1146
1130 EMIT_NATIVE_CODE(Throw, 0, Location::NoLocation(), LocationSummary::kCall) { 1147 EMIT_NATIVE_CODE(Throw, 0, Location::NoLocation(), LocationSummary::kCall) {
1131 __ Throw(0); 1148 __ Throw(0);
1132 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, 1149 compiler->AddCurrentDescriptor(RawPcDescriptors::kOther,
1133 deopt_id(), 1150 deopt_id(),
1134 token_pos()); 1151 token_pos());
1135 compiler->RecordAfterCall(this); 1152 compiler->RecordAfterCall(this);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 if (DeoptIfNull()) { 1410 if (DeoptIfNull()) {
1394 __ IfEqNull(value); 1411 __ IfEqNull(value);
1395 } else { 1412 } else {
1396 __ IfNeNull(value); 1413 __ IfNeNull(value);
1397 } 1414 }
1398 } else { 1415 } else {
1399 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || 1416 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
1400 (unary_checks().NumberOfChecks() > 1)); 1417 (unary_checks().NumberOfChecks() > 1));
1401 const intptr_t may_be_smi = 1418 const intptr_t may_be_smi =
1402 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; 1419 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0;
1420 bool is_dense_switch = false;
1421 intptr_t cid_mask = 0;
1403 if (IsDenseSwitch()) { 1422 if (IsDenseSwitch()) {
1404 ASSERT(cids_[0] < cids_[cids_.length() - 1]); 1423 ASSERT(cids_[0] < cids_[cids_.length() - 1]);
1424 cid_mask = ComputeCidMask();
1425 is_dense_switch = Smi::IsValid(cid_mask);
1426 }
1427 if (is_dense_switch) {
1405 const intptr_t low_cid = cids_[0]; 1428 const intptr_t low_cid = cids_[0];
1406 const intptr_t cid_mask = ComputeCidMask();
1407 __ CheckDenseSwitch(value, may_be_smi); 1429 __ CheckDenseSwitch(value, may_be_smi);
1408 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); 1430 __ Nop(compiler->ToEmbeddableCid(low_cid, this));
1409 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); 1431 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask))));
1410 } else { 1432 } else {
1411 GrowableArray<CidTarget> sorted_ic_data; 1433 GrowableArray<CidTarget> sorted_ic_data;
1412 FlowGraphCompiler::SortICDataByCount(unary_checks(), 1434 FlowGraphCompiler::SortICDataByCount(unary_checks(),
1413 &sorted_ic_data, 1435 &sorted_ic_data,
1414 /* drop_smi = */ true); 1436 /* drop_smi = */ true);
1415 const intptr_t sorted_length = sorted_ic_data.length(); 1437 const intptr_t sorted_length = sorted_ic_data.length();
1416 if (!Utils::IsUint(8, sorted_length)) { 1438 if (!Utils::IsUint(8, sorted_length)) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 __ IfULe(length, index); 1905 __ IfULe(length, index);
1884 compiler->EmitDeopt(deopt_id(), 1906 compiler->EmitDeopt(deopt_id(),
1885 ICData::kDeoptCheckArrayBound, 1907 ICData::kDeoptCheckArrayBound,
1886 (generalized_ ? ICData::kGeneralized : 0) | 1908 (generalized_ ? ICData::kGeneralized : 0) |
1887 (licm_hoisted_ ? ICData::kHoisted : 0)); 1909 (licm_hoisted_ ? ICData::kHoisted : 0));
1888 } 1910 }
1889 1911
1890 } // namespace dart 1912 } // namespace dart
1891 1913
1892 #endif // defined TARGET_ARCH_DBC 1914 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698