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

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

Issue 2974953002: Revise assertions and fix bug in the implementation of shifts (Closed)
Patch Set: Outdated comment corrected 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
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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 6067 matching lines...) Expand 10 before | Expand all | Expand 10 after
6078 6078
6079 Label* deopt = NULL; 6079 Label* deopt = NULL;
6080 if (CanDeoptimize()) { 6080 if (CanDeoptimize()) {
6081 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp); 6081 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinaryMintOp);
6082 } 6082 }
6083 if (locs()->in(1).IsConstant()) { 6083 if (locs()->in(1).IsConstant()) {
6084 // Code for a constant shift amount. 6084 // Code for a constant shift amount.
6085 ASSERT(locs()->in(1).constant().IsSmi()); 6085 ASSERT(locs()->in(1).constant().IsSmi());
6086 const int32_t shift = 6086 const int32_t shift =
6087 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1; 6087 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1;
6088 // TODO(alexmarkov): figure out why the following assertion fails on ia32 6088 ASSERT(shift >= 0);
6089 // ASSERT(!has_shift_count_check());
6090 // ASSERT(shift >= 0);
6091 switch (op_kind()) { 6089 switch (op_kind()) {
6092 case Token::kSHR: { 6090 case Token::kSHR: {
6093 if (shift > 31) { 6091 if (shift > 31) {
6094 __ movl(left_lo, left_hi); // Shift by 32. 6092 __ movl(left_lo, left_hi); // Shift by 32.
6095 __ sarl(left_hi, Immediate(31)); // Sign extend left hi. 6093 __ sarl(left_hi, Immediate(31)); // Sign extend left hi.
6096 if (shift > 32) { 6094 if (shift > 32) {
6097 __ sarl(left_lo, Immediate(shift > 63 ? 31 : shift - 32)); 6095 __ sarl(left_lo, Immediate(shift > 63 ? 31 : shift - 32));
6098 } 6096 }
6099 } else { 6097 } else {
6100 __ shrdl(left_lo, left_hi, Immediate(shift)); 6098 __ shrdl(left_lo, left_hi, Immediate(shift));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6154 } 6152 }
6155 default: 6153 default:
6156 UNREACHABLE(); 6154 UNREACHABLE();
6157 } 6155 }
6158 } else { 6156 } else {
6159 // Code for a variable shift amount. 6157 // Code for a variable shift amount.
6160 // Deoptimize if shift count is > 63. 6158 // Deoptimize if shift count is > 63.
6161 // sarl operation masks the count to 5 bits and 6159 // sarl operation masks the count to 5 bits and
6162 // shrdl is undefined with count > operand size (32) 6160 // shrdl is undefined with count > operand size (32)
6163 __ SmiUntag(ECX); 6161 __ SmiUntag(ECX);
6164 if (has_shift_count_check()) { 6162 if (!IsShiftCountInRange()) {
6165 __ cmpl(ECX, Immediate(kMintShiftCountLimit)); 6163 __ cmpl(ECX, Immediate(kMintShiftCountLimit));
6166 __ j(ABOVE, deopt); 6164 __ j(ABOVE, deopt);
6167 } 6165 }
6168 Label done, large_shift; 6166 Label done, large_shift;
6169 switch (op_kind()) { 6167 switch (op_kind()) {
6170 case Token::kSHR: { 6168 case Token::kSHR: {
6171 __ cmpl(ECX, Immediate(31)); 6169 __ cmpl(ECX, Immediate(31));
6172 __ j(ABOVE, &large_shift); 6170 __ j(ABOVE, &large_shift);
6173 6171
6174 __ shrdl(left_lo, left_hi, ECX); // Shift count in CL. 6172 __ shrdl(left_lo, left_hi, ECX); // Shift count in CL.
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
6788 __ Call(*StubCode::DebugStepCheck_entry()); 6786 __ Call(*StubCode::DebugStepCheck_entry());
6789 compiler->EmitCallsiteMetaData(token_pos(), deopt_id_, stub_kind_, locs()); 6787 compiler->EmitCallsiteMetaData(token_pos(), deopt_id_, stub_kind_, locs());
6790 } 6788 }
6791 6789
6792 6790
6793 } // namespace dart 6791 } // namespace dart
6794 6792
6795 #undef __ 6793 #undef __
6796 6794
6797 #endif // defined TARGET_ARCH_IA32 6795 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698