Skip to content

Commit

Permalink
Add more expr JIT ops
Browse files Browse the repository at this point in the history
eqatic_s, eqatim_s, ordbaseat, uc, lc, tc, split, join, getcp_s,
indexcp_s, index_s, graphs_s, codes_s, substr_s, ordat, chr, getenvhash,
backendconfig coerce_si, equaticim_s, unicmp_s, indexicim_s,
getstrfromname, indexic_s

Move coerce_sI into a function so we are able to JIT it.
  • Loading branch information
samcv authored and bdw committed Jun 24, 2018
1 parent 10f915d commit a9c088c
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/core/interp.c
Expand Up @@ -2,7 +2,6 @@
#include <math.h>
#include "platform/time.h"
#include "platform/sys.h"
#include "strings/unicode_ops.h"

/* Macros for getting things from the bytecode stream. */
#if MVM_GC_DEBUG == 2
Expand Down Expand Up @@ -1655,7 +1654,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 4;
goto NEXT;
OP(chr):
GET_REG(cur_op, 0).s = MVM_string_chr(tc, (MVMCodepoint)GET_REG(cur_op, 2).i64);
GET_REG(cur_op, 0).s = MVM_string_chr(tc, GET_REG(cur_op, 2).i64);
cur_op += 4;
goto NEXT;
OP(ordfirst): {
Expand Down Expand Up @@ -3461,21 +3460,14 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
goto NEXT;
}
OP(coerce_sI): {
MVMString *s = GET_REG(cur_op, 2).s;
MVMObject *type = GET_REG(cur_op, 4).o;
char *buf = MVM_string_ascii_encode(tc, s, NULL, 0);
MVMObject *a = MVM_repr_alloc_init(tc, type);
MVM_bigint_from_str(tc, a, buf);
MVM_free(buf);
GET_REG(cur_op, 0).o = a;
GET_REG(cur_op, 0).o = MVM_coerce_sI(tc, GET_REG(cur_op, 2).s, GET_REG(cur_op, 4).o);
cur_op += 6;
goto NEXT;
}
OP(isbig_I): {
OP(isbig_I):
GET_REG(cur_op, 0).i64 = MVM_bigint_is_big(tc, GET_REG(cur_op, 2).o);
cur_op += 4;
goto NEXT;
}
OP(bool_I):
GET_REG(cur_op, 0).i64 = MVM_bigint_bool(tc, GET_REG(cur_op, 2).o);
cur_op += 4;
Expand Down Expand Up @@ -5971,6 +5963,8 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
MVM_cross_thread_write_check(tc, obj, blame);
goto NEXT;
}
/* The compiler compiles faster if all deprecated are together and at the end
* even though the op numbers are technically out of order. */
OP(DEPRECATED_4):
OP(DEPRECATED_5):
OP(DEPRECATED_6):
Expand Down
167 changes: 167 additions & 0 deletions src/jit/core_templates.expr
Expand Up @@ -211,13 +211,140 @@
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: eqatic_s
(call (^func &MVM_string_equal_at_ignore_case)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: eqatim_s
(call (^func &MVM_string_equal_at_ignore_mark)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: ordbaseat
(call (^func &MVM_string_ord_basechar_at)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 int)) int_sz))

(template: concat_s
(call (^func &MVM_string_concatenate)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)) ptr_sz))

(template: uc
(call (^func &MVM_string_uc)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) ptr_sz))

(template: lc
(call (^func &MVM_string_lc)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) ptr_sz))

(template: tc
(call (^func &MVM_string_tc)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) ptr_sz))

(template: split
(call (^func &MVM_string_split)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)) ptr_sz))

(template: join
(call (^func &MVM_string_join)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)) ptr_sz))

(template: getcp_s
(call (^func &MVM_string_get_grapheme_at)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 int)) int_sz))

(template: indexcp_s
(call (^func &MVM_string_index_of_grapheme)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 int)) int_sz))

