Mercurial > hg > graal-jvmci-8
changeset 21215:e11eb6ec180e
Use double-checked locking in HotSpotConstantPool.lookupType.
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Mon, 04 May 2015 23:15:42 +0200 |
parents | bfb6e742ad0a |
children | 04339fd2c863 39ee26e85256 257fd6a46525 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon May 04 19:34:51 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon May 04 23:15:42 2015 +0200 @@ -489,16 +489,20 @@ @Override public JavaType lookupType(int cpi, int opcode) { - synchronized (this) { - if (cpi == this.lastTypeCpi) { - return this.lastType; + if (cpi == this.lastTypeCpi) { + synchronized (this) { + if (cpi == this.lastTypeCpi) { + return this.lastType; + } } } final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi); JavaType result = getJavaType(metaspacePointer); if (result instanceof ResolvedJavaType) { - this.lastType = (ResolvedJavaType) result; - this.lastTypeCpi = cpi; + synchronized (this) { + this.lastType = (ResolvedJavaType) result; + this.lastTypeCpi = cpi; + } } return result; }