search for: dtor_pairs

Displaying 5 results from an estimated 5 matches for "dtor_pairs".

2012 Mar 15
3
[LLVMdev] Using JIT code to code a program to call C++
My project has a C++ library that I want to allow the user to use via some programming language to be JIT'd to call functions in said library. For the sake of simplicity, assume the library has classes like: class item { public: item(); item( int ); ~item(); // ... }; class item_iterator { public: virtual ~item_iterator(); virtual bool next( item *result ) = 0; };
2012 Mar 21
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...LLVM exceptions, but I don't see any examples. A little help? One thought might be to try to handle all the C++ exception code in the thunks. The JIT'd code would create/maintain a simple array-of-structs like: struct dtor_pair { void (*dtor_fn)(void*); void *that; }; dtor_pair dtor_pairs[10]; that contain a pointer to the thunk for a destructor and a pointer to the object to be destructed. As the JIT'd code creates objects on the stack, it populates the dtor_pairs array. This array could then be passed to every thunk: extern "C" bool thunk_iterator_M_next( void *...
2012 Mar 22
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...de calling the JIT'ed code. > One thought might be to try to handle all the C++ exception code in the thunks. The JIT'd code would create/maintain a simple array-of-structs like: > > struct dtor_pair { > void (*dtor_fn)(void*); > void *that; > }; > dtor_pair dtor_pairs[10]; > > that contain a pointer to the thunk for a destructor and a pointer to the object to be destructed. > > As the JIT'd code creates objects on the stack, it populates the dtor_pairs array. This array could then be passed to every thunk: > > extern "C" bool...
2012 Mar 22
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...ptions in a separate function different from what I proposed (putting the try/catch in the thunks)? (Ideally, I want to minimize layers of function calls.) Again for reference: extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result, dtor_pairs *dtors ) { try { item_iterator *const that = static_cast<item_iterator*>( v_that ); item *const result = static_cast<item*>( v_result ); return that->next( result ); } catch ( ... ) { run_dtors( dtors ); throw; } } - Paul
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...you have the 'try{}catch(...){}', then it should run the d'tors for you. There's no reason for you to have a "run_dtors" function there. -bw > extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result, > dtor_pairs *dtors ) { > try { > item_iterator *const that = static_cast<item_iterator*>( v_that ); > item *const result = static_cast<item*>( v_result ); > return that->next( result ); > } > catch ( ... ) { > run_dtors( dtors ); > throw;...