|
5470 | 5470 | DISPATCH(); |
5471 | 5471 | } |
5472 | 5472 |
|
| 5473 | + TARGET(EAGER_IMPORT_NAME) { |
| 5474 | + #if Py_TAIL_CALL_INTERP |
| 5475 | + int opcode = EAGER_IMPORT_NAME; |
| 5476 | + (void)(opcode); |
| 5477 | + #endif |
| 5478 | + frame->instr_ptr = next_instr; |
| 5479 | + next_instr += 1; |
| 5480 | + INSTRUCTION_STATS(EAGER_IMPORT_NAME); |
| 5481 | + _PyStackRef level; |
| 5482 | + _PyStackRef fromlist; |
| 5483 | + _PyStackRef res; |
| 5484 | + fromlist = stack_pointer[-1]; |
| 5485 | + level = stack_pointer[-2]; |
| 5486 | + PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); |
| 5487 | + #ifdef ENABLE_LAZY_IMPORTS |
| 5488 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 5489 | + PyObject *res_o = _PyImport_ImportName( |
| 5490 | + tstate, BUILTINS(), GLOBALS(), LOCALS(), name, |
| 5491 | + PyStackRef_AsPyObjectBorrow(fromlist), PyStackRef_AsPyObjectBorrow(level)); |
| 5492 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 5493 | + #else |
| 5494 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 5495 | + PyObject *res_o = _PyEval_ImportName(tstate, frame, name, |
| 5496 | + PyStackRef_AsPyObjectBorrow(fromlist), |
| 5497 | + PyStackRef_AsPyObjectBorrow(level)); |
| 5498 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 5499 | + #endif |
| 5500 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 5501 | + _PyStackRef tmp = fromlist; |
| 5502 | + fromlist = PyStackRef_NULL; |
| 5503 | + stack_pointer[-1] = fromlist; |
| 5504 | + PyStackRef_CLOSE(tmp); |
| 5505 | + tmp = level; |
| 5506 | + level = PyStackRef_NULL; |
| 5507 | + stack_pointer[-2] = level; |
| 5508 | + PyStackRef_CLOSE(tmp); |
| 5509 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 5510 | + stack_pointer += -2; |
| 5511 | + assert(WITHIN_STACK_BOUNDS()); |
| 5512 | + if (res_o == NULL) { |
| 5513 | + JUMP_TO_LABEL(error); |
| 5514 | + } |
| 5515 | + res = PyStackRef_FromPyObjectSteal(res_o); |
| 5516 | + stack_pointer[0] = res; |
| 5517 | + stack_pointer += 1; |
| 5518 | + assert(WITHIN_STACK_BOUNDS()); |
| 5519 | + DISPATCH(); |
| 5520 | + } |
| 5521 | + |
5473 | 5522 | TARGET(END_ASYNC_FOR) { |
5474 | 5523 | #if Py_TAIL_CALL_INTERP |
5475 | 5524 | int opcode = END_ASYNC_FOR; |
|
6315 | 6364 | _PyStackRef res; |
6316 | 6365 | from = stack_pointer[-1]; |
6317 | 6366 | PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); |
| 6367 | + #ifdef ENABLE_LAZY_IMPORTS |
| 6368 | + PyObject *from_o = PyStackRef_AsPyObjectBorrow(from); |
| 6369 | + PyObject *res_o; |
| 6370 | + if (PyLazyImport_CheckExact(from_o)) { |
| 6371 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 6372 | + res_o = _PyImport_LazyImportFrom(tstate, from_o, name); |
| 6373 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6374 | + } else { |
| 6375 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 6376 | + res_o = _PyImport_ImportFrom(tstate, from_o, name); |
| 6377 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6378 | + } |
| 6379 | + #else |
6318 | 6380 | _PyFrame_SetStackPointer(frame, stack_pointer); |
6319 | 6381 | PyObject *res_o = _PyEval_ImportFrom(tstate, PyStackRef_AsPyObjectBorrow(from), name); |
6320 | 6382 | stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6383 | + #endif |
6321 | 6384 | if (res_o == NULL) { |
6322 | 6385 | JUMP_TO_LABEL(error); |
6323 | 6386 | } |
|
6342 | 6405 | fromlist = stack_pointer[-1]; |
6343 | 6406 | level = stack_pointer[-2]; |
6344 | 6407 | PyObject *name = GETITEM(FRAME_CO_NAMES, oparg); |
| 6408 | + #if defined(ENABLE_LAZY_IMPORTS) && !defined(Py_GIL_DISABLED) |
| 6409 | + PyObject *res_o; |
| 6410 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 6411 | + bool active = _PyImport_IsLazyImportsActive(tstate); |
| 6412 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6413 | + if (active) { |
| 6414 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 6415 | + res_o = _PyImport_LazyImportName( |
| 6416 | + tstate, BUILTINS(), GLOBALS(), LOCALS(), name, |
| 6417 | + PyStackRef_AsPyObjectBorrow(fromlist), PyStackRef_AsPyObjectBorrow(level)); |
| 6418 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6419 | + } else { |
| 6420 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
| 6421 | + res_o = _PyImport_ImportName( |
| 6422 | + tstate, BUILTINS(), GLOBALS(), LOCALS(), name, |
| 6423 | + PyStackRef_AsPyObjectBorrow(fromlist), PyStackRef_AsPyObjectBorrow(level)); |
| 6424 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6425 | + } |
| 6426 | + #else |
6345 | 6427 | _PyFrame_SetStackPointer(frame, stack_pointer); |
6346 | 6428 | PyObject *res_o = _PyEval_ImportName(tstate, frame, name, |
6347 | 6429 | PyStackRef_AsPyObjectBorrow(fromlist), |
6348 | 6430 | PyStackRef_AsPyObjectBorrow(level)); |
| 6431 | + stack_pointer = _PyFrame_GetStackPointer(frame); |
| 6432 | + #endif |
| 6433 | + _PyFrame_SetStackPointer(frame, stack_pointer); |
6349 | 6434 | _PyStackRef tmp = fromlist; |
6350 | 6435 | fromlist = PyStackRef_NULL; |
6351 | 6436 | stack_pointer[-1] = fromlist; |
|
8528 | 8613 | assert(_PyOpcode_Deopt[opcode] == (LOAD_ATTR)); |
8529 | 8614 | JUMP_TO_PREDICTED(LOAD_ATTR); |
8530 | 8615 | } |
| 8616 | + #ifdef ENABLE_LAZY_IMPORTS |
| 8617 | + if (PyLazyImport_CheckExact(attr_o)) { |
| 8618 | + UPDATE_MISS_STATS(LOAD_ATTR); |
| 8619 | + assert(_PyOpcode_Deopt[opcode] == (LOAD_ATTR)); |
| 8620 | + JUMP_TO_PREDICTED(LOAD_ATTR); |
| 8621 | + } |
| 8622 | + #endif |
8531 | 8623 | #ifdef Py_GIL_DISABLED |
8532 | 8624 | int increfed = _Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr); |
8533 | 8625 | if (!increfed) { |
|
8915 | 9007 | JUMP_TO_PREDICTED(LOAD_ATTR); |
8916 | 9008 | } |
8917 | 9009 | } |
| 9010 | + #ifdef ENABLE_LAZY_IMPORTS |
| 9011 | + if (PyLazyImport_CheckExact(attr_o)) { |
| 9012 | + UPDATE_MISS_STATS(LOAD_ATTR); |
| 9013 | + assert(_PyOpcode_Deopt[opcode] == (LOAD_ATTR)); |
| 9014 | + JUMP_TO_PREDICTED(LOAD_ATTR); |
| 9015 | + } |
| 9016 | + #endif |
8918 | 9017 | STAT_INC(LOAD_ATTR, hit); |
8919 | 9018 | #ifdef Py_GIL_DISABLED |
8920 | 9019 | int increfed = _Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr); |
|
9442 | 9541 | assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); |
9443 | 9542 | JUMP_TO_PREDICTED(LOAD_GLOBAL); |
9444 | 9543 | } |
| 9544 | + #ifdef ENABLE_LAZY_IMPORTS |
| 9545 | + if (PyLazyImport_CheckExact(res_o)) { |
| 9546 | + UPDATE_MISS_STATS(LOAD_GLOBAL); |
| 9547 | + assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); |
| 9548 | + JUMP_TO_PREDICTED(LOAD_GLOBAL); |
| 9549 | + } |
| 9550 | + #endif |
9445 | 9551 | #if Py_GIL_DISABLED |
9446 | 9552 | int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); |
9447 | 9553 | if (!increfed) { |
|
9509 | 9615 | assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); |
9510 | 9616 | JUMP_TO_PREDICTED(LOAD_GLOBAL); |
9511 | 9617 | } |
| 9618 | + #ifdef ENABLE_LAZY_IMPORTS |
| 9619 | + if (PyLazyImport_CheckExact(res_o)) { |
| 9620 | + UPDATE_MISS_STATS(LOAD_GLOBAL); |
| 9621 | + assert(_PyOpcode_Deopt[opcode] == (LOAD_GLOBAL)); |
| 9622 | + JUMP_TO_PREDICTED(LOAD_GLOBAL); |
| 9623 | + } |
| 9624 | + #endif |
9512 | 9625 | #if Py_GIL_DISABLED |
9513 | 9626 | int increfed = _Py_TryIncrefCompareStackRef(&entries[index].me_value, res_o, &res); |
9514 | 9627 | if (!increfed) { |
|
0 commit comments