Lines Matching refs:codestr
37 tuple_of_constants(unsigned char *codestr, Py_ssize_t n, PyObject *consts) in tuple_of_constants() argument
44 assert(codestr[n*3] == BUILD_TUPLE || codestr[n*3] == BUILD_LIST); in tuple_of_constants()
45 assert(GETARG(codestr, (n*3)) == n); in tuple_of_constants()
47 assert(codestr[i*3] == LOAD_CONST); in tuple_of_constants()
55 arg = GETARG(codestr, (i*3)); in tuple_of_constants()
71 memset(codestr, NOP, n*3); in tuple_of_constants()
72 codestr[n*3] = LOAD_CONST; in tuple_of_constants()
73 SETARG(codestr, (n*3), len_consts); in tuple_of_constants()
88 fold_binops_on_constants(unsigned char *codestr, PyObject *consts) in fold_binops_on_constants() argument
96 assert(codestr[0] == LOAD_CONST); in fold_binops_on_constants()
97 assert(codestr[3] == LOAD_CONST); in fold_binops_on_constants()
100 v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); in fold_binops_on_constants()
101 w = PyList_GET_ITEM(consts, GETARG(codestr, 3)); in fold_binops_on_constants()
102 opcode = codestr[6]; in fold_binops_on_constants()
183 memset(codestr, NOP, 4); in fold_binops_on_constants()
184 codestr[4] = LOAD_CONST; in fold_binops_on_constants()
185 SETARG(codestr, 4, len_consts); in fold_binops_on_constants()
190 fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) in fold_unaryops_on_constants() argument
198 assert(codestr[0] == LOAD_CONST); in fold_unaryops_on_constants()
201 v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); in fold_unaryops_on_constants()
202 opcode = codestr[3]; in fold_unaryops_on_constants()
236 codestr[0] = NOP; in fold_unaryops_on_constants()
237 codestr[1] = LOAD_CONST; in fold_unaryops_on_constants()
238 SETARG(codestr, 1, len_consts); in fold_unaryops_on_constants()
305 unsigned char *codestr = NULL; in PyCode_Optimize() local
331 codestr = (unsigned char *)PyMem_Malloc(codelen); in PyCode_Optimize()
332 if (codestr == NULL) in PyCode_Optimize()
334 codestr = (unsigned char *)memcpy(codestr, in PyCode_Optimize()
342 if (codestr[codelen-1] != RETURN_VALUE) in PyCode_Optimize()
352 blocks = markblocks(codestr, codelen); in PyCode_Optimize()
357 for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) { in PyCode_Optimize()
359 opcode = codestr[i]; in PyCode_Optimize()
368 if (codestr[i+1] != POP_JUMP_IF_FALSE in PyCode_Optimize()
371 j = GETARG(codestr, i+1); in PyCode_Optimize()
372 codestr[i] = POP_JUMP_IF_TRUE; in PyCode_Optimize()
373 SETARG(codestr, i, j); in PyCode_Optimize()
374 codestr[i+3] = NOP; in PyCode_Optimize()
383 j = GETARG(codestr, i); in PyCode_Optimize()
385 codestr[i+3] != UNARY_NOT || in PyCode_Optimize()
388 SETARG(codestr, i, (j^1)); in PyCode_Optimize()
389 codestr[i+3] = NOP; in PyCode_Optimize()
396 j = GETARG(codestr, i); in PyCode_Optimize()
409 codestr[i] = LOAD_CONST; in PyCode_Optimize()
410 SETARG(codestr, i, j); in PyCode_Optimize()
419 j = GETARG(codestr, i); in PyCode_Optimize()
420 if (codestr[i+3] != POP_JUMP_IF_FALSE || in PyCode_Optimize()
424 memset(codestr+i, NOP, 6); in PyCode_Optimize()
435 j = GETARG(codestr, i); in PyCode_Optimize()
442 codestr[i+3]==COMPARE_OP && in PyCode_Optimize()
444 (GETARG(codestr,i+3)==6 || in PyCode_Optimize()
445 GETARG(codestr,i+3)==7))) && in PyCode_Optimize()
446 tuple_of_constants(&codestr[h], j, consts)) { in PyCode_Optimize()
447 assert(codestr[i] == LOAD_CONST); in PyCode_Optimize()
451 if (codestr[i+3] != UNPACK_SEQUENCE || in PyCode_Optimize()
453 j != GETARG(codestr, i+3)) in PyCode_Optimize()
456 memset(codestr+i, NOP, 6); in PyCode_Optimize()
458 codestr[i] = ROT_TWO; in PyCode_Optimize()
459 memset(codestr+i+1, NOP, 5); in PyCode_Optimize()
461 codestr[i] = ROT_THREE; in PyCode_Optimize()
462 codestr[i+1] = ROT_TWO; in PyCode_Optimize()
463 memset(codestr+i+2, NOP, 4); in PyCode_Optimize()
484 fold_binops_on_constants(&codestr[i-6], consts)) { in PyCode_Optimize()
486 assert(codestr[i] == LOAD_CONST); in PyCode_Optimize()
498 fold_unaryops_on_constants(&codestr[i-3], consts)) { in PyCode_Optimize()
500 assert(codestr[i] == LOAD_CONST); in PyCode_Optimize()
521 tgt = GETJUMPTGT(codestr, i); in PyCode_Optimize()
522 j = codestr[tgt]; in PyCode_Optimize()
528 tgttgt = GETJUMPTGT(codestr, tgt); in PyCode_Optimize()
531 codestr[i] = j; in PyCode_Optimize()
532 SETARG(codestr, i, tgttgt); in PyCode_Optimize()
540 codestr[i] = POP_JUMP_IF_TRUE; in PyCode_Optimize()
542 codestr[i] = POP_JUMP_IF_FALSE; in PyCode_Optimize()
543 SETARG(codestr, i, (tgt + 3)); in PyCode_Optimize()
560 tgt = GETJUMPTGT(codestr, i); in PyCode_Optimize()
563 codestr[tgt] == RETURN_VALUE) { in PyCode_Optimize()
564 codestr[i] = RETURN_VALUE; in PyCode_Optimize()
565 memset(codestr+i+1, NOP, 2); in PyCode_Optimize()
568 if (!UNCONDITIONAL_JUMP(codestr[tgt])) in PyCode_Optimize()
570 tgttgt = GETJUMPTGT(codestr, tgt); in PyCode_Optimize()
577 codestr[i] = opcode; in PyCode_Optimize()
578 SETARG(codestr, i, tgttgt); in PyCode_Optimize()
589 if (codestr[i+4] == RETURN_VALUE && in PyCode_Optimize()
591 memset(codestr+i+1, NOP, 4); in PyCode_Optimize()
592 else if (UNCONDITIONAL_JUMP(codestr[i+1]) && in PyCode_Optimize()
594 memset(codestr+i+1, NOP, 3); in PyCode_Optimize()
600 for (i=0, nops=0 ; i<codelen ; i += CODESIZE(codestr[i])) { in PyCode_Optimize()
602 if (codestr[i] == NOP) in PyCode_Optimize()
617 opcode = codestr[i]; in PyCode_Optimize()
629 j = addrmap[GETARG(codestr, i)]; in PyCode_Optimize()
630 SETARG(codestr, i, j); in PyCode_Optimize()
639 j = addrmap[GETARG(codestr, i) + i + 3] - addrmap[i] - 3; in PyCode_Optimize()
640 SETARG(codestr, i, j); in PyCode_Optimize()
645 codestr[h++] = codestr[i++]; in PyCode_Optimize()
649 code = PyString_FromStringAndSize((char *)codestr, h); in PyCode_Optimize()
651 PyMem_Free(codestr); in PyCode_Optimize()
663 if (codestr != NULL) in PyCode_Optimize()
664 PyMem_Free(codestr); in PyCode_Optimize()