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

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

Issue 381803005: Reland r38116: Improve receiver class check in polymorphic inlining. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 4266 matching lines...) Expand 10 before | Expand all | Expand 10 after
4277 4277
4278 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4278 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4279 __ TraceSimMsg("BranchInstr"); 4279 __ TraceSimMsg("BranchInstr");
4280 comparison()->EmitBranchCode(compiler, this); 4280 comparison()->EmitBranchCode(compiler, this);
4281 } 4281 }
4282 4282
4283 4283
4284 LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate, 4284 LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate,
4285 bool opt) const { 4285 bool opt) const {
4286 const intptr_t kNumInputs = 1; 4286 const intptr_t kNumInputs = 1;
4287 const intptr_t kNumTemps = !IsNullCheck() ? 1 : 0; 4287 const bool need_mask_temp = IsDenseSwitch() && !IsDenseMask(ComputeCidMask());
4288 const intptr_t kNumTemps = !IsNullCheck() ? (need_mask_temp ? 2 : 1) : 0;
4288 LocationSummary* summary = new(isolate) LocationSummary( 4289 LocationSummary* summary = new(isolate) LocationSummary(
4289 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4290 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4290 summary->set_in(0, Location::RequiresRegister()); 4291 summary->set_in(0, Location::RequiresRegister());
4291 if (!IsNullCheck()) { 4292 if (!IsNullCheck()) {
4292 summary->set_temp(0, Location::RequiresRegister()); 4293 summary->set_temp(0, Location::RequiresRegister());
4294 if (need_mask_temp) {
4295 summary->set_temp(1, Location::RequiresRegister());
4296 }
4293 } 4297 }
4294 return summary; 4298 return summary;
4295 } 4299 }
4296 4300
4297 4301
4298 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4302 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4299 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? 4303 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ?
4300 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; 4304 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass;
4301 if (IsNullCheck()) { 4305 if (IsNullCheck()) {
4302 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason); 4306 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
(...skipping 11 matching lines...) Expand all
4314 intptr_t cix = 0; 4318 intptr_t cix = 0;
4315 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { 4319 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
4316 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4320 __ andi(CMPRES1, value, Immediate(kSmiTagMask));
4317 __ beq(CMPRES1, ZR, &is_ok); 4321 __ beq(CMPRES1, ZR, &is_ok);
4318 cix++; // Skip first check. 4322 cix++; // Skip first check.
4319 } else { 4323 } else {
4320 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4324 __ andi(CMPRES1, value, Immediate(kSmiTagMask));
4321 __ beq(CMPRES1, ZR, deopt); 4325 __ beq(CMPRES1, ZR, deopt);
4322 } 4326 }
4323 __ LoadClassId(temp, value); 4327 __ LoadClassId(temp, value);
4324 const intptr_t num_checks = unary_checks().NumberOfChecks(); 4328
4325 for (intptr_t i = cix; i < num_checks; i++) { 4329 if (IsDenseSwitch()) {
4326 ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid); 4330 ASSERT(cids_[0] < cids_[cids_.length() - 1]);
4327 __ LoadImmediate(TMP, unary_checks().GetReceiverClassIdAt(i)); 4331 __ LoadImmediate(TMP, cids_[0]);
4328 __ subu(CMPRES1, temp, TMP); 4332 __ subu(temp, temp, TMP);
4329 if (i == (num_checks - 1)) { 4333 __ LoadImmediate(TMP, cids_[cids_.length() - 1] - cids_[0]);
4330 __ bne(CMPRES1, ZR, deopt); 4334 __ BranchUnsignedGreater(temp, TMP, deopt);
4331 } else { 4335
4332 __ beq(CMPRES1, ZR, &is_ok); 4336 intptr_t mask = ComputeCidMask();
4337 if (!IsDenseMask(mask)) {
4338 // Only need mask if there are missing numbers in the range.
4339 ASSERT(cids_.length() > 2);
4340 Register mask_reg = locs()->temp(1).reg();
4341 __ LoadImmediate(mask_reg, 1);
4342 __ sllv(mask_reg, mask_reg, temp);
4343 __ AndImmediate(mask_reg, mask_reg, mask);
4344 __ beq(mask_reg, ZR, deopt);
4345 }
4346 } else {
4347 const intptr_t num_checks = unary_checks().NumberOfChecks();
4348 for (intptr_t i = cix; i < num_checks; i++) {
4349 ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid);
4350 __ LoadImmediate(TMP, unary_checks().GetReceiverClassIdAt(i));
4351 __ subu(CMPRES1, temp, TMP);
4352 if (i == (num_checks - 1)) {
4353 __ bne(CMPRES1, ZR, deopt);
4354 } else {
4355 __ beq(CMPRES1, ZR, &is_ok);
4356 }
4333 } 4357 }
4334 } 4358 }
4335 __ Bind(&is_ok); 4359 __ Bind(&is_ok);
4336 } 4360 }
4337 4361
4338 4362
4339 LocationSummary* CheckSmiInstr::MakeLocationSummary(Isolate* isolate, 4363 LocationSummary* CheckSmiInstr::MakeLocationSummary(Isolate* isolate,
4340 bool opt) const { 4364 bool opt) const {
4341 const intptr_t kNumInputs = 1; 4365 const intptr_t kNumInputs = 1;
4342 const intptr_t kNumTemps = 0; 4366 const intptr_t kNumTemps = 0;
4343 LocationSummary* summary = new(isolate) LocationSummary( 4367 LocationSummary* summary = new(isolate) LocationSummary(
4344 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4368 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4345 summary->set_in(0, Location::RequiresRegister()); 4369 summary->set_in(0, Location::RequiresRegister());
4346 return summary; 4370 return summary;
4347 } 4371 }
4348 4372
4349 4373
4350 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4374 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4351 __ TraceSimMsg("CheckSmiInstr"); 4375 __ TraceSimMsg("CheckSmiInstr");
4352 Register value = locs()->in(0).reg(); 4376 Register value = locs()->in(0).reg();
4353 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckSmi); 4377 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckSmi);
4354 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4378 __ andi(CMPRES1, value, Immediate(kSmiTagMask));
4355 __ bne(CMPRES1, ZR, deopt); 4379 __ bne(CMPRES1, ZR, deopt);
4356 } 4380 }
4357 4381
4358 4382
4383 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Isolate* isolate,
4384 bool opt) const {
4385 const intptr_t kNumInputs = 2;
4386 const intptr_t kNumTemps = 0;
4387 LocationSummary* summary = new(isolate) LocationSummary(
4388 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4389 summary->set_in(0, Location::RequiresRegister());
4390 summary->set_in(1, Location::RegisterOrSmiConstant(right()));
4391 return summary;
4392 }
4393
4394
4395 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4396 Register left = locs()->in(0).reg();
4397 Location right = locs()->in(1);
4398 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass);
4399 if (right.IsRegister()) {
4400 __ bne(left, right.reg(), deopt);
4401 } else {
4402 ASSERT(right.IsConstant());
4403 const Object& right_const = Smi::Cast(right.constant());
4404 __ BranchNotEqual(left,
4405 reinterpret_cast<int32_t>(right_const.raw()),
4406 deopt);
4407 }
4408 }
4409
4410
4359 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate, 4411 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate,
4360 bool opt) const { 4412 bool opt) const {
4361 const intptr_t kNumInputs = 2; 4413 const intptr_t kNumInputs = 2;
4362 const intptr_t kNumTemps = 0; 4414 const intptr_t kNumTemps = 0;
4363 LocationSummary* locs = new(isolate) LocationSummary( 4415 LocationSummary* locs = new(isolate) LocationSummary(
4364 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4416 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4365 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 4417 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
4366 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 4418 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
4367 return locs; 4419 return locs;
4368 } 4420 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
4710 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 4762 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
4711 #if defined(DEBUG) 4763 #if defined(DEBUG)
4712 __ LoadImmediate(S4, kInvalidObjectPointer); 4764 __ LoadImmediate(S4, kInvalidObjectPointer);
4713 __ LoadImmediate(S5, kInvalidObjectPointer); 4765 __ LoadImmediate(S5, kInvalidObjectPointer);
4714 #endif 4766 #endif
4715 } 4767 }
4716 4768
4717 } // namespace dart 4769 } // namespace dart
4718 4770
4719 #endif // defined TARGET_ARCH_MIPS 4771 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698