mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
0babafcaa0
I must admit this is very subtitle, but still... Here are the lines from public void defineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes) GetterSlot slot = (GetterSlot)getSlotToSet(propertyName, propertyName.hashCode(), true); slot.delegateTo = delegateTo; slot.getter = getter; slot.setter = setter; slot.setterReturnsValue = setter != null && setter.getReturnType() != Void.TYPE; slot.value = null; slot.attributes = (short) attributes; slot.flags = (byte)flags; Now suppose that after the new slot is added, another thread is accessing it. Then it would see not yet ready slot with all nasty consequences! For example, SMP computer can re-arrange writes so the new value of slot.flags would be visible before slot.getter then another thread would generate null pointer exception. race2_fix.diff fixes that by using the explicit Slot argument to addSlot instead of boolean flag so the new slot can be fully initialized and then inserted under synchronization to the table. I also call addSlot directly because it is supposed to be used with not-yet existed properties and split addSlot to addSlot and addSlotImpl so in case of table growth there is no need to re-enter already synchronized monitor. This changes also allows to explicitly throw RuntimeException if defineProperty is called for the property that is already exists instead of either throwing cast exception in "GetterSlot slot = (GetterSlot)getSlotToSet(propertyName," or worth yet re-initializing already existed slot. Regards, Igor |
||
---|---|---|
.. | ||
benchmarks | ||
js2 | ||
jsd | ||
jsdj | ||
jsj | ||
macbuild | ||
ref | ||
rhino | ||
src | ||
tests | ||
.cvsignore | ||
landbranch.pl | ||
Makefile.in | ||
makefile.win |