make release_clock always work on the current thread · rust-lang/rust@5fa30f7 (original) (raw)

`@@ -61,8 +61,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

61

61

`let current_thread = this.get_active_thread();

`

62

62

``

63

63

`if let Some(data_race) = &this.machine.data_race {

`

64

``

`-

data_race

`

65

``

`-

.acquire_clock(&this.machine.threads.sync.init_onces[id].clock, current_thread);

`

``

64

`+

data_race.acquire_clock(&this.machine.sync.init_onces[id].clock, current_thread);

`

66

65

`}

`

67

66

`}

`

68

67

``

`@@ -112,11 +111,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

112

111

`) -> InterpResult<'tcx, Option>,

`

113

112

`{

`

114

113

`let this = self.eval_context_mut();

`

115

``

`-

let next_index = this.machine.threads.sync.init_onces.next_index();

`

``

114

`+

let next_index = this.machine.sync.init_onces.next_index();

`

116

115

`if let Some(old) = existing(this, next_index)? {

`

117

116

`Ok(old)

`

118

117

`} else {

`

119

``

`-

let new_index = this.machine.threads.sync.init_onces.push(Default::default());

`

``

118

`+

let new_index = this.machine.sync.init_onces.push(Default::default());

`

120

119

`assert_eq!(next_index, new_index);

`

121

120

`Ok(new_index)

`

122

121

`}

`

`@@ -125,7 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

125

124

`#[inline]

`

126

125

`fn init_once_status(&mut self, id: InitOnceId) -> InitOnceStatus {

`

127

126

`let this = self.eval_context_ref();

`

128

``

`-

this.machine.threads.sync.init_onces[id].status

`

``

127

`+

this.machine.sync.init_onces[id].status

`

129

128

`}

`

130

129

``

131

130

`/// Put the thread into the queue waiting for the initialization.

`

`@@ -137,7 +136,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

137

136

`callback: Box<dyn MachineCallback<'mir, 'tcx> + 'tcx>,

`

138

137

`) {

`

139

138

`let this = self.eval_context_mut();

`

140

``

`-

let init_once = &mut this.machine.threads.sync.init_onces[id];

`

``

139

`+

let init_once = &mut this.machine.sync.init_onces[id];

`

141

140

`assert_ne!(init_once.status, InitOnceStatus::Complete, "queueing on complete init once");

`

142

141

` init_once.waiters.push_back(InitOnceWaiter { thread, callback });

`

143

142

` this.block_thread(thread, BlockReason::InitOnce(id));

`

`@@ -148,7 +147,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

148

147

`#[inline]

`

149

148

`fn init_once_begin(&mut self, id: InitOnceId) {

`

150

149

`let this = self.eval_context_mut();

`

151

``

`-

let init_once = &mut this.machine.threads.sync.init_onces[id];

`

``

150

`+

let init_once = &mut this.machine.sync.init_onces[id];

`

152

151

`assert_eq!(

`

153

152

` init_once.status,

`

154

153

`InitOnceStatus::Uninitialized,

`

`@@ -160,9 +159,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

160

159

`#[inline]

`

161

160

`fn init_once_complete(&mut self, id: InitOnceId) -> InterpResult<'tcx> {

`

162

161

`let this = self.eval_context_mut();

`

163

``

`-

let current_thread = this.get_active_thread();

`

164

``

`-

let current_span = this.machine.current_span();

`

165

``

`-

let init_once = &mut this.machine.threads.sync.init_onces[id];

`

``

162

`+

let init_once = &mut this.machine.sync.init_onces[id];

`

166

163

``

167

164

`assert_eq!(

`

168

165

` init_once.status,

`

`@@ -174,7 +171,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

174

171

``

175

172

`// Each complete happens-before the end of the wait

`

176

173

`if let Some(data_race) = &this.machine.data_race {

`

177

``

`-

init_once.clock.clone_from(&data_race.release_clock(current_thread, current_span));

`

``

174

`+

init_once.clock.clone_from(&data_race.release_clock(&this.machine.threads));

`

178

175

`}

`

179

176

``

180

177

`// Wake up everyone.

`

`@@ -189,9 +186,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

189

186

`#[inline]

`

190

187

`fn init_once_fail(&mut self, id: InitOnceId) -> InterpResult<'tcx> {

`

191

188

`let this = self.eval_context_mut();

`

192

``

`-

let current_thread = this.get_active_thread();

`

193

``

`-

let current_span = this.machine.current_span();

`

194

``

`-

let init_once = &mut this.machine.threads.sync.init_onces[id];

`

``

189

`+

let init_once = &mut this.machine.sync.init_onces[id];

`

195

190

`assert_eq!(

`

196

191

` init_once.status,

`

197

192

`InitOnceStatus::Begun,

`

`@@ -200,7 +195,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

`

200

195

``

201

196

`// Each complete happens-before the end of the wait

`

202

197

`if let Some(data_race) = &this.machine.data_race {

`

203

``

`-

init_once.clock.clone_from(&data_race.release_clock(current_thread, current_span));

`

``

198

`+

init_once.clock.clone_from(&data_race.release_clock(&this.machine.threads));

`

204

199

`}

`

205

200

``

206

201

`// Wake up one waiting thread, so they can go ahead and try to init this.

`