Skip to content

Commit

Permalink
Add data structure for representing a callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Mar 14, 2014
1 parent 42be074 commit b6e4a61
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/core/nativecall.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@
#define MVM_NATIVECALL_ARG_FREE_STR 1
#define MVM_NATIVECALL_ARG_FREE_STR_MASK 1

/* Native callback entry. Hung off ThreadContext, keyed on CUID of code ref.
* (May be better off a CompUnit, though that may cause an edge case where a
* premature collection is possible.) */
struct MVMNativeCallback {
/* The dyncall callback object. */
DCCallback *cb;

/* The routine that we will call. */
MVMObject *target;

/* Thread context we expect to run the callback on. */
MVMThreadContext *tc;

/* Return and argument type flags. */
MVMint16 *typeinfos;

/* Return and argument types themselves. */
MVMObject **types;

/* The number of entries in typeinfos/types. */
MVMint32 num_types;

/* The uthash hash handle inline struct. */
UT_hash_handle hash_handle;
};

/* Functions for working with native callsites. */
void MVM_nativecall_build(MVMThreadContext *tc, MVMObject *site, MVMString *lib,
MVMString *sym, MVMString *conv, MVMObject *arg_spec, MVMObject *ret_spec);
Expand Down
3 changes: 3 additions & 0 deletions src/core/threadcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ struct MVMThreadContext {
/* Random number generator state. */
MVMuint64 rand_state[2];

/* Cache of native code callback data. */
MVMNativeCallback *native_callback_cache;

#if MVM_HLL_PROFILE_CALLS
/* storage of profile timings */
MVMProfileRecord *profile_data;
Expand Down
1 change: 1 addition & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,4 @@ typedef struct MVMIOSyncPipeData MVMIOSyncPipeData;
typedef struct MVMDecodeStream MVMDecodeStream;
typedef struct MVMDecodeStreamBytes MVMDecodeStreamBytes;
typedef struct MVMDecodeStreamChars MVMDecodeStreamChars;
typedef struct MVMNativeCallback MVMNativeCallback;

0 comments on commit b6e4a61

Please sign in to comment.