Perform build and magnum tuning

Building o//third_party/python now takes 5 seconds on my PC

This change works towards modifying Python to use runtime dispatching
when appropriate. For example, when loading the magnums in the socket
module, it's a good idea to check if the magnum is zero, because that
means the local system platform doesn't support it.
This commit is contained in:
Justine Tunney 2021-08-10 10:26:13 -07:00
parent ee7e296339
commit d26d7ae0e4
1028 changed files with 6576 additions and 172777 deletions

View file

@ -1,4 +1,4 @@
/* clang-format off */
/* Parser accelerator module */
/* The parser as originally conceived had disappointing performance.
@ -10,11 +10,11 @@
are not part of the static data structure written on graminit.[ch]
by the parser generator. */
#include "pgenheaders.h"
#include "grammar.h"
#include "node.h"
#include "token.h"
#include "parser.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Parser/parser.h"
/* Forward references */
static void fixdfa(grammar *, dfa *);

View file

@ -1,8 +1,9 @@
/* clang-format off */
/* Bitset primitives used by the parser generator */
#include "pgenheaders.h"
#include "bitset.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/bitset.h"
bitset
newbitset(int nbits)

View file

@ -1,9 +1,10 @@
/* clang-format off */
/* Computation of FIRST stets */
#include "pgenheaders.h"
#include "grammar.h"
#include "token.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/token.h"
extern int Py_DebugFlag;

View file

@ -1,13 +1,11 @@
/* clang-format off */
/* Grammar implementation */
#include "Python.h"
#include "pgenheaders.h"
#include <ctype.h>
#include "token.h"
#include "grammar.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/grammar.h"
extern int Py_DebugFlag;

View file

@ -1,10 +1,11 @@
/* clang-format off */
/* Grammar subroutines needed by parser */
#include "Python.h"
#include "pgenheaders.h"
#include "grammar.h"
#include "token.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/token.h"
/* Return the DFA for the given type */

View file

@ -1,9 +1,10 @@
/* clang-format off */
/* List a node on a file */
#include "pgenheaders.h"
#include "token.h"
#include "node.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/node.h"
/* Forward */
static void list1node(FILE *, node *);

View file

@ -1,8 +1,10 @@
/* clang-format off */
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/metagrammar.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/pgen.h"
#include "pgenheaders.h"
#include "metagrammar.h"
#include "grammar.h"
#include "pgen.h"
static arc arcs_0_0[3] = {
{2, 0},
{3, 0},

View file

@ -1,3 +1,4 @@
/* clang-format off */
/* Readline interface for tokenizer.c and [raw_]input() in bltinmodule.c.
By default, or when stdin is not a tty device, we have a super
@ -9,17 +10,12 @@
- a malloc'ed string ending in \n normally
*/
#include "Python.h"
#ifdef MS_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif /* MS_WINDOWS */
#include "third_party/python/Include/Python.h"
PyThreadState* _PyOS_ReadlineTState;
#ifdef WITH_THREAD
#include "pythread.h"
#include "third_party/python/Include/pythread.h"
static PyThread_type_lock _PyOS_ReadlineLock = NULL;
#endif

View file

@ -1,10 +1,11 @@
/* Parse tree node implementation */
/* clang-format off */
#include "Python.h"
#include "node.h"
/* Parse tree node implementation */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/node.h"
#include "libc/nexgen32e/bsr.h"
#include "errcode.h"
#include "third_party/python/Include/errcode.h"
node *
PyNode_New(int type)

View file

@ -1,3 +1,4 @@
/* clang-format off */
/* Parser implementation */
@ -5,13 +6,13 @@
/* XXX To do: error recovery */
#include "Python.h"
#include "pgenheaders.h"
#include "token.h"
#include "grammar.h"
#include "node.h"
#include "parser.h"
#include "errcode.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Parser/parser.h"
#include "third_party/python/Include/errcode.h"
#ifdef Py_DEBUG

View file

@ -1,14 +1,15 @@
/* clang-format off */
/* Parser-tokenizer link implementation */
#include "pgenheaders.h"
#include "tokenizer.h"
#include "node.h"
#include "grammar.h"
#include "parser.h"
#include "parsetok.h"
#include "errcode.h"
#include "graminit.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Parser/tokenizer.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Parser/parser.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/graminit.h"
/* Forward */

View file

@ -1,2 +1,2 @@
#define PGEN
#include "parsetok.c"
#include "third_party/python/Parser/parsetok.c"

View file

@ -1,14 +1,16 @@
/* clang-format off */
/* Parser generator */
/* For a description, see the comments at end of this file */
#include "Python.h"
#include "pgenheaders.h"
#include "token.h"
#include "node.h"
#include "grammar.h"
#include "metagrammar.h"
#include "pgen.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/metagrammar.h"
#include "third_party/python/Include/pgen.h"
extern int Py_DebugFlag;
extern int Py_IgnoreEnvironmentFlag; /* needed by Py_GETENV */

View file

@ -1,3 +1,4 @@
/* clang-format off */
/* Parser generator main program */
@ -15,12 +16,12 @@
#define PGEN
#include "Python.h"
#include "pgenheaders.h"
#include "grammar.h"
#include "node.h"
#include "parsetok.h"
#include "pgen.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/pgen.h"
int Py_DebugFlag;
int Py_VerboseFlag;

View file

@ -1,10 +1,11 @@
/* clang-format off */
/* Print a bunch of C initializers that represent a grammar */
#define PGEN
#include "pgenheaders.h"
#include "grammar.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
/* Forward */
static void printarcs(int, dfa *, FILE *);

View file

@ -1,21 +1,19 @@
/* clang-format off */
/* Tokenizer implementation */
#include "Python.h"
#include "pgenheaders.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pgenheaders.h"
#include <ctype.h>
#include <assert.h>
#include "tokenizer.h"
#include "errcode.h"
#include "third_party/python/Parser/tokenizer.h"
#include "third_party/python/Include/errcode.h"
#ifndef PGEN
#include "unicodeobject.h"
#include "bytesobject.h"
#include "fileobject.h"
#include "codecs.h"
#include "abstract.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/abstract.h"
#endif /* PGEN */
#define is_potential_identifier_start(c) (\

View file

@ -1,14 +1,11 @@
#ifndef Py_TOKENIZER_H
#define Py_TOKENIZER_H
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/token.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "object.h"
/* Tokenizer interface */
#include "token.h" /* For token types */
/* clang-format off */
#define MAXINDENT 100 /* Max indentation level */

View file

@ -1,2 +1,3 @@
/* clang-format off */
#define PGEN
#include "tokenizer.c"
#include "third_party/python/Parser/tokenizer.c"