Functions | |
XED_DLL_EXPORT xed_error_enum_t | xed_decode_cache (xed_decoded_inst_t *xedd, const xed_uint8_t *itext, const unsigned int bytes, xed_decode_cache_t *cache) |
This is the main interface to the decoder. | |
XED_DLL_EXPORT void | xed_decode_cache_initialize (xed_decode_cache_t *cache, xed_decode_cache_entry_t *entries, xed_uint32_t n_entries) |
Have XED initialize the decode cache that you've allocated. |
Each cache entry is 224B, so allocating 16K entries results in a 3.5MB buffer. The interface requires that the user allocate the memory for the cache since XED does not ever allocate memory on its own.
The example shows one thread, but you could use many xed_decode_cache_t's, one per thread. If your JIT or interpreter is single threaded, you would only need one cache as shown.
/* once per thread */ xed_decode_cache_t cache; xed_uint32_t n_cache_entries = 16*1024; xed_decode_cache_entry_t* cache_entries = (xed_decode_cache_entry_t*) malloc(n_cache_entries * sizeof(xed_decode_cache_entry_t)); xed_decode_cache_initialize(&cache, cache_entries, n_cache_entries);
Then during execution, instead of calling xed_decode(), you call xed_decode_cache() and pass in a pointer to the thread's cache you initialized above.
xed_error_enum_t xed_error = xed_decode_cache(&xedd, itext_buffer, nbytes, &cache);
During thread shutdown you must free up each cache you allocated.
free(cache_entries);
|
This is the main interface to the decoder.
|
|
Have XED initialize the decode cache that you've allocated. You must allocate one decode cache per thread if you are using the xed_decode_cache. The number of entries must be a power of 2.
|