Commit graph

540 commits

Author SHA1 Message Date
ahgamut
725f4617fd fix refcount error found in MODE=dbg
all tests now pass in MODE=dbg
2021-11-09 03:37:04 +05:30
ahgamut
9aac17ff54 avoid PyMethodObject in slots
main change in python/cpython@516b98161a
test_exceptions changed in python/cpython@331bbe6aaa
type_settattro changed in python/cpython@193f7e094f
_PyObject_CallFunctionVa changed in python/cpython@fe4ff83049
2021-11-09 03:07:55 +05:30
ahgamut
7f4de20c0b PyCFunction_Call performance
refer python/cpython@12c5838dae
2021-11-09 01:18:21 +05:30
ahgamut
a7bf3bda15 added _PyMethodDef_RawFastCallKeywords
refer python/cpython@7399a05965
2021-11-09 01:14:23 +05:30
ahgamut
4802173eba speed up unpickling
refer python/cpython@bee09aecc2
2021-11-09 00:49:52 +05:30
ahgamut
ed44f3b14d convert some internal functions to FASTCALL
__import__ might need to be changed later, if it is possible to backport
the METH_FASTCALL | METH_KEYWORDS flag distinction later.
2021-11-07 04:48:32 +05:30
ahgamut
81c6b43e00 all tests pass in MODE=dbg 2021-11-05 03:21:59 +05:30
ahgamut
2231c966d8 add macros
refer python/cpython@68a001dd59
2021-11-05 03:21:59 +05:30
ahgamut
4eb67fa2c5 recursive calls in PyObject_Call
refer python/cpython@7399a05965

only partially ported, because RawFastCallKeywords hasn't been ported
2021-11-05 02:46:15 +05:30
ahgamut
4959ac1497 make deque methods faster
refer python/cpython@dd407d5006
2021-11-05 02:33:33 +05:30
ahgamut
f49003241f _struct module now uses Argument Clinic
refer python/cpython@3f2d10132d
2021-11-05 02:27:03 +05:30
ahgamut
d220f6f9b2 print now uses METH_FASTCALL
refer python/cpython@c3858bd7c6
refer python/cpython@bd584f169f
refer python/cpython@06d34393c2
2021-11-05 02:12:57 +05:30
ahgamut
7fb46fb510 cleanup _PyMethodDef_RawFastCallDict
refer python/cpython@0a2e46835d
refer python/cpython@98ccba8344
refer python/cpython@c89ef828cf
refer python/cpython@250e4b0063
2021-11-05 01:45:44 +05:30
ahgamut
9220b67b3e Optimize methoddescr_call
refer python/cpython@2a1b676d1f
refer python/cpython@c52572319c
refer python/cpython@35ecebe165
refer python/cpython@8128d5a491
2021-11-05 01:33:34 +05:30
ahgamut
73ea0ea4a6 FASTCALL for sorted, next, and getattr
refer python/cpython@5a60ecaa7a
refer python/cpython@fda6d0acf0
refer python/cpython@84b388bb80
2021-11-05 01:13:57 +05:30
ahgamut
81b5b2d524 speed up getargs
refer python/cpython@1741441649
2021-11-05 01:02:57 +05:30
ahgamut
e33788a384 Argument Clinic for ordered dictionary object
refer python/cpython@b05cbac052
2021-11-05 00:55:04 +05:30
ahgamut
f731074a5f Argument Clinic FASTCALL again
refer python/cpython@0c4a828ca
2021-11-05 00:45:34 +05:30
ahgamut
7272dace71 Added _PyArg_UnpackStack
refer python/cpython@fe54dda08
2021-11-05 00:35:35 +05:30
ahgamut
071d2ec8cf METH_FASTCALL changes to .inc files
done via python's Argument Clinic tool,
refer python/cpython@259f0e4437
2021-11-05 00:24:42 +05:30
ahgamut
21294d41f6 _PyStack_UnpackDict now returns int
refer python/cpython@998c20962c
2021-11-04 23:38:31 +05:30
ahgamut
bd127a01ee Add _PyArg_NoStackKeywords
refer python/cpython@29d39cc8f5
2021-11-04 23:29:46 +05:30
ahgamut
af384841c3 separate into ParseStack and ParseStackAndKeywords
refer python/cpython@6518a93cb1
refer python/cpython@3e1fad6913
refer python/cpython@c0083fc47d
2021-11-04 23:23:31 +05:30
ahgamut
f1f2a3ec6d type_prepare uses METH_FASTCALL
refer python/cpython@d526cfe546
refer python/cpython@80ab22fa2c

the prepare-related test still fails.  It's just related to the error
message format though.
2021-11-04 22:43:49 +05:30
ahgamut
ebc20796b4 __build_class__() uses METH_FASTCALL
refer python/cpython@69de71b255
refer python/cpython@773dc6dd06

a single test related to __prepare__ fails.
2021-11-04 22:29:47 +05:30
ahgamut
47ba7b8ef7 dict copy speedup
refer to bpo-31179 or python/cpython@boa7a037b8fde
2021-10-31 19:24:26 +05:30
Gautham
d7ff346b52
Add some Python 3.7 backports (#306)
* make.com now uses stack size of 2mb
* optimize _PyCFunction_FastCallKeywords
* backport python@cpython/7fc252adfbedece75f2330bcfdadbf84dee7836f
2021-10-29 22:54:14 -07:00
Justine Tunney
903cc38c37 Revert "Make MODE=tiny not depend on default build"
This reverts commit 30cd28b1f8.
2021-10-26 17:14:38 -07:00
ahgamut
3616f2a432 get make to build 2021-10-26 14:58:05 -07:00
ahgamut
7a50dba812 changes made to enable compilation 2021-10-26 14:58:05 -07:00
ahgamut
19f70a154e add make-4.3.tar.gz 2021-10-26 14:58:05 -07:00
jacereda
0a0997a872
Add WIN32 symbols for OpenGL support (#304) 2021-10-26 14:18:13 -07:00
Justine Tunney
30cd28b1f8 Make MODE=tiny not depend on default build
This issue was spotted by @ahgamut in #292.
2021-10-25 16:26:22 -07:00
Justine Tunney
91d783352a Apply fixup to cthread initialization (#301)
Cosmopolitan Threads are currently Linux-only (with some NetBSD
and Windows support too!). This change ensures we only initialize
the high-level threading runtime when Cosmopolitan Threads are used.
2021-10-25 16:22:10 -07:00
Florian Lemaitre
45a7435788
[WIP] Threading phase 2 (#301)
* Exponential back-off
* Removed "native" specifier
* Abstract away Futex for cthread
* Complete setup for TLS (including main thread)
2021-10-25 16:02:26 -07:00
Paul Kulchenko
660ff56d40
Redbean fix lua panic (#300)
* Fix Lua panic in redbean when calling request/connection functions from .init.lua

The error calls were triggered appropriately, but used the global Lua
state instead of the current Lua state (within protected call), which
triggered Lua panic. This executes the error in the proper context.

* Rename global Lua state object to make its (mis-)usage easier to detect
2021-10-25 14:54:56 -07:00
Paul Kulchenko
c00755f921
Improve error messages for consistency (#297) 2021-10-25 14:44:04 -07:00
Paul Kulchenko
013f03e33f
Redbean fix redirect (#294)
* Fix redbean crash during redirect in debug logging mode

* Add reset for redirect loop check in redbean Route

Without this reset a combination of RoutePath() and Route() calls
could return "508 loop detected", since RoutePath could be called
twice for the same redirected path.

The protection against looping is still there, as it can only
loop inside the Route() call (as it always serves something).

* Update redbean redirect message for clarity
2021-10-25 14:04:57 -07:00
Gautham
49db877fbe
Minimize Python startup imports (#292)
* get_exports_list should return list
* remove unintentional `CC=clang` in makefile
* avoid importing sysconfig during startup

site.py requires only a couple of functions from sysconfig, but needs to
load the entirety of sysconfig to get those functions. This commit
makes it such that sysconfig is imported only when sys.platform is darwin.

* remove redundant constants from stat module

The constants are only there in case the C implementation (ie the _stat
module) is not available. With Cosmopolitan the _stat module is always
available. The entire Lib/stat.py file can be removed if the Windows-based
constants can be moved into the Modules/_stat.c.

* minimal changes to os.py

python checks os-based assumptions at startup, some of  which can be
bypassed since this is Cosmopolitan Python.
2021-10-25 14:04:04 -07:00
Et7f3
253ac31a64
Fix build from docker build with alpine from macOS (#286)
* fix(build): Remove unused variable and fix const warning.
* fix(build): Fix others -Werror=discarded-qualifiers
Co-authored-by: Élie BRAMI <Et7f3@mbp-de-elie.home>
2021-10-25 13:39:05 -07:00
Justine Tunney
67b5200a0b Add MODE=optlinux build mode (#141) 2021-10-14 19:36:49 -07:00
Justine Tunney
226aaf3547 Improve memory safety
This commit makes numerous refinements to cosmopolitan memory handling.

The default stack size has been reduced from 2mb to 128kb. A new macro
is now provided so you can easily reconfigure the stack size to be any
value you want. Work around the breaking change by adding to your main:

    STATIC_STACK_SIZE(0x00200000);  // 2mb stack

If you're not sure how much stack you need, then you can use:

    STATIC_YOINK("stack_usage_logging");

After which you can `sort -nr o/$MODE/stack.log`. Based on the unit test
suite, nothing in the Cosmopolitan repository (except for Python) needs
a stack size greater than 30kb. There are also new macros for detecting
the size and address of the stack at runtime, e.g. GetStackAddr(). We
also now support sigaltstack() so if you want to see nice looking crash
reports whenever a stack overflow happens, you can put this in main():

    ShowCrashReports();

Under `make MODE=dbg` and `make MODE=asan` the unit testing framework
will now automatically print backtraces of memory allocations when
things like memory leaks happen. Bugs are now fixed in ASAN global
variable overrun detection. The memtrack and asan runtimes also handle
edge cases now. The new tools helped to identify a few memory leaks,
which are fixed by this change.

This change should fix an issue reported in #288 with ARG_MAX limits.
Fixing this doubled the performance of MKDEPS.COM and AR.COM yet again.
2021-10-13 17:27:13 -07:00
Florian Lemaitre
a0b39f886c
[WIP] Threading (#282)
* Thread creation
* Proper thread creation and exit
* Join/Detach protocol
* Added semaphore with futex (hopefully fast)
2021-10-13 11:26:05 -07:00
Gautham
d852640a1e
Add Python ftrace contextmanager (#285) 2021-10-13 11:00:25 -07:00
Justine Tunney
425a57080d Fix minor issues 2021-10-08 20:51:11 -07:00
Justine Tunney
bba144246a Improve Das Blinkenlights
It's now possible to scroll panels is the TUI while the display
is blocked on input. INT 16h now translates UTF-8 to CP-437 and
displays unmappable characters using a lambda symbol. Bracketed
paste mode guards will also be filtered out.
2021-10-08 16:44:19 -07:00
Justine Tunney
7061c79c22 Make fixes, improvements, and chibicc python bindings
- python now mixes audio 10x faster
- python octal notation is restored
- chibicc now builds code 3x faster
- chibicc now has help documentation
- chibicc can now generate basic python bindings
- linenoise now supports some paredit-like features

See #141
2021-10-08 08:41:57 -07:00
Justine Tunney
28997f3acb Make mkdeps.com go faster
This program usually runs once at the begininng of each GNU Make
invocation. It generates an o//depend file with 170,000 lines of
Makefile code to define source -> headers relationships.

This change makes that take 650 milliseconds rather than 1,100ms
by improving the performance of strstr(), using longsort(), plus
migrating to the new append library.
2021-10-04 06:46:46 -07:00
Justine Tunney
725f4d79f6 Apply fixes and speedups 2021-10-04 03:23:31 -07:00
Justine Tunney
7521bf9e73 Add stack overflow checking to Python 2021-10-02 10:50:41 -07:00