Skip to content

Commit

Permalink
Fix 32 bit implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Nov 8, 2017
1 parent 4288b0e commit a56f99e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/interpreter-stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ uintptr_t __stop_jl_interpreter_frame = (uintptr_t)&__stop_jl_interpreter_frame_
#warning "Interpreter backtraces not implemented for this platform"
#endif

#define STR(x) #x
#define XSTR(x) STR(x)

// This function is special. The unwinder looks for this function to find interpreter
// stack frames.
#ifdef _CPU_X86_64_

#define STR(x) #x
#define XSTR(x) STR(x)

// Instructions: Make sure that MAX_INTERP_STATE_SIZE is a multiple of
// alignof(struct interpreter_state) and larger than
// sizeof(struct interpreter_state). Additionally, make sure that
Expand Down Expand Up @@ -127,10 +126,12 @@ asm(
#define STACK_PADDING 4
#endif

static_assert(sizeof(interpreter_state) <= MAX_INTERP_STATE_SIZE, "Update assembly code above");
static_assert(MAX_INTERP_STATE_SIZE % alignof(interpreter_state) == 0, "Update assembly code above");
size_t TOTAL_STACK_PADDING = STACK_PADDING;

static_assert(sizeof(interpreter_state) <= MAX_INTERP_STATE_SIZE, "Stack layout invariants violated");
static_assert(MAX_INTERP_STATE_SIZE % alignof(interpreter_state) == 0, "Stack layout invariants violated");
#ifndef _OS_WINDOWS_
static_assert(MAX_INTERP_STATE_SIZE + STACK_PADDING % 16 == 0, "Update assembly code above");
static_assert((MAX_INTERP_STATE_SIZE + STACK_PADDING + 4) % 16 == 0, "Stack layout invariants violated");
#endif

asm(
Expand Down Expand Up @@ -182,8 +183,8 @@ asm(
// Restore 16 byte stack alignment
// Technically not necessary on windows, because we don't assume this
// alignment, but let's be nice if we ever start doing that.
"\tsubl $" STACK_PADDING ", %esp\n"
".cfi_def_cfa_offset " XSTR(MAX_INTERP_STATE_SIZE) " + " XSTR(ENTRY_OFFSET) "\n"
"\tsubl $" XSTR(STACK_PADDING) ", %esp\n"
".cfi_def_cfa_offset " XSTR(STACK_PADDING) " + " XSTR(MAX_INTERP_STATE_SIZE) " + " XSTR(ENTRY_OFFSET) "\n"
"Lenter_interpreter_frame_start_val:\n"
"\tcalll *%eax\n"
"Lenter_interpreter_frame_end_val:\n"
Expand Down

0 comments on commit a56f99e

Please sign in to comment.