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

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

Powered by Google App Engine
This is Rietveld 408576698