2021-06-03 08:46:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-09-01 14:53:55 +00:00
|
|
|
#include <LibJS/Bytecode/Executable.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
#include <LibJS/Bytecode/Instruction.h>
|
2021-06-07 13:12:43 +00:00
|
|
|
#include <LibJS/Bytecode/Op.h>
|
2021-06-03 08:46:30 +00:00
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
2021-06-07 13:12:43 +00:00
|
|
|
void Instruction::destroy(Instruction& instruction)
|
2021-06-03 08:46:30 +00:00
|
|
|
{
|
2021-06-07 13:12:43 +00:00
|
|
|
#define __BYTECODE_OP(op) \
|
|
|
|
case Type::op: \
|
|
|
|
static_cast<Op::op&>(instruction).~op(); \
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (instruction.type()) {
|
|
|
|
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef __BYTECODE_OP
|
|
|
|
}
|
|
|
|
|
2023-09-01 14:53:55 +00:00
|
|
|
UnrealizedSourceRange InstructionStreamIterator::source_range() const
|
|
|
|
{
|
|
|
|
VERIFY(m_executable);
|
|
|
|
auto record = dereference().source_record();
|
|
|
|
return {
|
|
|
|
.source_code = m_executable->source_code,
|
|
|
|
.start_offset = record.source_start_offset,
|
|
|
|
.end_offset = record.source_end_offset,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<SourceCode> InstructionStreamIterator::source_code() const
|
|
|
|
{
|
|
|
|
return m_executable ? m_executable->source_code.ptr() : nullptr;
|
|
|
|
}
|
|
|
|
|
2024-02-02 09:19:17 +00:00
|
|
|
Operand::Operand(Register reg)
|
|
|
|
: m_type(Type::Register)
|
|
|
|
, m_index(reg.index())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-03 08:46:30 +00:00
|
|
|
}
|