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

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

Issue 281823002: Fix an undetected Smi overflow on ARM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('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_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 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 Register result = locs()->out(0).reg(); 2912 Register result = locs()->out(0).reg();
2913 ASSERT(left == result); 2913 ASSERT(left == result);
2914 Label* deopt = NULL; 2914 Label* deopt = NULL;
2915 if (CanDeoptimize()) { 2915 if (CanDeoptimize()) {
2916 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp); 2916 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp);
2917 } 2917 }
2918 2918
2919 if (locs()->in(1).IsConstant()) { 2919 if (locs()->in(1).IsConstant()) {
2920 const Object& constant = locs()->in(1).constant(); 2920 const Object& constant = locs()->in(1).constant();
2921 ASSERT(constant.IsSmi()); 2921 ASSERT(constant.IsSmi());
2922 const int32_t imm = 2922 const int32_t imm = reinterpret_cast<int32_t>(constant.raw());
2923 reinterpret_cast<int32_t>(constant.raw());
2924 switch (op_kind()) { 2923 switch (op_kind()) {
2925 case Token::kADD: 2924 case Token::kADD:
2926 __ addl(left, Immediate(imm)); 2925 if (imm != 0) {
2927 if (deopt != NULL) __ j(OVERFLOW, deopt); 2926 // Checking overflow without emitting an instruction would be wrong.
2927 __ addl(left, Immediate(imm));
2928 if (deopt != NULL) __ j(OVERFLOW, deopt);
2929 }
2928 break; 2930 break;
2929 case Token::kSUB: { 2931 case Token::kSUB: {
2930 __ subl(left, Immediate(imm)); 2932 if (imm != 0) {
2931 if (deopt != NULL) __ j(OVERFLOW, deopt); 2933 // Checking overflow without emitting an instruction would be wrong.
2934 __ subl(left, Immediate(imm));
2935 if (deopt != NULL) __ j(OVERFLOW, deopt);
2936 }
2932 break; 2937 break;
2933 } 2938 }
2934 case Token::kMUL: { 2939 case Token::kMUL: {
2935 // Keep left value tagged and untag right value. 2940 // Keep left value tagged and untag right value.
2936 const intptr_t value = Smi::Cast(constant).Value(); 2941 const intptr_t value = Smi::Cast(constant).Value();
2937 if (value == 2) { 2942 if (value == 2) {
2938 __ shll(left, Immediate(1)); 2943 __ shll(left, Immediate(1));
2939 } else { 2944 } else {
2940 __ imull(left, Immediate(value)); 2945 __ imull(left, Immediate(value));
2941 } 2946 }
(...skipping 3048 matching lines...) Expand 10 before | Expand all | Expand 10 after
5990 } 5995 }
5991 } 5996 }
5992 5997
5993 __ setcc(true_condition, DL); 5998 __ setcc(true_condition, DL);
5994 5999
5995 if (is_power_of_two_kind) { 6000 if (is_power_of_two_kind) {
5996 const intptr_t shift = 6001 const intptr_t shift =
5997 Utils::ShiftForPowerOfTwo(Utils::Maximum(true_value, false_value)); 6002 Utils::ShiftForPowerOfTwo(Utils::Maximum(true_value, false_value));
5998 __ shll(EDX, Immediate(shift + kSmiTagSize)); 6003 __ shll(EDX, Immediate(shift + kSmiTagSize));
5999 } else { 6004 } else {
6000 __ subl(EDX, Immediate(1)); 6005 __ decl(EDX);
6001 __ andl(EDX, Immediate( 6006 __ andl(EDX, Immediate(
6002 Smi::RawValue(true_value) - Smi::RawValue(false_value))); 6007 Smi::RawValue(true_value) - Smi::RawValue(false_value)));
6003 if (false_value != 0) { 6008 if (false_value != 0) {
6004 __ addl(EDX, Immediate(Smi::RawValue(false_value))); 6009 __ addl(EDX, Immediate(Smi::RawValue(false_value)));
6005 } 6010 }
6006 } 6011 }
6007 } 6012 }
6008 6013
6009 6014
6010 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { 6015 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
6090 PcDescriptors::kOther, 6095 PcDescriptors::kOther,
6091 locs()); 6096 locs());
6092 __ Drop(ArgumentCount()); // Discard arguments. 6097 __ Drop(ArgumentCount()); // Discard arguments.
6093 } 6098 }
6094 6099
6095 } // namespace dart 6100 } // namespace dart
6096 6101
6097 #undef __ 6102 #undef __
6098 6103
6099 #endif // defined TARGET_ARCH_IA32 6104 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698