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

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

Issue 321593004: Refactor RangeBoundary +/- infinity to be distinct RangeBoundary kinds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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_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/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2884 matching lines...) Expand 10 before | Expand all | Expand 10 after
2895 } 2895 }
2896 return; 2896 return;
2897 } 2897 }
2898 2898
2899 const bool right_needs_check = 2899 const bool right_needs_check =
2900 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); 2900 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1));
2901 ASSERT(right == ECX); // Count must be in ECX 2901 ASSERT(right == ECX); // Count must be in ECX
2902 if (is_truncating) { 2902 if (is_truncating) {
2903 if (right_needs_check) { 2903 if (right_needs_check) {
2904 const bool right_may_be_negative = 2904 const bool right_may_be_negative =
2905 (right_range == NULL) || 2905 (right_range == NULL) || !right_range->IsPositive();
2906 !right_range->IsWithin(0, RangeBoundary::kPlusInfinity);
2907 if (right_may_be_negative) { 2906 if (right_may_be_negative) {
2908 ASSERT(shift_left->CanDeoptimize()); 2907 ASSERT(shift_left->CanDeoptimize());
2909 __ cmpl(right, Immediate(0)); 2908 __ cmpl(right, Immediate(0));
2910 __ j(NEGATIVE, deopt); 2909 __ j(NEGATIVE, deopt);
2911 } 2910 }
2912 Label done, is_not_zero; 2911 Label done, is_not_zero;
2913 __ cmpl(right, 2912 __ cmpl(right,
2914 Immediate(reinterpret_cast<int32_t>(Smi::New(Smi::kBits)))); 2913 Immediate(reinterpret_cast<int32_t>(Smi::New(Smi::kBits))));
2915 __ j(BELOW, &is_not_zero, Assembler::kNearJump); 2914 __ j(BELOW, &is_not_zero, Assembler::kNearJump);
2916 __ xorl(left, left); 2915 __ xorl(left, left);
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 // Result is negative, adjust it. 3261 // Result is negative, adjust it.
3263 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { 3262 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) {
3264 // Right can be positive and negative. 3263 // Right can be positive and negative.
3265 Label subtract; 3264 Label subtract;
3266 __ cmpl(right, Immediate(0)); 3265 __ cmpl(right, Immediate(0));
3267 __ j(LESS, &subtract, Assembler::kNearJump); 3266 __ j(LESS, &subtract, Assembler::kNearJump);
3268 __ addl(result, right); 3267 __ addl(result, right);
3269 __ jmp(&done, Assembler::kNearJump); 3268 __ jmp(&done, Assembler::kNearJump);
3270 __ Bind(&subtract); 3269 __ Bind(&subtract);
3271 __ subl(result, right); 3270 __ subl(result, right);
3272 } else if (right_range->IsWithin(0, RangeBoundary::kPlusInfinity)) { 3271 } else if (right_range->IsPositive()) {
3273 // Right is positive. 3272 // Right is positive.
3274 __ addl(result, right); 3273 __ addl(result, right);
3275 } else { 3274 } else {
3276 // Right is negative. 3275 // Right is negative.
3277 __ subl(result, right); 3276 __ subl(result, right);
3278 } 3277 }
3279 __ Bind(&done); 3278 __ Bind(&done);
3280 __ SmiTag(result); 3279 __ SmiTag(result);
3281 break; 3280 break;
3282 } 3281 }
3283 case Token::kSHR: { 3282 case Token::kSHR: {
3284 if (CanDeoptimize()) { 3283 if (CanDeoptimize()) {
3285 __ cmpl(right, Immediate(0)); 3284 __ cmpl(right, Immediate(0));
3286 __ j(LESS, deopt); 3285 __ j(LESS, deopt);
3287 } 3286 }
3288 __ SmiUntag(right); 3287 __ SmiUntag(right);
3289 // sarl operation masks the count to 5 bits. 3288 // sarl operation masks the count to 5 bits.
3290 const intptr_t kCountLimit = 0x1F; 3289 const intptr_t kCountLimit = 0x1F;
3291 if ((right_range == NULL) || 3290 if ((right_range == NULL) ||
3292 !right_range->IsWithin(RangeBoundary::kMinusInfinity, kCountLimit)) { 3291 !right_range->OnlyLessThanOrEqualTo(kCountLimit)) {
3293 __ cmpl(right, Immediate(kCountLimit)); 3292 __ cmpl(right, Immediate(kCountLimit));
3294 Label count_ok; 3293 Label count_ok;
3295 __ j(LESS, &count_ok, Assembler::kNearJump); 3294 __ j(LESS, &count_ok, Assembler::kNearJump);
3296 __ movl(right, Immediate(kCountLimit)); 3295 __ movl(right, Immediate(kCountLimit));
3297 __ Bind(&count_ok); 3296 __ Bind(&count_ok);
3298 } 3297 }
3299 ASSERT(right == ECX); // Count must be in ECX 3298 ASSERT(right == ECX); // Count must be in ECX
3300 __ SmiUntag(left); 3299 __ SmiUntag(left);
3301 __ sarl(left, right); 3300 __ sarl(left, right);
3302 __ SmiTag(left); 3301 __ SmiTag(left);
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after
5355 __ j(GREATER_EQUAL, &done, Assembler::kNearJump); 5354 __ j(GREATER_EQUAL, &done, Assembler::kNearJump);
5356 // Result is negative, adjust it. 5355 // Result is negative, adjust it.
5357 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) { 5356 if ((right_range == NULL) || right_range->Overlaps(-1, 1)) {
5358 Label subtract; 5357 Label subtract;
5359 __ cmpl(right, Immediate(0)); 5358 __ cmpl(right, Immediate(0));
5360 __ j(LESS, &subtract, Assembler::kNearJump); 5359 __ j(LESS, &subtract, Assembler::kNearJump);
5361 __ addl(EDX, right); 5360 __ addl(EDX, right);
5362 __ jmp(&done, Assembler::kNearJump); 5361 __ jmp(&done, Assembler::kNearJump);
5363 __ Bind(&subtract); 5362 __ Bind(&subtract);
5364 __ subl(EDX, right); 5363 __ subl(EDX, right);
5365 } else if (right_range->IsWithin(0, RangeBoundary::kPlusInfinity)) { 5364 } else if (right_range->IsPositive()) {
5366 // Right is positive. 5365 // Right is positive.
5367 __ addl(EDX, right); 5366 __ addl(EDX, right);
5368 } else { 5367 } else {
5369 // Right is negative. 5368 // Right is negative.
5370 __ subl(EDX, right); 5369 __ subl(EDX, right);
5371 } 5370 }
5372 __ Bind(&done); 5371 __ Bind(&done);
5373 5372
5374 __ SmiTag(EAX); 5373 __ SmiTag(EAX);
5375 __ SmiTag(EDX); 5374 __ SmiTag(EDX);
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
6294 PcDescriptors::kOther, 6293 PcDescriptors::kOther,
6295 locs()); 6294 locs());
6296 __ Drop(ArgumentCount()); // Discard arguments. 6295 __ Drop(ArgumentCount()); // Discard arguments.
6297 } 6296 }
6298 6297
6299 } // namespace dart 6298 } // namespace dart
6300 6299
6301 #undef __ 6300 #undef __
6302 6301
6303 #endif // defined TARGET_ARCH_IA32 6302 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698