diff options
Diffstat (limited to 'js/src/jsscript.cpp')
-rw-r--r-- | js/src/jsscript.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index ddc98ef3f..ad4cb2338 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -236,6 +236,7 @@ XDRRelazificationInfo(XDRState<mode>* xdr, HandleFunction fun, HandleScript scri uint32_t begin = script->sourceStart(); uint32_t end = script->sourceEnd(); uint32_t preludeStart = script->preludeStart(); + uint32_t postludeEnd = script->postludeEnd(); uint32_t lineno = script->lineno(); uint32_t column = script->column(); @@ -244,6 +245,7 @@ XDRRelazificationInfo(XDRState<mode>* xdr, HandleFunction fun, HandleScript scri MOZ_ASSERT(begin == lazy->begin()); MOZ_ASSERT(end == lazy->end()); MOZ_ASSERT(preludeStart == lazy->preludeStart()); + MOZ_ASSERT(postludeEnd == lazy->postludeEnd()); MOZ_ASSERT(lineno == lazy->lineno()); MOZ_ASSERT(column == lazy->column()); // We can assert we have no inner functions because we don't @@ -259,6 +261,11 @@ XDRRelazificationInfo(XDRState<mode>* xdr, HandleFunction fun, HandleScript scri lazy.set(LazyScript::Create(cx, fun, script, enclosingScope, script, packedFields, begin, end, preludeStart, lineno, column)); + if (!lazy) + return false; + + lazy->setPostludeEnd(postludeEnd); + // As opposed to XDRLazyScript, we need to restore the runtime bits // of the script, as we are trying to match the fact this function // has already been parsed and that it would need to be re-lazified. @@ -522,7 +529,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip sourceObject = &enclosingScript->sourceObject()->as<ScriptSourceObject>(); } - script = JSScript::Create(cx, options, sourceObject, 0, 0, 0); + script = JSScript::Create(cx, options, sourceObject, 0, 0, 0, 0); if (!script) return false; @@ -609,6 +616,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip return false; if (!xdr->codeUint32(&script->preludeStart_)) return false; + if (!xdr->codeUint32(&script->postludeEnd_)) + return false; if (!xdr->codeUint32(&lineno) || !xdr->codeUint32(&column) || @@ -940,6 +949,7 @@ js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope, HandleScript uint32_t begin; uint32_t end; uint32_t preludeStart; + uint32_t postludeEnd; uint32_t lineno; uint32_t column; uint64_t packedFields; @@ -954,6 +964,7 @@ js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope, HandleScript begin = lazy->begin(); end = lazy->end(); preludeStart = lazy->preludeStart(); + postludeEnd = lazy->postludeEnd(); lineno = lazy->lineno(); column = lazy->column(); packedFields = lazy->packedFields(); @@ -961,6 +972,7 @@ js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope, HandleScript if (!xdr->codeUint32(&begin) || !xdr->codeUint32(&end) || !xdr->codeUint32(&preludeStart) || + !xdr->codeUint32(&postludeEnd) || !xdr->codeUint32(&lineno) || !xdr->codeUint32(&column) || !xdr->codeUint64(&packedFields)) { @@ -972,6 +984,7 @@ js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope, HandleScript packedFields, begin, end, preludeStart, lineno, column)); if (!lazy) return false; + lazy->setPostludeEnd(postludeEnd); fun->initLazyScript(lazy); } } @@ -1015,6 +1028,15 @@ JSScript::setSourceObject(JSObject* object) sourceObject_ = object; } +void +JSScript::setDefaultClassConstructorSpan(JSObject* sourceObject, uint32_t start, uint32_t end) +{ + MOZ_ASSERT(isDefaultClassConstructor()); + setSourceObject(sourceObject); + preludeStart_ = start; + postludeEnd_ = end; +} + js::ScriptSourceObject& JSScript::scriptSourceUnwrap() const { return UncheckedUnwrap(sourceObject())->as<ScriptSourceObject>(); @@ -1443,10 +1465,10 @@ JSScript::sourceData(JSContext* cx, HandleScript script) } /* static */ JSFlatString* -JSScript::sourceDataWithPrelude(JSContext* cx, HandleScript script) +JSScript::sourceDataForToString(JSContext* cx, HandleScript script) { MOZ_ASSERT(script->scriptSource()->hasSourceData()); - return script->scriptSource()->substring(cx, script->preludeStart(), script->sourceEnd()); + return script->scriptSource()->substring(cx, script->preludeStart(), script->postludeEnd()); } UncompressedSourceCache::AutoHoldEntry::AutoHoldEntry() @@ -2448,7 +2470,7 @@ JSScript::initCompartment(ExclusiveContext* cx) /* static */ JSScript* JSScript::Create(ExclusiveContext* cx, const ReadOnlyCompileOptions& options, HandleObject sourceObject, uint32_t bufStart, uint32_t bufEnd, - uint32_t preludeStart) + uint32_t preludeStart, uint32_t postludeEnd) { MOZ_ASSERT(bufStart <= bufEnd); @@ -2471,6 +2493,7 @@ JSScript::Create(ExclusiveContext* cx, const ReadOnlyCompileOptions& options, script->sourceStart_ = bufStart; script->sourceEnd_ = bufEnd; script->preludeStart_ = preludeStart; + script->postludeEnd_ = postludeEnd; return script; } @@ -3407,7 +3430,7 @@ CreateEmptyScriptForClone(JSContext* cx, HandleScript src) .setVersion(src->getVersion()); return JSScript::Create(cx, options, sourceObject, src->sourceStart(), src->sourceEnd(), - src->preludeStart()); + src->preludeStart(), src->postludeEnd()); } JSScript* @@ -3968,6 +3991,7 @@ LazyScript::LazyScript(JSFunction* fun, void* table, uint64_t packedFields, begin_(begin), end_(end), preludeStart_(preludeStart), + postludeEnd_(end), lineno_(lineno), column_(column) { |