commit 7bc4fad41e8a5a2efaba6fc0d272e79357d3877f Author: Torvald Riegel Date: Mon Jul 18 23:18:13 2011 +0200 Add information to dispatch about closed nesting and uninstrumented code. * dispatch.h (GTM::abi_dispatch): Add can_run_uninstrumented_code and closed_nesting flags, as well as a closed nesting alternative. * method-serial.cc: Same. diff --git a/libitm/dispatch.h b/libitm/dispatch.h index 3643503..38f1342 100644 --- a/libitm/dispatch.h +++ b/libitm/dispatch.h @@ -255,8 +255,17 @@ public: // a unique object and so we don't want to destroy it from common code. virtual void fini() = 0; + // Return an alternative method that is compatible with the current + // method but supports closed nesting. Return zero if there is none. + virtual abi_dispatch* closed_nesting_alternative() { return 0; } + bool read_only () const { return m_read_only; } bool write_through() const { return m_write_through; } + bool can_run_uninstrumented_code() const + { + return m_can_run_uninstrumented_code; + } + bool closed_nesting() const { return m_closed_nesting; } static void *operator new(size_t s) { return xmalloc (s); } static void operator delete(void *p) { free (p); } @@ -275,7 +284,13 @@ public: protected: const bool m_read_only; const bool m_write_through; - abi_dispatch(bool ro, bool wt) : m_read_only(ro), m_write_through(wt) { } + const bool m_can_run_uninstrumented_code; + const bool m_closed_nesting; + abi_dispatch(bool ro, bool wt, bool uninstrumented, bool closed_nesting) : + m_read_only(ro), m_write_through(wt), + m_can_run_uninstrumented_code(uninstrumented), + m_closed_nesting(closed_nesting) + { } }; } diff --git a/libitm/method-serial.cc b/libitm/method-serial.cc index a6fbc7f..009d221 100644 --- a/libitm/method-serial.cc +++ b/libitm/method-serial.cc @@ -38,7 +38,7 @@ namespace { class serial_dispatch : public abi_dispatch { public: - serial_dispatch() : abi_dispatch(false, true) { } + serial_dispatch() : abi_dispatch(false, true, true, false) { } protected: // Transactional loads and stores simply access memory directly. @@ -77,9 +77,16 @@ class serial_dispatch : public abi_dispatch virtual void rollback() { abort(); } virtual void reinit() { } virtual void fini() { } + + virtual abi_dispatch* closed_nesting_alternative() + { + // For nested transactions with an instrumented code path, we can do + // undo logging. + return GTM::dispatch_serial(); + } }; -class serial_dispatch_ul : public serial_dispatch +class serial_dispatch_ul : public abi_dispatch { protected: static void log(const void *addr, size_t len) @@ -119,12 +126,17 @@ public: ::memset(dst, c, size); } + virtual bool trycommit() { return true; } // Local undo will handle this. // trydropreference() need not be changed either. virtual void rollback() { } + virtual void reinit() { } + virtual void fini() { } CREATE_DISPATCH_METHODS(virtual, ) CREATE_DISPATCH_METHODS_MEM() + + serial_dispatch_ul() : abi_dispatch(false, true, false, true) { } }; } // anon namespace