mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Tabify and reflow some long lines.
Much of the peephole optimizer is now indented badly, but it's about to be revised anyway.
This commit is contained in:
parent
224003baef
commit
e9357b21c0
1 changed files with 704 additions and 698 deletions
|
@ -13,10 +13,10 @@
|
||||||
* Note that compiler_mod() suggests module, but the module ast type
|
* Note that compiler_mod() suggests module, but the module ast type
|
||||||
* (mod_ty) has cases for expressions and interactive statements.
|
* (mod_ty) has cases for expressions and interactive statements.
|
||||||
*
|
*
|
||||||
* CAUTION: The VISIT_* macros abort the current function when they encounter
|
* CAUTION: The VISIT_* macros abort the current function when they
|
||||||
* a problem. So don't invoke them when there is memory which needs to be
|
* encounter a problem. So don't invoke them when there is memory
|
||||||
* released. Code blocks are OK, as the compiler structure takes care of
|
* which needs to be released. Code blocks are OK, as the compiler
|
||||||
* releasing those.
|
* structure takes care of releasing those.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
@ -204,7 +204,8 @@ _Py_Mangle(PyObject *private, PyObject *ident)
|
||||||
const char *p, *name = PyString_AsString(ident);
|
const char *p, *name = PyString_AsString(ident);
|
||||||
char *buffer;
|
char *buffer;
|
||||||
size_t nlen, plen;
|
size_t nlen, plen;
|
||||||
if (private == NULL || name == NULL || name[0] != '_' || name[1] != '_') {
|
if (private == NULL || name == NULL || name[0] != '_' ||
|
||||||
|
name[1] != '_') {
|
||||||
Py_INCREF(ident);
|
Py_INCREF(ident);
|
||||||
return ident;
|
return ident;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +397,8 @@ dictbytype(PyObject *src, int scope_type, int flag, int offset)
|
||||||
#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
|
#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
|
||||||
#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255
|
#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255
|
||||||
#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
|
#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
|
||||||
#define ISBASICBLOCK(blocks, start, bytes) (blocks[start]==blocks[start+bytes-1])
|
#define ISBASICBLOCK(blocks, start, bytes) \
|
||||||
|
(blocks[start]==blocks[start+bytes-1])
|
||||||
|
|
||||||
/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
|
/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
|
||||||
with LOAD_CONST (c1, c2, ... cn).
|
with LOAD_CONST (c1, c2, ... cn).
|
||||||
|
@ -482,7 +484,8 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
|
||||||
break;
|
break;
|
||||||
case BINARY_DIVIDE:
|
case BINARY_DIVIDE:
|
||||||
/* Cannot fold this operation statically since
|
/* Cannot fold this operation statically since
|
||||||
the result can depend on the run-time presence of the -Qnew flag */
|
the result can depend on the run-time presence
|
||||||
|
of the -Qnew flag */
|
||||||
return 0;
|
return 0;
|
||||||
case BINARY_TRUE_DIVIDE:
|
case BINARY_TRUE_DIVIDE:
|
||||||
newconst = PyNumber_TrueDivide(v, w);
|
newconst = PyNumber_TrueDivide(v, w);
|
||||||
|
@ -656,7 +659,8 @@ markblocks(unsigned char *code, int len)
|
||||||
a single pass. Line numbering is adjusted accordingly. */
|
a single pass. Line numbering is adjusted accordingly. */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *lineno_obj)
|
optimize_code(PyObject *code, PyObject* consts, PyObject *names,
|
||||||
|
PyObject *lineno_obj)
|
||||||
{
|
{
|
||||||
Py_ssize_t i, j, codelen;
|
Py_ssize_t i, j, codelen;
|
||||||
int nops, h, adj;
|
int nops, h, adj;
|
||||||
|
@ -665,7 +669,7 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
|
||||||
unsigned char *lineno;
|
unsigned char *lineno;
|
||||||
int *addrmap = NULL;
|
int *addrmap = NULL;
|
||||||
int new_line, cum_orig_line, last_line, tabsiz;
|
int new_line, cum_orig_line, last_line, tabsiz;
|
||||||
int cumlc=0, lastlc=0; /* Count runs of consecutive LOAD_CONST codes */
|
int cumlc=0, lastlc=0; /* Count runs of consecutive LOAD_CONSTs */
|
||||||
unsigned int *blocks = NULL;
|
unsigned int *blocks = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
@ -750,7 +754,8 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
|
||||||
codestr[i+3] = NOP;
|
codestr[i+3] = NOP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */
|
/* Replace LOAD_GLOBAL/LOAD_NAME None
|
||||||
|
with LOAD_CONST None */
|
||||||
case LOAD_NAME:
|
case LOAD_NAME:
|
||||||
case LOAD_GLOBAL:
|
case LOAD_GLOBAL:
|
||||||
j = GETARG(codestr, i);
|
j = GETARG(codestr, i);
|
||||||
|
@ -767,7 +772,8 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Skip over LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP */
|
/* Skip over LOAD_CONST trueconst
|
||||||
|
JUMP_IF_FALSE xx POP_TOP */
|
||||||
case LOAD_CONST:
|
case LOAD_CONST:
|
||||||
cumlc = lastlc + 1;
|
cumlc = lastlc + 1;
|
||||||
j = GETARG(codestr, i);
|
j = GETARG(codestr, i);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue