CodeChunk *current;
CodeChunk *full;
#if defined(__native_client_codegen__) && defined(__native_client__)
- MonoGHashTable *hash;
+ GHashTable *hash;
#endif
};
if (next_dynamic_code_addr == NULL) {
const guint kPageMask = 0xFFFF; /* 64K pages */
next_dynamic_code_addr = (uintptr_t)(etext + kPageMask) & ~kPageMask;
+#if defined (__GLIBC__)
+ /* TODO: For now, just jump 64MB ahead to avoid dynamic libraries. */
+ next_dynamic_code_addr += (uintptr_t)0x4000000;
+#else
/* Workaround bug in service runtime, unable to allocate */
/* from the first page in the dynamic code section. */
- /* TODO: remove */
next_dynamic_code_addr += (uintptr_t)0x10000;
+#endif
}
- cman->hash = mono_g_hash_table_new (NULL, NULL);
- /* Keep the hash table from being collected */
- mono_gc_register_root (&cman->hash, sizeof (void*), NULL);
+ cman->hash = g_hash_table_new (NULL, NULL);
if (patch_source_base == NULL) {
patch_source_base = g_malloc (kMaxPatchDepth * sizeof(unsigned char *));
patch_dest_base = g_malloc (kMaxPatchDepth * sizeof(unsigned char *));
/* Allocate code space from the service runtime */
code_ptr = allocate_code (size);
/* Insert pointer to code space in hash, keyed by buffer ptr */
- mono_g_hash_table_insert (cman->hash, temp_ptr, code_ptr);
+ g_hash_table_insert (cman->hash, temp_ptr, code_ptr);
nacl_jit_check_init ();
unsigned char *code;
int status;
g_assert (newsize <= size);
- code = mono_g_hash_table_lookup (cman->hash, data);
+ code = g_hash_table_lookup (cman->hash, data);
g_assert (code != NULL);
/* Pad space after code with HLTs */
/* TODO: this is x86/amd64 specific */
}
status = nacl_dyncode_create (code, data, newsize);
if (status != 0) {
+ unsigned char *codep;
+ fprintf(stderr, "Error creating Native Client dynamic code section attempted to be\n"
+ "emitted at %p (hex dissasembly of code follows):\n", code);
+ for (codep = data; codep < data + newsize; codep++)
+ fprintf(stderr, "%02x ", *codep);
+ fprintf(stderr, "\n");
g_assert_not_reached ();
}
- mono_g_hash_table_remove (cman->hash, data);
+ g_hash_table_remove (cman->hash, data);
g_assert (data == patch_source_base[patch_current_depth]);
g_assert (code == patch_dest_base[patch_current_depth]);
patch_current_depth--;
void *
nacl_code_manager_get_code_dest (MonoCodeManager *cman, void *data)
{
- return mono_g_hash_table_lookup (cman->hash, data);
+ return g_hash_table_lookup (cman->hash, data);
}
#endif