@@ -4684,16 +4684,6 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
46844684 ASSERT (OffsetInBytes () != 0 || slot ().has_untagged_instance ());
46854685 auto const rep = slot ().representation ();
46864686
4687- #if defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_RISCV64) || \
4688- defined (TARGET_ARCH_X64)
4689- if (FLAG_target_thread_sanitizer && !slot ().is_no_sanitize_thread () &&
4690- memory_order_ == compiler::Assembler::kRelaxedNonAtomic ) {
4691- intptr_t tag = slot ().has_untagged_instance () ? 0 : kHeapObjectTag ;
4692- __ AddImmediate (TMP, instance_reg, slot ().offset_in_bytes () - tag);
4693- __ TsanRead (TMP, RepresentationUtils::ValueSize (rep));
4694- }
4695- #endif
4696-
46974687 if (calls_initializer ()) {
46984688 __ LoadFromSlot (locs ()->out (0 ).reg (), instance_reg, slot (), memory_order_);
46994689 EmitNativeCodeForInitializerCall (compiler);
@@ -7293,6 +7283,91 @@ Definition* InvokeMathCFunctionInstr::Canonicalize(FlowGraph* flow_graph) {
72937283 return this ;
72947284}
72957285
7286+ LocationSummary* TsanReadWriteInstr::MakeLocationSummary (Zone* zone,
7287+ bool opt) const {
7288+ const intptr_t kNumTemps = 1 ;
7289+ LocationSummary* result = new (zone) LocationSummary (
7290+ zone, InputCount (), kNumTemps , LocationSummary::kNativeLeafCall );
7291+ result->set_temp (0 , Location::RegisterLocation (CALLEE_SAVED_TEMP));
7292+ result->set_in (0 , Location::RequiresRegister ());
7293+ return result;
7294+ }
7295+
7296+ const RuntimeEntry& TsanReadWriteInstr::RuntimeEntry () const {
7297+ intptr_t size = RepresentationUtils::ValueSize (slot ().representation ());
7298+ if (kind_ == Kind::kRead ) {
7299+ switch (size) {
7300+ case 1 :
7301+ return kTsanRead1RuntimeEntry ;
7302+ case 2 :
7303+ return kTsanRead2RuntimeEntry ;
7304+ case 4 :
7305+ return kTsanRead4RuntimeEntry ;
7306+ case 8 :
7307+ return kTsanRead8RuntimeEntry ;
7308+ case 16 :
7309+ return kTsanRead16RuntimeEntry ;
7310+ default :
7311+ UNREACHABLE ();
7312+ }
7313+ } else if (kind_ == kWrite ) {
7314+ switch (size) {
7315+ case 1 :
7316+ return kTsanWrite1RuntimeEntry ;
7317+ case 2 :
7318+ return kTsanWrite2RuntimeEntry ;
7319+ case 4 :
7320+ return kTsanWrite4RuntimeEntry ;
7321+ case 8 :
7322+ return kTsanWrite8RuntimeEntry ;
7323+ case 16 :
7324+ return kTsanWrite16RuntimeEntry ;
7325+ default :
7326+ UNREACHABLE ();
7327+ }
7328+ }
7329+ UNREACHABLE ();
7330+ }
7331+
7332+ void TsanReadWriteInstr::EmitNativeCode (FlowGraphCompiler* compiler) {
7333+ #if defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_RISCV64) || \
7334+ defined (TARGET_ARCH_X64)
7335+ const Register saved_sp = locs ()->temp (0 ).reg ();
7336+ ASSERT (IsAbiPreservedRegister (saved_sp));
7337+ ASSERT (IsAbiPreservedRegister (THR));
7338+ ASSERT (IsAbiPreservedRegister (PP));
7339+ ASSERT (IsAbiPreservedRegister (CODE_REG));
7340+ #if defined(TARGET_ARCH_ARM64)
7341+ ASSERT (IsAbiPreservedRegister (NULL_REG));
7342+ ASSERT (IsAbiPreservedRegister (HEAP_BITS));
7343+ ASSERT (IsAbiPreservedRegister (DISPATCH_TABLE_REG));
7344+ #endif
7345+ __ MoveRegister (saved_sp, SPREG);
7346+ #if defined(TARGET_ARCH_ARM64)
7347+ __ andi (CSP, SP, compiler::Immediate (~(OS::ActivationFrameAlignment () - 1 )));
7348+ #else
7349+ __ ReserveAlignedFrameSpace (0 );
7350+ #endif
7351+ const Register instance_reg = locs ()->in (0 ).reg ();
7352+ intptr_t tag = slot ().has_untagged_instance () ? 0 : kHeapObjectTag ;
7353+ __ AddImmediate (CallingConventions::ArgumentRegisters[0 ], instance_reg,
7354+ slot ().offset_in_bytes () - tag);
7355+ __ Load (TMP, compiler::Address (THR, RuntimeEntry ().OffsetFromThread ()));
7356+ __ Store (TMP,
7357+ compiler::Address (THR, compiler::target::Thread::vm_tag_offset ()));
7358+ __ CallCFunction (TMP);
7359+ __ LoadImmediate (TMP, VMTag::kDartTagId );
7360+ __ Store (TMP,
7361+ compiler::Address (THR, compiler::target::Thread::vm_tag_offset ()));
7362+ __ MoveRegister (SPREG, saved_sp);
7363+ #if defined(TARGET_ARCH_ARM64)
7364+ __ SetupCSPFromThread (THR);
7365+ #endif
7366+ #else
7367+ UNREACHABLE ();
7368+ #endif
7369+ }
7370+
72967371bool DoubleToIntegerInstr::SupportsFloorAndCeil () {
72977372#if defined(TARGET_ARCH_X64)
72987373 return CompilerState::Current ().is_aot () || FLAG_target_unknown_cpu;
@@ -7821,16 +7896,6 @@ void StoreFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
78217896 ASSERT (OffsetInBytes () != 0 || slot ().has_untagged_instance ());
78227897 const Representation rep = slot ().representation ();
78237898
7824- #if defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_RISCV64) || \
7825- defined (TARGET_ARCH_X64)
7826- if (FLAG_target_thread_sanitizer && !slot ().is_no_sanitize_thread () &&
7827- memory_order_ == compiler::Assembler::kRelaxedNonAtomic ) {
7828- intptr_t tag = slot ().has_untagged_instance () ? 0 : kHeapObjectTag ;
7829- __ AddImmediate (TMP, instance_reg, slot ().offset_in_bytes () - tag);
7830- __ TsanWrite (TMP, RepresentationUtils::ValueSize (rep));
7831- }
7832- #endif
7833-
78347899#if defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_RISCV32) || \
78357900 defined (TARGET_ARCH_RISCV64)
78367901 if (locs ()->in (kValuePos ).IsConstant () &&
0 commit comments