diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /js/src/vm/JSContext.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/vm/JSContext.cpp')
-rw-r--r-- | js/src/vm/JSContext.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index 4d355dc828..5a4bfa86cd 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -55,6 +55,7 @@ #include "vm/BytecodeUtil.h" // JSDVG_IGNORE_STACK #include "vm/ErrorObject.h" #include "vm/ErrorReporting.h" +#include "vm/FrameIter.h" #include "vm/JSFunction.h" #include "vm/JSObject.h" #include "vm/PlainObject.h" // js::PlainObject @@ -997,7 +998,6 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options) suppressProfilerSampling(false), tempLifoAlloc_(this, (size_t)TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE), debuggerMutations(this, 0), - ionPcScriptCache(this, nullptr), status(this, JS::ExceptionStatus::None), unwrappedException_(this), unwrappedExceptionStack_(this), @@ -1263,6 +1263,34 @@ void JSContext::resetJitStackLimit() { void JSContext::initJitStackLimit() { resetJitStackLimit(); } +JSScript* JSContext::currentScript(jsbytecode** ppc, + AllowCrossRealm allowCrossRealm) { + if (ppc) { + *ppc = nullptr; + } + + // Fast path: there are no JS frames on the stack if there's no activation. + if (!activation()) { + return nullptr; + } + + FrameIter iter(this); + if (iter.done() || !iter.hasScript()) { + return nullptr; + } + + JSScript* script = iter.script(); + if (allowCrossRealm == AllowCrossRealm::DontAllow && + script->realm() != realm()) { + return nullptr; + } + + if (ppc) { + *ppc = iter.pc(); + } + return script; +} + #ifdef JS_CRASH_DIAGNOSTICS void ContextChecks::check(AbstractFramePtr frame, int argIndex) { if (frame) { |