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

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

Issue 2974953002: Revise assertions and fix bug in the implementation of shifts (Closed)
Patch Set: Created 3 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
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/bit_operations_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 6046 matching lines...) Expand 10 before | Expand all | Expand 10 after
6057 return summary; 6057 return summary;
6058 } 6058 }
6059 6059
6060 6060
6061 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 6061 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
6062 const Register left = locs()->in(0).reg(); 6062 const Register left = locs()->in(0).reg();
6063 const Register out = locs()->out(0).reg(); 6063 const Register out = locs()->out(0).reg();
6064 ASSERT(left == out); 6064 ASSERT(left == out);
6065 6065
6066 Label* deopt = NULL; 6066 Label* deopt = NULL;
6067 if (CanDeoptimize()) { 6067 if (CanDeoptimize()) {
regis 2017/07/11 18:45:55 When specifying --limit-ints-to-64-bits, we probab
alexmarkov 2017/07/11 19:39:23 Acknowledged.
6068 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp); 6068 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp);
6069 } 6069 }
6070 if (locs()->in(1).IsConstant()) { 6070 if (locs()->in(1).IsConstant()) {
6071 // Code for a constant shift amount. 6071 // Code for a constant shift amount.
6072 ASSERT(locs()->in(1).constant().IsSmi()); 6072 ASSERT(locs()->in(1).constant().IsSmi());
6073 const int64_t shift = 6073 const int64_t shift =
6074 reinterpret_cast<int64_t>(locs()->in(1).constant().raw()) >> 1; 6074 reinterpret_cast<int64_t>(locs()->in(1).constant().raw()) >> 1;
6075 // TODO(alexmarkov): revise and uncomment the following assertions 6075 ASSERT(shift >= 0);
6076 // ASSERT(!has_shift_count_check());
6077 // ASSERT((0 <= shift) && (shift < 64));
6078 switch (op_kind()) { 6076 switch (op_kind()) {
6079 case Token::kSHR: 6077 case Token::kSHR:
6080 __ sarq(left, Immediate(shift)); 6078 __ sarq(left,
6079 Immediate(Utils::Minimum<int64_t>(shift, kBitsPerWord - 1)));
6081 break; 6080 break;
6082 case Token::kSHL: { 6081 case Token::kSHL: {
6082 ASSERT(shift < 64);
6083 if (can_overflow()) { 6083 if (can_overflow()) {
6084 // Check for overflow. 6084 // Check for overflow.
6085 Register temp = locs()->temp(0).reg(); 6085 Register temp = locs()->temp(0).reg();
6086 __ movq(temp, left); 6086 __ movq(temp, left);
6087 __ shlq(left, Immediate(shift)); 6087 __ shlq(left, Immediate(shift));
6088 __ sarq(left, Immediate(shift)); 6088 __ sarq(left, Immediate(shift));
6089 __ cmpq(left, temp); 6089 __ cmpq(left, temp);
6090 __ j(NOT_EQUAL, deopt); // Overflow. 6090 __ j(NOT_EQUAL, deopt); // Overflow.
6091 } 6091 }
6092 // Shift for result now we know there is no overflow. 6092 // Shift for result now we know there is no overflow.
6093 __ shlq(left, Immediate(shift)); 6093 __ shlq(left, Immediate(shift));
6094 break; 6094 break;
6095 } 6095 }
6096 default: 6096 default:
6097 UNREACHABLE(); 6097 UNREACHABLE();
6098 } 6098 }
6099 } else { 6099 } else {
6100 // Code for a variable shift amount. 6100 // Code for a variable shift amount.
6101 // Deoptimize if shift count is > 63. 6101 // Deoptimize if shift count is > 63.
6102 // sarl operation masks the count to 5 bits and 6102 // sarl operation masks the count to 5 bits and
6103 // shrd is undefined with count > operand size (32) 6103 // shrd is undefined with count > operand size (32)
regis 2017/07/11 18:45:55 This last comment does not look correct? shrd with
alexmarkov 2017/07/11 19:39:23 Done.
6104 __ SmiUntag(RCX); 6104 __ SmiUntag(RCX);
6105 if (has_shift_count_check()) { 6105 if (!IsShiftCountInRange()) {
6106 __ cmpq(RCX, Immediate(kMintShiftCountLimit)); 6106 __ cmpq(RCX, Immediate(kMintShiftCountLimit));
6107 __ j(ABOVE, deopt); 6107 __ j(ABOVE, deopt);
6108 } 6108 }
6109 Label done, large_shift; 6109 Label done, large_shift;
6110 switch (op_kind()) { 6110 switch (op_kind()) {
6111 case Token::kSHR: { 6111 case Token::kSHR: {
6112 __ sarq(left, RCX); 6112 __ sarq(left, RCX);
6113 break; 6113 break;
6114 } 6114 }
6115 case Token::kSHL: { 6115 case Token::kSHL: {
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
6649 compiler->AddCurrentDescriptor(stub_kind_, deopt_id_, token_pos()); 6649 compiler->AddCurrentDescriptor(stub_kind_, deopt_id_, token_pos());
6650 compiler->RecordSafepoint(locs()); 6650 compiler->RecordSafepoint(locs());
6651 } 6651 }
6652 6652
6653 6653
6654 } // namespace dart 6654 } // namespace dart
6655 6655
6656 #undef __ 6656 #undef __
6657 6657
6658 #endif // defined TARGET_ARCH_X64 6658 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/bit_operations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698