equal
deleted
inserted
replaced
402 } |
402 } |
403 // Reacquire cache lock. |
403 // Reacquire cache lock. |
404 d = lookupCache(types); |
404 d = lookupCache(types); |
405 // Class loading must have upgraded the cache. |
405 // Class loading must have upgraded the cache. |
406 assert(d != null && !d.isPlaceholder()); |
406 assert(d != null && !d.isPlaceholder()); |
407 if (OBSERVE_BMH_SPECIES_CREATION) { |
|
408 if (d == null) { |
|
409 throw new IllegalStateException("d == null"); |
|
410 } |
|
411 if (d.isPlaceholder()) { |
|
412 throw new IllegalStateException("d is place holder"); |
|
413 } |
|
414 } |
|
415 return d; |
407 return d; |
416 } |
408 } |
417 static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) { |
409 static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) { |
418 // clazz is a new class which is initializing its SPECIES_DATA field |
410 // clazz is a new class which is initializing its SPECIES_DATA field |
419 return updateCache(types, new SpeciesData(types, clazz)); |
411 return updateCache(types, new SpeciesData(types, clazz)); |
421 private static synchronized SpeciesData lookupCache(String types) { |
413 private static synchronized SpeciesData lookupCache(String types) { |
422 SpeciesData d = CACHE.get(types); |
414 SpeciesData d = CACHE.get(types); |
423 if (d != null) return d; |
415 if (d != null) return d; |
424 d = new SpeciesData(types); |
416 d = new SpeciesData(types); |
425 assert(d.isPlaceholder()); |
417 assert(d.isPlaceholder()); |
426 if (OBSERVE_BMH_SPECIES_CREATION && !d.isPlaceholder()) { |
|
427 throw new IllegalStateException("d is not place holder"); |
|
428 } |
|
429 CACHE.put(types, d); |
418 CACHE.put(types, d); |
430 return d; |
419 return d; |
431 } |
420 } |
432 private static synchronized SpeciesData updateCache(String types, SpeciesData d) { |
421 private static synchronized SpeciesData updateCache(String types, SpeciesData d) { |
433 SpeciesData d2; |
422 SpeciesData d2; |
434 assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder()); |
423 assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder()); |
435 assert(!d.isPlaceholder()); |
424 assert(!d.isPlaceholder()); |
436 if (OBSERVE_BMH_SPECIES_CREATION) { |
|
437 d2 = CACHE.get(types); |
|
438 if (d2 != null && !d2.isPlaceholder()) { |
|
439 throw new IllegalStateException("non-null d2 is not place holder"); |
|
440 } |
|
441 if (d.isPlaceholder()) { |
|
442 throw new IllegalStateException("d is place holder"); |
|
443 } |
|
444 } |
|
445 CACHE.put(types, d); |
425 CACHE.put(types, d); |
446 return d; |
426 return d; |
447 } |
427 } |
448 |
428 |
449 static { |
429 static { |