mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Revert "Make sure sandbox stack grows upwards in big-endian libretro builds"
This reverts commit 58e6f71ef3
.
The original behaviour was the correct one. The stack should always grow
downwards.
This commit is contained in:
parent
87eea255c5
commit
7347afed21
2 changed files with 4 additions and 29 deletions
|
@ -289,13 +289,7 @@ namespace mkxp_sandbox {
|
||||||
fiber->stack.pop_back();
|
fiber->stack.pop_back();
|
||||||
}
|
}
|
||||||
++fiber->stack_index;
|
++fiber->stack_index;
|
||||||
b.stack_ptr = w2c_ruby_rb_wasm_get_stack_pointer(&b.instance())
|
b.stack_ptr = w2c_ruby_rb_wasm_get_stack_pointer(&b.instance()) - CEIL_WASMSTACKALIGN(declared_slots_size<T>::value);
|
||||||
#ifdef MKXPZ_BIG_ENDIAN
|
|
||||||
+
|
|
||||||
#else
|
|
||||||
-
|
|
||||||
#endif // MKXPZ_BIG_ENDIAN
|
|
||||||
CEIL_WASMSTACKALIGN(declared_slots_size<T>::value);
|
|
||||||
assert(b.stack_ptr % sizeof(VALUE) == 0);
|
assert(b.stack_ptr % sizeof(VALUE) == 0);
|
||||||
assert(b.stack_ptr % WASMSTACKALIGN == 0);
|
assert(b.stack_ptr % WASMSTACKALIGN == 0);
|
||||||
if (declared_slots_size<T>::value != 0) {
|
if (declared_slots_size<T>::value != 0) {
|
||||||
|
@ -339,16 +333,7 @@ namespace mkxp_sandbox {
|
||||||
|
|
||||||
assert(fiber->stack.size() == fiber->stack_index);
|
assert(fiber->stack.size() == fiber->stack_index);
|
||||||
|
|
||||||
w2c_ruby_rb_wasm_set_stack_pointer(
|
w2c_ruby_rb_wasm_set_stack_pointer(&bind->instance(), fiber->stack.back().stack_ptr + CEIL_WASMSTACKALIGN(declared_slots_size<T>::value));
|
||||||
&bind->instance(),
|
|
||||||
fiber->stack.back().stack_ptr
|
|
||||||
#ifdef MKXPZ_BIG_ENDIAN
|
|
||||||
-
|
|
||||||
#else
|
|
||||||
+
|
|
||||||
#endif // MKXPZ_BIG_ENDIAN
|
|
||||||
CEIL_WASMSTACKALIGN(declared_slots_size<T>::value)
|
|
||||||
);
|
|
||||||
bind->stack_ptr = fiber->stack.back().stack_ptr;
|
bind->stack_ptr = fiber->stack.back().stack_ptr;
|
||||||
fiber->stack.pop_back();
|
fiber->stack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,16 +269,6 @@ PRELUDE = <<~HEREDOC
|
||||||
|
|
||||||
bindings::bindings(std::shared_ptr<struct w2c_#{MODULE_NAME}> m) : binding_base(m) {}
|
bindings::bindings(std::shared_ptr<struct w2c_#{MODULE_NAME}> m) : binding_base(m) {}
|
||||||
|
|
||||||
static wasm_ptr_t _sbindgen_stack_push(wasm_ptr_t frame_pointer, wasm_size_t num_bytes) {
|
|
||||||
return frame_pointer
|
|
||||||
#ifdef MKXPZ_BIG_ENDIAN
|
|
||||||
+
|
|
||||||
#else
|
|
||||||
-
|
|
||||||
#endif // MKXPZ_BIG_ENDIAN
|
|
||||||
num_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _sbindgen_strcpy(char *dst, const char *src) {
|
static void _sbindgen_strcpy(char *dst, const char *src) {
|
||||||
#ifdef MKXPZ_BIG_ENDIAN
|
#ifdef MKXPZ_BIG_ENDIAN
|
||||||
do {
|
do {
|
||||||
|
@ -522,7 +512,7 @@ File.readlines('tags', chomp: true).each do |line|
|
||||||
coroutine_initializer += <<~HEREDOC
|
coroutine_initializer += <<~HEREDOC
|
||||||
{
|
{
|
||||||
wasm_ptr_t fp = w2c_ruby_rb_wasm_get_stack_pointer(&bind.instance());
|
wasm_ptr_t fp = w2c_ruby_rb_wasm_get_stack_pointer(&bind.instance());
|
||||||
wasm_ptr_t sp = _sbindgen_stack_push(fp, CEIL_WASMSTACKALIGN(a#{args.length - 2} * sizeof(VALUE)));
|
wasm_ptr_t sp = fp - CEIL_WASMSTACKALIGN(a#{args.length - 2} * sizeof(VALUE));
|
||||||
if (sp > fp) {
|
if (sp > fp) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
@ -549,7 +539,7 @@ File.readlines('tags', chomp: true).each do |line|
|
||||||
do ++n; while (va_arg(b, VALUE));
|
do ++n; while (va_arg(b, VALUE));
|
||||||
va_end(b);
|
va_end(b);
|
||||||
wasm_ptr_t fp = w2c_ruby_rb_wasm_get_stack_pointer(&bind.instance());
|
wasm_ptr_t fp = w2c_ruby_rb_wasm_get_stack_pointer(&bind.instance());
|
||||||
wasm_ptr_t sp = _sbindgen_stack_push(fp, CEIL_WASMSTACKALIGN(n * sizeof(VALUE)));
|
wasm_ptr_t sp = fp - CEIL_WASMSTACKALIGN(n * sizeof(VALUE));
|
||||||
if (sp > fp) {
|
if (sp > fp) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue