Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several aspects of the JIT leak out to the rest of the VM, such as: - finding the correct deopt idx - finding the active frame handlers - finding the active set of inlines I want to contain them in the JIT and so provide a somewhat cleaner interface, primarily to change that interface to use the new stack walker.
- Loading branch information
Showing
11 changed files
with
108 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "moar.h" | ||
#include "internal.h" | ||
|
||
void * stack_find_return_address(void *base, void *end, MVMint64 depth); | ||
|
||
/* Enter the JIT code segment. The label is a continuation point where control | ||
* is resumed after the frame is properly setup. */ | ||
void MVM_jit_code_enter(MVMThreadContext *tc, MVMCompUnit *cu, | ||
MVMJitCode *code) { | ||
void *label = tc->cur_frame->jit_entry_label; | ||
MVMint32 ofs = (char*)label - (char*)code->func_ptr; | ||
if (ofs < 0 || ofs >= code->size) | ||
MVM_oops(tc, "JIT entry label out of range for code!\n" | ||
"(label %p, func_ptr %p, code size %lui, offset %li, frame_nr %i, seq nr %i)", | ||
label, code->func_ptr, code->size, ((char*)label) - ((char*)code->func_ptr), | ||
tc->cur_frame->sequence_nr, code->seq_nr); | ||
code->func_ptr(tc, cu, label); | ||
} | ||
|
||
MVMint32 MVM_jit_code_get_active_handlers(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame, MVMint32 *handlers_out) { | ||
MVMint32 i; | ||
MVMint32 j = 0; | ||
void *current_position = frame->jit_entry_label; | ||
fprintf(stderr, "Get active deopt idx: %" PRIx64 "\n", current_position); | ||
for (i = 0; i < code->num_handlers; i++) { | ||
void *start_label = code->labels[code->handlers[i].start_label]; | ||
void *end_label = code->labels[code->handlers[i].end_label]; | ||
if (start_label <= current_position && end_label >= current_position) { | ||
handlers_out[j++] = i; | ||
} | ||
} | ||
return j; | ||
} | ||
|
||
MVMint32 MVM_jit_code_get_active_deopt_idx(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame) { | ||
MVMint32 i; | ||
void *current_position = frame->jit_entry_label; | ||
for (i = 0; i < code->num_deopts; i++) { | ||
if (code->labels[code->deopts[i].label] == current_position) { | ||
break; | ||
} | ||
} | ||
return i; | ||
} | ||
|
||
MVMint32 MVM_jit_code_get_active_inlines(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame, MVMint32 *inlines) { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* Function for getting effective (JIT/specialized/original) bytecode. */ | ||
MVM_STATIC_INLINE MVMuint8 * MVM_frame_effective_bytecode(MVMFrame *f) { | ||
MVMSpeshCandidate *spesh_cand = f->spesh_cand; | ||
if (spesh_cand) | ||
return spesh_cand->jitcode ? spesh_cand->jitcode->bytecode : spesh_cand->bytecode; | ||
return f->static_info->body.bytecode; | ||
} | ||
|
||
void MVM_jit_code_enter(MVMThreadContext *tc, MVMCompUnit *cu, MVMJitCode * code); | ||
MVMint32 MVM_jit_code_get_active_handlers(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame, MVMint32 *handlers); | ||
MVMint32 MVM_jit_code_get_active_deopt_idx(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame); | ||
MVMint32 MVM_jit_code_get_active_inlines(MVMThreadContext *tc, MVMJitCode *code, MVMFrame *frame, MVMint32 *inlines); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters