Permalink
Browse files

removing the runtime checked exceptions (forgot how expensive they we…

…re in c++ land)

darcs-hash:20081021040137-7b3c0-2b0ac2299cbe7dd62cf69245b9722e375654b076.gz
  • Loading branch information...
1 parent e7976a4 commit 894cf09dfc67b0e87516d2f4f12f7b7e217bb188 @ekmett committed Oct 21, 2008
Showing with 46 additions and 46 deletions.
  1. +2 −2 jit++/exception.cc
  2. +4 −4 jit++/exception.h
  3. +5 −5 jit++/interpreter.cc
  4. +23 −23 jit++/interpreter.h
  5. +5 −5 jit++/tracer.cc
  6. +7 −7 jit++/tracer.h
View
@@ -2,10 +2,10 @@
#include <udis86.h>
namespace jitpp {
- unsupported_opcode_exception::unsupported_opcode_exception(const void * rip) throw() : m_rip(rip) {
+ unsupported_opcode_exception::unsupported_opcode_exception(const void * rip) : m_rip(rip) {
m_what[0] = '\0';
}
- const char * unsupported_opcode_exception::what() const throw() {
+ const char * unsupported_opcode_exception::what() const {
if (m_what[0] != '\0') return m_what;
ud_t ud;
ud_init(&ud);
View
@@ -7,16 +7,16 @@
namespace jitpp {
class tracer_exception : public std::exception {
public:
- virtual ~tracer_exception() throw() {}
- virtual const char * what() const throw() = 0;
+ virtual ~tracer_exception() {}
+ virtual const char * what() const = 0;
};
// what() displays the exception
class unsupported_opcode_exception : public tracer_exception {
public:
- unsupported_opcode_exception(const void * rip) throw();
+ unsupported_opcode_exception(const void * rip);
static const size_t max_length = 160;
- const char * what() const throw();
+ const char * what() const;
private:
const void * m_rip;
mutable char m_what[max_length];
View
@@ -52,7 +52,7 @@ struct size64 {
typedef uint64_t unsigned_default64;
static const int bits = 64;
static const char * reg_names[16];
- static inline const char * reg_name(int r) throw() {
+ static inline const char * reg_name(int r) {
return reg_names[r];
}
};
@@ -68,7 +68,7 @@ struct size32 {
typedef uint64_t unsigned_default64;
static const int bits = 32;
static const char * reg_names[16];
- static inline const char * reg_name(int r) throw() {
+ static inline const char * reg_name(int r) {
return reg_names[r];
}
};
@@ -84,7 +84,7 @@ struct size16 {
typedef uint16_t unsigned_default64;
static const int bits = 16;
static const char * reg_names[16];
- static inline const char * reg_name(int r) throw() {
+ static inline const char * reg_name(int r) {
return reg_names[r];
}
};
@@ -99,7 +99,7 @@ struct size8 {
static const int bits = 8;
static const char * reg_names_rex[16];
static const char * reg_names_norex[8];
- static inline const char * reg_name(int r, bool has_rex) throw() {
+ static inline const char * reg_name(int r, bool has_rex) {
return has_rex ? reg_names_rex[r] : reg_names_norex[r];
}
};
@@ -118,7 +118,7 @@ template <typename T> T fetch(uint8_t * & i) {
// assumes x86-64 long mode
// TODO: check for correct handling of 66h on e0-e3,70-7f,eb,e9,ff/4,e8,ff/2,c3,c2
-void interpreter::run() throw() {
+void interpreter::run() {
try {
// todo: spew proc self maps here
do {
View
@@ -7,40 +7,40 @@ namespace jitpp {
class interpreter : public tracer {
public:
interpreter() : tracer() {}
- inline void operator ()() throw() { start(); }
+ inline void operator ()() { start(); }
private:
- void run() throw();
+ void run();
// interpret the tail end of an opcode after the first byte has been read.
template <typename os, typename as> uint8_t * interpret_opcode(uint8_t * i);
// fetch a given register. if T = int8_t then rex byte influences result.
- template <typename T> inline T reg(int r) const throw();
- template <typename T> inline void reg(int r, T v) throw();
+ template <typename T> inline T reg(int r) const;
+ template <typename T> inline void reg(int r, T v);
// M (mod R/M specifies a memory operand)
- template <typename T> inline T M() const throw() { return *reinterpret_cast<T*>(m_M); }
- template <typename T> inline void M(T v) throw() { *reinterpret_cast<T*>(m_M) = v; }
+ template <typename T> inline T M() const { return *reinterpret_cast<T*>(m_M); }
+ template <typename T> inline void M(T v) { *reinterpret_cast<T*>(m_M) = v; }
// G (reg field of mod R/M byte selects a general register)
- template <typename T> inline T G() const throw() { return reg<T>(m_nnn); }
- template <typename T> inline void G(T v) throw() { reg<T>(m_nnn,v); }
+ template <typename T> inline T G() const { return reg<T>(m_nnn); }
+ template <typename T> inline void G(T v) { reg<T>(m_nnn,v); }
// R (r/m field of mod R/M byte selects a general register, mod = 3)
- template <typename T> inline T R() const throw() { return reg<T>(m_rm); }
- template <typename T> inline void R(T v) throw() { reg<T>(m_rm,v); }
+ template <typename T> inline T R() const { return reg<T>(m_rm); }
+ template <typename T> inline void R(T v) { reg<T>(m_rm,v); }
// E (r/m follows opcode and specifies operand, either memory or register)
- template <typename T> inline T E() const throw() { return m_mod == 3 ? R<T>() : M<T>(); }
- template <typename T> inline void E(T v) throw() { if (m_mod == 3) R<T>(v); else M<T>(v); }
+ template <typename T> inline T E() const { return m_mod == 3 ? R<T>() : M<T>(); }
+ template <typename T> inline void E(T v) { if (m_mod == 3) R<T>(v); else M<T>(v); }
- uint8_t & ah() throw() { return reinterpret_cast<uint8_t*>(m_reg)[1]; }
+ uint8_t & ah() { return reinterpret_cast<uint8_t*>(m_reg)[1]; }
- template <typename T> void push(T v) throw() {
+ template <typename T> void push(T v) {
rsp() -= sizeof(T);
*reinterpret_cast<T*>(rsp()) = v;
}
- template <typename T> T pop() throw() {
+ template <typename T> T pop() {
T result = *reinterpret_cast<T*>(rsp());
rsp() += sizeof(T);
return result;
@@ -60,20 +60,20 @@ namespace jitpp {
- template <> inline int64_t interpreter::reg<>(int r) const throw() { return m_reg[r]; }
- template <> inline int32_t interpreter::reg<>(int r) const throw() { return *reinterpret_cast<const int32_t*>(m_reg + r); }
- template <> inline int16_t interpreter::reg<>(int r) const throw() { return *reinterpret_cast<const int16_t*>(m_reg + r); }
- template <> inline int8_t interpreter::reg<>(int r) const throw() {
+ template <> inline int64_t interpreter::reg<>(int r) const { return m_reg[r]; }
+ template <> inline int32_t interpreter::reg<>(int r) const { return *reinterpret_cast<const int32_t*>(m_reg + r); }
+ template <> inline int16_t interpreter::reg<>(int r) const { return *reinterpret_cast<const int16_t*>(m_reg + r); }
+ template <> inline int8_t interpreter::reg<>(int r) const {
if (m_rex & 0xf != 0)
return *reinterpret_cast<const int8_t*>(m_reg + r);
else
return *(reinterpret_cast<const int8_t*>(m_reg + (r & 3)) + (r & 4 != 0 ? 1 : 0));
}
- template <> inline void interpreter::reg<>(int r, int64_t v) throw() { m_reg[r] = v; }
- template <> inline void interpreter::reg<>(int r, int32_t v) throw() { m_reg[r] = v; }
- template <> inline void interpreter::reg<>(int r, int16_t v) throw() { *reinterpret_cast<int16_t*>(m_reg + r) = v; }
- template <> void interpreter::reg<>(int r, int8_t v) throw() {
+ template <> inline void interpreter::reg<>(int r, int64_t v) { m_reg[r] = v; }
+ template <> inline void interpreter::reg<>(int r, int32_t v) { m_reg[r] = v; }
+ template <> inline void interpreter::reg<>(int r, int16_t v) { *reinterpret_cast<int16_t*>(m_reg + r) = v; }
+ template <> void interpreter::reg<>(int r, int8_t v) {
if (m_rex & 0xf != 0)
*reinterpret_cast<int8_t*>(m_reg + r) = v;
else
View
@@ -8,7 +8,7 @@
DEFINE_uint64(jitpp_default_stack_size,102400,"the default stack size for tracing fibers. must be larger than the size of /proc/self/maps!");
namespace jitpp {
- size_t tracer::default_stack_size() throw() {
+ size_t tracer::default_stack_size() {
return FLAGS_jitpp_default_stack_size;
}
@@ -20,28 +20,28 @@ namespace jitpp {
delete[] m_stack;
}
- int64_t tracer::fs_base() const throw() {
+ int64_t tracer::fs_base() const {
if (unlikely(!m_fs_base_known)) {
syscall(SYS_arch_prctl,ARCH_GET_FS,&m_fs_base);
m_fs_base_known = true;
}
return m_fs_base;
}
- int64_t tracer::gs_base() const throw() {
+ int64_t tracer::gs_base() const {
if (unlikely(!m_gs_base_known)) {
syscall(SYS_arch_prctl,ARCH_GET_FS,&m_gs_base);
m_gs_base_known = true;
}
return m_gs_base;
}
- void tracer::run_tracer(context & t_) throw() {
+ void tracer::run_tracer(context & t_) {
tracer & t = *static_cast<tracer *>(&t);
t.m_fs_base_known = t.m_gs_base_known = false;
t.run();
}
- void tracer::start() throw() {
+ void tracer::start() {
enter_interpreter(*this,m_stack,m_stack_size,&run_tracer);
}
} // namespace jitpp
View
@@ -24,19 +24,19 @@ namespace jitpp {
tracer(size_t stack_size = default_stack_size());
~tracer();
- static size_t default_stack_size() throw();
+ static size_t default_stack_size();
- void start() throw();
+ void start();
protected:
- int64_t fs_base() const throw();
- int64_t gs_base() const throw();
- int32_t eip() const throw() { return static_cast<int32_t>(rip()); }
+ int64_t fs_base() const;
+ int64_t gs_base() const;
+ int32_t eip() const { return static_cast<int32_t>(rip()); }
- virtual void run() throw() = 0;
+ virtual void run() = 0;
private:
- static void run_tracer(context & t) throw();
+ static void run_tracer(context & t);
tracer(const tracer & peer);
tracer & operator=(const tracer & peer);

0 comments on commit 894cf09

Please sign in to comment.