Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .buildbot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ cd ..

YK_BUILD_TYPE=release-with-asserts make -j "$(nproc)" V=1
# FIXME: add tests once upstream test has been fixed. See above.

# Check it builds with debug strings.
make clean
YK_BUILD_TYPE=release-with-asserts make -j "$(nproc)" V=1 \
CFLAGS_EXTRA=-DYKMP_DEBUG_STRS=1
# FIXME: add tests once upstream test has been fixed. See above.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ $ make submodules
Then to build with yk support, do:

```
PATH=/path/to/yk/bin:$PATH YK_BUILD_TYPE=<debug|release|...> V=1
PATH=/path/to/yk/bin:$PATH YK_BUILD_TYPE=<debug|release|...> make V=1
```

(To build with yk debug string support, add
`CFLAGS_EXTRA="-DYKMP_DEBUG_STRS=1"` at the end of the `make` invocation)

Then the vm executable can be found at `./build-standard/micropython`.

## yk-related tips
Expand Down
9 changes: 6 additions & 3 deletions ports/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ INC += -I$(TOP)
INC += -I$(BUILD)

# compiler settings
ifneq ($(strip $(YK_BUILD_TYPE)),)
ifeq ($(strip $(YK_BUILD_TYPE)),)
YK_CFLAGS=
YK_LDFLAGS=
else
CC= `yk-config ${YK_BUILD_TYPE} --cc`
AR= `yk-config ${YK_BUILD_TYPE} --ar` rcu
RANLIB= `yk-config ${YK_BUILD_TYPE} --ranlib`
CFLAGS_EXTRA+= `yk-config ${YK_BUILD_TYPE} --cflags --cppflags` -DUSE_YK
LDFLAGS_EXTRA+= `yk-config ${YK_BUILD_TYPE} --ldflags` \
CFLAGS+= `yk-config ${YK_BUILD_TYPE} --cflags --cppflags` -DUSE_YK
LDFLAGS+= `yk-config ${YK_BUILD_TYPE} --ldflags` \
`yk-config ${YK_BUILD_TYPE} --libs` -lm
endif

Expand Down
25 changes: 25 additions & 0 deletions py/emitbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,28 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
// If we are jitting, assign locations.
// XXX: figure out where to free this.
YkLocation *yklocs = m_new(YkLocation, bytecode_len);
#ifdef YKMP_DEBUG_STRS
// XXX: figure out where to free this.
char **ykdstrs = m_new(char *, bytecode_len);
#endif

// Initialise all positions with null locations to start with.
for (size_t idx = 0; idx < emit->code_info_size + emit->bytecode_size;
idx++) {
yklocs[idx] = yk_location_null();

#ifdef YKMP_DEBUG_STRS
if (idx >= emit->code_info_size) {
size_t bcoff = idx - emit->code_info_size;
char *dstr;
// XXX Figure out where to free these allocations.
if (asprintf(&dstr, "PC=%zu", bcoff) == -1) {
mp_raise_msg(&mp_type_RuntimeError,
MP_ERROR_TEXT("asprintf failed"));
}
ykdstrs[idx] = dstr;
}
#endif
}
// Then overwrite places traces can start with proper locations.
// XXX: instructions are variable length -- because here we simply bump
Expand All @@ -450,6 +468,10 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
if ((mp_int_t)slab < 0) {
const byte *target_ip = ip + slab;
yklocs[target_ip - emit->code_base] = yk_location_new();
#ifdef YKMP_DEBUG_STRS
yk_location_set_debug_str(&yklocs[target_ip - emit->code_base],
ykdstrs[target_ip - emit->code_base]);
#endif
continue;
}
}
Expand All @@ -464,6 +486,9 @@ bool mp_emit_bc_end_pass(emit_t *emit) {
#endif
#ifdef USE_YK
yklocs,
#ifdef YKMP_DEBUG_STRS
ykdstrs,
#endif
#endif
emit->scope->scope_flags);
}
Expand Down
6 changes: 6 additions & 0 deletions py/emitglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
#endif
#ifdef USE_YK
YkLocation *yklocs,
#ifdef YKMP_DEBUG_STRS
char **ykdstrs,
#endif
#endif
uint16_t scope_flags) {

Expand All @@ -77,6 +80,9 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
rc->fun_data = code;
#ifdef USE_YK
rc->yklocs = yklocs;
#ifdef YKMP_DEBUG_STRS
rc->ykdstrs = ykdstrs;
#endif
#endif
rc->children = children;

Expand Down
6 changes: 6 additions & 0 deletions py/emitglue.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ typedef struct _mp_raw_code_t {
const void *fun_data;
#ifdef USE_YK
YkLocation *yklocs;
#ifdef YKMP_DEBUG_STRS
char **ykdstrs;
#endif
#endif
struct _mp_raw_code_t **children;
#if MICROPY_PERSISTENT_CODE_SAVE
Expand Down Expand Up @@ -137,6 +140,9 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
#endif
#ifdef USE_YK
YkLocation *yklocs,
#ifdef YKMP_DEBUG_STRS
char **ykdstrs,
#endif
#endif
uint16_t scope_flags);

Expand Down
3 changes: 3 additions & 0 deletions py/persistentcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ static mp_raw_code_t *load_raw_code(mp_reader_t *reader, mp_module_context_t *co
#endif
#ifdef USE_YK
NULL,
#ifdef YKMP_DEBUG_STRS
NULL,
#endif
#endif
scope_flags);

Expand Down
6 changes: 6 additions & 0 deletions py/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ FRAME_SETUP();

#ifdef USE_YK
YkLocation *yklocs = code_state->fun_bc->rc->yklocs;
#ifdef YKMP_DEBUG_STRS
char **ykdstrs = code_state->fun_bc->rc->ykdstrs;
#endif
#endif

// outer exception handling loop
Expand Down Expand Up @@ -352,6 +355,9 @@ FRAME_SETUP();
yk_mt_control_point(mp_state_ctx.vm.ykmt, &yklocs[locidx]);
ip = (const byte *) yk_promote((void *) ip);
byte opcode = load_inst(ip++);
#ifdef YKMP_DEBUG_STRS
yk_debug_str(ykdstrs[locidx]);
#endif
#else
byte opcode = *ip++;
#endif
Expand Down