search for: v_that

Displaying 9 results from an estimated 9 matches for "v_that".

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
...ic: > virtual ~item_iterator(); > virtual bool next( item *result ) = 0; > }; > > I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks: > > extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) { > item_iterator *const that = static_cast<item_iterator*>( v_that ); > item *const result = static_cast<item*>( v_result ); > return that->next( result ); > } > > extern "C" void thunk_iterator_M_delete( void *v_that ) { &gt...
2012 Mar 22
1
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...m_iterator(); >> virtual bool next( item *result ) = 0; >> }; >> >> I'm aware that LLVM doesn't know anything about C++ and that one way to call C++ functions is to wrap them in C thunks: >> >> extern "C" bool thunk_iterator_M_next( void *v_that, void *v_result ) { >> item_iterator *const that = static_cast<item_iterator*>( v_that ); >> item *const result = static_cast<item*>( v_result ); >> return that->next( result ); >> } >> >> extern "C" void thunk_iterator_M_dele...
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...ers of function calls.) Again for reference: > No reason. But if 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 ); >...
2012 Mar 23
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...9;re right, that I shouldn't need any try/catch at all. When I put tracer print statements in my class's destructors, I can see that they are called only if I explicitly call them via JIT'd code that calls the relevant thunk, e.g.: extern "C" void thunk_item_M_delete( void *v_that ) { item *const that = static_cast<item*>( v_that ); that->~item(); } Given that I have to call the thunks to run the d'tors manually in the normal control-flow case, it would seem that I would also have to call them in the exception-thrown control-flow case -- right? - Paul
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...houldn't need any try/catch at all. > > When I put tracer print statements in my class's destructors, I can see that they are called only if I explicitly call them via JIT'd code that calls the relevant thunk, e.g.: > > extern "C" void thunk_item_M_delete( void *v_that ) { > item *const that = static_cast<item*>( v_that ); > that->~item(); > } > > Given that I have to call the thunks to run the d'tors manually in the normal control-flow case, it would seem that I would also have to call them in the exception-thrown control-flow...
2012 Mar 22
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...9;m not following. How is having the code that catches all exceptions 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...
2012 Mar 23
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
On Mar 23, 2012, at 3:25 PM, Bill Wendling wrote: > Let's take your example. You will have code that looks like this: > > extern "C" void thunk_item_M_delete( void *v_that ) { > item *that = 0; > try { > that = static_cast<item*>( v_that ); > that->~item(); > } catch (...) { > that->~item(); > } > } No I wouldn't since destructors should never throw exceptions: http://www.parashift.com/c++-faq-lit...
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
On Mar 23, 2012, at 4:29 PM, Paul J. Lucas wrote: > On Mar 23, 2012, at 3:25 PM, Bill Wendling wrote: > >> Let's take your example. You will have code that looks like this: >> >> extern "C" void thunk_item_M_delete( void *v_that ) { >> item *that = 0; >> try { >> that = static_cast<item*>( v_that ); >> that->~item(); >> } catch (...) { >> that->~item(); >> } >> } > > No I wouldn't since destructors should never throw exceptions: You...