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

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

Issue 13722022: Adds macros to the MIPS assembler for detecting overflow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/runtime_entry.h" 9 #include "vm/runtime_entry.h"
10 #include "vm/simulator.h" 10 #include "vm/simulator.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 lui(rd, Immediate(offset_high)); 72 lui(rd, Immediate(offset_high));
73 addu(rd, rd, PP); 73 addu(rd, rd, PP);
74 lw(rd, Address(rd, offset_low)); 74 lw(rd, Address(rd, offset_low));
75 } else { 75 } else {
76 lw(rd, Address(PP, offset_low)); 76 lw(rd, Address(PP, offset_low));
77 } 77 }
78 } 78 }
79 } 79 }
80 80
81 81
82 void Assembler::AdduDetectOverflow(Register rd, Register rs, Register rt,
83 Register ro) {
84 ASSERT(rd != ro);
85 ASSERT(rd != TMP);
86 ASSERT(ro != TMP);
87 ASSERT(ro != rs);
88 ASSERT(ro != rt);
89
90 if ((rs == rt) && (rd == rs)) {
91 ASSERT(rd != T9);
regis 2013/04/05 23:23:45 This macro should take a scratch register argument
zra 2013/04/06 00:04:19 I thought it might be clearer to require a scratch
92 ASSERT(ro != T9);
93 mov(T9, rt);
94 rt = T9;
95 }
96
97 if (rd == rs) {
98 mov(TMP, rs); // Preserve rs.
99 addu(rd, rs, rt); // rs is overwritten.
100 xor_(TMP, rd, TMP); // Original rs.
101 xor_(ro, rd, rt);
102 and_(ro, ro, TMP);
103 } else if (rd == rt) {
104 mov(TMP, rt); // Preserve rt.
105 addu(rd, rs, rt); // rt is overwritten.
106 xor_(TMP, rd, TMP); // Original rt.
107 xor_(ro, rd, rs);
108 and_(ro, ro, TMP);
109 } else {
110 addu(rd, rs, rt);
111 xor_(ro, rd, rs);
112 xor_(TMP, rd, rt);
113 and_(ro, TMP, ro);
114 }
115 }
116
117
118 void Assembler::AddiuDetectOverflow(Register rt, Register rs,
119 const Immediate& imm, Register ro) {
regis 2013/04/05 23:23:45 ditto, scratch argument instead of T8.
zra 2013/04/06 00:04:19 I decided to remove this function. Otherwise it wo
120 addiu(T8, ZR, imm);
121 AdduDetectOverflow(rt, rs, T8, ro);
122 }
123
124
82 void Assembler::LoadObject(Register rd, const Object& object) { 125 void Assembler::LoadObject(Register rd, const Object& object) {
83 // Smi's and VM heap objects are never relocated; do not use object pool. 126 // Smi's and VM heap objects are never relocated; do not use object pool.
84 if (object.IsSmi()) { 127 if (object.IsSmi()) {
85 LoadImmediate(rd, reinterpret_cast<int32_t>(object.raw())); 128 LoadImmediate(rd, reinterpret_cast<int32_t>(object.raw()));
86 } else if (object.InVMHeap()) { 129 } else if (object.InVMHeap()) {
87 // Make sure that class CallPattern is able to decode this load immediate. 130 // Make sure that class CallPattern is able to decode this load immediate.
88 int32_t object_raw = reinterpret_cast<int32_t>(object.raw()); 131 int32_t object_raw = reinterpret_cast<int32_t>(object.raw());
89 const uint16_t object_low = Utils::Low16Bits(object_raw); 132 const uint16_t object_low = Utils::Low16Bits(object_raw);
90 const uint16_t object_high = Utils::High16Bits(object_raw); 133 const uint16_t object_high = Utils::High16Bits(object_raw);
91 lui(rd, Immediate(object_high)); 134 lui(rd, Immediate(object_high));
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 b(&stop); 323 b(&stop);
281 Emit(reinterpret_cast<int32_t>(message)); 324 Emit(reinterpret_cast<int32_t>(message));
282 Bind(&stop); 325 Bind(&stop);
283 break_(Instr::kStopMessageCode); 326 break_(Instr::kStopMessageCode);
284 } 327 }
285 328
286 } // namespace dart 329 } // namespace dart
287 330
288 #endif // defined TARGET_ARCH_MIPS 331 #endif // defined TARGET_ARCH_MIPS
289 332
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698