mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibJS: Always inline the bytecode instruction iterator's operator++
This commit is contained in:
parent
a97d75bb63
commit
d203a86900
3 changed files with 32 additions and 31 deletions
|
@ -64,10 +64,4 @@ void BasicBlock::grow(size_t additional_size)
|
||||||
VERIFY(m_buffer_size <= m_buffer_capacity);
|
VERIFY(m_buffer_size <= m_buffer_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstructionStreamIterator::operator++()
|
|
||||||
{
|
|
||||||
VERIFY(!at_end());
|
|
||||||
m_offset += dereference().length();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,31 +13,6 @@
|
||||||
|
|
||||||
namespace JS::Bytecode {
|
namespace JS::Bytecode {
|
||||||
|
|
||||||
class InstructionStreamIterator {
|
|
||||||
public:
|
|
||||||
explicit InstructionStreamIterator(ReadonlyBytes bytes)
|
|
||||||
: m_bytes(bytes)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t offset() const { return m_offset; }
|
|
||||||
bool at_end() const { return m_offset >= m_bytes.size(); }
|
|
||||||
void jump(size_t offset)
|
|
||||||
{
|
|
||||||
VERIFY(offset <= m_bytes.size());
|
|
||||||
m_offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instruction const& operator*() const { return dereference(); }
|
|
||||||
void operator++();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Instruction const& dereference() const { return *reinterpret_cast<Instruction const*>(m_bytes.data() + offset()); }
|
|
||||||
|
|
||||||
ReadonlyBytes m_bytes;
|
|
||||||
size_t m_offset { 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UnwindInfo {
|
struct UnwindInfo {
|
||||||
Executable const* executable;
|
Executable const* executable;
|
||||||
BasicBlock const* handler;
|
BasicBlock const* handler;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
|
#include <AK/Span.h>
|
||||||
#include <LibJS/Forward.h>
|
#include <LibJS/Forward.h>
|
||||||
|
|
||||||
#define ENUMERATE_BYTECODE_OPS(O) \
|
#define ENUMERATE_BYTECODE_OPS(O) \
|
||||||
|
@ -106,4 +107,35 @@ protected:
|
||||||
private:
|
private:
|
||||||
Type m_type {};
|
Type m_type {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class InstructionStreamIterator {
|
||||||
|
public:
|
||||||
|
explicit InstructionStreamIterator(ReadonlyBytes bytes)
|
||||||
|
: m_bytes(bytes)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t offset() const { return m_offset; }
|
||||||
|
bool at_end() const { return m_offset >= m_bytes.size(); }
|
||||||
|
void jump(size_t offset)
|
||||||
|
{
|
||||||
|
VERIFY(offset <= m_bytes.size());
|
||||||
|
m_offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction const& operator*() const { return dereference(); }
|
||||||
|
|
||||||
|
ALWAYS_INLINE void operator++()
|
||||||
|
{
|
||||||
|
VERIFY(!at_end());
|
||||||
|
m_offset += dereference().length();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Instruction const& dereference() const { return *reinterpret_cast<Instruction const*>(m_bytes.data() + offset()); }
|
||||||
|
|
||||||
|
ReadonlyBytes m_bytes;
|
||||||
|
size_t m_offset { 0 };
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue