Commit Graph

970 Commits

Author SHA1 Message Date
K. Lange
a4e2b5c881 Relative imports 2022-05-28 15:41:47 +09:00
K. Lange
3645047051 Same for None 2022-05-28 11:45:38 +09:00
K. Lange
f14ca90792 Avoid NotImplemented.__hash__ resolving to object.__hash__ and segfaulting 2022-05-28 11:38:59 +09:00
K. Lange
81e3bb33a0 Defer freeing pre-grown stacks when using them in native calls
If the stack needs to grow during a native function call that has
taken a pointer into the stack as an argument, defer freeing this
copy of the stack until the outermost such call returns. The new
stack will always point to new memory, as we can not call realloc
in this case, and if repeated nested native function calls result
in multiple stack growths then several copies of the stack may
persistent in memory simultaneously, but we do not need to trouble
native function implementations with the possibility that their
arguments may become invalid, and we do not need to produce copies
of the stack when calling them.

This resolves a long-standing issue with resizable stacks where
native function calls always entailed a memcpy() penalty, and calls
with many arguments also had malloc()/free() overhead for heap
allocated stack copies.

With this change, performance improves, as the wrapper checks around
stack growth are uncommon, so their overall cost is less than the
repeated moving of arguments around for native function calls.
2022-05-27 21:57:17 +09:00
K. Lange
1f6afa7369 Add new CLOSE_MANY and POP_MANY instructions 2022-05-27 18:37:37 +09:00
K. Lange
7dff49ccb7 Fix incorrect hashing of classes in fallback added for subclass tracking 2022-05-27 18:37:37 +09:00
K. Lange
aa6781609e Fix bad encoding of large upvalue indexes 2022-05-27 18:37:37 +09:00
K. Lange
32b3af58cc Unset class bases when doing final free so we don't access potentially-freed subclass tables 2022-05-27 00:15:55 +09:00
K. Lange
1ac8f296b2 Invalidate caches of subclass method pointers when they change in a superclass 2022-05-27 00:05:27 +09:00
K. Lange
1c5fc954ed Update copyright years, it's been 2022 for a while now 2022-05-26 20:46:06 +09:00
K. Lange
3601411f54 Support step value in range() 2022-05-26 20:41:39 +09:00
K. Lange
1acd0243e4 Workaround horrible thread-local performance on macOS (aarch64) 2022-05-24 21:01:42 +09:00
K. Lange
74e064c82c Test case for preceding fix 2022-05-24 13:33:34 +09:00
K. Lange
b9776aec1e Revert loop on 'for ... if ...' 2022-05-24 13:27:01 +09:00
K. Lange
341fd877d5 New optimized loop and jump instructions 2022-05-23 22:14:22 +09:00
K. Lange
657a02af29 Reduce recursion overhead when calling objects 2022-05-23 22:14:01 +09:00
K. Lange
c4b83396df More efficient bool, int comparisons, sometimes 2022-05-23 21:10:09 +09:00
K. Lange
c38e78e21c Fast-case listiterator.__call__ instanceof check
It's highly unlikely this class is subclassed, and it can
be called a lot of times in a loop.
2022-05-23 21:09:03 +09:00
K. Lange
d0c2f8cec2 Cleanup memory size debugger, no need for external hashmap 2022-05-23 13:25:33 +09:00
K. Lange
cb14875406 Catch exceptions early in timeit.timeit 2022-05-23 10:16:07 +09:00
K. Lange
4a052191de Support 'else' blocks on for and while loops 2022-05-23 09:41:12 +09:00
K. Lange
ece7da299a Support = to print f-string expression alongside value 2022-05-23 08:42:40 +09:00
K. Lange
78e85ce873 Support an extensive memory debugging process, if you provide some extra files 2022-05-21 21:10:57 +09:00
K. Lange
27278cfa68 Fixup allocation size for bytes literals 2022-05-21 20:39:47 +09:00
K. Lange
953e57fa0d Fix two more instances of bad alloc/dealloc pairings 2022-05-21 20:05:16 +09:00
K. Lange
73c82e0868 Fixup display of gc debug info on 32-bit platforms 2022-05-21 19:18:30 +09:00
K. Lange
a50cfc63a7 Fix tracking of memory from instances of objects with allocSize != sizeof(Instance) 2022-05-21 19:18:13 +09:00
K. Lange
9b1875d8ce Fix incorrect memory usage tracking of taken strings 2022-05-21 19:15:04 +09:00
K. Lange
b6e591601b Fix incorrect memory usage tracking of code object line mappings 2022-05-21 19:14:50 +09:00
K. Lange
81f78b9199 fixup potential leaks when os.exec*() family fails 2022-05-21 19:14:24 +09:00
K. Lange
7c4b129b7c Dict unpacking should only happen on dicts, or we're going to have a bad time 2022-05-19 11:05:55 +09:00
K. Lange
396b8c0ae3 Inline string equality check to save overhead of object.__eq__ call 2022-05-05 16:14:15 +09:00
K. Lange
5df1469ba1 Optimized method invoke 2022-05-05 11:41:05 +09:00
K. Lange
d947e1aba3 Add bound method call test to benchmark suite 2022-05-05 08:23:49 +09:00
K. Lange
f8139f9352 Add versions, local Kuroko to benchmark 2022-05-05 08:23:40 +09:00
K. Lange
246316ad59 v1.2.5 2022-05-03 16:49:58 +09:00
K. Lange
6613db6cd4 Implement slice objects, slice stepping
This is an initial implementation of slice stepping and slice objects.
The __getslice__, __setslice__, and __delslice__ methods have been removed.
Slice expressions are now turned into slice objects with the OP_SLICE instruction.
Slice objects have a start, end, and step, all of which default to None.
Slice objects are passed to __getitem__, et al., as a normal parameter.

Support for slices in list.__getitem__, str.__getitem__, and bytes.__getitem__ has
been implemented.
2022-05-03 16:49:58 +09:00
K. Lange
c750f76a57 Assign non-None REPL results to __builtins__._ 2022-04-13 22:34:45 -04:00
K. Lange
c5b95645a7 Support KUROKOPATH similar to PYTHONPATH 2022-03-31 18:01:12 +09:00
K. Lange
dbd1071bc1 Internalize random's rng, seed it with more bits 2022-03-29 10:17:36 +09:00
K. Lange
e815497555 Fixup bad recursive locks in list functions? 2022-03-29 09:42:56 +09:00
K. Lange
73bfd17364 Improve some common string manipulation functions 2022-03-27 20:50:16 +09:00
K. Lange
b651f96094 Add random.seed 2022-03-27 16:32:12 +09:00
K. Lange
4c96839d1b Add os.get_terminal_size 2022-03-27 16:25:30 +09:00
K. Lange
799952c298 Fix str.replace when replacement string contains nil bytes 2022-03-24 10:23:52 +09:00
K. Lange
e24ea3d32c Fix incorrect handling of blank and comment lines before 'else', 'except', etc. 2022-02-17 09:49:24 +09:00
K. Lange
c1f2c7d9f3 Improve GC debug output and switch to a more aggressive strategy beyond 128MiB 2021-12-31 21:58:08 +09:00
K. Lange
38f3b6fa22 Allow 'del' on locals, upvalues as a shorthand for 'None' assignment 2021-12-31 21:57:25 +09:00
K. Lange
7c879c9675 Raise an exception on invalid sequence element lengths 2021-12-22 08:28:23 +09:00
K. Lange
7a7bb5662c Support sequence unpack for dict.__init__, fixes #23 2021-12-22 08:23:07 +09:00