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

Side by Side Diff: src/arm/simulator-arm.cc

Issue 677483005: [turbofan] Implement the correct semantics for integer division/modulus. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixes and tests Created 6 years, 1 month 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 | src/base/bits.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 if (FLAG_enable_sudiv) { 2734 if (FLAG_enable_sudiv) {
2735 if (instr->Bits(5, 4) == 0x1) { 2735 if (instr->Bits(5, 4) == 0x1) {
2736 if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) { 2736 if ((instr->Bit(22) == 0x0) && (instr->Bit(20) == 0x1)) {
2737 // (s/u)div (in V8 notation matching ARM ISA format) rn = rm/rs 2737 // (s/u)div (in V8 notation matching ARM ISA format) rn = rm/rs
2738 // Format(instr, "'(s/u)div'cond'b 'rn, 'rm, 'rs); 2738 // Format(instr, "'(s/u)div'cond'b 'rn, 'rm, 'rs);
2739 int rm = instr->RmValue(); 2739 int rm = instr->RmValue();
2740 int32_t rm_val = get_register(rm); 2740 int32_t rm_val = get_register(rm);
2741 int rs = instr->RsValue(); 2741 int rs = instr->RsValue();
2742 int32_t rs_val = get_register(rs); 2742 int32_t rs_val = get_register(rs);
2743 int32_t ret_val = 0; 2743 int32_t ret_val = 0;
2744 DCHECK(rs_val != 0);
2745 // udiv 2744 // udiv
2746 if (instr->Bit(21) == 0x1) { 2745 if (instr->Bit(21) == 0x1) {
2747 ret_val = static_cast<int32_t>(static_cast<uint32_t>(rm_val) / 2746 ret_val = bit_cast<int32_t>(base::bits::UnsignedDiv32(
2748 static_cast<uint32_t>(rs_val)); 2747 bit_cast<uint32_t>(rm_val), bit_cast<uint32_t>(rs_val)));
2749 } else if ((rm_val == kMinInt) && (rs_val == -1)) {
2750 ret_val = kMinInt;
2751 } else { 2748 } else {
2752 ret_val = rm_val / rs_val; 2749 ret_val = base::bits::SignedDiv32(rm_val, rs_val);
2753 } 2750 }
2754 set_register(rn, ret_val); 2751 set_register(rn, ret_val);
2755 return; 2752 return;
2756 } 2753 }
2757 } 2754 }
2758 } 2755 }
2759 // Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w"); 2756 // Format(instr, "'memop'cond'b 'rd, ['rn, -'shift_rm]'w");
2760 addr = rn_val - shifter_operand; 2757 addr = rn_val - shifter_operand;
2761 if (instr->HasW()) { 2758 if (instr->HasW()) {
2762 set_register(rn, addr); 2759 set_register(rn, addr);
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 uintptr_t address = *stack_slot; 3850 uintptr_t address = *stack_slot;
3854 set_register(sp, current_sp + sizeof(uintptr_t)); 3851 set_register(sp, current_sp + sizeof(uintptr_t));
3855 return address; 3852 return address;
3856 } 3853 }
3857 3854
3858 } } // namespace v8::internal 3855 } } // namespace v8::internal
3859 3856
3860 #endif // USE_SIMULATOR 3857 #endif // USE_SIMULATOR
3861 3858
3862 #endif // V8_TARGET_ARCH_ARM 3859 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/base/bits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698