ROSE 2.20.0
Loading...
Searching...
No Matches
DispatcherJvm.h
1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_DispatcherJvm_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_DispatcherJvm_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/InstructionSemantics/DescriptorParser.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/Dispatcher.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/FrameState.h>
9
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>
16#endif
17
18namespace Rose {
19namespace BinaryAnalysis {
20namespace InstructionSemantics {
21
23using DispatcherJvmPtr = boost::shared_ptr<class DispatcherJvm>;
24
29public:
32
35
36public:
45#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
46private:
47 friend class boost::serialization::access;
48
49 template<class S>
50 void save(S &s, const unsigned /*version*/) const {
51 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
52 }
53
54 template<class S>
55 void load(S &s, const unsigned /*version*/) {
56 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Super);
57 initializeDispatchTable();
58 initializeMemoryState();
59 }
60
61 BOOST_SERIALIZATION_SPLIT_MEMBER();
62#endif
63
64public:
65 ~DispatcherJvm();
66protected:
67 DispatcherJvm() = delete;
68 explicit DispatcherJvm(const Architecture::BaseConstPtr&);
70
71public:
76
79
82
83public:
84 // documented in the base class
86
87 virtual int iprocKey(SgAsmInstruction*) const override;
89
91 void recordSemanticError(const std::string &msg);
92
95
98
100 static std::string methodDescriptor(SgAsmJvmConstantPool *pool, size_t index);
101
103 static std::string fieldDescriptor(SgAsmJvmConstantPool *pool, size_t index);
104
107
110 const BaseSemantics::SValue::Ptr &receiver);
111
115 const DescriptorType &type,
116 const std::string &symbolName = "");
117
121 const std::string &descriptor,
122 const std::string &symbolName = "");
123
127 const std::string &descriptor,
128 const std::string &symbolName = "");
129
133 const std::string &descriptor, bool hasReceiver);
134
135private:
136 // Initializes the dispatch table that handles each kind of instruction
137 void initializeDispatchTable();
138
139 // Initializes memory state, such as the default byte order
140 void initializeMemoryState();
141};
142
143} // namespace
144} // namespace
145} // namespace
146
147#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
149#endif
150
151#endif
152#endif
Dispatches instructions through the RISC layer.
Definition Dispatcher.h:48
virtual SValuePtr protoval() const
Return the prototypical value.
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.
ByteCode::Method::Ptr resolveRuntimeMethod(SgAsmJvmConstantPool *pool, size_t index, const BaseSemantics::SValue::Ptr &receiver)
Finds and returns the JVM method selected by the runtime type of the receiver.
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.
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.
ByteCode::Method::Ptr resolveMethod(SgAsmJvmConstantPool *pool, size_t index)
Finds and returns the JVM method referenced by the constant pool entry at the given index.
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.
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.
Definition SValue.h:28
boost::shared_ptr< class DispatcherJvm > DispatcherJvmPtr
Shared-ownership pointer to a JVM instruction dispatcher.
The ROSE library.