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

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

Issue 336773003: More precise range analysis for smi multiplication. (Closed) Base URL: http://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
« no previous file with comments | « no previous file | no next file » | 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 3078
3079 if (!SymbolicSub(left_max, right_range->min(), &max)) { 3079 if (!SymbolicSub(left_max, right_range->min(), &max)) {
3080 max = 3080 max =
3081 RangeBoundary::Sub(Range::ConstantMax(left_range), 3081 RangeBoundary::Sub(Range::ConstantMax(left_range),
3082 Range::ConstantMin(right_range), 3082 Range::ConstantMin(right_range),
3083 RangeBoundary::PositiveInfinity()); 3083 RangeBoundary::PositiveInfinity());
3084 } 3084 }
3085 break; 3085 break;
3086 3086
3087 case Token::kMUL: { 3087 case Token::kMUL: {
3088 const int64_t left_max = ConstantAbsMax(left_range); 3088 const int64_t left_max = ConstantAbsMax(left_range);
Vyacheslav Egorov (Google) 2014/06/13 13:59:29 Can you test it for kMinInt64 * -1? Because I am b
Florian Schneider 2014/06/16 10:45:10 We're staying in smi range here: ConstantAbsMax re
3089 const int64_t right_max = ConstantAbsMax(right_range); 3089 const int64_t right_max = ConstantAbsMax(right_range);
3090 if ((left_max < 0x7FFFFFFF) && (right_max < 0x7FFFFFFF)) { 3090 if ((left_max == 0) || (right_max <= kMaxInt64 / left_max)) {
3091 // Product of left and right max values stays in 64 bit range. 3091 // Product of left and right max values stays in 64 bit range.
3092 const int64_t result_max = left_max * right_max; 3092 const int64_t result_max = left_max * right_max;
3093 if (Smi::IsValid64(result_max) && Smi::IsValid64(-result_max)) { 3093 if (Smi::IsValid64(result_max) && Smi::IsValid64(-result_max)) {
3094 const intptr_t r_min = 3094 const intptr_t r_min =
3095 OnlyPositiveOrZero(left_range, right_range) ? 0 : -result_max; 3095 OnlyPositiveOrZero(left_range, right_range) ? 0 : -result_max;
3096 min = RangeBoundary::FromConstant(r_min); 3096 min = RangeBoundary::FromConstant(r_min);
3097 const intptr_t r_max = 3097 const intptr_t r_max =
3098 OnlyNegativeOrZero(left_range, right_range) ? 0 : result_max; 3098 OnlyNegativeOrZero(left_range, right_range) ? 0 : result_max;
3099 max = RangeBoundary::FromConstant(r_max); 3099 max = RangeBoundary::FromConstant(r_max);
3100 break; 3100 break;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
3587 case Token::kTRUNCDIV: return 0; 3587 case Token::kTRUNCDIV: return 0;
3588 case Token::kMOD: return 1; 3588 case Token::kMOD: return 1;
3589 default: UNIMPLEMENTED(); return -1; 3589 default: UNIMPLEMENTED(); return -1;
3590 } 3590 }
3591 } 3591 }
3592 3592
3593 3593
3594 #undef __ 3594 #undef __
3595 3595
3596 } // namespace dart 3596 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698