mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[Simulator] Fix MicroPython in Web simulator and update to Emscripten 3.1.30
This commit is contained in:
@@ -279,6 +279,8 @@ Q(popitem)
|
||||
Q(pow)
|
||||
Q(print)
|
||||
Q(property)
|
||||
Q(pystack_space_exhausted)
|
||||
Q(pystack_use)
|
||||
Q(radians)
|
||||
Q(randint)
|
||||
Q(random)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
/* MicroPython configuration options
|
||||
* We're not listing the default options as defined in mpconfig.h */
|
||||
|
||||
#if __EMSCRIPTEN__
|
||||
// Enable a PyStack where most objects are allocated instead of always using the heap
|
||||
/* This enables to allocate and free memory in a scope (thus, Python can call
|
||||
* Python) but also has the collateral effect of removing bugs regarding
|
||||
@@ -17,7 +18,10 @@
|
||||
* collecting roots the transpiled C code is denied access to Javascript
|
||||
* variables that can store pointers to the Python heap. The pointed objects
|
||||
* are therefore erased prematurely. */
|
||||
#define MICROPY_ENABLE_PYSTACK (1)
|
||||
#else
|
||||
#define MICROPY_ENABLE_PYSTACK (0)
|
||||
#endif
|
||||
|
||||
// Whether to encode None/False/True as immediate objects instead of pointers to
|
||||
// real objects. Reduces code size by a decent amount without hurting
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
|
||||
__attribute__((noinline))
|
||||
void python_error_start(const char* type) {
|
||||
EM_ASM({
|
||||
Module.___temp_python_error = new Object();
|
||||
@@ -18,6 +19,7 @@ void python_error_start(const char* type) {
|
||||
}, type);
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
void python_error_add_trace(const char* file, int line, const char* block) {
|
||||
EM_ASM({
|
||||
var temp_obj = new Object();
|
||||
@@ -28,10 +30,11 @@ void python_error_add_trace(const char* file, int line, const char* block) {
|
||||
}, file, line, block);
|
||||
}
|
||||
|
||||
__attribute__((noinline))
|
||||
void python_error_end() {
|
||||
EM_ASM({
|
||||
if (typeof Module.onPythonError === "function") {
|
||||
Module.onPythonError(Module.___temp_python_error);
|
||||
Module.onPythonError(Module.___temp_python_error);
|
||||
}
|
||||
delete Module.___temp_python_error;
|
||||
});
|
||||
@@ -55,6 +58,7 @@ extern "C" {
|
||||
#include "py/mphal.h"
|
||||
#include "py/nlr.h"
|
||||
#include "py/parsenum.h"
|
||||
#include "py/pystack.h"
|
||||
#include "py/repl.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/stackctrl.h"
|
||||
@@ -163,6 +167,10 @@ extern "C" {
|
||||
}
|
||||
|
||||
void MicroPython::init(void * heapStart, void * heapEnd) {
|
||||
#if __EMSCRIPTEN__
|
||||
static mp_obj_t pystack[1024];
|
||||
mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]);
|
||||
#endif
|
||||
/* We delimit the stack part that will be used by Python. The stackTop is the
|
||||
* address of the first object that can be allocated on Python stack. This
|
||||
* boundaries are used:
|
||||
|
||||
Reference in New Issue
Block a user