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

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

Issue 79653002: Merge TRUNCDIV and MOD into one instruction. Icorporated feedback from CL https://codereview.chromi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 3379 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 __ movd(result, base); // base is NaN, return NaN. 3390 __ movd(result, base); // base is NaN, return NaN.
3391 __ b(&skip_call); 3391 __ b(&skip_call);
3392 } 3392 }
3393 __ Bind(&do_call); 3393 __ Bind(&do_call);
3394 // double values are passed and returned in vfp registers. 3394 // double values are passed and returned in vfp registers.
3395 __ CallRuntime(TargetFunction(), InputCount()); 3395 __ CallRuntime(TargetFunction(), InputCount());
3396 __ Bind(&skip_call); 3396 __ Bind(&skip_call);
3397 } 3397 }
3398 3398
3399 3399
3400 LocationSummary* MergedMathInstr::MakeLocationSummary() const {
3401 if (kind() == MergedMathInstr::kTruncDivMod) {
3402 const intptr_t kNumInputs = 2;
3403 const intptr_t kNumTemps = 3;
3404 LocationSummary* summary =
3405 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3406 summary->set_in(0, Location::RequiresRegister());
3407 summary->set_in(1, Location::RequiresRegister());
3408 summary->set_temp(0, Location::RequiresRegister());
3409 summary->set_temp(1, Location::RequiresRegister()); // result_div.
3410 summary->set_temp(2, Location::RequiresRegister()); // result_mod.
3411 summary->set_out(Location::RequiresRegister());
3412 return summary;
3413 }
3414 UNIMPLEMENTED();
3415 return NULL;
3416 }
3417
3418
3419 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3420 Label* deopt = NULL;
3421 if (CanDeoptimize()) {
3422 deopt = compiler->AddDeoptStub(deopt_id(), kDeoptBinarySmiOp);
3423 }
3424 if (kind() == MergedMathInstr::kTruncDivMod) {
3425 Register left = locs()->in(0).reg();
3426 Register right = locs()->in(1).reg();
3427 Register result = locs()->out().reg();
3428 Register temp = locs()->temp(0).reg();
3429 Register result_div = locs()->temp(1).reg();
3430 Register result_mod = locs()->temp(2).reg();
3431 // Handle divide by zero in runtime.
3432 __ beq(right, ZR, deopt);
3433 __ sra(temp, left, kSmiTagSize); // SmiUntag left into temp.
3434 __ sra(TMP, right, kSmiTagSize); // SmiUntag right into TMP.
3435 __ div(temp, TMP);
3436 __ mflo(result_div);
3437 __ mfhi(result_mod);
3438 // Check the corner case of dividing the 'MIN_SMI' with -1, in which
3439 // case we cannot tag the result.
3440 __ BranchEqual(result_div, 0x40000000, deopt);
3441 // res = left % right;
3442 // if (res < 0) {
3443 // if (right < 0) {
3444 // res = res - right;
3445 // } else {
3446 // res = res + right;
3447 // }
3448 // }
3449 Label done, subtract;
3450 __ bgez(result_mod, &done);
3451 __ bltz(right, &subtract);
3452 __ addu(result_mod, result_mod, TMP);
3453 __ b(&done);
3454 __ Bind(&subtract);
3455 __ subu(result_mod, result_mod, TMP);
3456 __ Bind(&done);
3457
3458 __ SmiTag(result_div);
3459 __ SmiTag(result_mod);
3460 __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld)));
3461 // Note that index is expected smi-tagged, (i.e, times 2) for all arrays.
3462 // [0]: divide resut, [1]: mod result.
3463 __ LoadImmediate(temp,
3464 FlowGraphCompiler::DataOffsetFor(kArrayCid) - kHeapObjectTag);
3465 __ addu(temp, result, temp);
3466 Address div_result_address(temp, 0);
3467 Address mod_result_address(temp, kWordSize);
3468 __ StoreIntoObjectNoBarrier(result, div_result_address, result_div);
3469 __ StoreIntoObjectNoBarrier(result, mod_result_address, result_mod);
3470 return;
3471 }
3472 UNIMPLEMENTED();
3473 }
3474
3475
3400 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { 3476 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const {
3401 return MakeCallSummary(); 3477 return MakeCallSummary();
3402 } 3478 }
3403 3479
3404 3480
3405 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3481 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3406 Label* deopt = compiler->AddDeoptStub(deopt_id(), 3482 Label* deopt = compiler->AddDeoptStub(deopt_id(),
3407 kDeoptPolymorphicInstanceCallTestFail); 3483 kDeoptPolymorphicInstanceCallTestFail);
3408 __ TraceSimMsg("PolymorphicInstanceCallInstr"); 3484 __ TraceSimMsg("PolymorphicInstanceCallInstr");
3409 if (ic_data().NumberOfChecks() == 0) { 3485 if (ic_data().NumberOfChecks() == 0) {
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3895 compiler->GenerateCall(token_pos(), 3971 compiler->GenerateCall(token_pos(),
3896 &label, 3972 &label,
3897 PcDescriptors::kOther, 3973 PcDescriptors::kOther,
3898 locs()); 3974 locs());
3899 __ Drop(2); // Discard type arguments and receiver. 3975 __ Drop(2); // Discard type arguments and receiver.
3900 } 3976 }
3901 3977
3902 } // namespace dart 3978 } // namespace dart
3903 3979
3904 #endif // defined TARGET_ARCH_MIPS 3980 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698