Skip to content

Commit

Permalink
Add osrpoint opcode for hot loop detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 23, 2014
1 parent d2e0732 commit 6158f0b
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 74 deletions.
76 changes: 40 additions & 36 deletions lib/MAST/Ops.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ BEGIN {
1458,
1462,
1466,
1466,
1468,
1470,
1472,
Expand Down Expand Up @@ -1255,6 +1256,7 @@ BEGIN {
4,
4,
4,
0,
2,
2,
2,
Expand Down Expand Up @@ -3465,42 +3467,43 @@ BEGIN {
'param_on2_n', 605,
'param_on2_s', 606,
'param_on2_o', 607,
'sp_log', 608,
'sp_guardconc', 609,
'sp_guardtype', 610,
'sp_guardcontconc', 611,
'sp_guardconttype', 612,
'sp_getarg_o', 613,
'sp_getarg_i', 614,
'sp_getarg_n', 615,
'sp_getarg_s', 616,
'sp_fastinvoke_v', 617,
'sp_fastinvoke_i', 618,
'sp_fastinvoke_n', 619,
'sp_fastinvoke_s', 620,
'sp_fastinvoke_o', 621,
'sp_namedarg_used', 622,
'sp_getspeshslot', 623,
'sp_findmeth', 624,
'sp_fastcreate', 625,
'sp_get_o', 626,
'sp_get_i', 627,
'sp_get_n', 628,
'sp_get_s', 629,
'sp_bind_o', 630,
'sp_bind_i', 631,
'sp_bind_n', 632,
'sp_bind_s', 633,
'sp_p6oget_o', 634,
'sp_p6ogetvt_o', 635,
'sp_p6ogetvc_o', 636,
'sp_p6oget_i', 637,
'sp_p6oget_n', 638,
'sp_p6oget_s', 639,
'sp_p6obind_o', 640,
'sp_p6obind_i', 641,
'sp_p6obind_n', 642,
'sp_p6obind_s', 643);
'osrpoint', 608,
'sp_log', 609,
'sp_guardconc', 610,
'sp_guardtype', 611,
'sp_guardcontconc', 612,
'sp_guardconttype', 613,
'sp_getarg_o', 614,
'sp_getarg_i', 615,
'sp_getarg_n', 616,
'sp_getarg_s', 617,
'sp_fastinvoke_v', 618,
'sp_fastinvoke_i', 619,
'sp_fastinvoke_n', 620,
'sp_fastinvoke_s', 621,
'sp_fastinvoke_o', 622,
'sp_namedarg_used', 623,
'sp_getspeshslot', 624,
'sp_findmeth', 625,
'sp_fastcreate', 626,
'sp_get_o', 627,
'sp_get_i', 628,
'sp_get_n', 629,
'sp_get_s', 630,
'sp_bind_o', 631,
'sp_bind_i', 632,
'sp_bind_n', 633,
'sp_bind_s', 634,
'sp_p6oget_o', 635,
'sp_p6ogetvt_o', 636,
'sp_p6ogetvc_o', 637,
'sp_p6oget_i', 638,
'sp_p6oget_n', 639,
'sp_p6oget_s', 640,
'sp_p6obind_o', 641,
'sp_p6obind_i', 642,
'sp_p6obind_n', 643,
'sp_p6obind_s', 644);
MAST::Ops.WHO<@names> := nqp::list('no_op',
'const_i8',
'const_i16',
Expand Down Expand Up @@ -4109,6 +4112,7 @@ BEGIN {
'param_on2_n',
'param_on2_s',
'param_on2_o',
'osrpoint',
'sp_log',
'sp_guardconc',
'sp_guardtype',
Expand Down
3 changes: 3 additions & 0 deletions src/core/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ void MVM_frame_invoke(MVMThreadContext *tc, MVMStaticFrame *static_frame,
/* Clear frame flags. */
frame->flags = 0;

/* Initialize OSR counter. */
frame->osr_counter = 0;

/* Update interpreter and thread context, so next execution will use this
* frame. */
tc->cur_frame = frame;
Expand Down
4 changes: 4 additions & 0 deletions src/core/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ struct MVMFrame {
* spesh_cand is set in this frame at all. */
MVMint8 spesh_log_idx;

/* On Stack Replacement iteration counter; incremented in loops, and will
* trigger if the limit is hit. */
MVMuint8 osr_counter;

#if MVM_HLL_PROFILE_CALLS
/* Index of the profile data record. */
MVMuint32 profile_index;
Expand Down
3 changes: 3 additions & 0 deletions src/core/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4362,6 +4362,9 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
}
goto NEXT;
}
OP(osrpoint):
tc->cur_frame->osr_counter++;
goto NEXT;
OP(sp_log):
if (tc->cur_frame->spesh_log_idx >= 0) {
MVM_ASSIGN_REF(tc, &(tc->cur_frame->static_info->common.header),
Expand Down
2 changes: 1 addition & 1 deletion src/core/oplabels.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ static const void * const LABELS[] = {
&&OP_param_on2_n,
&&OP_param_on2_s,
&&OP_param_on2_o,
&&OP_osrpoint,
&&OP_sp_log,
&&OP_sp_guardconc,
&&OP_sp_guardtype,
Expand Down Expand Up @@ -1024,7 +1025,6 @@ static const void * const LABELS[] = {
NULL,
NULL,
NULL,
NULL,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
&&OP_CALL_EXTOP,
Expand Down
1 change: 1 addition & 0 deletions src/core/oplist
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ param_on2_i w(int64) str str ins :noinline
param_on2_n w(num64) str str ins :noinline
param_on2_s w(str) str str ins :noinline
param_on2_o w(obj) str str ins :noinline
osrpoint :deoptonepoint

# Spesh ops. Naming convention: start with sp_. Must all be marked .s, which
# is how the validator knows to exclude them.
Expand Down
11 changes: 10 additions & 1 deletion src/core/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -6082,6 +6082,15 @@ static MVMOpInfo MVM_op_infos[] = {
1,
{ MVM_operand_write_reg | MVM_operand_obj, MVM_operand_str, MVM_operand_str, MVM_operand_ins }
},
{
MVM_OP_osrpoint,
"osrpoint",
" ",
0,
0,
1,
0,
},
{
MVM_OP_sp_log,
"sp_log",
Expand Down Expand Up @@ -6444,7 +6453,7 @@ static MVMOpInfo MVM_op_infos[] = {
},
};

static unsigned short MVM_op_counts = 644;
static unsigned short MVM_op_counts = 645;

MVMOpInfo * MVM_op_get_op(unsigned short op) {
if (op >= MVM_op_counts)
Expand Down
73 changes: 37 additions & 36 deletions src/core/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,42 +609,43 @@
#define MVM_OP_param_on2_n 605
#define MVM_OP_param_on2_s 606
#define MVM_OP_param_on2_o 607
#define MVM_OP_sp_log 608
#define MVM_OP_sp_guardconc 609
#define MVM_OP_sp_guardtype 610
#define MVM_OP_sp_guardcontconc 611
#define MVM_OP_sp_guardconttype 612
#define MVM_OP_sp_getarg_o 613
#define MVM_OP_sp_getarg_i 614
#define MVM_OP_sp_getarg_n 615
#define MVM_OP_sp_getarg_s 616
#define MVM_OP_sp_fastinvoke_v 617
#define MVM_OP_sp_fastinvoke_i 618
#define MVM_OP_sp_fastinvoke_n 619
#define MVM_OP_sp_fastinvoke_s 620
#define MVM_OP_sp_fastinvoke_o 621
#define MVM_OP_sp_namedarg_used 622
#define MVM_OP_sp_getspeshslot 623
#define MVM_OP_sp_findmeth 624
#define MVM_OP_sp_fastcreate 625
#define MVM_OP_sp_get_o 626
#define MVM_OP_sp_get_i 627
#define MVM_OP_sp_get_n 628
#define MVM_OP_sp_get_s 629
#define MVM_OP_sp_bind_o 630
#define MVM_OP_sp_bind_i 631
#define MVM_OP_sp_bind_n 632
#define MVM_OP_sp_bind_s 633
#define MVM_OP_sp_p6oget_o 634
#define MVM_OP_sp_p6ogetvt_o 635
#define MVM_OP_sp_p6ogetvc_o 636
#define MVM_OP_sp_p6oget_i 637
#define MVM_OP_sp_p6oget_n 638
#define MVM_OP_sp_p6oget_s 639
#define MVM_OP_sp_p6obind_o 640
#define MVM_OP_sp_p6obind_i 641
#define MVM_OP_sp_p6obind_n 642
#define MVM_OP_sp_p6obind_s 643
#define MVM_OP_osrpoint 608
#define MVM_OP_sp_log 609
#define MVM_OP_sp_guardconc 610
#define MVM_OP_sp_guardtype 611
#define MVM_OP_sp_guardcontconc 612
#define MVM_OP_sp_guardconttype 613
#define MVM_OP_sp_getarg_o 614
#define MVM_OP_sp_getarg_i 615
#define MVM_OP_sp_getarg_n 616
#define MVM_OP_sp_getarg_s 617
#define MVM_OP_sp_fastinvoke_v 618
#define MVM_OP_sp_fastinvoke_i 619
#define MVM_OP_sp_fastinvoke_n 620
#define MVM_OP_sp_fastinvoke_s 621
#define MVM_OP_sp_fastinvoke_o 622
#define MVM_OP_sp_namedarg_used 623
#define MVM_OP_sp_getspeshslot 624
#define MVM_OP_sp_findmeth 625
#define MVM_OP_sp_fastcreate 626
#define MVM_OP_sp_get_o 627
#define MVM_OP_sp_get_i 628
#define MVM_OP_sp_get_n 629
#define MVM_OP_sp_get_s 630
#define MVM_OP_sp_bind_o 631
#define MVM_OP_sp_bind_i 632
#define MVM_OP_sp_bind_n 633
#define MVM_OP_sp_bind_s 634
#define MVM_OP_sp_p6oget_o 635
#define MVM_OP_sp_p6ogetvt_o 636
#define MVM_OP_sp_p6ogetvc_o 637
#define MVM_OP_sp_p6oget_i 638
#define MVM_OP_sp_p6oget_n 639
#define MVM_OP_sp_p6oget_s 640
#define MVM_OP_sp_p6obind_o 641
#define MVM_OP_sp_p6obind_i 642
#define MVM_OP_sp_p6obind_n 643
#define MVM_OP_sp_p6obind_s 644

#define MVM_OP_EXT_BASE 1024
#define MVM_OP_EXT_CU_LIMIT 1024
Expand Down

0 comments on commit 6158f0b

Please sign in to comment.