@@ -193,7 +193,9 @@ def trace_object_allocations
193
193
module_function :trace_object_allocations
194
194
195
195
def trace_object_allocations_clear
196
- ALLOCATIONS . clear
196
+ Truffle ::System . synchronized ( ALLOCATIONS ) do
197
+ ALLOCATIONS . clear
198
+ end
197
199
end
198
200
module_function :trace_object_allocations_clear
199
201
@@ -213,21 +215,27 @@ def trace_object_allocations_stop
213
215
module_function :trace_object_allocations_stop
214
216
215
217
def allocation_class_path ( object )
216
- allocation = ALLOCATIONS [ object ]
218
+ allocation = Truffle ::System . synchronized ( ALLOCATIONS ) do
219
+ ALLOCATIONS [ object ]
220
+ end
217
221
return nil if allocation . nil?
218
222
allocation . class_path
219
223
end
220
224
module_function :allocation_class_path
221
225
222
226
def allocation_generation ( object )
223
- allocation = ALLOCATIONS [ object ]
227
+ allocation = Truffle ::System . synchronized ( ALLOCATIONS ) do
228
+ ALLOCATIONS [ object ]
229
+ end
224
230
return nil if allocation . nil?
225
231
allocation . generation
226
232
end
227
233
module_function :allocation_generation
228
234
229
235
def allocation_method_id ( object )
230
- allocation = ALLOCATIONS [ object ]
236
+ allocation = Truffle ::System . synchronized ( ALLOCATIONS ) do
237
+ ALLOCATIONS [ object ]
238
+ end
231
239
return nil if allocation . nil?
232
240
233
241
method_id = allocation . method_id
@@ -238,14 +246,18 @@ def allocation_method_id(object)
238
246
module_function :allocation_method_id
239
247
240
248
def allocation_sourcefile ( object )
241
- allocation = ALLOCATIONS [ object ]
249
+ allocation = Truffle ::System . synchronized ( ALLOCATIONS ) do
250
+ ALLOCATIONS [ object ]
251
+ end
242
252
return nil if allocation . nil?
243
253
allocation . sourcefile
244
254
end
245
255
module_function :allocation_sourcefile
246
256
247
257
def allocation_sourceline ( object )
248
- allocation = ALLOCATIONS [ object ]
258
+ allocation = Truffle ::System . synchronized ( ALLOCATIONS ) do
259
+ ALLOCATIONS [ object ]
260
+ end
249
261
return nil if allocation . nil?
250
262
allocation . sourceline
251
263
end
@@ -256,7 +268,10 @@ def allocation_sourceline(object)
256
268
ALLOCATIONS = { } . compare_by_identity
257
269
258
270
def trace_allocation ( object , class_path , method_id , sourcefile , sourceline , generation )
259
- ALLOCATIONS [ object ] = Allocation . new ( class_path , method_id , sourcefile , sourceline , generation )
271
+ allocation = Allocation . new ( class_path , method_id , sourcefile , sourceline , generation )
272
+ Truffle ::System . synchronized ( ALLOCATIONS ) do
273
+ ALLOCATIONS [ object ] = allocation
274
+ end
260
275
end
261
276
module_function :trace_allocation
262
277
0 commit comments