From ad1c1555763f96b103ad016bd0dc5615ccd63598 Mon Sep 17 00:00:00 2001 From: Max Trivedi Date: Mon, 3 Feb 2025 11:39:06 -0800 Subject: [PATCH] rename to ICInaccessibleSpecialCase NoKeyedByICAndLeakIC__DO_NOT_USE Reviewed By: KendallHopkins, jano Differential Revision: D68927777 fbshipit-source-id: 3695390239125ec3482bd3337aca8f19a60cb9b4 --- .../src/hackc/emitter/emit_memoize_function.rs | 6 +++--- .../src/hackc/emitter/emit_memoize_method.rs | 16 +++++++++------- hphp/hack/src/hackc/hhbc/attribute.rs | 4 ++-- hphp/hack/src/naming/naming_special_names.rs | 2 +- hphp/hack/src/parser/syntax_error.rs | 2 +- hphp/runtime/ext/hh/ext_implicit_context.php | 2 +- hphp/runtime/ext/reflection/ext_reflection.cpp | 4 ++-- hphp/runtime/vm/func-emitter.cpp | 6 +++--- hphp/runtime/vm/func.h | 2 +- .../ic-inaccessible-special-case-coeffects.php | 2 +- ...accessible-special-case-coeffects.php.expectf | 2 +- .../ic-inaccessible-special-case.php | 4 ++-- 12 files changed, 27 insertions(+), 25 deletions(-) diff --git a/hphp/hack/src/hackc/emitter/emit_memoize_function.rs b/hphp/hack/src/hackc/emitter/emit_memoize_function.rs index 83595d8e7aeea5..11bae587d1c88d 100644 --- a/hphp/hack/src/hackc/emitter/emit_memoize_function.rs +++ b/hphp/hack/src/hackc/emitter/emit_memoize_function.rs @@ -93,12 +93,12 @@ pub(crate) fn emit_wrapper_function<'a, 'd>( .any(|tp| tp.reified.is_reified() || tp.reified.is_soft_reified()); let coeffects = Coeffects::from_ast(f.ctxs.as_ref(), &f.params, &fd.tparams, vec![]); let should_emit_implicit_context = hhbc::is_keyed_by_ic_memoize(attributes.iter()); - // #ICInaccessibleSpecialCase won't shard by IC but will access IC - let is_inaccessible_special_case = hhbc::is_inaccessible_special_case(attributes.iter()); + // #NotKeyedByICAndLeakIC__DO_NOT_USE won't shard by IC but will access IC + let is_not_keyed_by_ic_and_leak_ic = hhbc::is_not_keyed_by_ic_and_leak_ic(attributes.iter()); // This fn either has IC unoptimizable static coeffects, or has any dynamic coeffects let has_ic_unoptimizable_coeffects: bool = coeffects.has_ic_unoptimizable_coeffects(); - let should_make_ic_inaccessible: bool = !is_inaccessible_special_case + let should_make_ic_inaccessible: bool = !is_not_keyed_by_ic_and_leak_ic && !should_emit_implicit_context && has_ic_unoptimizable_coeffects; diff --git a/hphp/hack/src/hackc/emitter/emit_memoize_method.rs b/hphp/hack/src/hackc/emitter/emit_memoize_method.rs index 8d273fbf8814dd..bb25c0e2196aac 100644 --- a/hphp/hack/src/hackc/emitter/emit_memoize_method.rs +++ b/hphp/hack/src/hackc/emitter/emit_memoize_method.rs @@ -163,7 +163,7 @@ fn make_memoize_wrapper_method<'a, 'd>( ); arg_flags.set( Flags::IS_IC_INACCESSIBLE_SPECIAL_CASE, - hhbc::is_inaccessible_special_case(attributes.iter()), + hhbc::is_not_keyed_by_ic_and_leak_ic(attributes.iter()), ); let mut args = Args { info, @@ -306,8 +306,9 @@ fn make_memoize_method_with_params_code<'a, 'd>( // so the first unnamed local is parameter count + 1 when there are reified generics. let is_reified = args.flags.contains(Flags::IS_REIFIED); let add_reified = usize::from(is_reified); - // #ICInaccessibleSpecialCase won't shard by IC but will access IC - let is_inaccessible_special_case = args.flags.contains(Flags::IS_IC_INACCESSIBLE_SPECIAL_CASE); + // #NotKeyedByICAndLeakIC__DO_NOT_USE won't shard by IC but will access IC + let is_not_keyed_by_ic_and_leak_ic = + args.flags.contains(Flags::IS_IC_INACCESSIBLE_SPECIAL_CASE); let should_emit_implicit_context = args.flags.contains(Flags::SHOULD_EMIT_IMPLICIT_CONTEXT); let add_implicit_context = usize::from(should_emit_implicit_context); let first_unnamed_idx = param_count + add_reified; @@ -374,7 +375,7 @@ fn make_memoize_method_with_params_code<'a, 'd>( let ic_stash_local = Local::new((key_count) as usize + first_unnamed_idx); // This fn either has IC unoptimizable static coeffects, or has any dynamic coeffects let has_ic_unoptimizable_coeffects: bool = coeffects.has_ic_unoptimizable_coeffects(); - let should_make_ic_inaccessible: bool = !is_inaccessible_special_case + let should_make_ic_inaccessible: bool = !is_not_keyed_by_ic_and_leak_ic && !should_emit_implicit_context && has_ic_unoptimizable_coeffects; let instrs = InstrSeq::gather(vec![ @@ -466,12 +467,13 @@ fn make_memoize_method_no_params_code<'a, 'd>( }, None, ); - // #ICInaccessibleSpecialCase won't shard by IC but will access IC - let is_inaccessible_special_case = args.flags.contains(Flags::IS_IC_INACCESSIBLE_SPECIAL_CASE); + // #NotKeyedByICAndLeakIC__DO_NOT_USE won't shard by IC but will access IC + let is_not_keyed_by_ic_and_leak_ic = + args.flags.contains(Flags::IS_IC_INACCESSIBLE_SPECIAL_CASE); let ic_stash_local = Local::new(0); // we are in a no parameter function that sets no zoned IC either, default to what coeffects suggest let should_make_ic_inaccessible: bool = - coeffects.has_ic_unoptimizable_coeffects() && !is_inaccessible_special_case; + coeffects.has_ic_unoptimizable_coeffects() && !is_not_keyed_by_ic_and_leak_ic; let instrs = InstrSeq::gather(vec![ deprecation_body, if args.method.static_ { diff --git a/hphp/hack/src/hackc/hhbc/attribute.rs b/hphp/hack/src/hackc/hhbc/attribute.rs index 422919cab362e2..be50dd32efc185 100644 --- a/hphp/hack/src/hackc/hhbc/attribute.rs +++ b/hphp/hack/src/hackc/hhbc/attribute.rs @@ -86,8 +86,8 @@ pub fn is_keyed_by_ic_memoize(attrs: impl AsRef<[Attribute]>) -> bool { is_memoize_with(attrs, "KeyedByIC") } -pub fn is_inaccessible_special_case(attrs: impl AsRef<[Attribute]>) -> bool { - is_memoize_with(attrs, "ICInaccessibleSpecialCase") +pub fn is_not_keyed_by_ic_and_leak_ic(attrs: impl AsRef<[Attribute]>) -> bool { + is_memoize_with(attrs, "NotKeyedByICAndLeakIC__DO_NOT_USE") } fn is_foldable(attr: &Attribute) -> bool { diff --git a/hphp/hack/src/naming/naming_special_names.rs b/hphp/hack/src/naming/naming_special_names.rs index ddf355ca9dc7b6..367cff59344d54 100644 --- a/hphp/hack/src/naming/naming_special_names.rs +++ b/hphp/hack/src/naming/naming_special_names.rs @@ -386,7 +386,7 @@ pub mod memoize_option { pub const MAKE_IC_INACCESSSIBLE: &str = "MakeICInaccessible"; - pub const IC_INACCESSSIBLE_SPECIAL_CASE: &str = "ICInaccessibleSpecialCase"; + pub const IC_INACCESSSIBLE_SPECIAL_CASE: &str = "NotKeyedByICAndLeakIC__DO_NOT_USE"; pub static _ALL: &[&str] = &[ KEYED_BY_IC, diff --git a/hphp/hack/src/parser/syntax_error.rs b/hphp/hack/src/parser/syntax_error.rs index 800e4d0a42a742..34736f7db96592 100644 --- a/hphp/hack/src/parser/syntax_error.rs +++ b/hphp/hack/src/parser/syntax_error.rs @@ -1070,7 +1070,7 @@ pub fn policy_sharded_memoized_without_policied(kind: &str) -> Error { pub fn memoize_make_ic_inaccessible_without_defaults(kind: &str, is_special_case: bool) -> Error { let context = if is_special_case { - "#ICInaccessibleSpecialCase" + "#NotKeyedByICAndLeakIC__DO_NOT_USE" } else { "#MakeICInaccessible" }; diff --git a/hphp/runtime/ext/hh/ext_implicit_context.php b/hphp/runtime/ext/hh/ext_implicit_context.php index 66c1893ec9779d..bb803ca676659e 100644 --- a/hphp/runtime/ext/hh/ext_implicit_context.php +++ b/hphp/runtime/ext/hh/ext_implicit_context.php @@ -175,7 +175,7 @@ protected static function get()[this::CRun]: ?this::T { enum class MemoizeOption: string { string KeyedByIC = 'KeyedByIC'; string MakeICInaccessible = 'MakeICInaccessible'; - string ICInaccessibleSpecialCase = 'ICInaccessibleSpecialCase'; + string NotKeyedByICAndLeakIC = 'NotKeyedByICAndLeakIC__DO_NOT_USE'; } } // namespace HH diff --git a/hphp/runtime/ext/reflection/ext_reflection.cpp b/hphp/runtime/ext/reflection/ext_reflection.cpp index 1f9e7fb8c382db..0d292afc291ee3 100644 --- a/hphp/runtime/ext/reflection/ext_reflection.cpp +++ b/hphp/runtime/ext/reflection/ext_reflection.cpp @@ -940,7 +940,7 @@ const StaticString s_systemlib_create_opaque_value("__SystemLib\\create_opaque_value"), s_KeyedByIC("KeyedByIC"), s_MakeICInaccessible("MakeICInaccessible"), - s_ICInaccessibleSpecialCase("ICInaccessibleSpecialCase"); + s_NotKeyedByICAndLeakIC("NotKeyedByICAndLeakIC__DO_NOT_USE"); ALWAYS_INLINE static Array get_function_user_attributes(const Func* func) { @@ -963,7 +963,7 @@ static Array get_function_user_attributes(const Func* func) { auto const sd = tv.m_data.pstr; if (sd->same(s_KeyedByIC.get()) || sd->same(s_MakeICInaccessible.get()) || - sd->same(s_ICInaccessibleSpecialCase.get())) { + sd->same(s_NotKeyedByICAndLeakIC.get())) { if (Cfg::Eval::EmitNativeEnumClassLabels) { args.append(make_tv(sd)); } else { diff --git a/hphp/runtime/vm/func-emitter.cpp b/hphp/runtime/vm/func-emitter.cpp index 3ca2da30d60a16..9f651734c1373d 100644 --- a/hphp/runtime/vm/func-emitter.cpp +++ b/hphp/runtime/vm/func-emitter.cpp @@ -209,7 +209,7 @@ const StaticString s_MemoizeLSB("__MemoizeLSB"), s_KeyedByIC("KeyedByIC"), s_MakeICInaccessible("MakeICInaccessible"), - s_ICInaccessibleSpecialCase("ICInaccessibleSpecialCase"), + s_NotKeyedByICAndLeakIC("NotKeyedByICAndLeakIC__DO_NOT_USE"), s_SoftInternal("__SoftInternal"); namespace { @@ -304,8 +304,8 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { icType = Func::MemoizeICType::KeyedByIC; } else if (elem.m_data.pstr->same(s_MakeICInaccessible.get())) { icType = Func::MemoizeICType::MakeICInaccessible; - } else if (elem.m_data.pstr->same(s_ICInaccessibleSpecialCase.get())) { - icType = Func::MemoizeICType::ICInaccessibleSpecialCase; + } else if (elem.m_data.pstr->same(s_NotKeyedByICAndLeakIC.get())) { + icType = Func::MemoizeICType::NotKeyedByICAndLeakIC; } else { assertx(false && "invalid string"); } diff --git a/hphp/runtime/vm/func.h b/hphp/runtime/vm/func.h index 552cb06eae06f5..12e88d50e247d4 100644 --- a/hphp/runtime/vm/func.h +++ b/hphp/runtime/vm/func.h @@ -721,7 +721,7 @@ struct Func final { NoIC = 0, KeyedByIC = 1, MakeICInaccessible = 2, - ICInaccessibleSpecialCase = 3, + NotKeyedByICAndLeakIC = 3, }; MemoizeICType memoizeICType() const; diff --git a/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php b/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php index 529e9e36b12bf3..c0d67f5f9cbb80 100644 --- a/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php +++ b/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php @@ -1,7 +1,7 @@ > +<<__Memoize(#NotKeyedByICAndLeakIC__DO_NOT_USE)>> function memo_inaccessible_sc_leaksafe($a, $b)[leak_safe]: mixed{ echo "memo_inaccessible_sc_leaksafe: $a, $b \n"; } diff --git a/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php.expectf b/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php.expectf index 3bd223399e84da..21e8dc13623f4a 100644 --- a/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php.expectf +++ b/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php.expectf @@ -1,2 +1,2 @@ -Fatal error: This function requires the defaults, leak_safe_shallow, or leak_safe_local context to be memoized using #ICInaccessibleSpecialCase in %s/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php on line 4 +Fatal error: This function requires the defaults, leak_safe_shallow, or leak_safe_local context to be memoized using #NotKeyedByICAndLeakIC__DO_NOT_USE in %s/hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php on line 4 diff --git a/hphp/test/slow/implicit-context/ic-inaccessible-special-case.php b/hphp/test/slow/implicit-context/ic-inaccessible-special-case.php index 9658860f0a88ec..77317caf024e5a 100644 --- a/hphp/test/slow/implicit-context/ic-inaccessible-special-case.php +++ b/hphp/test/slow/implicit-context/ic-inaccessible-special-case.php @@ -37,7 +37,7 @@ public function memo_inaccessible($a, $b)[defaults]: mixed { echo "args: $a, $b name: $context\n"; } - <<__Memoize(#ICInaccessibleSpecialCase)>> + <<__Memoize(#NotKeyedByICAndLeakIC__DO_NOT_USE)>> public function memo_inaccessible_sc($a, $b)[defaults]: mixed { $context = ClassContext::getContext()->name(); echo "args: $a, $b name: $context\n"; @@ -58,7 +58,7 @@ function memo_inaccessible($a, $b)[defaults]: mixed{ echo "args: $a, $b name: $context\n"; } -<<__Memoize(#ICInaccessibleSpecialCase)>> +<<__Memoize(#NotKeyedByICAndLeakIC__DO_NOT_USE)>> function memo_inaccessible_sc($a, $b)[defaults]: mixed{ $context = ClassContext::getContext()->name(); echo "args: $a, $b name: $context\n";