Commit 53769235 authored by Adam Holm's avatar Adam Holm
Browse files

Bug 1573062 - Use BytecodeLocation and BytecodeIterator in JitScript::printTypes. r=mgaudet

Replaced uses of `jsbytecode*` and `pcToOffset` with the bytecode
interface classes `BytecodeLocation` and `BytecodeIterator`.

Differential Revision: https://phabricator.services.mozilla.com/D47514

--HG--
extra : moz-landing-system : lando
parent f0739b12
......@@ -13,6 +13,8 @@
#include "jit/BaselineIC.h"
#include "jit/BytecodeAnalysis.h"
#include "vm/BytecodeIterator.h"
#include "vm/BytecodeLocation.h"
#include "vm/BytecodeUtil.h"
#include "vm/JSScript.h"
#include "vm/Stack.h"
......@@ -21,6 +23,8 @@
#include "gc/FreeOp-inl.h"
#include "jit/JSJitFrameIter-inl.h"
#include "vm/BytecodeIterator-inl.h"
#include "vm/BytecodeLocation-inl.h"
#include "vm/JSScript-inl.h"
#include "vm/TypeInference-inl.h"
......@@ -279,7 +283,7 @@ void JitScript::printTypes(JSContext* cx, HandleScript script) {
fprintf(stderr, "\n this:");
thisTypes(sweep, script)->print();
for (unsigned i = 0; script->functionNonDelazifying() &&
for (uint32_t i = 0; script->functionNonDelazifying() &&
i < script->functionNonDelazifying()->nargs();
i++) {
fprintf(stderr, "\n arg%u:", i);
......@@ -287,21 +291,21 @@ void JitScript::printTypes(JSContext* cx, HandleScript script) {
}
fprintf(stderr, "\n");
for (jsbytecode* pc = script->code(); pc < script->codeEnd();
pc += GetBytecodeLength(pc)) {
for (BytecodeLocation it : AllBytecodesIterable(script)) {
{
fprintf(stderr, "%p:", script.get());
Sprinter sprinter(cx);
if (!sprinter.init()) {
return;
}
Disassemble1(cx, script, pc, script->pcToOffset(pc), true, &sprinter);
Disassemble1(cx, script, it.toRawBytecode(), it.bytecodeToOffset(script),
true, &sprinter);
fprintf(stderr, "%s", sprinter.string());
}
if (BytecodeOpHasTypeSet(JSOp(*pc))) {
StackTypeSet* types = bytecodeTypes(sweep, script, pc);
fprintf(stderr, " typeset %u:", unsigned(types - typeArray(sweep)));
if (it.opHasTypeSet()) {
StackTypeSet* types = bytecodeTypes(sweep, script, it.toRawBytecode());
fprintf(stderr, " typeset %u:", uint32_t(types - typeArray(sweep)));
types->print();
fprintf(stderr, "\n");
}
......
......@@ -22,7 +22,8 @@ inline bool BytecodeLocation::isValid(const JSScript* script) const {
inline bool BytecodeLocation::isInBounds(const JSScript* script) const {
return script->contains(*this);
}
inline uint32_t BytecodeLocation::bytecodeToOffset(JSScript* script) {
inline uint32_t BytecodeLocation::bytecodeToOffset(
const JSScript* script) const {
return script->pcToOffset(this->rawBytecode_);
}
......
......@@ -69,7 +69,7 @@ class BytecodeLocation {
// bytecode for a given script.
bool isInBounds(const JSScript* script) const;
uint32_t bytecodeToOffset(JSScript* script);
uint32_t bytecodeToOffset(const JSScript* script) const;
PropertyName* getPropertyName(const JSScript* script) const;
......@@ -120,6 +120,8 @@ class BytecodeLocation {
bool isJump() const { return IsJumpOpcode(getOp()); }
bool opHasTypeSet() const { return BytecodeOpHasTypeSet(getOp()); }
bool fallsThrough() const { return BytecodeFallsThrough(getOp()); }
uint32_t icIndex() const { return GET_ICINDEX(rawBytecode_); }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment