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

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

Issue 396733006: Optimize the multiplication of two 32-bit unsigned integers. (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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 6112 matching lines...) Expand 10 before | Expand all | Expand 10 after
6123 ASSERT(op_kind() == Token::kSUB); 6123 ASSERT(op_kind() == Token::kSUB);
6124 __ subs(out_lo, left_lo, Operand(right_lo)); 6124 __ subs(out_lo, left_lo, Operand(right_lo));
6125 __ sbcs(out_hi, left_hi, Operand(right_hi)); 6125 __ sbcs(out_hi, left_hi, Operand(right_hi));
6126 } 6126 }
6127 if (can_overflow()) { 6127 if (can_overflow()) {
6128 // Deopt on overflow. 6128 // Deopt on overflow.
6129 __ b(deopt, VS); 6129 __ b(deopt, VS);
6130 } 6130 }
6131 break; 6131 break;
6132 } 6132 }
6133 default: 6133 case Token::kMUL: {
6134 UNREACHABLE(); 6134 // We only support the multiplication of two positive 32-bit integers
6135 break; 6135 // resulting in a positive 64-bit integer fitting in a mint.
6136 // We deopt in all other cases.
6137 // This guarantees that the multiplication of 16-bit unsigned integers,
6138 // as used in bignum arithmetic, will always succeed.
6139 if (TargetCPUFeatures::arm_version() == ARMv7) {
6140 __ orrs(out_hi, left_hi, Operand(right_hi));
6141 __ b(deopt, NE);
6142 __ smull(out_lo, out_hi, left_lo, right_lo);
Vyacheslav Egorov (Google) 2014/07/16 23:51:35 should not this be umul given that we look at hi?
regis 2014/07/18 02:44:56 You are right. This should have been an unsigned m
Vyacheslav Egorov (Google) 2014/07/18 11:15:34 Well this particular case would not call a deopt r
6143 if (can_overflow()) {
6144 __ TestImmediate(out_hi, 0xC0000000);
6145 __ b(deopt, NE);
6146 }
6147 } else {
6148 __ b(deopt);
6149 }
6150 break;
6151 }
6152 default: UNREACHABLE();
6136 } 6153 }
6137 if (FLAG_throw_on_javascript_int_overflow) { 6154 if (FLAG_throw_on_javascript_int_overflow) {
6138 EmitJavascriptIntOverflowCheck(compiler, deopt, out_lo, out_hi); 6155 EmitJavascriptIntOverflowCheck(compiler, deopt, out_lo, out_hi);
6139 } 6156 }
6140 } 6157 }
6141 6158
6142 6159
6143 LocationSummary* ShiftMintOpInstr::MakeLocationSummary(Isolate* isolate, 6160 LocationSummary* ShiftMintOpInstr::MakeLocationSummary(Isolate* isolate,
6144 bool opt) const { 6161 bool opt) const {
6145 const intptr_t kNumInputs = 2; 6162 const intptr_t kNumInputs = 2;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
6309 summary->set_out(0, Location::RequiresRegister()); 6326 summary->set_out(0, Location::RequiresRegister());
6310 return summary; 6327 return summary;
6311 } 6328 }
6312 6329
6313 6330
6314 void BinaryUint32OpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6331 void BinaryUint32OpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6315 Register left = locs()->in(0).reg(); 6332 Register left = locs()->in(0).reg();
6316 Register right = locs()->in(1).reg(); 6333 Register right = locs()->in(1).reg();
6317 Register out = locs()->out(0).reg(); 6334 Register out = locs()->out(0).reg();
6318 ASSERT(out != left); 6335 ASSERT(out != left);
6336 Label* deopt = CanDeoptimize() ?
6337 compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryUint32Op) : NULL;
6319 switch (op_kind()) { 6338 switch (op_kind()) {
6320 case Token::kBIT_AND: 6339 case Token::kBIT_AND:
6321 __ and_(out, left, Operand(right)); 6340 __ and_(out, left, Operand(right));
6322 break; 6341 break;
6323 case Token::kBIT_OR: 6342 case Token::kBIT_OR:
6324 __ orr(out, left, Operand(right)); 6343 __ orr(out, left, Operand(right));
6325 break; 6344 break;
6326 case Token::kBIT_XOR: 6345 case Token::kBIT_XOR:
6327 __ eor(out, left, Operand(right)); 6346 __ eor(out, left, Operand(right));
6328 break; 6347 break;
6329 case Token::kADD: 6348 case Token::kADD:
6330 __ add(out, left, Operand(right)); 6349 __ add(out, left, Operand(right));
6331 break; 6350 break;
6332 case Token::kSUB: 6351 case Token::kSUB:
6333 __ sub(out, left, Operand(right)); 6352 __ sub(out, left, Operand(right));
6334 break; 6353 break;
6354 case Token::kMUL: {
6355 if (TargetCPUFeatures::arm_version() == ARMv7) {
6356 __ smull(out, IP, left, right);
Cutch 2014/07/16 18:09:48 Have you tested this code path?
regis 2014/07/16 23:12:42 Yes, I have ran all the tests, including the RSA b
6357 __ TestImmediate(IP, 0xC0000000);
6358 __ b(deopt, NE);
6359 } else {
6360 __ b(deopt);
6361 }
6362 break;
6363 }
6335 default: 6364 default:
6336 UNREACHABLE(); 6365 UNREACHABLE();
6337 } 6366 }
6338 } 6367 }
6339 6368
6340 6369
6341 LocationSummary* ShiftUint32OpInstr::MakeLocationSummary(Isolate* isolate, 6370 LocationSummary* ShiftUint32OpInstr::MakeLocationSummary(Isolate* isolate,
6342 bool opt) const { 6371 bool opt) const {
6343 const intptr_t kNumInputs = 2; 6372 const intptr_t kNumInputs = 2;
6344 const intptr_t kNumTemps = 1; 6373 const intptr_t kNumTemps = 1;
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
6816 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 6845 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
6817 #if defined(DEBUG) 6846 #if defined(DEBUG)
6818 __ LoadImmediate(R4, kInvalidObjectPointer); 6847 __ LoadImmediate(R4, kInvalidObjectPointer);
6819 __ LoadImmediate(R5, kInvalidObjectPointer); 6848 __ LoadImmediate(R5, kInvalidObjectPointer);
6820 #endif 6849 #endif
6821 } 6850 }
6822 6851
6823 } // namespace dart 6852 } // namespace dart
6824 6853
6825 #endif // defined TARGET_ARCH_ARM 6854 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698