ROSE 2.15.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
98
100 void recordSemanticError(const std::string &msg);
101
104
107
109 static std::string methodDescriptor(SgAsmJvmConstantPool *pool, size_t index);
110
112 static std::string fieldDescriptor(SgAsmJvmConstantPool *pool, size_t index);
113
117 const DescriptorType &type,
118 const std::string &symbolName = "");
119
123 const std::string &descriptor,
124 const std::string &symbolName = "");
125
129 const std::string &descriptor,
130 const std::string &symbolName = "");
131
135 const std::string &descriptor, bool hasReceiver);
136
137private:
138 // Initializes the dispatch table that handles each kind of instruction
139 void initializeDispatchTable();
140
141 // Initializes memory state, such as the default byte order
142 void initializeMemoryState();
143};
144
145} // namespace
146} // namespace
147} // namespace
148
149#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
151#endif
152
153#endif
154#endif
Dispatches instructions through the RISC layer.
Definition Dispatcher.h:47
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.
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.
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.
Definition SValue.h:28
boost::shared_ptr< class DispatcherJvm > DispatcherJvmPtr
Shared-ownership pointer to a JVM instruction dispatcher.
The ROSE library.