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

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

Issue 2098573004: DBC: CheckClassInstr (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix bug, cleanup, add tests Created 4 years, 5 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 __ CheckNull(value, DeoptIfNull() ? 1 : 0);
959 compiler->EmitDeopt(deopt_id(),
960 ICData::kDeoptCheckClass,
961 licm_hoisted_ ? ICData::kHoisted : 0);
962 return;
963 }
964
965 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
966 (unary_checks().NumberOfChecks() > 1));
967 const intptr_t ic_data = __ AddConstant(unary_checks());
968 if (IsDenseSwitch()) {
969 ASSERT(cids_[0] < cids_[cids_.length() - 1]);
970 __ PushConstant(Smi::Handle(Smi::New(cids_[0])));
Vyacheslav Egorov (Google) 2016/06/28 13:03:10 This encoding of the dense switch is suboptimal. I
zra 2016/06/28 19:31:40 It looks like cids can be 32-bits, so I think thos
971 __ PushConstant(Smi::Handle(Smi::New(ComputeCidMask())));
972 __ CheckDenseSwitchTOS(value, ic_data);
973 } else {
974 __ CheckForCid(value, ic_data);
Vyacheslav Egorov (Google) 2016/06/28 13:03:10 Similar note here. I suggest making this very fast
zra 2016/06/28 19:31:40 Done.
975 }
976 compiler->EmitDeopt(deopt_id(),
977 ICData::kDeoptCheckClass,
Vyacheslav Egorov (Google) 2016/06/28 13:03:10 Indentation. Can this be shared with NullCheck c
zra 2016/06/28 19:31:40 Done.
978 licm_hoisted_ ? ICData::kHoisted : 0);
979 }
980
981
948 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) { 982 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) {
949 const Register left = locs()->in(0).reg(); 983 const Register left = locs()->in(0).reg();
950 const Register right = locs()->in(1).reg(); 984 const Register right = locs()->in(1).reg();
951 const Register out = locs()->out(0).reg(); 985 const Register out = locs()->out(0).reg();
952 const bool can_deopt = CanDeoptimize(); 986 const bool can_deopt = CanDeoptimize();
953 bool needs_nop = false; 987 bool needs_nop = false;
954 switch (op_kind()) { 988 switch (op_kind()) {
955 case Token::kADD: 989 case Token::kADD:
956 __ Add(out, left, right); 990 __ Add(out, left, right);
957 needs_nop = true; 991 needs_nop = true;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 __ BitNot(locs()->out(0).reg(), locs()->in(0).reg()); 1048 __ BitNot(locs()->out(0).reg(), locs()->in(0).reg());
1015 break; 1049 break;
1016 default: 1050 default:
1017 UNREACHABLE(); 1051 UNREACHABLE();
1018 } 1052 }
1019 } 1053 }
1020 1054
1021 } // namespace dart 1055 } // namespace dart
1022 1056
1023 #endif // defined TARGET_ARCH_DBC 1057 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698