Chromium Code Reviews| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 M(ExtractNthOutput) \ | 98 M(ExtractNthOutput) \ |
| 99 M(BinaryUint32Op) \ | 99 M(BinaryUint32Op) \ |
| 100 M(ShiftUint32Op) \ | 100 M(ShiftUint32Op) \ |
| 101 M(UnaryUint32Op) \ | 101 M(UnaryUint32Op) \ |
| 102 M(UnboxedIntConverter) \ | 102 M(UnboxedIntConverter) \ |
| 103 M(GrowRegExpStack) \ | 103 M(GrowRegExpStack) \ |
| 104 M(BoxInteger32) \ | 104 M(BoxInteger32) \ |
| 105 M(UnboxInteger32) \ | 105 M(UnboxInteger32) \ |
| 106 M(CheckedSmiOp) \ | 106 M(CheckedSmiOp) \ |
| 107 M(CheckArrayBound) \ | 107 M(CheckArrayBound) \ |
| 108 M(CheckClass) \ | |
| 109 M(TestSmi) \ | 108 M(TestSmi) \ |
| 110 M(RelationalOp) \ | 109 M(RelationalOp) \ |
| 111 M(EqualityCompare) \ | 110 M(EqualityCompare) \ |
| 112 M(LoadIndexed) | 111 M(LoadIndexed) |
| 113 | 112 |
| 114 // Location summaries actually are not used by the unoptimizing DBC compiler | 113 // Location summaries actually are not used by the unoptimizing DBC compiler |
| 115 // because we don't allocate any registers. | 114 // because we don't allocate any registers. |
| 116 static LocationSummary* CreateLocationSummary( | 115 static LocationSummary* CreateLocationSummary( |
| 117 Zone* zone, | 116 Zone* zone, |
| 118 intptr_t num_inputs, | 117 intptr_t num_inputs, |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 return comparison()->locs(); | 473 return comparison()->locs(); |
| 475 } | 474 } |
| 476 | 475 |
| 477 | 476 |
| 478 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 477 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 479 comparison()->EmitBranchCode(compiler, this); | 478 comparison()->EmitBranchCode(compiler, this); |
| 480 } | 479 } |
| 481 | 480 |
| 482 | 481 |
| 483 EMIT_NATIVE_CODE(Goto, 0) { | 482 EMIT_NATIVE_CODE(Goto, 0) { |
| 483 if (!compiler->is_optimizing()) { | |
| 484 // Add a deoptimization descriptor for deoptimizing instructions that | |
| 485 // may be inserted before this instruction. | |
| 486 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, | |
| 487 GetDeoptId(), | |
| 488 TokenPosition::kNoSource); | |
| 489 } | |
| 484 if (HasParallelMove()) { | 490 if (HasParallelMove()) { |
| 485 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 491 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
| 486 } | 492 } |
| 487 // We can fall through if the successor is the next block in the list. | 493 // We can fall through if the successor is the next block in the list. |
| 488 // Otherwise, we need a jump. | 494 // Otherwise, we need a jump. |
| 489 if (!compiler->CanFallThroughTo(successor())) { | 495 if (!compiler->CanFallThroughTo(successor())) { |
| 490 __ Jump(compiler->GetJumpLabel(successor())); | 496 __ Jump(compiler->GetJumpLabel(successor())); |
| 491 } | 497 } |
| 492 } | 498 } |
| 493 | 499 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 } | 944 } |
| 939 | 945 |
| 940 | 946 |
| 941 EMIT_NATIVE_CODE(CheckClassId, 1) { | 947 EMIT_NATIVE_CODE(CheckClassId, 1) { |
| 942 intptr_t cid = __ AddConstant(Smi::Handle(Smi::New(cid_))); | 948 intptr_t cid = __ AddConstant(Smi::Handle(Smi::New(cid_))); |
| 943 __ CheckClassId(locs()->in(0).reg(), cid); | 949 __ CheckClassId(locs()->in(0).reg(), cid); |
| 944 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); | 950 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass); |
| 945 } | 951 } |
| 946 | 952 |
| 947 | 953 |
| 954 EMIT_NATIVE_CODE(CheckClass, 1) { | |
| 955 const Register value = locs()->in(0).reg(); | |
| 956 if (IsNullCheck()) { | |
| 957 ASSERT(DeoptIfNull() || DeoptIfNotNull()); | |
| 958 if (DeoptIfNull()) { | |
| 959 __ IfEqNull(value); | |
| 960 } else { | |
| 961 __ IfNeNull(value); | |
| 962 } | |
| 963 } else { | |
| 964 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || | |
| 965 (unary_checks().NumberOfChecks() > 1)); | |
| 966 const intptr_t may_be_smi = | |
| 967 (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; | |
| 968 if (IsDenseSwitch()) { | |
| 969 ASSERT(cids_[0] < cids_[cids_.length() - 1]); | |
| 970 __ CheckDenseSwitch(value, may_be_smi); | |
| 971 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cids_[0])))); | |
| 972 __ Nop(__ AddConstant(Smi::Handle(Smi::New(ComputeCidMask())))); | |
| 973 } else { | |
| 974 GrowableArray<CidTarget> sorted_ic_data; | |
| 975 FlowGraphCompiler::SortICDataByCount(unary_checks(), | |
| 976 &sorted_ic_data, | |
| 977 /* drop_smi = */ true); | |
| 978 ASSERT(sorted_ic_data.length() >= 1); | |
| 979 if (sorted_ic_data.length() == 1) { | |
| 980 __ CheckCid(value, may_be_smi); | |
| 981 __ Nop(__ AddConstant(Smi::Handle(Smi::New(sorted_ic_data[0].cid)))); | |
| 982 } else { | |
| 983 const Array& sorted_smi_cids = | |
| 984 Array::Handle(Array::New(sorted_ic_data.length(), Heap::kOld)); | |
| 985 for (intptr_t i = 0; i < sorted_ic_data.length(); i++) { | |
| 986 sorted_smi_cids.SetAt(i, | |
| 987 Smi::Handle(Smi::New(sorted_ic_data[i].cid))); | |
| 988 } | |
| 989 __ CheckCids(value, may_be_smi); | |
| 990 __ Nop(__ AddConstant(sorted_smi_cids)); | |
|
Vyacheslav Egorov (Google)
2016/06/29 17:11:06
I suggest just embedding them into the code instea
zra
2016/06/29 22:19:18
Done.
| |
| 991 } | |
| 992 } | |
| 993 } | |
| 994 compiler->EmitDeopt(deopt_id(), | |
| 995 ICData::kDeoptCheckClass, | |
|
Vyacheslav Egorov (Google)
2016/06/29 17:11:06
indentation
zra
2016/06/29 22:19:17
Done.
| |
| 996 licm_hoisted_ ? ICData::kHoisted : 0); | |
| 997 } | |
| 998 | |
| 999 | |
| 948 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) { | 1000 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) { |
| 949 const Register left = locs()->in(0).reg(); | 1001 const Register left = locs()->in(0).reg(); |
| 950 const Register right = locs()->in(1).reg(); | 1002 const Register right = locs()->in(1).reg(); |
| 951 const Register out = locs()->out(0).reg(); | 1003 const Register out = locs()->out(0).reg(); |
| 952 const bool can_deopt = CanDeoptimize(); | 1004 const bool can_deopt = CanDeoptimize(); |
| 953 bool needs_nop = false; | 1005 bool needs_nop = false; |
| 954 switch (op_kind()) { | 1006 switch (op_kind()) { |
| 955 case Token::kADD: | 1007 case Token::kADD: |
| 956 __ Add(out, left, right); | 1008 __ Add(out, left, right); |
| 957 needs_nop = true; | 1009 needs_nop = true; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 991 case Token::kSHL: | 1043 case Token::kSHL: |
| 992 __ Shl(out, left, right); | 1044 __ Shl(out, left, right); |
| 993 needs_nop = true; | 1045 needs_nop = true; |
| 994 break; | 1046 break; |
| 995 default: | 1047 default: |
| 996 UNREACHABLE(); | 1048 UNREACHABLE(); |
| 997 } | 1049 } |
| 998 if (can_deopt) { | 1050 if (can_deopt) { |
| 999 compiler->EmitDeopt(deopt_id(), ICData::kDeoptBinarySmiOp); | 1051 compiler->EmitDeopt(deopt_id(), ICData::kDeoptBinarySmiOp); |
| 1000 } else if (needs_nop) { | 1052 } else if (needs_nop) { |
| 1001 __ Nop(); | 1053 __ Nop(0); |
| 1002 } | 1054 } |
| 1003 } | 1055 } |
| 1004 | 1056 |
| 1005 | 1057 |
| 1006 EMIT_NATIVE_CODE(UnarySmiOp, 1, Location::RequiresRegister()) { | 1058 EMIT_NATIVE_CODE(UnarySmiOp, 1, Location::RequiresRegister()) { |
| 1007 switch (op_kind()) { | 1059 switch (op_kind()) { |
| 1008 case Token::kNEGATE: { | 1060 case Token::kNEGATE: { |
| 1009 __ Neg(locs()->out(0).reg(), locs()->in(0).reg()); | 1061 __ Neg(locs()->out(0).reg(), locs()->in(0).reg()); |
| 1010 compiler->EmitDeopt(deopt_id(), ICData::kDeoptUnaryOp); | 1062 compiler->EmitDeopt(deopt_id(), ICData::kDeoptUnaryOp); |
| 1011 break; | 1063 break; |
| 1012 } | 1064 } |
| 1013 case Token::kBIT_NOT: | 1065 case Token::kBIT_NOT: |
| 1014 __ BitNot(locs()->out(0).reg(), locs()->in(0).reg()); | 1066 __ BitNot(locs()->out(0).reg(), locs()->in(0).reg()); |
| 1015 break; | 1067 break; |
| 1016 default: | 1068 default: |
| 1017 UNREACHABLE(); | 1069 UNREACHABLE(); |
| 1018 } | 1070 } |
| 1019 } | 1071 } |
| 1020 | 1072 |
| 1021 } // namespace dart | 1073 } // namespace dart |
| 1022 | 1074 |
| 1023 #endif // defined TARGET_ARCH_DBC | 1075 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |