| OLD | NEW |
| 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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_MIPS) | 9 #if defined(TARGET_ARCH_MIPS) |
| 10 | 10 |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 SetExclusiveAccess(addr); | 1166 SetExclusiveAccess(addr); |
| 1167 return ReadW(addr, instr); | 1167 return ReadW(addr, instr); |
| 1168 } | 1168 } |
| 1169 | 1169 |
| 1170 | 1170 |
| 1171 intptr_t Simulator::WriteExclusiveW(uword addr, intptr_t value, Instr* instr) { | 1171 intptr_t Simulator::WriteExclusiveW(uword addr, intptr_t value, Instr* instr) { |
| 1172 MutexLocker ml(exclusive_access_lock_); | 1172 MutexLocker ml(exclusive_access_lock_); |
| 1173 bool write_allowed = HasExclusiveAccessAndOpen(addr); | 1173 bool write_allowed = HasExclusiveAccessAndOpen(addr); |
| 1174 if (write_allowed) { | 1174 if (write_allowed) { |
| 1175 WriteW(addr, value, instr); | 1175 WriteW(addr, value, instr); |
| 1176 return 0; // Success. | 1176 return 1; // Success. |
| 1177 } | 1177 } |
| 1178 return 1; // Failure. | 1178 return 0; // Failure. |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 | 1181 |
| 1182 uword Simulator::CompareExchange(uword* address, | 1182 uword Simulator::CompareExchange(uword* address, |
| 1183 uword compare_value, | 1183 uword compare_value, |
| 1184 uword new_value) { | 1184 uword new_value) { |
| 1185 MutexLocker ml(exclusive_access_lock_); | 1185 MutexLocker ml(exclusive_access_lock_); |
| 1186 // We do not get a reservation as it would be guaranteed to be found when | 1186 // We do not get a reservation as it would be guaranteed to be found when |
| 1187 // writing below. No other thread is able to make a reservation while we | 1187 // writing below. No other thread is able to make a reservation while we |
| 1188 // hold the lock. | 1188 // hold the lock. |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 int32_t res = ReadHU(addr, instr); | 2162 int32_t res = ReadHU(addr, instr); |
| 2163 set_register(instr->RtField(), res); | 2163 set_register(instr->RtField(), res); |
| 2164 } | 2164 } |
| 2165 break; | 2165 break; |
| 2166 } | 2166 } |
| 2167 case LUI: { | 2167 case LUI: { |
| 2168 ASSERT(instr->RsField() == 0); | 2168 ASSERT(instr->RsField() == 0); |
| 2169 set_register(instr->RtField(), instr->UImmField() << 16); | 2169 set_register(instr->RtField(), instr->UImmField() << 16); |
| 2170 break; | 2170 break; |
| 2171 } | 2171 } |
| 2172 case LL: { |
| 2173 // Format(instr, "ll 'rt, 'imms('rs)"); |
| 2174 int32_t base_val = get_register(instr->RsField()); |
| 2175 int32_t imm_val = instr->SImmField(); |
| 2176 uword addr = base_val + imm_val; |
| 2177 if (Simulator::IsIllegalAddress(addr)) { |
| 2178 HandleIllegalAccess(addr, instr); |
| 2179 } else { |
| 2180 int32_t res = ReadExclusiveW(addr, instr); |
| 2181 set_register(instr->RtField(), res); |
| 2182 } |
| 2183 break; |
| 2184 } |
| 2172 case LW: { | 2185 case LW: { |
| 2173 // Format(instr, "lw 'rt, 'imms('rs)"); | 2186 // Format(instr, "lw 'rt, 'imms('rs)"); |
| 2174 int32_t base_val = get_register(instr->RsField()); | 2187 int32_t base_val = get_register(instr->RsField()); |
| 2175 int32_t imm_val = instr->SImmField(); | 2188 int32_t imm_val = instr->SImmField(); |
| 2176 uword addr = base_val + imm_val; | 2189 uword addr = base_val + imm_val; |
| 2177 if (Simulator::IsIllegalAddress(addr)) { | 2190 if (Simulator::IsIllegalAddress(addr)) { |
| 2178 HandleIllegalAccess(addr, instr); | 2191 HandleIllegalAccess(addr, instr); |
| 2179 } else { | 2192 } else { |
| 2180 int32_t res = ReadW(addr, instr); | 2193 int32_t res = ReadW(addr, instr); |
| 2181 set_register(instr->RtField(), res); | 2194 set_register(instr->RtField(), res); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2207 int32_t base_val = get_register(instr->RsField()); | 2220 int32_t base_val = get_register(instr->RsField()); |
| 2208 int32_t imm_val = instr->SImmField(); | 2221 int32_t imm_val = instr->SImmField(); |
| 2209 uword addr = base_val + imm_val; | 2222 uword addr = base_val + imm_val; |
| 2210 if (Simulator::IsIllegalAddress(addr)) { | 2223 if (Simulator::IsIllegalAddress(addr)) { |
| 2211 HandleIllegalAccess(addr, instr); | 2224 HandleIllegalAccess(addr, instr); |
| 2212 } else { | 2225 } else { |
| 2213 WriteB(addr, rt_val & 0xff); | 2226 WriteB(addr, rt_val & 0xff); |
| 2214 } | 2227 } |
| 2215 break; | 2228 break; |
| 2216 } | 2229 } |
| 2230 case SC: { |
| 2231 // Format(instr, "sc 'rt, 'imms('rs)"); |
| 2232 int32_t rt_val = get_register(instr->RtField()); |
| 2233 int32_t base_val = get_register(instr->RsField()); |
| 2234 int32_t imm_val = instr->SImmField(); |
| 2235 uword addr = base_val + imm_val; |
| 2236 if (Simulator::IsIllegalAddress(addr)) { |
| 2237 HandleIllegalAccess(addr, instr); |
| 2238 } else { |
| 2239 intptr_t status = WriteExclusiveW(addr, rt_val, instr); |
| 2240 set_register(instr->RtField(), status); |
| 2241 } |
| 2242 break; |
| 2243 } |
| 2217 case SLTI: { | 2244 case SLTI: { |
| 2218 // Format(instr, "slti 'rt, 'rs, 'imms"); | 2245 // Format(instr, "slti 'rt, 'rs, 'imms"); |
| 2219 int32_t rs_val = get_register(instr->RsField()); | 2246 int32_t rs_val = get_register(instr->RsField()); |
| 2220 int32_t imm_val = instr->SImmField(); | 2247 int32_t imm_val = instr->SImmField(); |
| 2221 set_register(instr->RtField(), rs_val < imm_val ? 1 : 0); | 2248 set_register(instr->RtField(), rs_val < imm_val ? 1 : 0); |
| 2222 break; | 2249 break; |
| 2223 } | 2250 } |
| 2224 case SLTIU: { | 2251 case SLTIU: { |
| 2225 // Format(instr, "sltiu 'rt, 'rs, 'imms"); | 2252 // Format(instr, "sltiu 'rt, 'rs, 'imms"); |
| 2226 uint32_t rs_val = get_register(instr->RsField()); | 2253 uint32_t rs_val = get_register(instr->RsField()); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2538 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
| 2512 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2539 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 2513 buf->Longjmp(); | 2540 buf->Longjmp(); |
| 2514 } | 2541 } |
| 2515 | 2542 |
| 2516 } // namespace dart | 2543 } // namespace dart |
| 2517 | 2544 |
| 2518 #endif // defined(USING_SIMULATOR) | 2545 #endif // defined(USING_SIMULATOR) |
| 2519 | 2546 |
| 2520 #endif // defined TARGET_ARCH_MIPS | 2547 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |