1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_DispatcherJvm_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_DispatcherJvm_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/InstructionSemantics/DescriptorParser.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Dispatcher.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/FrameState.h>
10#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/base_object.hpp>
13#include <boost/serialization/export.hpp>
14#include <boost/serialization/nvp.hpp>
15#include <boost/serialization/split_member.hpp>
19namespace BinaryAnalysis {
20namespace InstructionSemantics {
45#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
47 friend class boost::serialization::access;
50 void save(S &s,
const unsigned )
const {
51 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Super);
55 void load(S &s,
const unsigned ) {
56 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Super);
57 initializeDispatchTable();
58 initializeMemoryState();
61 BOOST_SERIALIZATION_SPLIT_MEMBER();
67 DispatcherJvm() =
delete;
118 const std::string &symbolName =
"");
123 const std::string &descriptor,
124 const std::string &symbolName =
"");
129 const std::string &descriptor,
130 const std::string &symbolName =
"");
135 const std::string &descriptor,
bool hasReceiver);
139 void initializeDispatchTable();
142 void initializeMemoryState();
149#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
Dispatches instructions through the RISC layer.
virtual SValuePtr protoval() const
Return the prototypical value.
FrameStatePtr Ptr
Shared-ownership pointer.
Base class for most instruction semantics RISC operators.
Dispatches JVM instructions through the semantics layer.
static void initializeInvocationLocals(BaseSemantics::RiscOperators *ops, const BaseSemantics::FrameState::Ptr &frame, const std::string &descriptor, bool hasReceiver)
Initializes local variables in advance of a method invocation.
static BaseSemantics::SValuePtr syntheticValue(const BaseSemantics::SValuePtr &protoval, const DescriptorType &type, const std::string &symbolName="")
Creates a synthetic JVM value having the specified descriptor type and unknown value.
virtual RegisterDescriptor instructionPointerRegister() const override
Returns the instruction pointer register.
static std::string methodDescriptor(SgAsmJvmConstantPool *pool, size_t index)
Finds and returns the descriptor for a method from the constant pool at the given index.
virtual int iprocKey(SgAsmInstruction *) const override
Given an instruction, return the InsnProcessor key that can be used as an index into the iproc_table.
static std::string fieldDescriptor(SgAsmJvmConstantPool *pool, size_t index)
Finds and returns the descriptor for a field from the constant pool at the given index.
const RegisterDescriptor REG_SP
Cached register.
static Ptr instance(const Architecture::BaseConstPtr &, const BaseSemantics::RiscOperatorsPtr &)
Constructor.
BaseSemantics::Dispatcher Super
Base type.
const RegisterDescriptor REG_FP
Cached register.
static Ptr promote(const BaseSemantics::DispatcherPtr &)
Dynamic cast to DispatcherJvmPtr with assertion.
const RegisterDescriptor REG_PC
Cached register.
static Ptr instance(const Architecture::BaseConstPtr &)
Construct a prototypical dispatcher.
DispatcherJvmPtr Ptr
Shared-ownership pointer.
void recordSemanticError(const std::string &msg)
Records an error in the semantic analysis.
virtual BaseSemantics::DispatcherPtr create(const BaseSemantics::RiscOperatorsPtr &) const override
Virtual constructor.
static size_t nBitsForKind(BaseSemantics::ValueKind)
Returns the bit width for a JVM value kind.
static BaseSemantics::SValuePtr syntheticArrayReference(const BaseSemantics::SValuePtr &protoval, const std::string &descriptor, const std::string &symbolName="")
Creates a synthetic JVM array reference with an unknown reference and length.
static BaseSemantics::SValuePtr syntheticObjectReference(const BaseSemantics::SValuePtr &protoval, const std::string &descriptor, const std::string &symbolName="")
Creates a synthetic JVM object reference with an unknown reference value.
static SgAsmJvmConstantPool * constantPool(BaseSemantics::RiscOperators *ops)
Returns the constant pool.
void completeReturn(BaseSemantics::RiscOperators *, const BaseSemantics::SValuePtr result=BaseSemantics::SValuePtr())
Completes a return from the current JVM method.
Describes (part of) a physical CPU register.
Base class for machine instructions.
Represents an JVM constant pool.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
boost::shared_ptr< Dispatcher > DispatcherPtr
Shared-ownership pointer to a semantics instruction dispatcher.
ValueKind
Kind of an SValue for emulating JVM and CIL instructions.
boost::shared_ptr< class DispatcherJvm > DispatcherJvmPtr
Shared-ownership pointer to a JVM instruction dispatcher.
A parsed JVM descriptor type.