summaryrefslogtreecommitdiff
path: root/dom/base/nsJSUtils.h
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-04-23 17:53:38 -0500
committerBrian Smith <brian@dbsoft.org>2023-04-27 13:35:21 -0500
commit1adf442e9249afed3d557ba0c679150e4d85c60e (patch)
tree0f4e4d6c54b865064228f42b3307ec30c962b5ab /dom/base/nsJSUtils.h
parent7b42bc809de8cd925f413f39d5248c765bd56c43 (diff)
downloaduxp-1adf442e9249afed3d557ba0c679150e4d85c60e.tar.gz
Issue #1691 - Part 12: Fix return value in ExecScript() and debug assert in ParseTask.
https://bugzilla.mozilla.org/show_bug.cgi?id=1331662 Replace nsJSUtils::EvaluateString calls by ExecutionContext scopes. ExecutionContext: The mRetValue is not used even though it is checked in various asserts. This is how it is in the Mozilla code even years later, only the passed in value is used. ParseTask: JoinDecode() and JoinCompile() run the same code but the type is different causing a debug assert when it checks the type Script vs ScriptDecode. (cherry picked from commit 8f577428b7834b7d0f0d5afacbe060fbb1ff2136)
Diffstat (limited to 'dom/base/nsJSUtils.h')
-rw-r--r--dom/base/nsJSUtils.h65
1 files changed, 9 insertions, 56 deletions
diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h
index 8d5ccc95ef..db70cd924d 100644
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -128,6 +128,15 @@ public:
return *this;
}
+ // When set, this flag records and encodes the bytecode as soon as it is
+ // being compiled, and before it is being executed. The bytecode can then be
+ // requested by using |JS::FinishIncrementalEncoding| with the mutable
+ // handle |aScript| argument of |CompileAndExec| or |JoinAndExec|.
+ ExecutionContext& SetEncodeBytecode(bool aEncodeBytecode) {
+ mEncodeBytecode = aEncodeBytecode;
+ return *this;
+ }
+
// Set the scope chain in which the code should be executed.
void SetScopeChain(const JS::AutoObjectVector& aScopeChain);
@@ -177,52 +186,6 @@ public:
MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
};
- struct MOZ_STACK_CLASS EvaluateOptions {
- bool coerceToString;
- JS::AutoObjectVector scopeChain;
-
- explicit EvaluateOptions(JSContext* cx)
- : coerceToString(false)
- , scopeChain(cx)
- {}
-
- EvaluateOptions& setCoerceToString(bool aCoerce) {
- coerceToString = aCoerce;
- return *this;
- }
- };
-
- // aEvaluationGlobal is the global to evaluate in. The return value
- // will then be wrapped back into the compartment aCx is in when
- // this function is called. For all the EvaluateString overloads,
- // the JSContext must come from an AutoJSAPI that has had
- // TakeOwnershipOfErrorReporting() called on it.
- static nsresult EvaluateString(JSContext* aCx,
- const nsAString& aScript,
- JS::Handle<JSObject*> aEvaluationGlobal,
- JS::CompileOptions &aCompileOptions,
- const EvaluateOptions& aEvaluateOptions,
- JS::MutableHandle<JS::Value> aRetValue);
-
- static nsresult EvaluateString(JSContext* aCx,
- JS::SourceBufferHolder& aSrcBuf,
- JS::Handle<JSObject*> aEvaluationGlobal,
- JS::CompileOptions &aCompileOptions,
- const EvaluateOptions& aEvaluateOptions,
- JS::MutableHandle<JS::Value> aRetValue);
-
-
- static nsresult EvaluateString(JSContext* aCx,
- const nsAString& aScript,
- JS::Handle<JSObject*> aEvaluationGlobal,
- JS::CompileOptions &aCompileOptions);
-
- static nsresult EvaluateString(JSContext* aCx,
- JS::SourceBufferHolder& aSrcBuf,
- JS::Handle<JSObject*> aEvaluationGlobal,
- JS::CompileOptions &aCompileOptions,
- void **aOffThreadToken);
-
static nsresult CompileModule(JSContext* aCx,
JS::SourceBufferHolder& aSrcBuf,
JS::Handle<JSObject*> aEvaluationGlobal,
@@ -242,16 +205,6 @@ public:
JS::AutoObjectVector& aScopeChain);
static void ResetTimeZone();
-
-private:
- // Implementation for our EvaluateString bits
- static nsresult EvaluateString(JSContext* aCx,
- JS::SourceBufferHolder& aSrcBuf,
- JS::Handle<JSObject*> aEvaluationGlobal,
- JS::CompileOptions& aCompileOptions,
- const EvaluateOptions& aEvaluateOptions,
- JS::MutableHandle<JS::Value> aRetValue,
- void **aOffThreadToken);
};
template<typename T>