private Object ensureId(int id) { Object[] array = valueArray; if (array == null) { synchronized (this) { array = valueArray; if (array == null) { array = new Object[maxId * SLOT_SPAN]; valueArray = array; attributeArray = new short[maxId]; } } } int valueSlot = (id - 1) * SLOT_SPAN + VALUE_SLOT; Object value = array[valueSlot]; if (value == null) { if (id == constructorId) { initSlot(constructorId, "constructor", constructor, constructorAttrs); constructor = null; // no need to refer it any longer } else { obj.initPrototypeId(id); } value = array[valueSlot]; if (value == null) { throw new IllegalStateException( obj.getClass().getName() + ".initPrototypeId(int id) " + "did not initialize id=" + id); } } return value; }
final IdFunctionObject createPrecachedConstructor() { if (constructorId != 0) throw new IllegalStateException(); constructorId = obj.findPrototypeId("constructor"); if (constructorId == 0) { throw new IllegalStateException("No id for constructor property"); } obj.initPrototypeId(constructorId); if (constructor == null) { throw new IllegalStateException( obj.getClass().getName() + ".initPrototypeId() did not " + "initialize id=" + constructorId); } constructor.initFunction(obj.getClassName(), ScriptableObject.getTopLevelScope(obj)); constructor.markAsConstructor(obj); return constructor; }