(template: index_s
(call (^func &MVM_string_index)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: graphs_s
(call (^func &MVM_string_graphs)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) int_sz))

(template: codes_s
(call (^func &MVM_string_codes)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) int_sz))

(template: substr_s
(call (^func &MVM_string_substring)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 int)
(carg $3 int)) ptr_sz))

(template: ordat
(call (^func &MVM_string_ord_at)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 int)) int_sz))

(template: chr
(call (^func &MVM_string_chr)
(arglist
(carg (tc) ptr)
(carg $1 int)) ptr_sz))

(template: getenvhash
(call (^func &MVM_proc_getenvhash)
(arglist
(carg (tc) ptr)) ptr_sz))

(template: backendconfig
(call (^func &MVM_backend_config)
(arglist
(carg (tc) ptr)) ptr_sz))

(template: coerce_sI
(call (^func &MVM_coerce_sI)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)) ptr_sz))

(template: null (^vmnull))

(template: isnull
Expand Down Expand Up @@ -827,6 +954,46 @@
(arglist
(carg (tc) ptr)) ptr_sz))

(template: eqaticim_s
(call (^func &MVM_string_equal_at_ignore_case_ignore_mark)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: unicmp_s
(call (^func &MVM_unicode_string_compare)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)
(carg $4 int)
(carg $4 int)) int_sz))

(template: indexicim_s
(call (^func &MVM_string_index_ignore_case_ignore_mark)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: getstrfromname
(call (^func &MVM_unicode_string_from_name)
(arglist
(carg (tc) ptr)
(carg $1 ptr)) ptr_sz))

(template: indexic_s
(call (^func &MVM_string_index_ignore_case)
(arglist
(carg (tc) ptr)
(carg $1 ptr)
(carg $2 ptr)
(carg $3 int)) int_sz))

(template: slice!
(let: (
($dest (call (^getf (^repr $1) MVMREPROps allocate)
Expand Down
7 changes: 7 additions & 0 deletions src/math/bigintops.c
Expand Up @@ -841,6 +841,13 @@ void MVM_bigint_from_str(MVMThreadContext *tc, MVMObject *a, const char *buf) {
body->u.bigint = i;
}
}
MVMObject * MVM_coerce_sI(MVMThreadContext *tc, MVMString *s, MVMObject *type) {
char *buf = MVM_string_ascii_encode(tc, s, NULL, 0);
MVMObject *a = MVM_repr_alloc_init(tc, type);
MVM_bigint_from_str(tc, a, buf);
MVM_free(buf);
return a;
}

MVMObject * MVM_bigint_from_bigint(MVMThreadContext *tc, MVMObject *result_type, MVMObject *a) {
MVMP6bigintBody *a_body;
Expand Down
1 change: 1 addition & 0 deletions src/math/bigintops.h
Expand Up @@ -38,3 +38,4 @@ MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a, MVMint64 b);
MVMObject * MVM_bigint_radix(MVMThreadContext *tc, MVMint64 radix, MVMString *str, MVMint64 offset, MVMint64 flag, MVMObject *type);
MVMint64 MVM_bigint_is_big(MVMThreadContext *tc, MVMObject *a);
MVMint64 MVM_bigint_bool(MVMThreadContext *tc, MVMObject *a);
MVMObject * MVM_coerce_sI(MVMThreadContext *tc, MVMString *s, MVMObject *type);
1 change: 1 addition & 0 deletions src/moar.h
Expand Up @@ -178,6 +178,7 @@ MVM_PUBLIC const MVMint32 MVM_jit_support(void);
#include "strings/latin1.h"
#include "strings/windows1252.h"
#include "strings/shiftjis.h"
#include "strings/unicode_ops.h"
#include "io/io.h"
#include "io/eventloop.h"
#include "io/syncfile.h"
Expand Down

0 comments on commit a9c088c

Please sign in to comment.