Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-114058: The Tier2 Optimizer#114059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
29db898c1332cc9d85c3576cee0cb71aa06f0e5dec52e368fa273a2f60a1d797077ad55169bf30929bb870ee73e7d664406b18e304b1dff46a61b189e32f75119548e27ce30389157620974dadc9cd8a8eb56a90c9c78543e64d1fdf3b93881a859b7280281ac6e29f9e5ef681f27abbc88a8c6307c66f19ce538c7015813353996543c8276e554804e74c5b68298441de0ccbd2917b7553ac534555b0c4155d84e48a7947e7ba2d9aa7ccdd3d1e60d8d82e09692146fe648e22dc0d0cb132a878a726e00d9df64a72d6ef95991137de4b37acc6490cf59bba41882ce797bc1e22da28064fa51c262f9784a9e2b45868fb85a3f44ff450646d2268829a3585a882b48c551466f17a989cfcdc84c065b8a45be3458580dd14d603792f206bd017b4ae3913d95b425b40d2c884e2d7d8e8c47ee73201fb22463f8abd784d17179ba2be07ba96450154ada0b58b14573fca2096a8a4ad2804224f6b4b78461729835536a6b11fcfe1de05ad621173daf91cac3616e7df93a65fae9a3fec959dde7d1204c902b05e93c255f9bcb0726766a8adadaab60387File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,6 +51,8 @@ | ||
| } | ||
| MANGLED_NULL = "__null_" | ||
| def declare_variables( | ||
| uop: Uop, | ||
| out: CWriter, | ||
| @@ -75,6 +77,9 @@ def declare_variables( | ||
| out.emit(f"{type}{var.name} = NULL;\n") | ||
| else: | ||
| out.emit(f"{type}{var.name};\n") | ||
| if var.name == MANGLED_NULL and not var.peek: | ||
| out.emit(f"{var.name} = sym_init_push_null(ctx);\n") | ||
| out.emit(f"if ({var.name} == NULL) {{ goto error; }}\n") | ||
| for var in uop.stack.outputs: | ||
| if skip_peeks and var.peek: | ||
| continue | ||
| @@ -89,6 +94,9 @@ def declare_variables( | ||
| out.emit(f"{type}{var.name} = NULL;\n") | ||
| else: | ||
| out.emit(f"{type}{var.name};\n") | ||
| if var.name == MANGLED_NULL and not var.peek: | ||
| out.emit(f"{var.name} = sym_init_push_null(ctx);\n") | ||
| out.emit(f"if ({var.name} == NULL) {{ goto error; }}\n") | ||
| def tier2_replace_deopt( | ||
| @@ -106,31 +114,9 @@ def tier2_replace_deopt( | ||
| out.emit(") goto error;\n") | ||
| TIER2_REPLACEMENT_FUNCTIONS = REPLACEMENT_FUNCTIONS.copy() | ||
| TIER2_REPLACEMENT_FUNCTIONS["ERROR_IF"] = tier2_replace_error | ||
| TIER2_REPLACEMENT_FUNCTIONS["DEOPT_IF"] = tier2_replace_deopt | ||
| def _write_body_abstract_interp_impure_uop( | ||
| mangled_uop: Uop, uop: Uop, out: CWriter, stack: Stack | ||
| @@ -142,12 +128,11 @@ def _write_body_abstract_interp_impure_uop( | ||
| continue | ||
| if var.size == "1": | ||
| if var.name != MANGLED_NULL: | ||
| out.emit(f"{var.name} = sym_init_unknown(ctx);\n") | ||
| out.emit(f"if({var.name} == NULL) goto error;\n") | ||
| if var.type_prop: | ||
| out.emit(f"sym_set_type({var.name}, {var.type_prop[0]}, 0);\n") | ||
Comment on lines +131 to +135 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is an example of something that I think can be streamlined further. Instead of calling | ||
| else: | ||
| # See UNPACK_SEQUENCE for when we need this. | ||
| out.emit( | ||
| @@ -202,24 +187,31 @@ def new_sym( | ||
| ) | ||
| def declare_caches(uop: Uop, out: CWriter): | ||
| for cache in uop.caches: | ||
| if cache.name not in UNUSED: | ||
| if cache.size == 4: | ||
| type = cast = "PyObject *" | ||
| else: | ||
| type = f"uint{cache.size*16}_t " | ||
| cast = f"uint{cache.size*16}_t" | ||
| out.emit(f"{type}{cache.name} = ({cast})CURRENT_OPERAND();\n") | ||
| def _write_body_abstract_interp_pure_uop( | ||
| mangled_uop: Uop, uop: Uop, out: CWriter, stack: Stack | ||
| ) -> None: | ||
| arr_var_name, arr_var_size, subexpressions = get_subexpressions( | ||
| mangled_uop.stack.inputs | ||
| ) | ||
| # uop isnon-trivial - we cannot const evaluate it | ||
| if uop.name in NO_CONST_OR_TYPE_EVALUATE: | ||
| for in_ in mangled_uop.stack.inputs: | ||
| out.emit(f"(void){in_.name};\n") | ||
| return | ||
| # Constant prop handled no variadic inputs. | ||
| # Perhaps in the future we can support these. | ||
| if all(input.size == "1" for input in uop.stack.inputs): | ||
| # We can try a constant evaluation | ||
| @@ -232,6 +224,9 @@ def _write_body_abstract_interp_pure_uop( | ||
| ] | ||
| ) | ||
| if predicates: | ||
| declare_caches(uop, out) | ||
| out.emit(f"if ({predicates or 0}) {{\n") | ||
| declare_variables(uop, out, default_type="PyObject *") | ||
| for var, mangled_var in zip(uop.stack.inputs, mangled_uop.stack.inputs): | ||
| @@ -273,15 +268,6 @@ def _write_body_abstract_interp_guard_uop( | ||
| if uop.name in NO_CONST_OR_TYPE_EVALUATE: | ||
| return | ||
| out.emit("// Constant evaluation\n") | ||
| predicates_str = " && ".join( | ||
| [ | ||
| @@ -291,6 +277,7 @@ def _write_body_abstract_interp_guard_uop( | ||
| ] | ||
| ) | ||
| if predicates_str: | ||
| declare_caches(uop, out) | ||
| out.emit(f"if ({predicates_str}) {{\n") | ||
| declare_variables(uop, out, default_type="PyObject *") | ||
| for var, mangled_var in zip(uop.stack.inputs, mangled_uop.stack.inputs): | ||