Serialize/Deserialize JSScript

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Serialize/Deserialize JSScript

wsj1518
Hi.

I'm trying to serialize/deserialize JSScript and JSBench is used for evaluation.

I'm using latest version of spidermonkey from mozila-central and I use disable-ion option for configuration.

I just use JS_EncodeScript in JSFunction::createScriptForLazilyInterpretedFunction, jsscript.cpp like this.

/////////////////////////////////////////////////////////////////////////

if (!frontend::CompileLazyFunction(cx, lazy, lazyStart, lazyLength)) {
     fun->initLazyScript(lazy);
     if (lazy->maybeScriptUnbarriered())
         lazy->resetScript();
     return false;
 }
 script = fun->nonLazyScript();

 uint32_t nbytes;
 void* memory = JS_EncodeScript(cx, script, &nbytes);

/////////////////////////////////////////////////////////////////////////

However, when I try to run jsbench/twitter/chrome, chrome-win, safari, the error 'eval:1:1 ReferenceError: *** is not defined' is occurred.

(1) I wonder that the JS_EncodeScript() is able to affect program even I didn't use serialized script at all.

Additionally, when I attempt to use serialized JSScript instead of compilation (frontend::CompileLazyFunction) in second run, four of jsbench (jsbench/facebook, google/chrome-win, safari) make similar error. (It's okay in first run.)

To use deserialized JSScript,

   script->enclosingStaticScope_ = fun->lazyScript()->enclosingScope();
   script->lazyScript = lazy;
   script->setFunction(fun);
   fun->setUnlazifiedScript(script);

I link these things.

(2) I compared members of JSScript and JSFunction original version and deserialized version, but I couldn't find difference. Is there anything wrong for reuse JSScript?

(3) Which member of JSScript makes 'ReferenceError'? EnclosingStaticScope or SourceObject? I'm very confused...

Sorry about too many questions and thank you for your help in advance.
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: Serialize/Deserialize JSScript

Nicolas B. Pierron
Hi,

On 10/24/2015 01:38 PM, [hidden email] wrote:
> I'm trying to serialize/deserialize JSScript and JSBench is used for evaluation.

If you are interested, I already did serialize/deserialize the JSScript
while evaluating JSBench in orderto have a rough idea of the benefit of
caching the JavaScript of web pages in bytecode form.

I did not managed to instrument all benchmarks, and did not tried to, but if
I recall correctly the instrumented benchmarks should be here:

   http://people.mozilla.org/~npierron/jsbench.tgz

In these instrumented benchmarks, I basically used the evaluate function of
the JS shell to save the bytecode into a CacheEntry, which is an opaque
representation of associative container entry.

> I'm using latest version of spidermonkey from mozila-central and I use disable-ion option for configuration.

I am not sure why you would want to use --disable-ion ?

> (1) I wonder that the JS_EncodeScript() is able to affect program even I didn't use serialized script at all.

Except for oom, it should not affect the program.  The only problem is if
the lookup rules are not the same.

Also note, that JSBench is generated by instrumenting the DOM, and caching
the results of the evaluation.  These state are not reentrant, so doing the
same evaluation twice would not work, unless you properly reset the content
and the counters.

> (3) Which member of JSScript makes 'ReferenceError'? EnclosingStaticScope or SourceObject? I'm very confused...

ReferenceError are when a JS variable is not bound.  So this is unlikely to
be the source object, but might be related to the fact that the enclosing
scope chained is not properly restored.

--
Nicolas B. Pierron
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine