Skip to content

Commit

Permalink
Merge branch 'master' into grapheme_iterator_cached
Browse files Browse the repository at this point in the history
  • Loading branch information
samcv committed Sep 3, 2017
2 parents 75d2b28 + d65be80 commit fec81bb
Show file tree
Hide file tree
Showing 29 changed files with 55,449 additions and 49,753 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Expand Up @@ -36,6 +36,7 @@ addons:
- llvm-5.0
- expect
- libffi-dev
- gdb

before_script:
- echo "Begin ‘before_script’ section of .travis.yml"
Expand Down Expand Up @@ -64,15 +65,19 @@ before_script:

script:
- echo "Begin ‘script’ section of .travis.yml"
# Enable coredumps
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then ulimit -c unlimited; fi
- export MOAR_PREFIX="/tmp/moar"; export MOAR_FOLDER="$TRAVIS_BUILD_DIR"
- export NQP_FOLDER="$(resolve_folder ./nqp)"
# Set location for core dumps
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo bash -c "echo \"${MOAR_PREFIX}/core.%p.%E\" > /proc/sys/kernel/core_pattern"; sudo cat /proc/sys/kernel/core_pattern; fi
- echo "perl Configure.pl --prefix=$MOAR_PREFIX $MVM_OPTIONS --cc=\"$CC\" $MVM_debug $MVM_optimize;"
- perl Configure.pl --prefix=$MOAR_PREFIX $MVM_OPTIONS --cc="$CC" $MVM_debug $MVM_optimize;
- make install;
- cd -- "$NQP_FOLDER";
- echo "perl Configure.pl --prefix=$MOAR_PREFIX --backends=moar;"
- perl Configure.pl --prefix=$MOAR_PREFIX --backends=moar;
- make;
- make
- make test;
- cd -- "$MOAR_FOLDER"
- if [ "$COVERAGE" ]; then git clone --depth 1 'https://github.com/samcv/MoarVM-cover.git' && cp -v MoarVM-cover/html-cover.sh . && cp -v MoarVM-cover/nqp-profile ./nqp/ && cp -v MoarVM-cover/merge-profraw.sh ./nqp/ && ./html-cover.sh 2; fi
Expand All @@ -83,8 +88,10 @@ after_success:
- if [ "$COVERAGE" ]; then ./tools/update-gh-pages.sh; fi

after_failure:
# On failure, dump all ENV vars, in case we need to look at them
# On failure, dump all ENV vars, in case we need to look at them (doesn't print if our secrets are defined)
- if [ ! "$encrypted_b77ce3a1cc5c_key" ] && [ ! "$encrypted_b77ce3a1cc5c_iv" ]; then printenv; fi
# If we have any coredumps, print out the traces with gdb
- for i in $(find "${MOAR_PREFIX}" -maxdepth 1 -name 'core*' -print); do gdb "${MOAR_PREFIX}/bin/moar" "${i}" -ex "thread apply all bt" -ex "set pagination 0" -batch; done;

branches:
only:
Expand Down
16 changes: 8 additions & 8 deletions src/6model/reprs/Decoder.c
Expand Up @@ -156,7 +156,7 @@ void MVM_decoder_set_separators(MVMThreadContext *tc, MVMDecoder *decoder, MVMOb
STABLE(seps)).boxed_primitive == MVM_STORAGE_SPEC_BP_STR;
get_ds(tc, decoder); /* Ensure we're sufficiently initialized. */
if (is_str_array) {
MVMString **c_seps;
MVMString **c_seps = NULL;
MVMuint64 i;
MVMuint64 num_seps = MVM_repr_elems(tc, seps);
if (num_seps > 0xFFFFFF)
Expand All @@ -181,7 +181,7 @@ void MVM_decoder_add_bytes(MVMThreadContext *tc, MVMDecoder *decoder, MVMObject
if (REPR(buffer)->ID == MVM_REPR_ID_VMArray) {
/* To be safe, we need to make a copy of data in a resizable array; it
* may change/move under us. */
char *output, *copy;
char *output = NULL, *copy = NULL;
MVMint64 output_size;
switch (((MVMArrayREPRData *)STABLE(buffer)->REPR_data)->slot_type) {
case MVM_ARRAY_U8:
Expand Down Expand Up @@ -218,7 +218,7 @@ void MVM_decoder_add_bytes(MVMThreadContext *tc, MVMDecoder *decoder, MVMObject
* is not enough. */
MVMString * MVM_decoder_take_chars(MVMThreadContext *tc, MVMDecoder *decoder, MVMint64 chars,
MVMint64 eof) {
MVMString *result;
MVMString *result = NULL;
enter_single_user(tc, decoder);
MVMROOT(tc, decoder, {
result = MVM_string_decodestream_get_chars(tc, get_ds(tc, decoder), (MVMint32)chars, eof);
Expand All @@ -229,7 +229,7 @@ MVMString * MVM_decoder_take_chars(MVMThreadContext *tc, MVMDecoder *decoder, MV

/* Takes all chars from the decoder. */
MVMString * MVM_decoder_take_all_chars(MVMThreadContext *tc, MVMDecoder *decoder) {
MVMString *result;
MVMString *result = NULL;
enter_single_user(tc, decoder);
MVMROOT(tc, decoder, {
result = MVM_string_decodestream_get_all(tc, get_ds(tc, decoder));
Expand All @@ -240,7 +240,7 @@ MVMString * MVM_decoder_take_all_chars(MVMThreadContext *tc, MVMDecoder *decoder

/* Takes all available chars from the decoder. */
MVMString * MVM_decoder_take_available_chars(MVMThreadContext *tc, MVMDecoder *decoder) {
MVMString *result;
MVMString *result = NULL;
enter_single_user(tc, decoder);
MVMROOT(tc, decoder, {
result = MVM_string_decodestream_get_available(tc, get_ds(tc, decoder));
Expand All @@ -254,7 +254,7 @@ MVMString * MVM_decoder_take_line(MVMThreadContext *tc, MVMDecoder *decoder,
MVMint64 chomp, MVMint64 incomplete_ok) {
MVMDecodeStream *ds = get_ds(tc, decoder);
MVMDecodeStreamSeparators *sep_spec = get_sep_spec(tc, decoder);
MVMString *result;
MVMString *result = NULL;
enter_single_user(tc, decoder);
MVMROOT(tc, decoder, {
result = incomplete_ok
Expand All @@ -280,9 +280,9 @@ MVMint64 MVM_decoder_bytes_available(MVMThreadContext *tc, MVMDecoder *decoder)
MVMObject * MVM_decoder_take_bytes(MVMThreadContext *tc, MVMDecoder *decoder,
MVMObject *buf_type, MVMint64 bytes) {
MVMDecodeStream *ds = get_ds(tc, decoder);
char *buf;
char *buf = NULL;
MVMint64 read;
MVMObject *result;
MVMObject *result = NULL;

/* Ensure the target is in the correct form. */
if (REPR(buf_type)->ID != MVM_REPR_ID_VMArray)
Expand Down
2 changes: 1 addition & 1 deletion src/6model/reprs/MVMSpeshLog.h
Expand Up @@ -65,7 +65,7 @@ struct MVMSpeshLogEntry {
struct {
MVMStaticFrame *sf;
MVMint16 caller_is_outer;
MVMint16 was_multi;
MVMuint16 was_multi;
MVMint32 bytecode_offset;
} invoke;

Expand Down
7 changes: 3 additions & 4 deletions src/6model/reprs/NFA.c
Expand Up @@ -107,10 +107,9 @@ static void serialize(MVMThreadContext *tc, MVMSTable *st, void *data, MVMSerial
* and then each of the codepoints. */
MVMNFGSynthetic *si = MVM_nfg_get_synthetic_info(tc, g);
MVMint32 k;
MVM_serialization_write_int(tc, writer, -(si->num_combs + 1));
MVM_serialization_write_int(tc, writer, si->base);
for (k = 0; k < si->num_combs; k++)
MVM_serialization_write_int(tc, writer, si->combs[k]);
MVM_serialization_write_int(tc, writer, -(si->num_codes));
for (k = 0; k < si->num_codes; k++)
MVM_serialization_write_int(tc, writer, si->codes[k]);
}
break;
}
Expand Down
7 changes: 3 additions & 4 deletions src/core/coerce.c
Expand Up @@ -149,18 +149,17 @@ static void flip_return(MVMThreadContext *tc, void *sr_data) {
MVMString * MVM_coerce_i_s(MVMThreadContext *tc, MVMint64 i) {
char buffer[64];
int len;

/* See if we can hit the cache. */
int cache = i >= 0 && i < MVM_INT_TO_STR_CACHE_SIZE;
int cache = 0 <= i && i < MVM_INT_TO_STR_CACHE_SIZE;
if (cache) {
MVMString *cached = tc->instance->int_to_str_cache[i];
if (cached)
return cached;
}

/* Otherwise, need to do the work; cache it if in range. */
len = snprintf(buffer, 64, "%lld", (long long int)i);
if (len >= 0) {
len = snprintf(buffer, 64, "%"PRIi64"", i);
if (0 <= len) {
MVMString *result = MVM_string_ascii_decode(tc, tc->instance->VMString, buffer, len);
if (cache)
tc->instance->int_to_str_cache[i] = result;
Expand Down
19 changes: 13 additions & 6 deletions src/core/interp.c
Expand Up @@ -15,6 +15,10 @@ MVM_STATIC_INLINE MVMuint16 check_reg(MVMThreadContext *tc, MVMRegister *reg_bas
MVM_ASSERT_NOT_FROMSPACE(tc, reg_base[idx].o);
return idx;
}
/* The bytecode stream is OPs (16 bit numbers) followed by the (16 bit numbers) of the registers
* the OP needs (return register + argument registers. The pc will point to the first place after
* the current op, i.e. the first 16 bit register number. We add the requested number to that and
* use the result as index into the reg_base array which stores the frame's locals. */
#define GET_REG(pc, idx) reg_base[check_reg(tc, reg_base, *((MVMuint16 *)(pc + idx)))]
#else
#define GET_REG(pc, idx) reg_base[*((MVMuint16 *)(pc + idx))]
Expand Down Expand Up @@ -58,7 +62,8 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
#include "oplabels.h"
#endif

/* Points to the current opcode. */
/* Points to the place in the bytecode right after the current opcode. */
/* See the NEXT_OP macro for making sense of this */
MVMuint8 *cur_op = NULL;

/* The current frame's bytecode start. */
Expand Down Expand Up @@ -892,11 +897,13 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
{
MVMObject *code = GET_REG(cur_op, 0).o;
MVMRegister *args = tc->cur_frame->args;
MVMint16 was_multi = 0;
MVMuint16 was_multi = 0;
/* was_multi argument is MVMuint16* */
code = MVM_frame_find_invokee_multi_ok(tc, code, &cur_callsite, args,
&was_multi);
if (MVM_spesh_log_is_logging(tc)) {
MVMROOT(tc, code, {
/* was_multi is MVMint16 */
MVM_spesh_log_invoke_target(tc, code, was_multi);
});
}
Expand All @@ -911,7 +918,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
{
MVMObject *code = GET_REG(cur_op, 2).o;
MVMRegister *args = tc->cur_frame->args;
MVMint16 was_multi = 0;
MVMuint16 was_multi = 0;
code = MVM_frame_find_invokee_multi_ok(tc, code, &cur_callsite, args,
&was_multi);
if (MVM_spesh_log_is_logging(tc)) {
Expand All @@ -930,7 +937,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
{
MVMObject *code = GET_REG(cur_op, 2).o;
MVMRegister *args = tc->cur_frame->args;
MVMint16 was_multi = 0;
MVMuint16 was_multi = 0;
code = MVM_frame_find_invokee_multi_ok(tc, code, &cur_callsite, args,
&was_multi);
if (MVM_spesh_log_is_logging(tc)) {
Expand All @@ -949,7 +956,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
{
MVMObject *code = GET_REG(cur_op, 2).o;
MVMRegister *args = tc->cur_frame->args;
MVMint16 was_multi = 0;
MVMuint16 was_multi = 0;
code = MVM_frame_find_invokee_multi_ok(tc, code, &cur_callsite, args,
&was_multi);
if (MVM_spesh_log_is_logging(tc)) {
Expand All @@ -968,7 +975,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
{
MVMObject *code = GET_REG(cur_op, 2).o;
MVMRegister *args = tc->cur_frame->args;
MVMint16 was_multi = 0;
MVMuint16 was_multi = 0;
code = MVM_frame_find_invokee_multi_ok(tc, code, &cur_callsite, args,
&was_multi);
if (MVM_spesh_log_is_logging(tc)) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/nativecall.c
Expand Up @@ -365,7 +365,7 @@ static const char *dlerror(void)
DWORD dw = GetLastError();
if (dw == 0)
return NULL;
sprintf(buf, "error 0x%x", (unsigned int)dw);
snprintf(buf, 32, "error 0x%"PRIx32"", (MVMuint32)dw);
return buf;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/gc/debug.h
Expand Up @@ -18,5 +18,5 @@
} \
} while (0)
#else
#define MVM_ASSERT_NOT_FROMSPACE
#define MVM_ASSERT_NOT_FROMSPACE(tc, c)
#endif
42 changes: 42 additions & 0 deletions src/jit/graph.c
Expand Up @@ -320,6 +320,9 @@ static void * op_to_func(MVMThreadContext *tc, MVMint16 opcode) {
case MVM_OP_fc: return MVM_string_fc;
case MVM_OP_eq_s: return MVM_string_equal;
case MVM_OP_eqat_s: return MVM_string_equal_at;
case MVM_OP_eqatic_s: return MVM_string_equal_at_ignore_case;
case MVM_OP_eqatim_s: return MVM_string_equal_at_ignore_mark;
case MVM_OP_eqaticim_s: return MVM_string_equal_at_ignore_case_ignore_mark;
case MVM_OP_chars: case MVM_OP_graphs_s: return MVM_string_graphs;
case MVM_OP_chr: return MVM_string_chr;
case MVM_OP_codes_s: return MVM_string_codes;
Expand Down Expand Up @@ -2403,6 +2406,45 @@ static MVMint32 jgb_consume_ins(MVMThreadContext *tc, JitGraphBuilder *jgb,
MVM_JIT_RV_INT, dst);
break;
}
case MVM_OP_eqatic_s: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 src_a = ins->operands[1].reg.orig;
MVMint16 src_b = ins->operands[2].reg.orig;
MVMint16 offset = ins->operands[3].reg.orig;
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, { MVM_JIT_INTERP_TC } },
{ MVM_JIT_REG_VAL, { src_a } },
{ MVM_JIT_REG_VAL, { src_b } },
{ MVM_JIT_REG_VAL, { offset } } };
jgb_append_call_c(tc, jgb, op_to_func(tc, op), 4, args,
MVM_JIT_RV_INT, dst);
break;
}
case MVM_OP_eqatim_s: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 src_a = ins->operands[1].reg.orig;
MVMint16 src_b = ins->operands[2].reg.orig;
MVMint16 offset = ins->operands[3].reg.orig;
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, { MVM_JIT_INTERP_TC } },
{ MVM_JIT_REG_VAL, { src_a } },
{ MVM_JIT_REG_VAL, { src_b } },
{ MVM_JIT_REG_VAL, { offset } } };
jgb_append_call_c(tc, jgb, op_to_func(tc, op), 4, args,
MVM_JIT_RV_INT, dst);
break;
}
case MVM_OP_eqaticim_s: {
MVMint16 dst = ins->operands[0].reg.orig;
MVMint16 src_a = ins->operands[1].reg.orig;
MVMint16 src_b = ins->operands[2].reg.orig;
MVMint16 offset = ins->operands[3].reg.orig;
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, { MVM_JIT_INTERP_TC } },
{ MVM_JIT_REG_VAL, { src_a } },
{ MVM_JIT_REG_VAL, { src_b } },
{ MVM_JIT_REG_VAL, { offset } } };
jgb_append_call_c(tc, jgb, op_to_func(tc, op), 4, args,
MVM_JIT_RV_INT, dst);
break;
}
case MVM_OP_chars:
case MVM_OP_graphs_s:
case MVM_OP_codes_s:
Expand Down
5 changes: 3 additions & 2 deletions src/jit/log.c
Expand Up @@ -15,9 +15,10 @@ void MVM_jit_log_bytecode(MVMThreadContext *tc, MVMJitCode *code) {
* bytes, moar-jit-.bin is 13 bytes, one byte for the zero at the
* end, one byte for the directory separator is 25 bytes, plus the
* length of the bytecode directory itself */
char * filename = MVM_malloc(strlen(tc->instance->jit_bytecode_dir) + 25);
size_t filename_size = strlen(tc->instance->jit_bytecode_dir) + 25;
char * filename = MVM_malloc(filename_size);
FILE * out;
sprintf(filename, "%s/moar-jit-%04d.bin", tc->instance->jit_bytecode_dir, code->seq_nr);
snprintf(filename, filename_size, "%s/moar-jit-%04d.bin", tc->instance->jit_bytecode_dir, code->seq_nr);
out = fopen(filename, "w");
if (out) {
fwrite(code->func_ptr, sizeof(char), code->size, out);
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Expand Up @@ -5,14 +5,14 @@

#if MVM_TRACING
# define TRACING_OPT "[--tracing] "
# define TRACING_USAGE "\n --tracing output a line to stderr on every interpreter instr"
# define TRACING_USAGE "\n --tracing output a line to stderr on every interpreter instr"
#else
# define TRACING_OPT ""
# define TRACING_USAGE ""
#endif

#ifdef HAVE_TELEMEH
# define TELEMEH_USAGE "MVM_TELEMETRY_LOG Log internal events at high precision to this file\n"
# define TELEMEH_USAGE " MVM_TELEMETRY_LOG Log internal events at high precision to this file\n"
#else
# define TELEMEH_USAGE ""
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/moar.c
Expand Up @@ -239,8 +239,9 @@ MVMInstance * MVM_vm_create_instance(void) {
instance->jit_log_fh = fopen_perhaps_with_pid(jit_log, "w");
jit_bytecode_dir = getenv("MVM_JIT_BYTECODE_DIR");
if (jit_bytecode_dir && jit_bytecode_dir[0]) {
char *bytecode_map_name = MVM_malloc(strlen(jit_bytecode_dir) + strlen("/jit-map.txt") + 1);
sprintf(bytecode_map_name, "%s/jit-map.txt", jit_bytecode_dir);
size_t bytecode_map_name_size = strlen(jit_bytecode_dir) + strlen("/jit-map.txt") + 1;
char *bytecode_map_name = MVM_malloc(bytecode_map_name_size);
snprintf(bytecode_map_name, bytecode_map_name_size, "%s/jit-map.txt", jit_bytecode_dir);
instance->jit_bytecode_map = fopen(bytecode_map_name, "w");
instance->jit_bytecode_dir = jit_bytecode_dir;
MVM_free(bytecode_map_name);
Expand Down
2 changes: 1 addition & 1 deletion src/spesh/dump.c
Expand Up @@ -324,7 +324,7 @@ static void dump_bb(MVMThreadContext *tc, DumpStr *ds, MVMSpeshGraph *g, MVMSpes
append(ds, " Successors: ");
for (i = 0; i < bb->num_succ; i++)
appendf(ds, (i == 0 ? "%d" : ", %d"), bb->succ[i]->idx);
append(ds, "\n Predeccessors: ");
append(ds, "\n Predecessors: ");
for (i = 0; i < bb->num_pred; i++)
appendf(ds, (i == 0 ? "%d" : ", %d"), bb->pred[i]->idx);
append(ds, "\n Dominance children: ");
Expand Down

0 comments on commit fec81bb

Please sign in to comment.