RFR: 8166187: Regression: NPE during reparse when using persistent code cache and optimistic types
hannes.wallnoefer at oracle.com
Tue Jan 10 14:50:00 UTC 2017
I just realized I used the wrong bug id for the second webrev linked below. Here’s the webrev again, with the correct id:
> Am 23.12.2016 um 12:20 schrieb Hannes Wallnöfer <hannes.wallnoefer at oracle.com>:
> Thanks Attila, I had forgotten cached AST is not just a performance feature.
> I uploaded a new webrev. It pretty much follows your suggestions, except I used a slightly different approach to conditional serialization of cachedAst - I left the field transient and serialize it explicitly if it is an instance of SerializedAst, otherwise write out null. I also added a test case for split stored functions.
>> Am 22.12.2016 um 16:48 schrieb Attila Szegedi <szegedia at gmail.com>:
>> Hm… cachedAst is essential for split functions; specifically if it contains a SerializedAst, then its "byte serializedAst" field is essential. If cachedAst is lost, we can reparse an unsplit function from source, but we can’t reparse fragments of split functions.
>> I’d suggest instead of making cachedAst transient, we should:
>> 1. make SerializedAst Serializable, and have SerializedAst.cachedAst within it transient (reference objects aren’t serializable, and we can afford to lose it anyway).
>> 2. introduce RecompilableScriptFunctionData.writeObject and make sure that if serializedAst contains a reference (instead of a SerializedAst object) then we don’t attempt to serialize it — write null instead (this can be accomplished by just setting serializedAst = null, and maybe re-setting it back to what it was after defaultWriteObject)
>> 3. make sure there’s a null check on SerializedAst.cachedAst read in getCachedAst() (as now it can actually be null on deserialization, it was an invariant that it was never null before)
>>> On 22 Dec 2016, at 16:18, Hannes Wallnöfer <hannes.wallnoefer at oracle.com> wrote:
>>> Please review:
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8166187
>>> Webrev: http://cr.openjdk.java.net/~hannesw/8166187/webrev/
>>> It was actually the combination of having a non-serialisable AST reference and not initialising the transient fields of nested functions that caused this error.
More information about the nashorn-dev