Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 21902:e9b787f8134f
Truffle: make transitionMap a ConcurrentHashMap
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Wed, 10 Jun 2015 20:06:17 +0200 |
parents | 19340125f182 |
children | 1b695a36c4d5 |
comparison
equal
deleted
inserted
replaced
21901:19340125f182 | 21902:e9b787f8134f |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.object; | 23 package com.oracle.truffle.object; |
24 | 24 |
25 import java.util.*; | 25 import java.util.*; |
26 import java.util.concurrent.*; | |
26 | 27 |
27 import com.oracle.truffle.api.*; | 28 import com.oracle.truffle.api.*; |
28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | 29 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
29 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | 30 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
30 import com.oracle.truffle.api.interop.*; | 31 import com.oracle.truffle.api.interop.*; |
88 * Shape transition map; lazily initialized. | 89 * Shape transition map; lazily initialized. |
89 * | 90 * |
90 * @see #getTransitionMapForRead() | 91 * @see #getTransitionMapForRead() |
91 * @see #getTransitionMapForWrite() | 92 * @see #getTransitionMapForWrite() |
92 */ | 93 */ |
93 private HashMap<Transition, ShapeImpl> transitionMap; | 94 private volatile Map<Transition, ShapeImpl> transitionMap; |
94 | 95 |
95 private final Transition transitionFromParent; | 96 private final Transition transitionFromParent; |
96 | 97 |
97 /** | 98 /** |
98 * Private constructor. | 99 * Private constructor. |
301 | 302 |
302 private Map<Transition, ShapeImpl> getTransitionMapForWrite() { | 303 private Map<Transition, ShapeImpl> getTransitionMapForWrite() { |
303 if (transitionMap != null) { | 304 if (transitionMap != null) { |
304 return transitionMap; | 305 return transitionMap; |
305 } else { | 306 } else { |
306 invalidateLeafAssumption(); | 307 synchronized (getMutex()) { |
307 return transitionMap = new HashMap<>(); | 308 if (transitionMap != null) { |
309 return transitionMap; | |
310 } | |
311 invalidateLeafAssumption(); | |
312 return transitionMap = new ConcurrentHashMap<>(); | |
313 } | |
308 } | 314 } |
309 } | 315 } |
310 | 316 |
311 public final PropertyMap getPropertyMap() { | 317 public final PropertyMap getPropertyMap() { |
312 return propertyMap; | 318 return propertyMap; |