| OLD | NEW |
| 1 | 1 |
| 2 /* Execute compiled code */ | 2 /* Execute compiled code */ |
| 3 | 3 |
| 4 /* XXX TO DO: | 4 /* XXX TO DO: |
| 5 XXX speed up searching for keywords by using a dictionary | 5 XXX speed up searching for keywords by using a dictionary |
| 6 XXX document it! | 6 XXX document it! |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /* enable more aggressive intra-module optimizations, where available */ | 9 /* enable more aggressive intra-module optimizations, where available */ |
| 10 #define PY_LOCAL_AGGRESSIVE | 10 #define PY_LOCAL_AGGRESSIVE |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 #ifdef LLTRACE | 104 #ifdef LLTRACE |
| 105 static int lltrace; | 105 static int lltrace; |
| 106 static int prtrace(PyObject *, char *); | 106 static int prtrace(PyObject *, char *); |
| 107 #endif | 107 #endif |
| 108 static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, | 108 static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *, |
| 109 int, PyObject *); | 109 int, PyObject *); |
| 110 static int call_trace_protected(Py_tracefunc, PyObject *, | 110 static int call_trace_protected(Py_tracefunc, PyObject *, |
| 111 PyFrameObject *, int, PyObject *); | 111 PyFrameObject *, int, PyObject *); |
| 112 static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); | 112 static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); |
| 113 static int maybe_call_line_trace(Py_tracefunc, PyObject *, | 113 static int maybe_call_line_trace(Py_tracefunc, PyObject *, |
| 114 » » » » PyFrameObject *, int *, int *, int *); | 114 » » » » PyFrameObject *, int *, int *, int *, int *); |
| 115 | 115 |
| 116 static PyObject * apply_slice(PyObject *, PyObject *, PyObject *); | 116 static PyObject * apply_slice(PyObject *, PyObject *, PyObject *); |
| 117 static int assign_slice(PyObject *, PyObject *, | 117 static int assign_slice(PyObject *, PyObject *, |
| 118 PyObject *, PyObject *); | 118 PyObject *, PyObject *); |
| 119 static PyObject * cmp_outcome(int, PyObject *, PyObject *); | 119 static PyObject * cmp_outcome(int, PyObject *, PyObject *); |
| 120 static PyObject * import_from(PyObject *, PyObject *); | 120 static PyObject * import_from(PyObject *, PyObject *); |
| 121 static int import_all_from(PyObject *, PyObject *); | 121 static int import_all_from(PyObject *, PyObject *); |
| 122 static PyObject * build_class(PyObject *, PyObject *, PyObject *); | 122 static PyObject * build_class(PyObject *, PyObject *, PyObject *); |
| 123 static int exec_statement(PyFrameObject *, | 123 static int exec_statement(PyFrameObject *, |
| 124 PyObject *, PyObject *, PyObject *); | 124 PyObject *, PyObject *, PyObject *); |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 register PyObject *u; | 681 register PyObject *u; |
| 682 register PyObject *t; | 682 register PyObject *t; |
| 683 register PyObject *stream = NULL; /* for PRINT opcodes */ | 683 register PyObject *stream = NULL; /* for PRINT opcodes */ |
| 684 register PyObject **fastlocals, **freevars; | 684 register PyObject **fastlocals, **freevars; |
| 685 PyObject *retval = NULL; /* Return value */ | 685 PyObject *retval = NULL; /* Return value */ |
| 686 PyThreadState *tstate = PyThreadState_GET(); | 686 PyThreadState *tstate = PyThreadState_GET(); |
| 687 PyCodeObject *co; | 687 PyCodeObject *co; |
| 688 | 688 |
| 689 /* when tracing we set things up so that | 689 /* when tracing we set things up so that |
| 690 | 690 |
| 691 not (instr_lb <= current_bytecode_offset < instr_ub) | 691 instr_lb <= current_bytecode_offset < instr_ub |
| 692 | 692 |
| 693 » is true when the line being executed has changed. The | 693 » is false when the line being executed may have changed. |
| 694 initial values are such as to make this false the first | 694 » The initial values are such as to make this false the first |
| 695 time it is tested. */ | 695 » time it is tested. Then maybe_call_line_trace calls |
| 696 » PyCode_CheckLineNumber() to check if the line has actually |
| 697 » changed. */ |
| 696 int instr_ub = -1, instr_lb = 0, instr_prev = -1; | 698 int instr_ub = -1, instr_lb = 0, instr_prev = -1; |
| 699 int cur_line = 0; |
| 697 | 700 |
| 698 unsigned char *first_instr; | 701 unsigned char *first_instr; |
| 699 PyObject *names; | 702 PyObject *names; |
| 700 PyObject *consts; | 703 PyObject *consts; |
| 701 #if defined(Py_DEBUG) || defined(LLTRACE) | 704 #if defined(Py_DEBUG) || defined(LLTRACE) |
| 702 /* Make it easier to find out where we are with a debugger */ | 705 /* Make it easier to find out where we are with a debugger */ |
| 703 char *filename; | 706 char *filename; |
| 704 #endif | 707 #endif |
| 705 | 708 |
| 706 /* Tuple access macros */ | 709 /* Tuple access macros */ |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 they were a single new opcode with the bodies combined. | 781 they were a single new opcode with the bodies combined. |
| 779 | 782 |
| 780 If collecting opcode statistics, your choices are to either keep the | 783 If collecting opcode statistics, your choices are to either keep the |
| 781 predictions turned-on and interpret the results as if some opcodes | 784 predictions turned-on and interpret the results as if some opcodes |
| 782 had been combined or turn-off predictions so that the opcode frequency | 785 had been combined or turn-off predictions so that the opcode frequency |
| 783 counter updates for both opcodes. | 786 counter updates for both opcodes. |
| 784 */ | 787 */ |
| 785 | 788 |
| 786 #ifdef DYNAMIC_EXECUTION_PROFILE | 789 #ifdef DYNAMIC_EXECUTION_PROFILE |
| 787 #define PREDICT(op) if (0) goto PRED_##op | 790 #define PREDICT(op) if (0) goto PRED_##op |
| 791 #define PREDICT_WITH_SIGNALS(op) if (0) goto PRED_##op |
| 788 #else | 792 #else |
| 789 #define PREDICT(op) if (*next_instr == op) goto PRED_##op | 793 #define PREDICT(op) if (*next_instr == op) goto PRED_##op |
| 794 #define PREDICT_WITH_SIGNALS(op) \ |
| 795 if (*next_instr == op && --_Py_Ticker > 0) goto PRED_##op |
| 790 #endif | 796 #endif |
| 791 | 797 |
| 792 #define PREDICTED(op) PRED_##op: next_instr++ | 798 #define PREDICTED(op) PRED_##op: next_instr++ |
| 793 #define PREDICTED_WITH_ARG(op) PRED_##op: oparg = PEEKARG(); next_instr += 3 | 799 #define PREDICTED_WITH_ARG(op) PRED_##op: oparg = PEEKARG(); next_instr += 3 |
| 794 | 800 |
| 795 /* Stack manipulation macros */ | 801 /* Stack manipulation macros */ |
| 796 | 802 |
| 797 /* The stack can grow at most MAXINT deep, as co_nlocals and | 803 /* The stack can grow at most MAXINT deep, as co_nlocals and |
| 798 co_stacksize are ints. */ | 804 co_stacksize are ints. */ |
| 799 #define STACK_LEVEL() ((int)(stack_pointer - f->f_valuestack)) | 805 #define STACK_LEVEL() ((int)(stack_pointer - f->f_valuestack)) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 this wasn't always true before 2.3! PyFrame_New now sets | 907 this wasn't always true before 2.3! PyFrame_New now sets |
| 902 f->f_lasti to -1 (i.e. the index *before* the first instruction) | 908 f->f_lasti to -1 (i.e. the index *before* the first instruction) |
| 903 and YIELD_VALUE doesn't fiddle with f_lasti any more. So this | 909 and YIELD_VALUE doesn't fiddle with f_lasti any more. So this |
| 904 does work. Promise. | 910 does work. Promise. |
| 905 | 911 |
| 906 When the PREDICT() macros are enabled, some opcode pairs follow in | 912 When the PREDICT() macros are enabled, some opcode pairs follow in |
| 907 direct succession without updating f->f_lasti. A successful | 913 direct succession without updating f->f_lasti. A successful |
| 908 prediction effectively links the two codes together as if they | 914 prediction effectively links the two codes together as if they |
| 909 were a single new opcode; accordingly,f->f_lasti will point to | 915 were a single new opcode; accordingly,f->f_lasti will point to |
| 910 the first code in the pair (for instance, GET_ITER followed by | 916 the first code in the pair (for instance, GET_ITER followed by |
| 911 FOR_ITER is effectively a single opcode and f->f_lasti will point | 917 JUMP_FORWARD is effectively a single opcode and f->f_lasti will |
| 912 at to the beginning of the combined pair.) | 918 point at to the beginning of the combined pair.) |
| 913 */ | 919 */ |
| 914 next_instr = first_instr + f->f_lasti + 1; | 920 next_instr = first_instr + f->f_lasti + 1; |
| 915 stack_pointer = f->f_stacktop; | 921 stack_pointer = f->f_stacktop; |
| 916 assert(stack_pointer != NULL); | 922 assert(stack_pointer != NULL); |
| 917 f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */ | 923 f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */ |
| 918 | 924 |
| 919 #ifdef LLTRACE | 925 #ifdef LLTRACE |
| 920 lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL; | 926 lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL; |
| 921 #endif | 927 #endif |
| 922 #if defined(Py_DEBUG) || defined(LLTRACE) | 928 #if defined(Py_DEBUG) || defined(LLTRACE) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 | 1026 |
| 1021 if (_Py_TracingPossible && | 1027 if (_Py_TracingPossible && |
| 1022 tstate->c_tracefunc != NULL && !tstate->tracing) { | 1028 tstate->c_tracefunc != NULL && !tstate->tracing) { |
| 1023 /* see maybe_call_line_trace | 1029 /* see maybe_call_line_trace |
| 1024 for expository comments */ | 1030 for expository comments */ |
| 1025 f->f_stacktop = stack_pointer; | 1031 f->f_stacktop = stack_pointer; |
| 1026 | 1032 |
| 1027 err = maybe_call_line_trace(tstate->c_tracefunc, | 1033 err = maybe_call_line_trace(tstate->c_tracefunc, |
| 1028 tstate->c_traceobj, | 1034 tstate->c_traceobj, |
| 1029 f, &instr_lb, &instr_ub, | 1035 f, &instr_lb, &instr_ub, |
| 1030 » » » » » » &instr_prev); | 1036 » » » » » » &instr_prev, &cur_line); |
| 1031 /* Reload possibly changed frame fields */ | 1037 /* Reload possibly changed frame fields */ |
| 1032 JUMPTO(f->f_lasti); | 1038 JUMPTO(f->f_lasti); |
| 1033 if (f->f_stacktop != NULL) { | 1039 if (f->f_stacktop != NULL) { |
| 1034 stack_pointer = f->f_stacktop; | 1040 stack_pointer = f->f_stacktop; |
| 1035 f->f_stacktop = NULL; | 1041 f->f_stacktop = NULL; |
| 1036 } | 1042 } |
| 1037 if (err) { | 1043 if (err) { |
| 1038 /* trace function raised an exception */ | 1044 /* trace function raised an exception */ |
| 1039 goto on_error; | 1045 goto on_error; |
| 1040 } | 1046 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 SET_TOP(x); | 1424 SET_TOP(x); |
| 1419 if (x != NULL) continue; | 1425 if (x != NULL) continue; |
| 1420 break; | 1426 break; |
| 1421 | 1427 |
| 1422 case LIST_APPEND: | 1428 case LIST_APPEND: |
| 1423 w = POP(); | 1429 w = POP(); |
| 1424 v = stack_pointer[-oparg]; | 1430 v = stack_pointer[-oparg]; |
| 1425 err = PyList_Append(v, w); | 1431 err = PyList_Append(v, w); |
| 1426 Py_DECREF(w); | 1432 Py_DECREF(w); |
| 1427 if (err == 0) { | 1433 if (err == 0) { |
| 1428 » » » » PREDICT(JUMP_ABSOLUTE); | 1434 » » » » PREDICT(FOR_ITER); |
| 1429 continue; | 1435 continue; |
| 1430 } | 1436 } |
| 1431 break; | 1437 break; |
| 1432 | 1438 |
| 1433 case INPLACE_POWER: | 1439 case INPLACE_POWER: |
| 1434 w = POP(); | 1440 w = POP(); |
| 1435 v = TOP(); | 1441 v = TOP(); |
| 1436 x = PyNumber_InPlacePower(v, w, Py_None); | 1442 x = PyNumber_InPlacePower(v, w, Py_None); |
| 1437 Py_DECREF(v); | 1443 Py_DECREF(v); |
| 1438 Py_DECREF(w); | 1444 Py_DECREF(w); |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2286 case IMPORT_FROM: | 2292 case IMPORT_FROM: |
| 2287 w = GETITEM(names, oparg); | 2293 w = GETITEM(names, oparg); |
| 2288 v = TOP(); | 2294 v = TOP(); |
| 2289 READ_TIMESTAMP(intr0); | 2295 READ_TIMESTAMP(intr0); |
| 2290 x = import_from(v, w); | 2296 x = import_from(v, w); |
| 2291 READ_TIMESTAMP(intr1); | 2297 READ_TIMESTAMP(intr1); |
| 2292 PUSH(x); | 2298 PUSH(x); |
| 2293 if (x != NULL) continue; | 2299 if (x != NULL) continue; |
| 2294 break; | 2300 break; |
| 2295 | 2301 |
| 2302 PREDICTED_WITH_ARG(JUMP_FORWARD); |
| 2296 case JUMP_FORWARD: | 2303 case JUMP_FORWARD: |
| 2297 JUMPBY(oparg); | 2304 JUMPBY(oparg); |
| 2298 goto fast_next_opcode; | 2305 goto fast_next_opcode; |
| 2299 | 2306 |
| 2300 PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE); | 2307 PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE); |
| 2301 case POP_JUMP_IF_FALSE: | 2308 case POP_JUMP_IF_FALSE: |
| 2302 w = POP(); | 2309 w = POP(); |
| 2303 if (w == Py_True) { | 2310 if (w == Py_True) { |
| 2304 Py_DECREF(w); | 2311 Py_DECREF(w); |
| 2305 goto fast_next_opcode; | 2312 goto fast_next_opcode; |
| 2306 } | 2313 } |
| 2307 if (w == Py_False) { | 2314 if (w == Py_False) { |
| 2308 Py_DECREF(w); | 2315 Py_DECREF(w); |
| 2309 JUMPTO(oparg); | 2316 JUMPTO(oparg); |
| 2317 #if FAST_LOOPS /* See JUMP_ABSOLUTE for a description of this define */ |
| 2310 goto fast_next_opcode; | 2318 goto fast_next_opcode; |
| 2319 #else |
| 2320 continue; |
| 2321 #endif |
| 2311 } | 2322 } |
| 2312 err = PyObject_IsTrue(w); | 2323 err = PyObject_IsTrue(w); |
| 2313 Py_DECREF(w); | 2324 Py_DECREF(w); |
| 2314 if (err > 0) | 2325 if (err > 0) |
| 2315 err = 0; | 2326 err = 0; |
| 2316 » » » else if (err == 0) | 2327 » » » else if (err == 0) { |
| 2317 JUMPTO(oparg); | 2328 JUMPTO(oparg); |
| 2329 #if FAST_LOOPS /* See JUMP_ABSOLUTE for a description of this define */ |
| 2330 goto fast_next_opcode; |
| 2331 #endif |
| 2332 } |
| 2318 else | 2333 else |
| 2319 break; | 2334 break; |
| 2320 continue; | 2335 continue; |
| 2321 | 2336 |
| 2322 PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE); | 2337 PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE); |
| 2323 case POP_JUMP_IF_TRUE: | 2338 case POP_JUMP_IF_TRUE: |
| 2324 w = POP(); | 2339 w = POP(); |
| 2325 if (w == Py_False) { | 2340 if (w == Py_False) { |
| 2326 Py_DECREF(w); | 2341 Py_DECREF(w); |
| 2327 goto fast_next_opcode; | 2342 goto fast_next_opcode; |
| 2328 } | 2343 } |
| 2329 if (w == Py_True) { | 2344 if (w == Py_True) { |
| 2330 Py_DECREF(w); | 2345 Py_DECREF(w); |
| 2331 JUMPTO(oparg); | 2346 JUMPTO(oparg); |
| 2347 #if FAST_LOOPS /* See JUMP_ABSOLUTE for a description of this define */ |
| 2332 goto fast_next_opcode; | 2348 goto fast_next_opcode; |
| 2349 #else |
| 2350 continue; |
| 2351 #endif |
| 2333 } | 2352 } |
| 2334 err = PyObject_IsTrue(w); | 2353 err = PyObject_IsTrue(w); |
| 2335 Py_DECREF(w); | 2354 Py_DECREF(w); |
| 2336 if (err > 0) { | 2355 if (err > 0) { |
| 2337 err = 0; | 2356 err = 0; |
| 2338 JUMPTO(oparg); | 2357 JUMPTO(oparg); |
| 2358 #if FAST_LOOPS /* See JUMP_ABSOLUTE for a description of this define */ |
| 2359 goto fast_next_opcode; |
| 2360 #endif |
| 2339 } | 2361 } |
| 2340 else if (err == 0) | 2362 else if (err == 0) |
| 2341 ; | 2363 ; |
| 2342 else | 2364 else |
| 2343 break; | 2365 break; |
| 2344 continue; | 2366 continue; |
| 2345 | 2367 |
| 2346 case JUMP_IF_FALSE_OR_POP: | 2368 case JUMP_IF_FALSE_OR_POP: |
| 2347 w = TOP(); | 2369 w = TOP(); |
| 2348 if (w == Py_True) { | 2370 if (w == Py_True) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 JUMPTO(oparg); | 2405 JUMPTO(oparg); |
| 2384 } | 2406 } |
| 2385 else if (err == 0) { | 2407 else if (err == 0) { |
| 2386 STACKADJ(-1); | 2408 STACKADJ(-1); |
| 2387 Py_DECREF(w); | 2409 Py_DECREF(w); |
| 2388 } | 2410 } |
| 2389 else | 2411 else |
| 2390 break; | 2412 break; |
| 2391 continue; | 2413 continue; |
| 2392 | 2414 |
| 2393 PREDICTED_WITH_ARG(JUMP_ABSOLUTE); | |
| 2394 case JUMP_ABSOLUTE: | 2415 case JUMP_ABSOLUTE: |
| 2395 JUMPTO(oparg); | 2416 JUMPTO(oparg); |
| 2396 #if FAST_LOOPS | 2417 #if FAST_LOOPS |
| 2397 /* Enabling this path speeds-up all while and for-loops
by bypassing | 2418 /* Enabling this path speeds-up all while and for-loops
by bypassing |
| 2398 the per-loop checks for signals. By default, this sh
ould be turned-off | 2419 the per-loop checks for signals. By default, this sh
ould be turned-off |
| 2399 because it prevents detection of a control-break in t
ight loops like | 2420 because it prevents detection of a control-break in t
ight loops like |
| 2400 "while 1: pass". Compile with this option turned-on
when you need | 2421 "while 1: pass". Compile with this option turned-on
when you need |
| 2401 the speed-up and do not need break checking inside ti
ght loops (ones | 2422 the speed-up and do not need break checking inside ti
ght loops (ones |
| 2402 that contain only instructions ending with goto fast_
next_opcode). | 2423 that contain only instructions ending with goto fast_
next_opcode). |
| 2403 */ | 2424 */ |
| 2404 goto fast_next_opcode; | 2425 goto fast_next_opcode; |
| 2405 #else | 2426 #else |
| 2406 continue; | 2427 continue; |
| 2407 #endif | 2428 #endif |
| 2408 | 2429 |
| 2409 case GET_ITER: | 2430 case GET_ITER: |
| 2410 /* before: [obj]; after [getiter(obj)] */ | 2431 /* before: [obj]; after [getiter(obj)] */ |
| 2411 v = TOP(); | 2432 v = TOP(); |
| 2412 x = PyObject_GetIter(v); | 2433 x = PyObject_GetIter(v); |
| 2413 Py_DECREF(v); | 2434 Py_DECREF(v); |
| 2414 if (x != NULL) { | 2435 if (x != NULL) { |
| 2415 SET_TOP(x); | 2436 SET_TOP(x); |
| 2416 » » » » PREDICT(FOR_ITER); | 2437 » » » » PREDICT(JUMP_FORWARD); |
| 2417 continue; | 2438 continue; |
| 2418 } | 2439 } |
| 2419 STACKADJ(-1); | 2440 STACKADJ(-1); |
| 2420 break; | 2441 break; |
| 2421 | 2442 |
| 2422 PREDICTED_WITH_ARG(FOR_ITER); | 2443 PREDICTED_WITH_ARG(FOR_ITER); |
| 2423 case FOR_ITER: | 2444 case FOR_ITER: |
| 2424 /* before: [iter]; after: [iter, iter()] *or* [] */ | 2445 /* before: [iter]; after: [iter, iter()] *or* [] */ |
| 2425 v = TOP(); | 2446 v = TOP(); |
| 2426 x = (*v->ob_type->tp_iternext)(v); | 2447 x = (*v->ob_type->tp_iternext)(v); |
| 2427 if (x != NULL) { | 2448 if (x != NULL) { |
| 2428 PUSH(x); | 2449 PUSH(x); |
| 2429 » » » » PREDICT(STORE_FAST); | 2450 » » » » JUMPTO(oparg); |
| 2451 » » » » /* STORE_FAST is a fast_next_opcode so we must b
e careful |
| 2452 » » » » about not blocking signals in an empty loop.
*/ |
| 2453 » » » » PREDICT_WITH_SIGNALS(STORE_FAST); |
| 2430 PREDICT(UNPACK_SEQUENCE); | 2454 PREDICT(UNPACK_SEQUENCE); |
| 2431 continue; | 2455 continue; |
| 2432 } | 2456 } |
| 2433 if (PyErr_Occurred()) { | 2457 if (PyErr_Occurred()) { |
| 2434 if (!PyErr_ExceptionMatches( | 2458 if (!PyErr_ExceptionMatches( |
| 2435 PyExc_StopIteration)) | 2459 PyExc_StopIteration)) |
| 2436 break; | 2460 break; |
| 2437 PyErr_Clear(); | 2461 PyErr_Clear(); |
| 2438 } | 2462 } |
| 2439 /* iterator ended normally */ | 2463 /* iterator ended normally */ |
| 2440 » » » x = v = POP(); | 2464 » » » x = v = POP(); |
| 2441 Py_DECREF(v); | 2465 Py_DECREF(v); |
| 2442 JUMPBY(oparg); | |
| 2443 continue; | 2466 continue; |
| 2444 | 2467 |
| 2445 case BREAK_LOOP: | 2468 case BREAK_LOOP: |
| 2446 why = WHY_BREAK; | 2469 why = WHY_BREAK; |
| 2447 goto fast_block_end; | 2470 goto fast_block_end; |
| 2448 | 2471 |
| 2449 case CONTINUE_LOOP: | 2472 case CONTINUE_LOOP: |
| 2450 retval = PyInt_FromLong(oparg); | 2473 retval = PyInt_FromLong(oparg); |
| 2451 if (!retval) { | 2474 if (!retval) { |
| 2452 x = NULL; | 2475 x = NULL; |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3587 || (tstate->c_profilefunc != NULL)); | 3610 || (tstate->c_profilefunc != NULL)); |
| 3588 result = PyObject_Call(func, args, NULL); | 3611 result = PyObject_Call(func, args, NULL); |
| 3589 tstate->tracing = save_tracing; | 3612 tstate->tracing = save_tracing; |
| 3590 tstate->use_tracing = save_use_tracing; | 3613 tstate->use_tracing = save_use_tracing; |
| 3591 return result; | 3614 return result; |
| 3592 } | 3615 } |
| 3593 | 3616 |
| 3594 static int | 3617 static int |
| 3595 maybe_call_line_trace(Py_tracefunc func, PyObject *obj, | 3618 maybe_call_line_trace(Py_tracefunc func, PyObject *obj, |
| 3596 PyFrameObject *frame, int *instr_lb, int *instr_ub, | 3619 PyFrameObject *frame, int *instr_lb, int *instr_ub, |
| 3597 » » int *instr_prev) | 3620 » » int *instr_prev, int *cur_line) |
| 3598 { | 3621 { |
| 3599 int result = 0; | 3622 int result = 0; |
| 3600 | 3623 |
| 3601 /* If the last instruction executed isn't in the current | 3624 /* If the last instruction executed isn't in the current |
| 3602 instruction window, reset the window. If the last | 3625 instruction window, reset the window. If the last |
| 3603 instruction happens to fall at the start of a line or if it | 3626 instruction happens to fall at the start of a line or if it |
| 3604 represents a jump backwards, call the trace function. | 3627 represents a jump backwards, call the trace function. |
| 3605 */ | 3628 */ |
| 3606 if ((frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub)) { | 3629 if ((frame->f_lasti < *instr_lb || frame->f_lasti >= *instr_ub)) { |
| 3607 int line; | 3630 int line; |
| 3608 PyAddrPair bounds; | 3631 PyAddrPair bounds; |
| 3609 | 3632 |
| 3610 line = PyCode_CheckLineNumber(frame->f_code, frame->f_lasti, | 3633 line = PyCode_CheckLineNumber(frame->f_code, frame->f_lasti, |
| 3611 &bounds); | 3634 &bounds); |
| 3612 » » if (line >= 0) { | 3635 » » if (line >= 0 && line != *cur_line) { |
| 3613 frame->f_lineno = line; | 3636 frame->f_lineno = line; |
| 3614 result = call_trace(func, obj, frame, | 3637 result = call_trace(func, obj, frame, |
| 3615 PyTrace_LINE, Py_None); | 3638 PyTrace_LINE, Py_None); |
| 3616 } | 3639 } |
| 3617 *instr_lb = bounds.ap_lower; | 3640 *instr_lb = bounds.ap_lower; |
| 3618 *instr_ub = bounds.ap_upper; | 3641 *instr_ub = bounds.ap_upper; |
| 3642 *cur_line = line; |
| 3619 } | 3643 } |
| 3620 else if (frame->f_lasti <= *instr_prev) { | 3644 else if (frame->f_lasti <= *instr_prev) { |
| 3621 result = call_trace(func, obj, frame, PyTrace_LINE, Py_None); | 3645 result = call_trace(func, obj, frame, PyTrace_LINE, Py_None); |
| 3622 } | 3646 } |
| 3623 *instr_prev = frame->f_lasti; | 3647 *instr_prev = frame->f_lasti; |
| 3624 return result; | 3648 return result; |
| 3625 } | 3649 } |
| 3626 | 3650 |
| 3627 void | 3651 void |
| 3628 PyEval_SetProfile(Py_tracefunc func, PyObject *arg) | 3652 PyEval_SetProfile(Py_tracefunc func, PyObject *arg) |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4771 Py_DECREF(l); | 4795 Py_DECREF(l); |
| 4772 return NULL; | 4796 return NULL; |
| 4773 } | 4797 } |
| 4774 PyList_SetItem(l, i, x); | 4798 PyList_SetItem(l, i, x); |
| 4775 } | 4799 } |
| 4776 return l; | 4800 return l; |
| 4777 #endif | 4801 #endif |
| 4778 } | 4802 } |
| 4779 | 4803 |
| 4780 #endif | 4804 #endif |
| OLD | NEW |