Skip to content
This repository
Browse code

[JIT] remove undocumented dependency of jit code on PMC internals, fi…

…xing TT #365

Infinoid++ for the original patch
Whiteknight++ for the review


git-svn-id: https://svn.parrot.org/parrot/trunk@37997 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 4108fd8e6a186e5e2ef4859dc5368b5d42528ff7 1 parent 275045c
cotto cotto authored

Showing 2 changed files with 24 additions and 10 deletions. Show diff stats Hide diff stats

  1. +18 3 src/jit/i386/jit_defs.c
  2. +6 7 src/pmc/nci.pmc
21 src/jit/i386/jit_defs.c
@@ -2317,10 +2317,25 @@ Parrot_jit_build_call_func(PARROT_INTERP, PMC *pmc_nci, STRING *signature, int *
2317 2317 sig++;
2318 2318 }
2319 2319
2320   - emitm_addl_i_r(pc, 16, emit_ESP);
2321   - /* get the pmc from stack - movl 12(%ebp), %eax */
  2320 + /* prepare to call VTABLE_get_pointer, set up args */
  2321 + /* interpreter - movl 8(%ebp), %eax */
  2322 + emitm_movl_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, 8);
  2323 + emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 0);
  2324 +
  2325 + /* pmc - movl 12(%ebp), %eax */
2322 2326 emitm_movl_m_r(interp, pc, emit_EAX, emit_EBP, 0, 1, 12);
2323   - emitm_callm(pc, emit_EAX, emit_None, emit_None, 0);
  2327 + emitm_movl_r_m(interp, pc, emit_EAX, emit_EBP, 0, 1, temp_calls_offset + 4);
  2328 +
  2329 + /* get the get_pointer() pointer from the pmc's vtable */
  2330 + emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(PMC, vtable));
  2331 + emitm_movl_m_r(interp, pc, emit_EAX, emit_EAX, 0, 1, offsetof(VTABLE, get_pointer));
  2332 +
  2333 + /* call get_pointer(), result goes into eax */
  2334 + emitm_callr(pc, emit_EAX);
  2335 + emitm_addl_i_r(pc, 16, emit_ESP);
  2336 +
  2337 + /* call the resulting function pointer */
  2338 + emitm_callr(pc, emit_EAX);
2324 2339 emitm_subl_i_r(pc, 16, emit_ESP);
2325 2340
2326 2341 /* SAVE OFF EAX */
13 src/pmc/nci.pmc
@@ -171,6 +171,10 @@ Sets the specified function pointer and signature (C<*key>).
171 171 PObj_flag_SET(private2, SELF);
172 172 }
173 173
  174 + VTABLE void *get_pointer() {
  175 + return PARROT_NCI(SELF)->orig_func;
  176 + }
  177 +
174 178 VTABLE void set_pointer_keyed_str(STRING *key, void *func) {
175 179 Parrot_NCI_attributes * const nci_info = PARROT_NCI(SELF);
176 180 int jitted = 0;
@@ -260,7 +264,7 @@ Creates and returns a clone of the NCI.
260 264 nci_info_ret->pcc_params_signature = nci_info_self->pcc_params_signature;
261 265 nci_info_ret->arity = nci_info_self->arity;
262 266 nci_info_ret->jitted = nci_info_self->jitted;
263   - PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
  267 + PObj_get_FLAGS(ret) |= (PObj_get_FLAGS(SELF) & 0x7);
264 268
265 269 return ret;
266 270 }
@@ -312,13 +316,8 @@ shifted down.
312 316
313 317 nci_jit_sub_t jit_func = (nci_jit_sub_t) D2FPTR(nci_info->func);
314 318
315   - /* TT #365 - Some i386 jit code depends on this. If t/pmc/nci.t
316   - * passes without it, the next line is safe to remove. */
317   - PMC_struct_val(SELF) = nci_info->orig_func;
318   -
319 319 /* Parrot_eprintf(interp, "JITTED %S\n", nci_info->signature); */
320   - jit_func(INTERP, SELF,
321   - (char *) nci_info->pcc_params_signature->strstart);
  320 + jit_func(INTERP, SELF, (char *) nci_info->pcc_params_signature->strstart);
322 321 }
323 322 else {
324 323 if (PObj_flag_TEST(private2, SELF)) {

0 comments on commit 4108fd8

Please sign in to comment.
Something went wrong with that request. Please try again.