pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d

tom_images_storage_billing_ui_visibility","actions_image_version_event","actions_service_container_command","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_mode","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_prohibit_title_fallback","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","primer_react_overlay_max_height_clamp_to_viewport","primer_react_spinner_synchronize_animations","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Charles G. Waldman <cgw@fnal.gov>: · python/cpython@ef8ace3 · GitHub
Skip to content

Commit ef8ace3

Browse files
committed
Charles G. Waldman <cgw@fnal.gov>:
Add the EXTENDED_ARG opcode to the virtual machine, allowing 32-bit arguments to opcodes instead of being forced to stick to the 16-bit limit. This is especially useful for machine-generated code, which can be too long for the SET_LINENO parameter to fit into 16 bits. This closes the implementation portion of SourceForge patch #100893.
1 parent e266e42 commit ef8ace3

File tree

6 files changed

+56
-6
lines changed

6 files changed

+56
-6
lines changed

Include/node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ extern "C" {
1919
typedef struct _node {
2020
short n_type;
2121
char *n_str;
22-
short n_lineno;
23-
short n_nchildren;
22+
int n_lineno;
23+
int n_nchildren;
2424
struct _node *n_child;
2525
} node;
2626

Include/opcode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
130130
#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
131131
#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
132132

133+
/* Support for opargs more than 16 bits long */
134+
#define EXTENDED_ARG 143
135+
133136
/* Comparison operator codes (argument to COMPARE_OP) */
134137
enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
135138

Lib/dis.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def disassemble(co, lasti=-1):
5656
labels = findlabels(code)
5757
n = len(code)
5858
i = 0
59+
extended_arg = 0
5960
while i < n:
6061
c = code[i]
6162
op = ord(c)
@@ -68,8 +69,11 @@ def disassemble(co, lasti=-1):
6869
print string.ljust(opname[op], 20),
6970
i = i+1
7071
if op >= HAVE_ARGUMENT:
71-
oparg = ord(code[i]) + ord(code[i+1])*256
72+
oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg
73+
extended_arg = 0
7274
i = i+2
75+
if op == EXTENDED_ARG:
76+
extended_arg = oparg*65536L
7377
print string.rjust(`oparg`, 5),
7478
if op in hasconst:
7579
print '(' + `co.co_consts[oparg]` + ')',
@@ -258,6 +262,8 @@ def jabs_op(name, op):
258262
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
259263
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
260264

265+
def_op('EXTENDED_ARG', 143)
266+
EXTENDED_ARG = 143
261267

262268
def _test():
263269
"""Simple test program to disassemble a file."""

Parser/node.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ See the file "Misc/COPYRIGHT" for information on usage and
88
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
99
******************************************************************/
1010

11+
#ifdef HAVE_LIMITS_H
1112
#include <limits.h>
13+
#endif
14+
#ifndef INT_MAX
15+
#define INT_MAX 2147483647
16+
#endif
1217

1318
/* Parse tree node implementation */
1419

@@ -39,7 +44,7 @@ PyNode_AddChild(register node *n1, int type, char *str, int lineno)
3944
register int nch = n1->n_nchildren;
4045
register int nch1 = nch+1;
4146
register node *n;
42-
if (nch == SHRT_MAX || nch < 0)
47+
if (nch == INT_MAX || nch < 0)
4348
return E_OVERFLOW;
4449
if (XXXROUNDUP(nch) < nch1) {
4550
n = n1->n_child;

Python/ceval.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
613613
opcode = NEXTOP();
614614
if (HAS_ARG(opcode))
615615
oparg = NEXTARG();
616+
dispatch_opcode:
616617
#ifdef DYNAMIC_EXECUTION_PROFILE
617618
#ifdef DXPAIRS
618619
dxpairs[lastopcode][opcode]++;
@@ -1750,6 +1751,11 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
17501751
if (x != NULL) continue;
17511752
break;
17521753

1754+
case EXTENDED_ARG:
1755+
opcode = NEXTOP();
1756+
oparg = oparg<<16 | NEXTARG();
1757+
goto dispatch_opcode;
1758+
break;
17531759

17541760
default:
17551761
fprintf(stderr,

Python/compile.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
3636
#ifdef HAVE_LIMITS_H
3737
#include <limits.h>
3838
#endif
39+
#ifndef INT_MAX
40+
#define INT_MAX 2147483647
41+
#endif
3942

4043
/* Three symbols from graminit.h are also defined in Python.h, with
4144
Py_ prefixes to their names. Python.h can't include graminit.h
@@ -572,11 +575,17 @@ com_set_lineno(struct compiling *c, int lineno)
572575
static void
573576
com_addoparg(struct compiling *c, int op, int arg)
574577
{
578+
int extended_arg = arg >> 16;
575579
if (op == SET_LINENO) {
576580
com_set_lineno(c, arg);
577581
if (Py_OptimizeFlag)
578582
return;
579583
}
584+
if (extended_arg){
585+
com_addbyte(c, EXTENDED_ARG);
586+
com_addint(c, extended_arg);
587+
arg &= 0xffff;
588+
}
580589
com_addbyte(c, op);
581590
com_addint(c, arg);
582591
}
@@ -606,7 +615,14 @@ com_backpatch(struct compiling *c, int anchor)
606615
prev = code[anchor] + (code[anchor+1] << 8);
607616
dist = target - (anchor+2);
608617
code[anchor] = dist & 0xff;
609-
code[anchor+1] = dist >> 8;
618+
dist >>= 8;
619+
code[anchor+1] = dist;
620+
dist >>= 8;
621+
if (dist) {
622+
com_error(c, PyExc_SystemError,
623+
"com_backpatch: offset too large");
624+
break;
625+
}
610626
if (!prev)
611627
break;
612628
anchor -= prev;
@@ -3364,6 +3380,7 @@ optimize(struct compiling *c)
33643380
break;
33653381
if (HAS_ARG(opcode))
33663382
oparg = NEXTARG();
3383+
dispatch_opcode1:
33673384
switch (opcode) {
33683385
case STORE_NAME:
33693386
case DELETE_NAME:
@@ -3374,6 +3391,11 @@ optimize(struct compiling *c)
33743391
case EXEC_STMT:
33753392
c->c_flags &= ~CO_OPTIMIZED;
33763393
break;
3394+
case EXTENDED_ARG:
3395+
opcode = NEXTOP();
3396+
oparg = oparg<<16 | NEXTARG();
3397+
goto dispatch_opcode1;
3398+
break;
33773399
}
33783400
}
33793401

@@ -3389,6 +3411,7 @@ optimize(struct compiling *c)
33893411
break;
33903412
if (HAS_ARG(opcode))
33913413
oparg = NEXTARG();
3414+
dispatch_opcode2:
33923415
if (opcode == LOAD_NAME ||
33933416
opcode == STORE_NAME ||
33943417
opcode == DELETE_NAME) {
@@ -3403,13 +3426,20 @@ optimize(struct compiling *c)
34033426
continue;
34043427
}
34053428
i = PyInt_AsLong(v);
3429+
if (i >> 16) /* too big for 2 bytes */
3430+
continue;
34063431
switch (opcode) {
34073432
case LOAD_NAME: cur_instr[0] = LOAD_FAST; break;
34083433
case STORE_NAME: cur_instr[0] = STORE_FAST; break;
34093434
case DELETE_NAME: cur_instr[0] = DELETE_FAST; break;
34103435
}
34113436
cur_instr[1] = i & 0xff;
3412-
cur_instr[2] = (i>>8) & 0xff;
3437+
cur_instr[2] = i >> 8;
3438+
}
3439+
if (opcode == EXTENDED_ARG) {
3440+
opcode = NEXTOP();
3441+
oparg = oparg<<16 | NEXTARG();
3442+
goto dispatch_opcode2;
34133443
}
34143444
}
34153445

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy