...
 
Commits (8)
......@@ -533,6 +533,7 @@ pass CORE_UNICODE/unicode_subscr
10 tests passed
pass CORE_FLOAT/array_construct
pass CORE_FLOAT/builtin_float_abs
pass CORE_FLOAT/builtin_float_hash
pass CORE_FLOAT/builtin_float_minmax
pass CORE_FLOAT/builtin_float_round
......@@ -571,8 +572,8 @@ pass CORE_FLOAT/string_format_modulo3
pass CORE_FLOAT/string_format_modulo
pass CORE_FLOAT/true_value
pass CORE_FLOAT/types
39 tests performed (2888 individual testcases)
39 tests passed
40 tests performed (2896 individual testcases)
40 tests passed
pass CORE_EXTMOD/ubinascii_a2b_base64
pass CORE_EXTMOD/ubinascii_b2a_base64
......@@ -654,6 +655,7 @@ pass spacebel_tickets/SPB_861
pass spacebel_tickets/SPB_862
pass spacebel_tickets/SPB_868
pass spacebel_tickets/SPB_869
pass spacebel_tickets/SPB_871
pass spacebel_tickets/SPB_872
pass spacebel_tickets/SPB_877
pass spacebel_tickets/SPB_883
......@@ -665,8 +667,8 @@ FAIL spacebel_tickets/SPB_997
pass spacebel_tickets/SPB_998
pass spacebel_tickets/SPB_999
pass spacebel_tickets/SPB_extra
50 tests performed (210 individual testcases)
49 tests passed
51 tests performed (218 individual testcases)
50 tests passed
1 tests failed - SPB_997
pass cpydiff/builtin_next_arg2
......
......@@ -27,7 +27,7 @@ CFLAGS += -DRTEMS_4_8 -DRTEMS_4_8_EDISOFT
CFLAGS += -I$(LEON_COMMON_FROM_HERE)/libc-include
CFLAGS += -B/opt/rtems-4.8/sparc-rtems4.8/leon2/lib
LIBS += -Wl,--start-group -lrtemscpu -lio -lno_event -lmsg -lsem -ltimer -lno_rtmon -lno_ext -lrtemsbsp -lrtemscpu -Wl,--end-group
SRC_RTEMS = leon-common/sparcisr.c leon-common/leon2serial.c
SRC_RTEMS = leon-common/leon2serial.c
endif
# Settings for RTEMS 4.8 Gaisler
......
......@@ -6,16 +6,38 @@
#include <stdint.h>
#include "leon-common/sparcisr.h"
#if RTEMS_4_8_EDISOFT
// This function retrieves the value of the Trap Base Register, to be used
// to install a window flushing trap handler next.
static void TRAP_read_TBR(volatile uint32_t* const tbrPtr) {
asm("mov %0, %%o1" : : "r" (tbrPtr) : "%o1");
asm("rd %%tbr, %%o0" : : : "%o0");
asm("st %o0, [%o1]");
}
// This function installs the "ta 3" ISR which handles window flushing.
// It is only needed for Edisoft RTEMS 4.8 because the trap handler is not
// included in that version, but it is needed by MicroPython to implement
// setjmp/longjmp calls for exception handling.
void sparc_install_ta_3_window_flush_isr(void) {
extern int sparc_window_flush_trap_handler(void);
uint32_t *m = (uint32_t*)0x40000830;
volatile uint32_t tbr = 0;
TRAP_read_TBR(&tbr);
tbr &= 0xfffff000;
tbr |= 0x830;
uint32_t *m = (uint32_t*)tbr;
uint32_t addr = (uint32_t)sparc_window_flush_trap_handler;
m[0] = 0xa1480000; // rd %psr, %l0
m[1] = 0x29100000 | (addr >> 10); // sethi %hi(addr), %l4
m[2] = 0x81c52000 | (addr & 0x3ff); // jmp %l4 + (addr & 0x3ff)
m[3] = 0xa6102083; // mov 0x83, %l3
}
#else
// For non-Edisoft builds the "ta 3" ISR is already installed.
void sparc_install_ta_3_window_flush_isr(void) {
}
#endif
......@@ -5,15 +5,5 @@
#pragma once
#if RTEMS_4_8_EDISOFT
// This function is needed to install the "ta 3" window flush handler.
void sparc_install_ta_3_window_flush_isr(void);
#else
// This function is not needed for non-Edisoft builds.
static inline void sparc_install_ta_3_window_flush_isr(void) {
}
#endif
......@@ -41,6 +41,7 @@ LIBS += -lm
SRC_C = \
main.c \
lib/libc/string0.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/mputil.c \
$(LEON_COMMON)/mpvmmanage.c \
......
......@@ -41,6 +41,7 @@ LIBS += -lm
SRC_C = \
main.c \
lib/libc/string0.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/mputil.c \
$(LEON_COMMON)/mphalport.c \
......
......@@ -43,6 +43,7 @@ LIBS += -lm
SRC_C = \
main.c \
lib/libc/string0.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/mputil.c \
$(LEON_COMMON)/mphalport.c \
......
......@@ -41,6 +41,7 @@ LIBS += -lm
SRC_C = \
main.c \
lib/libc/string0.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/mputil.c \
$(LEON_COMMON)/mphalport.c \
......
......@@ -48,6 +48,7 @@ SRC_C = \
lib/libc/strcmp.c \
lib/libc/strlen.c \
lib/libc/strncmp.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/nearbyint.c \
$(LEON_COMMON)/mputil.c \
......
......@@ -48,6 +48,7 @@ SRC_C = \
lib/libc/strcmp.c \
lib/libc/strlen.c \
lib/libc/strncmp.c \
$(LEON_COMMON)/sparcisr.c \
$(LEON_COMMON)/leonprintf.c \
$(LEON_COMMON)/nearbyint.c \
$(LEON_COMMON)/mputil.c \
......
# test large list sorting (should not stack overflow)
l = list(range(2000))
l = list(range(1800))
l.sort()
print(l[0], l[-1])
l.sort(reverse=True)
......
......@@ -135,9 +135,11 @@ void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args,
mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals);
}
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
NORETURN void mp_arg_error_terse_mismatch(void) {
mp_raise_TypeError("argument num/types mismatch");
}
#endif
#if MICROPY_CPYTHON_COMPAT
NORETURN void mp_arg_error_unimpl_kw(void) {
......
......@@ -604,6 +604,7 @@ void gc_free(void *ptr) {
}
}
#if MICROPY_PY_MICROPYTHON_MEM_INFO
size_t gc_nbytes(const void *ptr) {
GC_ENTER();
if (VERIFY_PTR(ptr)) {
......@@ -623,6 +624,7 @@ size_t gc_nbytes(const void *ptr) {
GC_EXIT();
return 0;
}
#endif
#if 0
// old, simple realloc that didn't expand memory in place
......
......@@ -137,10 +137,6 @@ STATIC void mp_map_rehash(mp_map_t *map) {
m_del(mp_map_elem_t, old_table, old_alloc);
}
#if !MICROPY_PY_COLLECTIONS_ORDEREDDICT
static mp_map_elem_t dummy_map_elem; // Used to appease static analysers
#endif
// MP_MAP_LOOKUP behaviour:
// - returns NULL if not found, else the slot it was found in with key,value non-null
// MP_MAP_LOOKUP_ADD_IF_NOT_FOUND behaviour:
......@@ -206,7 +202,6 @@ mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t
}
return elem;
#else
if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) { return &dummy_map_elem; } // To appease static analysers
return NULL;
#endif
}
......
......@@ -126,7 +126,6 @@ unichar utf8_get_char(const byte *s);
const byte *utf8_next_char(const byte *s);
size_t utf8_charlen(const byte *str, size_t len);
#else
static inline unichar utf8_get_char(const byte *s) { return *s; }
static inline const byte *utf8_next_char(const byte *s) { return s + 1; }
static inline size_t utf8_charlen(const byte *str, size_t len) { (void)str; return len; }
#endif
......
......@@ -235,6 +235,7 @@ typedef struct _mp_state_thread_t {
#if MICROPY_STACK_CHECK
size_t stack_limit;
size_t peak_stack_usage;
#endif
#if MICROPY_ENABLE_PYSTACK
......
......@@ -1359,6 +1359,7 @@ void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
mpz_free(n);
}
#if MICROPY_PY_BUILTINS_POW3
/* computes dest = (lhs ** rhs) % mod
can have dest, lhs, rhs the same; mod can't be the same as dest
*/
......@@ -1396,6 +1397,7 @@ void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t
mpz_free(x);
mpz_free(n);
}
#endif
#if 0
these functions are unused
......
......@@ -37,6 +37,7 @@ __attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr);
#endif
#endif
#if !MICROPY_NLR_SPARC
unsigned int nlr_push_tail(nlr_buf_t *nlr) {
nlr_buf_t **top = &MP_STATE_THREAD(nlr_top);
nlr->prev = *top;
......@@ -44,6 +45,7 @@ unsigned int nlr_push_tail(nlr_buf_t *nlr) {
*top = nlr;
return 0; // normal return
}
#endif
void nlr_pop(void) {
nlr_buf_t **top = &MP_STATE_THREAD(nlr_top);
......
......@@ -97,6 +97,7 @@ const mp_obj_type_t mp_type_module = {
.attr = module_attr,
};
#if MICROPY_ENABLE_EXTERNAL_IMPORT
mp_obj_t mp_obj_new_module(qstr module_name) {
mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
......@@ -120,6 +121,7 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
// return the new module
return MP_OBJ_FROM_PTR(o);
}
#endif
mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_module));
......@@ -261,10 +263,12 @@ mp_obj_t mp_module_get(qstr module_name) {
return el->value;
}
#if MICROPY_MODULE_BUILTIN_INIT
void mp_module_register(qstr qst, mp_obj_t module) {
mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map;
mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module;
}
#endif
#if MICROPY_MODULE_BUILTIN_INIT
void mp_module_call_init(qstr module_name, mp_obj_t module_obj) {
......
......@@ -76,12 +76,15 @@ typedef struct _mp_parse_node_struct_t {
#define MP_PARSE_NODE_STRUCT_KIND(pns) ((pns)->kind_num_nodes & 0xff)
#define MP_PARSE_NODE_STRUCT_NUM_NODES(pns) ((pns)->kind_num_nodes >> 8)
#if MICROPY_ENABLE_COMPILER
static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) {
return (mp_parse_node_t)(MP_PARSE_NODE_SMALL_INT | ((mp_uint_t)val << 1));
}
static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) {
return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4));
}
#endif
bool mp_parse_node_is_const_false(mp_parse_node_t pn);
bool mp_parse_node_is_const_true(mp_parse_node_t pn);
bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o);
......
......@@ -39,13 +39,24 @@ void mp_stack_set_top(void *top) {
mp_uint_t mp_stack_usage(void) {
// Assumes descending stack
volatile int stack_dummy;
return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy;
mp_uint_t usage = MP_STATE_THREAD(stack_top) - (char*)&stack_dummy;
#if MICROPY_STACK_CHECK
if (usage > MP_STATE_THREAD(peak_stack_usage)) {
MP_STATE_THREAD(peak_stack_usage) = usage;
}
#endif
return usage;
}
#if MICROPY_STACK_CHECK
void mp_stack_set_limit(mp_uint_t limit) {
MP_STATE_THREAD(stack_limit) = limit;
MP_STATE_THREAD(peak_stack_usage) = 0;
}
size_t mp_peak_stack_usage(void) {
return MP_STATE_THREAD(peak_stack_usage);
}
void mp_stack_check(void) {
......
......@@ -35,6 +35,7 @@ mp_uint_t mp_stack_usage(void);
#if MICROPY_STACK_CHECK
void mp_stack_set_limit(mp_uint_t limit);
size_t mp_peak_stack_usage(void);
void mp_stack_check(void);
#define MP_STACK_CHECK() mp_stack_check()
......
......@@ -136,9 +136,11 @@ bool unichar_isxdigit(unichar c) {
return c < 128 && (attr[c] & FL_XDIGIT) != 0;
}
#if MICROPY_HELPER_REPL
bool unichar_isident(unichar c) {
return c < 128 && ((attr[c] & (FL_ALPHA | FL_DIGIT)) != 0 || c == '_');
}
#endif
bool unichar_isupper(unichar c) {
return c < 128 && (attr[c] & FL_UPPER) != 0;
......