Skip to content

Commit

Permalink
rename to ICInaccessibleSpecialCase NoKeyedByICAndLeakIC__DO_NOT_USE
Browse files Browse the repository at this point in the history
Reviewed By: KendallHopkins, jano

Differential Revision: D68927777

fbshipit-source-id: 3695390239125ec3482bd3337aca8f19a60cb9b4
  • Loading branch information
Max Trivedi authored and facebook-github-bot committed Feb 3, 2025
1 parent 214acc9 commit ad1c155
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions hphp/hack/src/hackc/emitter/emit_memoize_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 9 additions & 7 deletions hphp/hack/src/hackc/emitter/emit_memoize_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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_ {
Expand Down
4 changes: 2 additions & 2 deletions hphp/hack/src/hackc/hhbc/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/naming/naming_special_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/parser/syntax_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/ext/hh/ext_implicit_context.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions hphp/runtime/ext/reflection/ext_reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<KindOfEnumClassLabel>(sd));
} else {
Expand Down
6 changes: 3 additions & 3 deletions hphp/runtime/vm/func-emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/vm/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ struct Func final {
NoIC = 0,
KeyedByIC = 1,
MakeICInaccessible = 2,
ICInaccessibleSpecialCase = 3,
NotKeyedByICAndLeakIC = 3,
};

MemoizeICType memoizeICType() const;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?hh

// we are matching the coeffect requiments for MakeICInaccessible, so leak_safe or less is no allowed
<<__Memoize(#ICInaccessibleSpecialCase)>>
<<__Memoize(#NotKeyedByICAndLeakIC__DO_NOT_USE)>>
function memo_inaccessible_sc_leaksafe($a, $b)[leak_safe]: mixed{
echo "memo_inaccessible_sc_leaksafe: $a, $b \n";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down

0 comments on commit ad1c155

Please sign in to comment.