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

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

Issue 2754543006: [arm64] Use exclusive instructions in exchange (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <cmath> 6 #include <cmath>
7 #include <cstdarg> 7 #include <cstdarg>
8 8
9 #if V8_TARGET_ARCH_ARM64 9 #if V8_TARGET_ARCH_ARM64
10 10
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 case 2: 1945 case 2:
1946 return TransactionSize::HalfWord; 1946 return TransactionSize::HalfWord;
1947 case 4: 1947 case 4:
1948 return TransactionSize::Word; 1948 return TransactionSize::Word;
1949 default: 1949 default:
1950 UNREACHABLE(); 1950 UNREACHABLE();
1951 } 1951 }
1952 return TransactionSize::None; 1952 return TransactionSize::None;
1953 } 1953 }
1954 1954
1955 void Simulator::VisitLoadStoreExclusive(Instruction* instr) {
1956 unsigned rs = instr->Rs();
1957 unsigned rt = instr->Rt();
1958 unsigned rn = instr->Rn();
1959 LoadStoreExclusiveOp op =
1960 static_cast<LoadStoreExclusiveOp>(instr->Mask(LoadStoreExclusiveMask));
1961 int32_t is_load = instr->LoadStoreXLoad();
1962 unsigned access_size = 1 << instr->LoadStoreXSizeLog2();
1963 uintptr_t address = LoadStoreAddress(rn, 0, AddrMode::Offset);
1964 DCHECK_EQ(address % access_size, 0);
1965 base::LockGuard<base::Mutex> lock_guard(&global_monitor_.Pointer()->mutex);
1966 if (is_load != 0) {
1967 local_monitor_.NotifyLoadExcl(address, get_transaction_size(access_size));
1968 global_monitor_.Pointer()->NotifyLoadExcl_Locked(
1969 address, &global_monitor_processor_);
1970 switch (op) {
1971 case LDXRB:
1972 set_wreg_no_log(rt, MemoryRead<uint8_t>(address));
1973 break;
1974 case LDXRH:
1975 set_wreg_no_log(rt, MemoryRead<uint16_t>(address));
1976 break;
1977 case LDXR_w:
1978 set_wreg_no_log(rt, MemoryRead<uint32_t>(address));
1979 break;
1980 default:
1981 UNIMPLEMENTED();
1982 }
1983 LogRead(address, access_size, rt);
1984 } else {
1985 if (local_monitor_.NotifyStoreExcl(address,
1986 get_transaction_size(access_size)) &&
1987 global_monitor_.Pointer()->NotifyStoreExcl_Locked(
1988 address, &global_monitor_processor_)) {
1989 switch (op) {
1990 case STXRB:
1991 MemoryWrite<uint8_t>(address, wreg(rt));
1992 break;
1993 case STXRH:
1994 MemoryWrite<uint16_t>(address, wreg(rt));
1995 break;
1996 case STXR_w:
1997 MemoryWrite<uint32_t>(address, wreg(rt));
1998 break;
1999 default:
2000 UNIMPLEMENTED();
2001 }
2002 LogWrite(address, access_size, rt);
2003 set_wreg(rs, 0);
2004 } else {
2005 set_wreg(rs, 1);
2006 }
2007 }
2008 }
2009
1955 void Simulator::VisitLoadStoreAcquireRelease(Instruction* instr) { 2010 void Simulator::VisitLoadStoreAcquireRelease(Instruction* instr) {
1956 unsigned rs = instr->Rs(); 2011 unsigned rs = instr->Rs();
1957 unsigned rt = instr->Rt(); 2012 unsigned rt = instr->Rt();
1958 unsigned rn = instr->Rn(); 2013 unsigned rn = instr->Rn();
1959 LoadStoreAcquireReleaseOp op = static_cast<LoadStoreAcquireReleaseOp>( 2014 LoadStoreAcquireReleaseOp op = static_cast<LoadStoreAcquireReleaseOp>(
1960 instr->Mask(LoadStoreAcquireReleaseMask)); 2015 instr->Mask(LoadStoreAcquireReleaseMask));
1961 int32_t is_acquire_release = instr->LoadStoreXAcquireRelease(); 2016 int32_t is_acquire_release = instr->LoadStoreXAcquireRelease();
1962 int32_t is_not_exclusive = instr->LoadStoreXNotExclusive(); 2017 int32_t is_not_exclusive = instr->LoadStoreXNotExclusive();
1963 int32_t is_load = instr->LoadStoreXLoad(); 2018 int32_t is_load = instr->LoadStoreXLoad();
1964 int32_t is_pair = instr->LoadStoreXPair(); 2019 int32_t is_pair = instr->LoadStoreXPair();
1965 DCHECK_NE(is_acquire_release, 0); 2020 DCHECK_NE(is_acquire_release, 0);
1966 DCHECK_EQ(is_not_exclusive, 0); // Non exclusive unimplemented. 2021 DCHECK_EQ(is_not_exclusive, 0); // Non exclusive unimplemented.
1967 DCHECK_EQ(is_pair, 0); // Pair unimplemented. 2022 DCHECK_EQ(is_pair, 0); // Pair unimplemented.
1968 unsigned access_size = 1 << instr->LoadStoreXSizeLog2(); 2023 unsigned access_size = 1 << instr->LoadStoreXSizeLog2();
1969 uintptr_t address = LoadStoreAddress(rn, 0, AddrMode::Offset); 2024 uintptr_t address = LoadStoreAddress(rn, 0, AddrMode::Offset);
1970 DCHECK(address % access_size == 0); 2025 DCHECK_EQ(address % access_size, 0);
1971 base::LockGuard<base::Mutex> lock_guard(&global_monitor_.Pointer()->mutex); 2026 base::LockGuard<base::Mutex> lock_guard(&global_monitor_.Pointer()->mutex);
1972 if (is_load != 0) { 2027 if (is_load != 0) {
1973 local_monitor_.NotifyLoadExcl(address, get_transaction_size(access_size)); 2028 local_monitor_.NotifyLoadExcl(address, get_transaction_size(access_size));
1974 global_monitor_.Pointer()->NotifyLoadExcl_Locked( 2029 global_monitor_.Pointer()->NotifyLoadExcl_Locked(
1975 address, &global_monitor_processor_); 2030 address, &global_monitor_processor_);
1976 switch (op) { 2031 switch (op) {
1977 case LDAXR_b: 2032 case LDAXR_b:
1978 set_wreg_no_log(rt, MemoryRead<uint8_t>(address)); 2033 set_wreg_no_log(rt, MemoryRead<uint8_t>(address));
1979 break; 2034 break;
1980 case LDAXR_h: 2035 case LDAXR_h:
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
4160 processor->prev_ = nullptr; 4215 processor->prev_ = nullptr;
4161 processor->next_ = nullptr; 4216 processor->next_ = nullptr;
4162 } 4217 }
4163 4218
4164 #endif // USE_SIMULATOR 4219 #endif // USE_SIMULATOR
4165 4220
4166 } // namespace internal 4221 } // namespace internal
4167 } // namespace v8 4222 } // namespace v8
4168 4223
4169 #endif // V8_TARGET_ARCH_ARM64 4224 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698