Permalink
Browse files

Moved all jumptables code to mini/ directory.

  • Loading branch information...
1 parent 2027600 commit a8bd364cf987905c26c42f1af9b601f3c1623d3a Nikolay Igotti committed Feb 25, 2013
Showing with 123 additions and 130 deletions.
  1. +0 −12 mono/metadata/domain-internals.h
  2. +0 −94 mono/metadata/domain.c
  3. +3 −3 mono/mini/mini-arm.c
  4. +92 −1 mono/mini/mini.c
  5. +8 −0 mono/mini/mini.h
  6. +20 −20 mono/mini/tramp-arm.c
@@ -402,18 +402,6 @@ typedef struct {
#define mono_domain_jit_code_hash_lock(domain) mono_locks_acquire(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
#define mono_domain_jit_code_hash_unlock(domain) mono_locks_release(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
-#ifdef USE_JUMP_TABLES
-void
-mono_jumptable_init (void) MONO_INTERNAL;
-gpointer*
-mono_jumptable_add_entry (void) MONO_INTERNAL;
-gpointer*
-mono_jumptable_add_entries (guint32 entries) MONO_INTERNAL;
-void
-mono_jumptable_cleanup (void) MONO_INTERNAL;
-#endif
-
-
typedef MonoDomain* (*MonoLoadFunc) (const char *filename, const char *runtime_version);
void
View
@@ -952,96 +952,6 @@ mono_jit_info_get_generic_jit_info (MonoJitInfo *ji)
return NULL;
}
-#ifdef USE_JUMP_TABLES
-
-#define DEFAULT_JUMPTABLE_CHUNK_ELEMENTS 128
-
-typedef struct MonoJumpTableChunk {
- guint32 total;
- guint32 active;
- struct MonoJumpTableChunk *previous;
- /* gpointer entries[total]; */
-} MonoJumpTableChunk;
-
-static MonoJumpTableChunk* g_jumptable = NULL;
-#define mono_jumptable_lock() EnterCriticalSection (&jumptable_mutex)
-#define mono_jumptable_unlock() LeaveCriticalSection (&jumptable_mutex)
-static CRITICAL_SECTION jumptable_mutex;
-
-static MonoJumpTableChunk*
-mono_create_jumptable_chunk (guint32 max_entries)
-{
- guint32 size = sizeof (MonoJumpTableChunk) + max_entries * sizeof(gpointer);
- MonoJumpTableChunk *chunk = (MonoJumpTableChunk*) g_new0 (guchar, size);
- chunk->total = max_entries;
- return chunk;
-}
-
-void
-mono_jumptable_init (void)
-{
- if (g_jumptable == NULL) {
- InitializeCriticalSection (&jumptable_mutex);
- g_jumptable = mono_create_jumptable_chunk (DEFAULT_JUMPTABLE_CHUNK_ELEMENTS);
- }
-}
-
-gpointer*
-mono_jumptable_add_entry (void)
-{
- return mono_jumptable_add_entries (1);
-}
-
-gpointer*
-mono_jumptable_add_entries (guint32 entries)
-{
- guint32 index;
- gpointer *result;
-
- mono_jumptable_init ();
- mono_jumptable_lock ();
- index = g_jumptable->active;
- if (index + entries >= g_jumptable->total) {
- /*
- * Grow jumptable, by adding one more chunk.
- * We cannot realloc jumptable, as there could be pointers
- * to existing jump table entries in the code, so instead
- * we just add one more chunk.
- */
- guint32 max_entries = entries;
- MonoJumpTableChunk *new_chunk;
-
- if (max_entries < DEFAULT_JUMPTABLE_CHUNK_ELEMENTS)
- max_entries = DEFAULT_JUMPTABLE_CHUNK_ELEMENTS;
- new_chunk = mono_create_jumptable_chunk (max_entries);
- /* Link old jumptable, so that we could free it up later. */
- new_chunk->previous = g_jumptable;
- g_jumptable = new_chunk;
- index = 0;
- }
- g_jumptable->active = index + entries;
- result = (gpointer*)((guchar*)g_jumptable + sizeof(MonoJumpTableChunk)) + index;
- mono_jumptable_unlock();
-
- return result;
-}
-
-void
-mono_jumptable_cleanup (void)
-{
- if (g_jumptable) {
- MonoJumpTableChunk *current = g_jumptable, *prev;
- while (current != NULL) {
- prev = current->previous;
- g_free (current);
- current = prev;
- }
- g_jumptable = NULL;
- DeleteCriticalSection (&jumptable_mutex);
- }
-}
-#endif
-
/*
* mono_jit_info_get_generic_sharing_context:
* @ji: a jit info
@@ -1847,10 +1757,6 @@ mono_cleanup (void)
mono_images_cleanup ();
mono_debug_cleanup ();
mono_metadata_cleanup ();
-#ifdef USE_JUMP_TABLES
- mono_jumptable_cleanup ();
-#endif
-
mono_native_tls_free (appdomain_thread_id);
DeleteCriticalSection (&appdomains_mutex);
View
@@ -5547,7 +5547,7 @@ mono_arch_emit_prolog (MonoCompile *cfg)
jte = mono_jumptable_add_entries (3);
jte [0] = (gpointer)&ss_trigger_var;
jte [1] = single_step_func_wrapper;
- jte [2] = breakpoint_func_wrapper;
+ jte [2] = breakpoint_func_wrapper;
code = mono_arm_load_jumptable_entry_addr (code, jte, ARMREG_LR);
#else
ARM_MOV_REG_REG (code, ARMREG_LR, ARMREG_PC);
@@ -5967,8 +5967,8 @@ gpointer
mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
- int size, i;
- arminstr_t *code, *start;
+ int size, i;
+ arminstr_t *code, *start;
#ifdef USE_JUMP_TABLES
gpointer *jte;
#else
View
@@ -7249,6 +7249,10 @@ mini_cleanup (MonoDomain *domain)
DeleteCriticalSection (&jit_mutex);
DeleteCriticalSection (&mono_delegate_section);
+
+#ifdef USE_JUMP_TABLES
+ mono_jumptable_cleanup ();
+#endif
}
void
@@ -7446,9 +7450,96 @@ mono_arch_get_gsharedvt_call_info (gpointer addr, MonoMethodSignature *normal_si
#endif
#ifdef USE_JUMP_TABLES
+#define DEFAULT_JUMPTABLE_CHUNK_ELEMENTS 128
+
+typedef struct MonoJumpTableChunk {
+ guint32 total;
+ guint32 active;
+ struct MonoJumpTableChunk *previous;
+ /* gpointer entries[total]; */
+} MonoJumpTableChunk;
+
+static MonoJumpTableChunk* g_jumptable = NULL;
+#define mono_jumptable_lock() EnterCriticalSection (&jumptable_mutex)
+#define mono_jumptable_unlock() LeaveCriticalSection (&jumptable_mutex)
+static CRITICAL_SECTION jumptable_mutex;
+
+static MonoJumpTableChunk*
+mono_create_jumptable_chunk (guint32 max_entries)
+{
+ guint32 size = sizeof (MonoJumpTableChunk) + max_entries * sizeof(gpointer);
+ MonoJumpTableChunk *chunk = (MonoJumpTableChunk*) g_new0 (guchar, size);
+ chunk->total = max_entries;
+ return chunk;
+}
+
+void
+mono_jumptable_init (void)
+{
+ if (g_jumptable == NULL) {
+ InitializeCriticalSection (&jumptable_mutex);
+ g_jumptable = mono_create_jumptable_chunk (DEFAULT_JUMPTABLE_CHUNK_ELEMENTS);
+ }
+}
+
+gpointer*
+mono_jumptable_add_entry (void)
+{
+ return mono_jumptable_add_entries (1);
+}
+
+gpointer*
+mono_jumptable_add_entries (guint32 entries)
+{
+ guint32 index;
+ gpointer *result;
+
+ mono_jumptable_init ();
+ mono_jumptable_lock ();
+ index = g_jumptable->active;
+ if (index + entries >= g_jumptable->total) {
+ /*
+ * Grow jumptable, by adding one more chunk.
+ * We cannot realloc jumptable, as there could be pointers
+ * to existing jump table entries in the code, so instead
+ * we just add one more chunk.
+ */
+ guint32 max_entries = entries;
+ MonoJumpTableChunk *new_chunk;
+
+ if (max_entries < DEFAULT_JUMPTABLE_CHUNK_ELEMENTS)
+ max_entries = DEFAULT_JUMPTABLE_CHUNK_ELEMENTS;
+ new_chunk = mono_create_jumptable_chunk (max_entries);
+ /* Link old jumptable, so that we could free it up later. */
+ new_chunk->previous = g_jumptable;
+ g_jumptable = new_chunk;
+ index = 0;
+ }
+ g_jumptable->active = index + entries;
+ result = (gpointer*)((guchar*)g_jumptable + sizeof(MonoJumpTableChunk)) + index;
+ mono_jumptable_unlock();
+
+ return result;
+}
+
+void
+mono_jumptable_cleanup (void)
+{
+ if (g_jumptable) {
+ MonoJumpTableChunk *current = g_jumptable, *prev;
+ while (current != NULL) {
+ prev = current->previous;
+ g_free (current);
+ current = prev;
+ }
+ g_jumptable = NULL;
+ DeleteCriticalSection (&jumptable_mutex);
+ }
+}
+
gpointer*
mono_jumptable_get_entry (guint8 *code_ptr)
{
- return mono_arch_jumptable_entry_from_code (code_ptr);
+ return mono_arch_jumptable_entry_from_code (code_ptr);
}
#endif
View
@@ -2184,6 +2184,14 @@ void mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func
#endif
#ifdef USE_JUMP_TABLES
+void
+mono_jumptable_init (void) MONO_INTERNAL;
+gpointer*
+mono_jumptable_add_entry (void) MONO_INTERNAL;
+gpointer*
+mono_jumptable_add_entries (guint32 entries) MONO_INTERNAL;
+void
+mono_jumptable_cleanup (void) MONO_INTERNAL;
gpointer*
mono_arch_jumptable_entry_from_code (guint8 *code);
gpointer*
View
@@ -30,7 +30,7 @@ static guint8* nullified_class_init_trampoline;
static guint16
decode_imm16 (guint32 insn)
{
- return (((insn >> 16) & 0xf) << 12) | (insn & 0xfff);
+ return (((insn >> 16) & 0xf) << 12) | (insn & 0xfff);
}
#define INSN_MASK 0xff00000
@@ -40,18 +40,18 @@ decode_imm16 (guint32 insn)
gpointer*
mono_arch_jumptable_entry_from_code (guint8 *code)
{
- guint32 insn1 = ((guint32*)code) [0];
- guint32 insn2 = ((guint32*)code) [1];
-
- if (((insn1 & INSN_MASK) == MOVW_MASK) &&
- ((insn2 & INSN_MASK) == MOVT_MASK) ) {
- guint32 imm_lo = decode_imm16 (insn1);
- guint32 imm_hi = decode_imm16 (insn2);
- return (gpointer*) GUINT_TO_POINTER (imm_lo | (imm_hi << 16));
- } else {
- g_assert_not_reached ();
- return NULL;
- }
+ guint32 insn1 = ((guint32*)code) [0];
+ guint32 insn2 = ((guint32*)code) [1];
+
+ if (((insn1 & INSN_MASK) == MOVW_MASK) &&
+ ((insn2 & INSN_MASK) == MOVT_MASK) ) {
+ guint32 imm_lo = decode_imm16 (insn1);
+ guint32 imm_hi = decode_imm16 (insn2);
+ return (gpointer*) GUINT_TO_POINTER (imm_lo | (imm_hi << 16));
+ } else {
+ g_assert_not_reached ();
+ return NULL;
+ }
}
#undef INSN_MASK
@@ -506,20 +506,20 @@ mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_ty
#ifdef USE_JUMP_TABLES
/* For jumptables case we always generate the same code for trampolines,
- * namely
+ * namely
* push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}
* movw lr, lo(jte)
* movt lr, hi(jte)
* ldr r1, [lr + 4]
* bx r1
*/
ARM_PUSH (code, 0x5fff);
- constants = mono_jumptable_add_entries (2);
- code = mono_arm_load_jumptable_entry_addr (code, constants, ARMREG_LR);
- ARM_LDR_IMM (code, ARMREG_R1, ARMREG_LR, 4);
+ constants = mono_jumptable_add_entries (2);
+ code = mono_arm_load_jumptable_entry_addr (code, constants, ARMREG_LR);
+ ARM_LDR_IMM (code, ARMREG_R1, ARMREG_LR, 4);
code = emit_bx (code, ARMREG_R1);
- constants[0] = arg1;
- constants[1] = tramp;
+ constants [0] = arg1;
+ constants [1] = tramp;
#else
/* we could reduce this to 12 bytes if tramp is within reach:
* ARM_PUSH ()
@@ -579,7 +579,7 @@ mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr)
MonoDomain *domain = mono_domain_get ();
#ifdef USE_JUMP_TABLES
gpointer *jte;
- guint32 size = 20;
+ guint32 size = 20;
#else
guint32 size = 16;
#endif

0 comments on commit a8bd364

Please sign in to comment.