summaryrefslogtreecommitdiffstats
path: root/js/src/vm/BytecodeLocation-inl.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/vm/BytecodeLocation-inl.h
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/vm/BytecodeLocation-inl.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/js/src/vm/BytecodeLocation-inl.h b/js/src/vm/BytecodeLocation-inl.h
new file mode 100644
index 0000000000..f254515a50
--- /dev/null
+++ b/js/src/vm/BytecodeLocation-inl.h
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: set ts=8 sts=2 et sw=2 tw=80:
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef vm_BytecodeLocation_inl_h
+#define vm_BytecodeLocation_inl_h
+
+#include "vm/BytecodeLocation.h"
+
+#include "vm/JSScript.h"
+
+#include "vm/BytecodeUtil-inl.h"
+#include "vm/JSScript-inl.h"
+
+namespace js {
+
+inline uint32_t BytecodeLocation::bytecodeToOffset(
+ const JSScript* script) const {
+ MOZ_ASSERT(this->isInBounds());
+ return script->pcToOffset(this->rawBytecode_);
+}
+
+inline JSAtom* BytecodeLocation::getAtom(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ return script->getAtom(this->rawBytecode_);
+}
+
+inline PropertyName* BytecodeLocation::getPropertyName(
+ const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ return script->getName(this->rawBytecode_);
+}
+
+inline JS::BigInt* BytecodeLocation::getBigInt(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ MOZ_ASSERT(is(JSOp::BigInt));
+ return script->getBigInt(this->rawBytecode_);
+}
+
+inline JSObject* BytecodeLocation::getObject(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ MOZ_ASSERT(is(JSOp::CallSiteObj) || is(JSOp::Object));
+ return script->getObject(this->rawBytecode_);
+}
+
+inline JSFunction* BytecodeLocation::getFunction(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ MOZ_ASSERT(is(JSOp::Lambda) || is(JSOp::LambdaArrow) ||
+ is(JSOp::FunWithProto));
+ return script->getFunction(this->rawBytecode_);
+}
+
+inline js::RegExpObject* BytecodeLocation::getRegExp(
+ const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ MOZ_ASSERT(is(JSOp::RegExp));
+ return script->getRegExp(this->rawBytecode_);
+}
+
+inline js::Scope* BytecodeLocation::getScope(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ return script->getScope(this->rawBytecode_);
+}
+
+inline Scope* BytecodeLocation::innermostScope(const JSScript* script) const {
+ MOZ_ASSERT(this->isValid());
+ return script->innermostScope(this->rawBytecode_);
+}
+
+inline uint32_t BytecodeLocation::tableSwitchCaseOffset(
+ const JSScript* script, uint32_t caseIndex) const {
+ return script->tableSwitchCaseOffset(this->rawBytecode_, caseIndex);
+}
+
+inline uint32_t BytecodeLocation::getJumpTargetOffset(
+ const JSScript* script) const {
+ MOZ_ASSERT(this->isJump());
+ return this->bytecodeToOffset(script) + GET_JUMP_OFFSET(this->rawBytecode_);
+}
+
+inline uint32_t BytecodeLocation::getTableSwitchDefaultOffset(
+ const JSScript* script) const {
+ MOZ_ASSERT(this->is(JSOp::TableSwitch));
+ return this->bytecodeToOffset(script) + GET_JUMP_OFFSET(this->rawBytecode_);
+}
+
+BytecodeLocation BytecodeLocation::getTableSwitchDefaultTarget() const {
+ MOZ_ASSERT(is(JSOp::TableSwitch));
+ return BytecodeLocation(*this, rawBytecode_ + GET_JUMP_OFFSET(rawBytecode_));
+}
+
+BytecodeLocation BytecodeLocation::getTableSwitchCaseTarget(
+ const JSScript* script, uint32_t caseIndex) const {
+ MOZ_ASSERT(is(JSOp::TableSwitch));
+ jsbytecode* casePC = script->tableSwitchCasePC(rawBytecode_, caseIndex);
+ return BytecodeLocation(*this, casePC);
+}
+
+inline uint32_t BytecodeLocation::useCount() const {
+ return GetUseCount(this->rawBytecode_);
+}
+
+inline uint32_t BytecodeLocation::defCount() const {
+ return GetDefCount(this->rawBytecode_);
+}
+
+} // namespace js
+
+#endif