Bug 1898677 - Cache the result of bytecode encoding condition. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D211517
This commit is contained in:
@@ -182,9 +182,33 @@ class ScriptLoadRequest : public nsISupports,
|
||||
|
||||
void SetPendingFetchingError();
|
||||
|
||||
void MarkForBytecodeEncoding(JSScript* aScript);
|
||||
bool PassedConditionForBytecodeEncoding() const {
|
||||
return mBytecodeEncodingPlan == BytecodeEncodingPlan::PassedCondition ||
|
||||
mBytecodeEncodingPlan == BytecodeEncodingPlan::MarkedForEncode;
|
||||
}
|
||||
|
||||
bool IsMarkedForBytecodeEncoding() const;
|
||||
void MarkSkippedBytecodeEncoding() {
|
||||
MOZ_ASSERT(mBytecodeEncodingPlan == BytecodeEncodingPlan::Uninitialized);
|
||||
mBytecodeEncodingPlan = BytecodeEncodingPlan::Skipped;
|
||||
}
|
||||
|
||||
void MarkPassedConditionForBytecodeEncoding() {
|
||||
MOZ_ASSERT(mBytecodeEncodingPlan == BytecodeEncodingPlan::Uninitialized);
|
||||
mBytecodeEncodingPlan = BytecodeEncodingPlan::PassedCondition;
|
||||
}
|
||||
|
||||
bool IsMarkedForBytecodeEncoding() const {
|
||||
return mBytecodeEncodingPlan == BytecodeEncodingPlan::MarkedForEncode;
|
||||
}
|
||||
|
||||
protected:
|
||||
void MarkForBytecodeEncoding() {
|
||||
MOZ_ASSERT(mBytecodeEncodingPlan == BytecodeEncodingPlan::PassedCondition);
|
||||
mBytecodeEncodingPlan = BytecodeEncodingPlan::MarkedForEncode;
|
||||
}
|
||||
|
||||
public:
|
||||
void MarkScriptForBytecodeEncoding(JSScript* aScript);
|
||||
|
||||
mozilla::CORSMode CORSMode() const { return mFetchOptions->mCORSMode; }
|
||||
|
||||
@@ -218,6 +242,23 @@ class ScriptLoadRequest : public nsISupports,
|
||||
State mState; // Are we still waiting for a load to complete?
|
||||
bool mFetchSourceOnly; // Request source, not cached bytecode.
|
||||
|
||||
enum class BytecodeEncodingPlan : uint8_t {
|
||||
// This is not yet considered for encoding.
|
||||
Uninitialized,
|
||||
|
||||
// This is marked for skipping the encoding.
|
||||
Skipped,
|
||||
|
||||
// This fits the condition for the encoding (e.g. file size, fetch count).
|
||||
PassedCondition,
|
||||
|
||||
// This is marked for encoding, with setting sufficient input,
|
||||
// e.g. mScriptForBytecodeEncoding for script.
|
||||
MarkedForEncode,
|
||||
};
|
||||
BytecodeEncodingPlan mBytecodeEncodingPlan =
|
||||
BytecodeEncodingPlan::Uninitialized;
|
||||
|
||||
// The referrer policy used for the initial fetch and for fetching any
|
||||
// imported modules
|
||||
enum mozilla::dom::ReferrerPolicy mReferrerPolicy;
|
||||
@@ -247,10 +288,9 @@ class ScriptLoadRequest : public nsISupports,
|
||||
RefPtr<LoadedScript> mLoadedScript;
|
||||
|
||||
// Holds the top-level JSScript that corresponds to the current source, once
|
||||
// it is parsed, and planned to be saved in the bytecode cache.
|
||||
// it is parsed, and marked to be saved in the bytecode cache.
|
||||
//
|
||||
// NOTE: This field is not used for ModuleLoadRequest.
|
||||
// See ModuleLoadRequest::mIsMarkedForBytecodeEncoding.
|
||||
JS::Heap<JSScript*> mScriptForBytecodeEncoding;
|
||||
|
||||
// Holds the Cache information, which is used to register the bytecode
|
||||
|
||||
Reference in New Issue
Block a user