Bug 1899090 - Part 9: Rename *IncrementalEncoding public API to *CollectDelazifications. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D230385
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#include <utility> // std::move
|
#include <utility> // std::move
|
||||||
#include "ErrorList.h" // NS_ERROR_OUT_OF_MEMORY, NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW, NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE
|
#include "ErrorList.h" // NS_ERROR_OUT_OF_MEMORY, NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW, NS_SUCCESS_DOM_SCRIPT_EVALUATION_THREW_UNCATCHABLE
|
||||||
#include "js/CompilationAndEvaluation.h" // JS::UpdateDebugMetadata
|
#include "js/CompilationAndEvaluation.h" // JS::UpdateDebugMetadata
|
||||||
#include "js/experimental/JSStencil.h" // JS::StartIncrementalEncoding
|
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::CompileGlobalScriptToStencil
|
||||||
#include "js/SourceText.h" // JS::SourceText, JS::SourceOwnership
|
#include "js/SourceText.h" // JS::SourceText, JS::SourceOwnership
|
||||||
#include "jsapi.h" // JS_IsExceptionPending
|
#include "jsapi.h" // JS_IsExceptionPending
|
||||||
#include "nsTPromiseFlatString.h" // PromiseFlatString
|
#include "nsTPromiseFlatString.h" // PromiseFlatString
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ nsresult ModuleLoader::CompileJavaScriptModule(
|
|||||||
if (aRequest->IsTextSource() &&
|
if (aRequest->IsTextSource() &&
|
||||||
aRequest->PassedConditionForBytecodeEncoding()) {
|
aRequest->PassedConditionForBytecodeEncoding()) {
|
||||||
bool alreadyStarted;
|
bool alreadyStarted;
|
||||||
if (!JS::StartIncrementalEncoding(aCx, aModuleOut, stencil,
|
if (!JS::StartCollectingDelazifications(aCx, aModuleOut, stencil,
|
||||||
alreadyStarted)) {
|
alreadyStarted)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ nsresult ModuleLoader::CompileJavaScriptModule(
|
|||||||
if (aRequest->IsTextSource() &&
|
if (aRequest->IsTextSource() &&
|
||||||
aRequest->PassedConditionForBytecodeEncoding()) {
|
aRequest->PassedConditionForBytecodeEncoding()) {
|
||||||
bool alreadyStarted;
|
bool alreadyStarted;
|
||||||
if (!JS::StartIncrementalEncoding(aCx, aModuleOut, stencil,
|
if (!JS::StartCollectingDelazifications(aCx, aModuleOut, stencil,
|
||||||
alreadyStarted)) {
|
alreadyStarted)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "js/CompilationAndEvaluation.h"
|
#include "js/CompilationAndEvaluation.h"
|
||||||
#include "js/CompileOptions.h" // JS::CompileOptions, JS::OwningCompileOptions, JS::DecodeOptions, JS::OwningDecodeOptions, JS::DelazificationOption
|
#include "js/CompileOptions.h" // JS::CompileOptions, JS::OwningCompileOptions, JS::DecodeOptions, JS::OwningDecodeOptions, JS::DelazificationOption
|
||||||
#include "js/ContextOptions.h" // JS::ContextOptionsRef
|
#include "js/ContextOptions.h" // JS::ContextOptionsRef
|
||||||
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::InstantiationStorage
|
#include "js/experimental/JSStencil.h" // JS::Stencil, JS::InstantiationStorage, JS::StartCollectingDelazifications, JS::FinishCollectingDelazifications, JS::AbortCollectingDelazifications
|
||||||
#include "js/experimental/CompileScript.h" // JS::FrontendContext, JS::NewFrontendContext, JS::DestroyFrontendContext, JS::SetNativeStackQuota, JS::ThreadStackQuotaForSize, JS::CompilationStorage, JS::CompileGlobalScriptToStencil, JS::CompileModuleScriptToStencil, JS::DecodeStencil, JS::PrepareForInstantiate
|
#include "js/experimental/CompileScript.h" // JS::FrontendContext, JS::NewFrontendContext, JS::DestroyFrontendContext, JS::SetNativeStackQuota, JS::ThreadStackQuotaForSize, JS::CompilationStorage, JS::CompileGlobalScriptToStencil, JS::CompileModuleScriptToStencil, JS::DecodeStencil, JS::PrepareForInstantiate
|
||||||
#include "js/loader/ScriptLoadRequest.h"
|
#include "js/loader/ScriptLoadRequest.h"
|
||||||
#include "ScriptCompression.h"
|
#include "ScriptCompression.h"
|
||||||
@@ -2747,7 +2747,7 @@ static void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
|||||||
static void InstantiateStencil(
|
static void InstantiateStencil(
|
||||||
JSContext* aCx, JS::CompileOptions& aCompileOptions, JS::Stencil* aStencil,
|
JSContext* aCx, JS::CompileOptions& aCompileOptions, JS::Stencil* aStencil,
|
||||||
JS::MutableHandle<JSScript*> aScript,
|
JS::MutableHandle<JSScript*> aScript,
|
||||||
bool& incrementalEncodingAlreadyStarted,
|
bool& aCollectingDelazificationsAlreadyStarted,
|
||||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv,
|
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv,
|
||||||
bool aEncodeBytecode = false,
|
bool aEncodeBytecode = false,
|
||||||
@@ -2762,8 +2762,8 @@ static void InstantiateStencil(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aEncodeBytecode) {
|
if (aEncodeBytecode) {
|
||||||
if (!JS::StartIncrementalEncoding(aCx, script, aStencil,
|
if (!JS::StartCollectingDelazifications(
|
||||||
incrementalEncodingAlreadyStarted)) {
|
aCx, script, aStencil, aCollectingDelazificationsAlreadyStarted)) {
|
||||||
aRv.NoteJSContextException(aCx);
|
aRv.NoteJSContextException(aCx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2903,12 +2903,12 @@ void ScriptLoader::InstantiateClassicScriptFromCachedStencil(
|
|||||||
JS::MutableHandle<JSScript*> aScript,
|
JS::MutableHandle<JSScript*> aScript,
|
||||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||||
bool incrementalEncodingAlreadyStarted = false;
|
bool collectingDelazificationsAlreadyStarted = false;
|
||||||
InstantiateStencil(aCx, aCompileOptions, aStencil, aScript,
|
InstantiateStencil(aCx, aCompileOptions, aStencil, aScript,
|
||||||
incrementalEncodingAlreadyStarted, aDebuggerPrivateValue,
|
collectingDelazificationsAlreadyStarted,
|
||||||
aDebuggerIntroductionScript, aRv,
|
aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv,
|
||||||
/* aEncodeBytecode */ true);
|
/* aEncodeBytecode */ true);
|
||||||
if (incrementalEncodingAlreadyStarted) {
|
if (collectingDelazificationsAlreadyStarted) {
|
||||||
aRequest->MarkSkippedBytecodeEncoding();
|
aRequest->MarkSkippedBytecodeEncoding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3286,14 +3286,14 @@ void ScriptLoader::EncodeRequestBytecode(JSContext* aCx,
|
|||||||
aRequest->mScriptForBytecodeEncoding = nullptr;
|
aRequest->mScriptForBytecodeEncoding = nullptr;
|
||||||
ModuleScript* moduleScript = aRequest->AsModuleRequest()->mModuleScript;
|
ModuleScript* moduleScript = aRequest->AsModuleRequest()->mModuleScript;
|
||||||
JS::Rooted<JSObject*> module(aCx, moduleScript->ModuleRecord());
|
JS::Rooted<JSObject*> module(aCx, moduleScript->ModuleRecord());
|
||||||
result =
|
result = JS::FinishCollectingDelazifications(aCx, module,
|
||||||
JS::FinishIncrementalEncoding(aCx, module, aRequest->SRIAndBytecode());
|
aRequest->SRIAndBytecode());
|
||||||
} else if (mCache) {
|
} else if (mCache) {
|
||||||
RefPtr<JS::Stencil> stencil;
|
RefPtr<JS::Stencil> stencil;
|
||||||
JS::Rooted<JSScript*> script(aCx, aRequest->mScriptForBytecodeEncoding);
|
JS::Rooted<JSScript*> script(aCx, aRequest->mScriptForBytecodeEncoding);
|
||||||
aRequest->mScriptForBytecodeEncoding = nullptr;
|
aRequest->mScriptForBytecodeEncoding = nullptr;
|
||||||
result =
|
result = JS::FinishCollectingDelazifications(aCx, script,
|
||||||
JS::FinishIncrementalEncoding(aCx, script, getter_AddRefs(stencil));
|
getter_AddRefs(stencil));
|
||||||
if (result) {
|
if (result) {
|
||||||
aRequest->SetStencil(stencil.forget());
|
aRequest->SetStencil(stencil.forget());
|
||||||
bytecodeFailed.release();
|
bytecodeFailed.release();
|
||||||
@@ -3302,8 +3302,8 @@ void ScriptLoader::EncodeRequestBytecode(JSContext* aCx,
|
|||||||
// TODO: Bytecode encoding for script, at different timing.
|
// TODO: Bytecode encoding for script, at different timing.
|
||||||
} else {
|
} else {
|
||||||
JS::Rooted<JSScript*> script(aCx, aRequest->mScriptForBytecodeEncoding);
|
JS::Rooted<JSScript*> script(aCx, aRequest->mScriptForBytecodeEncoding);
|
||||||
result =
|
result = JS::FinishCollectingDelazifications(aCx, script,
|
||||||
JS::FinishIncrementalEncoding(aCx, script, aRequest->SRIAndBytecode());
|
aRequest->SRIAndBytecode());
|
||||||
aRequest->mScriptForBytecodeEncoding = nullptr;
|
aRequest->mScriptForBytecodeEncoding = nullptr;
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -3400,12 +3400,12 @@ void ScriptLoader::GiveUpBytecodeEncoding() {
|
|||||||
if (request->IsModuleRequest()) {
|
if (request->IsModuleRequest()) {
|
||||||
ModuleScript* moduleScript = request->AsModuleRequest()->mModuleScript;
|
ModuleScript* moduleScript = request->AsModuleRequest()->mModuleScript;
|
||||||
JS::Rooted<JSObject*> module(aes->cx(), moduleScript->ModuleRecord());
|
JS::Rooted<JSObject*> module(aes->cx(), moduleScript->ModuleRecord());
|
||||||
JS::AbortIncrementalEncoding(module);
|
JS::AbortCollectingDelazifications(module);
|
||||||
} else {
|
} else {
|
||||||
JS::Rooted<JSScript*> script(aes->cx(),
|
JS::Rooted<JSScript*> script(aes->cx(),
|
||||||
request->mScriptForBytecodeEncoding);
|
request->mScriptForBytecodeEncoding);
|
||||||
request->mScriptForBytecodeEncoding = nullptr;
|
request->mScriptForBytecodeEncoding = nullptr;
|
||||||
JS::AbortIncrementalEncoding(script);
|
JS::AbortCollectingDelazifications(script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,60 +86,6 @@ inline bool IsTranscodingBytecodeAligned(const void* offset) {
|
|||||||
return IsTranscodingBytecodeOffsetAligned(size_t(offset));
|
return IsTranscodingBytecodeOffsetAligned(size_t(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finish incremental encoding started by JS::StartIncrementalEncoding.
|
|
||||||
//
|
|
||||||
// * Regular script case
|
|
||||||
// the |script| argument must be the top-level script returned from
|
|
||||||
// |JS::InstantiateGlobalStencil| with the same stencil
|
|
||||||
//
|
|
||||||
// * Module script case
|
|
||||||
// the |script| argument must be the script returned by
|
|
||||||
// |JS::GetModuleScript| called on the module returned by
|
|
||||||
// |JS::InstantiateModuleStencil| with the same stencil
|
|
||||||
//
|
|
||||||
// NOTE: |JS::GetModuleScript| doesn't work after evaluating the
|
|
||||||
// module script. For the case, use Handle<JSObject*> variant of
|
|
||||||
// this function below.
|
|
||||||
//
|
|
||||||
// The |buffer| argument of |FinishIncrementalEncoding| is used for appending
|
|
||||||
// the encoded bytecode into the buffer. If any of these functions failed, the
|
|
||||||
// content of |buffer| would be undefined.
|
|
||||||
//
|
|
||||||
// |buffer| contains encoded CompilationStencil.
|
|
||||||
//
|
|
||||||
// If the `buffer` isn't empty, the start of the `buffer` should meet
|
|
||||||
// IsTranscodingBytecodeAligned, and the length should meet
|
|
||||||
// IsTranscodingBytecodeOffsetAligned.
|
|
||||||
//
|
|
||||||
// NOTE: As long as IsTranscodingBytecodeOffsetAligned is met, that means
|
|
||||||
// there's JS::BytecodeOffsetAlignment+extra bytes in the buffer,
|
|
||||||
// IsTranscodingBytecodeAligned should be guaranteed to meet by
|
|
||||||
// malloc, used by MallocAllocPolicy in mozilla::Vector.
|
|
||||||
extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
|
||||||
Handle<JSScript*> script,
|
|
||||||
TranscodeBuffer& buffer);
|
|
||||||
|
|
||||||
// Similar to |JS::FinishIncrementalEncoding|, but receives module obect.
|
|
||||||
//
|
|
||||||
// The |module| argument must be the module returned by
|
|
||||||
// |JS::InstantiateModuleStencil| with the same stencil that's passed to
|
|
||||||
// |JS::StartIncrementalEncoding|.
|
|
||||||
extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
|
||||||
Handle<JSObject*> module,
|
|
||||||
TranscodeBuffer& buffer);
|
|
||||||
|
|
||||||
// Instead of transcoding to a buffer, return the JS::Stencil that reflects
|
|
||||||
// the delazification from the execution.
|
|
||||||
// The resulting stencil's ownership is passed to the consumer and the
|
|
||||||
// ref count is 1.
|
|
||||||
extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
|
||||||
Handle<JSScript*> script,
|
|
||||||
JS::Stencil** stencilOut);
|
|
||||||
|
|
||||||
// Abort incremental encoding started by JS::StartIncrementalEncoding.
|
|
||||||
extern JS_PUBLIC_API void AbortIncrementalEncoding(Handle<JSScript*> script);
|
|
||||||
extern JS_PUBLIC_API void AbortIncrementalEncoding(Handle<JSObject*> module);
|
|
||||||
|
|
||||||
// Check if the compile options and script's flag matches.
|
// Check if the compile options and script's flag matches.
|
||||||
//
|
//
|
||||||
// JS::DecodeScript* and JS::DecodeOffThreadScript internally check this.
|
// JS::DecodeScript* and JS::DecodeOffThreadScript internally check this.
|
||||||
|
|||||||
@@ -206,22 +206,52 @@ extern JS_PUBLIC_API TranscodeResult
|
|||||||
DecodeStencil(JS::FrontendContext* fc, const ReadOnlyDecodeOptions& options,
|
DecodeStencil(JS::FrontendContext* fc, const ReadOnlyDecodeOptions& options,
|
||||||
const TranscodeRange& range, Stencil** stencilOut);
|
const TranscodeRange& range, Stencil** stencilOut);
|
||||||
|
|
||||||
|
// ************************************************************************
|
||||||
|
// Collect delazifications
|
||||||
|
// ************************************************************************
|
||||||
|
|
||||||
// Start collecting delazifications for given script or module's source object.
|
// Start collecting delazifications for given script or module's source object.
|
||||||
//
|
//
|
||||||
// If the source object is already collecting delazifications, alreadyStarted is
|
// If the source object is already collecting delazifications, alreadyStarted is
|
||||||
// set to true and returns true. alreadyStarted is set to false otherwise.
|
// set to true and returns true. alreadyStarted is set to false otherwise.
|
||||||
//
|
extern JS_PUBLIC_API bool StartCollectingDelazifications(
|
||||||
// TODO: Rename public APIs.
|
JSContext* cx, JS::Handle<JSScript*> script, Stencil* stencil,
|
||||||
extern JS_PUBLIC_API bool StartIncrementalEncoding(JSContext* cx,
|
|
||||||
JS::Handle<JSScript*> script,
|
|
||||||
Stencil* stencil,
|
|
||||||
bool& alreadyStarted);
|
bool& alreadyStarted);
|
||||||
|
|
||||||
extern JS_PUBLIC_API bool StartIncrementalEncoding(JSContext* cx,
|
extern JS_PUBLIC_API bool StartCollectingDelazifications(
|
||||||
JS::Handle<JSObject*> module,
|
JSContext* cx, JS::Handle<JSObject*> module, Stencil* stencil,
|
||||||
Stencil* stencil,
|
|
||||||
bool& alreadyStarted);
|
bool& alreadyStarted);
|
||||||
|
|
||||||
|
// Finish collecting delazifications and retrieve the result.
|
||||||
|
//
|
||||||
|
// With |buffer| out-parameter, the result is encoded and appended to the
|
||||||
|
// buffer. If failed, the content of |buffer| would be undefined.
|
||||||
|
//
|
||||||
|
// If the `buffer` isn't empty, the start of the `buffer` should meet
|
||||||
|
// JS::IsTranscodingBytecodeAligned, and the length should meet
|
||||||
|
// JS::IsTranscodingBytecodeOffsetAligned.
|
||||||
|
//
|
||||||
|
// NOTE: As long as IsTranscodingBytecodeOffsetAligned is met, that means
|
||||||
|
// there's JS::BytecodeOffsetAlignment+extra bytes in the buffer,
|
||||||
|
// IsTranscodingBytecodeAligned should be guaranteed to meet by
|
||||||
|
// malloc, used by MallocAllocPolicy in mozilla::Vector.
|
||||||
|
extern JS_PUBLIC_API bool FinishCollectingDelazifications(
|
||||||
|
JSContext* cx, Handle<JSScript*> script, TranscodeBuffer& buffer);
|
||||||
|
|
||||||
|
// Similar to |JS::FinishCollectingDelazifications|, but receives module obect.
|
||||||
|
extern JS_PUBLIC_API bool FinishCollectingDelazifications(
|
||||||
|
JSContext* cx, Handle<JSObject*> module, TranscodeBuffer& buffer);
|
||||||
|
|
||||||
|
// Instead of transcoding to a buffer, return the JS::Stencil that reflects
|
||||||
|
// the delazification from the execution.
|
||||||
|
extern JS_PUBLIC_API bool FinishCollectingDelazifications(
|
||||||
|
JSContext* cx, Handle<JSScript*> script, JS::Stencil** stencilOut);
|
||||||
|
|
||||||
|
extern JS_PUBLIC_API void AbortCollectingDelazifications(
|
||||||
|
Handle<JSScript*> script);
|
||||||
|
extern JS_PUBLIC_API void AbortCollectingDelazifications(
|
||||||
|
Handle<JSObject*> module);
|
||||||
|
|
||||||
} // namespace JS
|
} // namespace JS
|
||||||
|
|
||||||
#endif // js_experimental_JSStencil_h
|
#endif // js_experimental_JSStencil_h
|
||||||
|
|||||||
@@ -5477,20 +5477,20 @@ bool CompilationStencilMerger::addDelazification(
|
|||||||
|
|
||||||
if (destFun.hasSharedData()) {
|
if (destFun.hasSharedData()) {
|
||||||
// If the function was already non-lazy, it means the following happened:
|
// If the function was already non-lazy, it means the following happened:
|
||||||
// A. delazified twice within single incremental encoding
|
// A. delazified twice within single collecting delazifications
|
||||||
// 1. this function is lazily parsed
|
// 1. this function is lazily parsed
|
||||||
// 2. incremental encoding is started
|
// 2. collecting delazifications is started
|
||||||
// 3. this function is delazified, encoded, and merged
|
// 3. this function is delazified, encoded, and merged
|
||||||
// 4. this function is relazified
|
// 4. this function is relazified
|
||||||
// 5. this function is delazified, encoded, and merged
|
// 5. this function is delazified, encoded, and merged
|
||||||
//
|
//
|
||||||
// B. delazified twice across decode
|
// B. delazified twice across decode
|
||||||
// 1. this function is lazily parsed
|
// 1. this function is lazily parsed
|
||||||
// 2. incremental encoding is started
|
// 2. collecting delazifications is started
|
||||||
// 3. this function is delazified, encoded, and merged
|
// 3. this function is delazified, encoded, and merged
|
||||||
// 4. incremental encoding is finished
|
// 4. collecting delazifications is finished
|
||||||
// 5. decoded
|
// 5. decoded
|
||||||
// 6. incremental encoding is started
|
// 6. collecting delazifications is started
|
||||||
// here, this function is non-lazy
|
// here, this function is non-lazy
|
||||||
// 7. this function is relazified
|
// 7. this function is relazified
|
||||||
// 8. this function is delazified, encoded, and merged
|
// 8. this function is delazified, encoded, and merged
|
||||||
@@ -5499,7 +5499,7 @@ bool CompilationStencilMerger::addDelazification(
|
|||||||
//
|
//
|
||||||
// B cannot happen with public API, but can happen if incremental
|
// B cannot happen with public API, but can happen if incremental
|
||||||
// encoding at step B.6 is explicitly started by internal function.
|
// encoding at step B.6 is explicitly started by internal function.
|
||||||
// See Evaluate and StartIncrementalEncoding in js/src/shell/js.cpp.
|
// See Evaluate and StartCollectingDelazifications in js/src/shell/js.cpp.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2900,7 +2900,8 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) {
|
|||||||
|
|
||||||
if (saveIncrementalBytecode) {
|
if (saveIncrementalBytecode) {
|
||||||
bool alreadyStarted;
|
bool alreadyStarted;
|
||||||
if (!JS::StartIncrementalEncoding(cx, script, stencil, alreadyStarted)) {
|
if (!JS::StartCollectingDelazifications(cx, script, stencil,
|
||||||
|
alreadyStarted)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(!alreadyStarted);
|
MOZ_ASSERT(!alreadyStarted);
|
||||||
@@ -2931,7 +2932,7 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) {
|
|||||||
// Serialize the encoded bytecode, recorded before the execution, into a
|
// Serialize the encoded bytecode, recorded before the execution, into a
|
||||||
// buffer which can be deserialized linearly.
|
// buffer which can be deserialized linearly.
|
||||||
if (saveIncrementalBytecode) {
|
if (saveIncrementalBytecode) {
|
||||||
if (!FinishIncrementalEncoding(cx, script, saveBuffer)) {
|
if (!FinishCollectingDelazifications(cx, script, saveBuffer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9719,8 +9720,8 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
|
|||||||
" the bytecode would be loaded and decoded from the cache entry instead\n"
|
" the bytecode would be loaded and decoded from the cache entry instead\n"
|
||||||
" of being parsed, then it would be executed as usual.\n"
|
" of being parsed, then it would be executed as usual.\n"
|
||||||
" saveIncrementalBytecode: if true, and if the source is a\n"
|
" saveIncrementalBytecode: if true, and if the source is a\n"
|
||||||
" CacheEntryObject, the bytecode would be incrementally encoded and\n"
|
" CacheEntryObject, the delazifications are collected during the\n"
|
||||||
" saved into the cache entry.\n"
|
" execution, and encoded after that, and saved into the cache entry.\n"
|
||||||
" execute: if false, do not execute the script, but do parse and/or\n"
|
" execute: if false, do not execute the script, but do parse and/or\n"
|
||||||
" transcode.\n"
|
" transcode.\n"
|
||||||
" assertEqBytecode: if true, and if both loadBytecode and either\n"
|
" assertEqBytecode: if true, and if both loadBytecode and either\n"
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ static bool StartCollectingDelazifications(JSContext* cx,
|
|||||||
alreadyStarted = false;
|
alreadyStarted = false;
|
||||||
|
|
||||||
// We don't support asm.js in XDR.
|
// We don't support asm.js in XDR.
|
||||||
// Failures are reported by the FinishIncrementalEncoding function below.
|
// Failures are reported by the FinishCollectingDelazifications function
|
||||||
|
// below.
|
||||||
if (stencil->getInitial()->asmJS) {
|
if (stencil->getInitial()->asmJS) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -136,24 +137,22 @@ static bool StartCollectingDelazifications(JSContext* cx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::StartIncrementalEncoding(JSContext* cx,
|
JS_PUBLIC_API bool JS::StartCollectingDelazifications(
|
||||||
JS::Handle<JSScript*> script,
|
JSContext* cx, JS::Handle<JSScript*> script, JS::Stencil* stencil,
|
||||||
JS::Stencil* stencil,
|
|
||||||
bool& alreadyStarted) {
|
bool& alreadyStarted) {
|
||||||
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
||||||
return StartCollectingDelazifications(cx, sso, stencil, alreadyStarted);
|
return ::StartCollectingDelazifications(cx, sso, stencil, alreadyStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::StartIncrementalEncoding(JSContext* cx,
|
JS_PUBLIC_API bool JS::StartCollectingDelazifications(
|
||||||
JS::Handle<JSObject*> module,
|
JSContext* cx, JS::Handle<JSObject*> module, JS::Stencil* stencil,
|
||||||
JS::Stencil* stencil,
|
|
||||||
bool& alreadyStarted) {
|
bool& alreadyStarted) {
|
||||||
JS::Rooted<ScriptSourceObject*> sso(
|
JS::Rooted<ScriptSourceObject*> sso(
|
||||||
cx, module->as<ModuleObject>().scriptSourceObject());
|
cx, module->as<ModuleObject>().scriptSourceObject());
|
||||||
return StartCollectingDelazifications(cx, sso, stencil, alreadyStarted);
|
return ::StartCollectingDelazifications(cx, sso, stencil, alreadyStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FinishIncrementalEncoding(JSContext* cx,
|
static bool FinishCollectingDelazifications(JSContext* cx,
|
||||||
JS::Handle<ScriptSourceObject*> sso,
|
JS::Handle<ScriptSourceObject*> sso,
|
||||||
JS::TranscodeBuffer& buffer) {
|
JS::TranscodeBuffer& buffer) {
|
||||||
RefPtr<frontend::InitialStencilAndDelazifications> stencils =
|
RefPtr<frontend::InitialStencilAndDelazifications> stencils =
|
||||||
@@ -189,7 +188,7 @@ static bool FinishIncrementalEncoding(JSContext* cx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FinishIncrementalEncoding(JSContext* cx,
|
static bool FinishCollectingDelazifications(JSContext* cx,
|
||||||
JS::Handle<ScriptSourceObject*> sso,
|
JS::Handle<ScriptSourceObject*> sso,
|
||||||
JS::Stencil** stencilOut) {
|
JS::Stencil** stencilOut) {
|
||||||
RefPtr<frontend::InitialStencilAndDelazifications> stencils =
|
RefPtr<frontend::InitialStencilAndDelazifications> stencils =
|
||||||
@@ -203,36 +202,34 @@ static bool FinishIncrementalEncoding(JSContext* cx,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::FinishIncrementalEncoding(JSContext* cx,
|
JS_PUBLIC_API bool JS::FinishCollectingDelazifications(
|
||||||
JS::HandleScript script,
|
JSContext* cx, JS::HandleScript script, JS::TranscodeBuffer& buffer) {
|
||||||
JS::TranscodeBuffer& buffer) {
|
|
||||||
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
||||||
return ::FinishIncrementalEncoding(cx, sso, buffer);
|
return ::FinishCollectingDelazifications(cx, sso, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::FinishIncrementalEncoding(JSContext* cx,
|
JS_PUBLIC_API bool JS::FinishCollectingDelazifications(
|
||||||
JS::HandleScript script,
|
JSContext* cx, JS::HandleScript script, JS::Stencil** stencilOut) {
|
||||||
JS::Stencil** stencilOut) {
|
|
||||||
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
JS::Rooted<ScriptSourceObject*> sso(cx, script->sourceObject());
|
||||||
return ::FinishIncrementalEncoding(cx, sso, stencilOut);
|
return ::FinishCollectingDelazifications(cx, sso, stencilOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API bool JS::FinishIncrementalEncoding(JSContext* cx,
|
JS_PUBLIC_API bool JS::FinishCollectingDelazifications(
|
||||||
JS::Handle<JSObject*> module,
|
JSContext* cx, JS::Handle<JSObject*> module, JS::TranscodeBuffer& buffer) {
|
||||||
JS::TranscodeBuffer& buffer) {
|
|
||||||
JS::Rooted<ScriptSourceObject*> sso(
|
JS::Rooted<ScriptSourceObject*> sso(
|
||||||
cx, module->as<ModuleObject>().scriptSourceObject());
|
cx, module->as<ModuleObject>().scriptSourceObject());
|
||||||
return ::FinishIncrementalEncoding(cx, sso, buffer);
|
return ::FinishCollectingDelazifications(cx, sso, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API void JS::AbortIncrementalEncoding(JS::HandleScript script) {
|
JS_PUBLIC_API void JS::AbortCollectingDelazifications(JS::HandleScript script) {
|
||||||
if (!script) {
|
if (!script) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
script->sourceObject()->clearStencils();
|
script->sourceObject()->clearStencils();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API void JS::AbortIncrementalEncoding(JS::Handle<JSObject*> module) {
|
JS_PUBLIC_API void JS::AbortCollectingDelazifications(
|
||||||
|
JS::Handle<JSObject*> module) {
|
||||||
module->as<ModuleObject>().scriptSourceObject()->clearStencils();
|
module->as<ModuleObject>().scriptSourceObject()->clearStencils();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user