-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add #ICInaccessibleSpecialCase memoize option
Summary: Some DEIC special case memoize functions require access to the implicit context while not emitting implicit context key (accesses IC, not sharded by IC). Adding the memoize option to do that. Reviewed By: jano Differential Revision: D68542539 fbshipit-source-id: b501b5c4332b843a72e9f6517b83e89a9ecaca52
- Loading branch information
1 parent
c18bc98
commit 2e164dc
Showing
15 changed files
with
168 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?hh | ||
|
||
// we are matching the coeffect requiments for MakeICInaccessible, so leak_safe or less is no allowed | ||
<<__Memoize(#ICInaccessibleSpecialCase)>> | ||
function memo_inaccessible_sc_leaksafe($a, $b)[leak_safe]: mixed{ | ||
echo "memo_inaccessible_sc_leaksafe: $a, $b \n"; | ||
} | ||
|
||
<<__EntryPoint>> | ||
function main() { | ||
memo_inaccessible_sc_leaksafe(1, 2); | ||
} |
2 changes: 2 additions & 0 deletions
2
hphp/test/slow/implicit-context/ic-inaccessible-special-case-coeffects.php.expectf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 |
92 changes: 92 additions & 0 deletions
92
hphp/test/slow/implicit-context/ic-inaccessible-special-case.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?hh | ||
|
||
class Base implements HH\IMemoizeParam { | ||
public function getInstanceKey()[]: string { | ||
return 'KEY' . $this->name(); | ||
} | ||
public function name()[]: string { return static::class; } | ||
} | ||
|
||
abstract final class ClassContext extends HH\ImplicitContext { | ||
const type T = Base; | ||
const bool IS_MEMO_SENSITIVE = true; | ||
const ctx CRun = [defaults]; | ||
public static function start(Base $context, (function (): int) $f)[this::CRun, ctx $f] { | ||
return parent::runWith($context, $f); | ||
} | ||
public static function getContext()[this::CRun]: Base { | ||
return parent::get() as nonnull; | ||
} | ||
public static function exists()[this::CRun]: bool { | ||
return parent::exists() as bool; | ||
} | ||
} | ||
|
||
class A extends Base {} | ||
|
||
class B extends Base { | ||
<<__Memoize(#KeyedByIC)>> | ||
public function memo_kbic($a, $b)[defaults]: mixed { | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
<<__Memoize(#MakeICInaccessible)>> | ||
public function memo_inaccessible($a, $b)[defaults]: mixed { | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
<<__Memoize(#ICInaccessibleSpecialCase)>> | ||
public function memo_inaccessible_sc($a, $b)[defaults]: mixed { | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
} | ||
|
||
|
||
<<__Memoize(#KeyedByIC)>> | ||
function memo_kbic($a, $b)[defaults]: mixed{ | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
<<__Memoize(#MakeICInaccessible)>> | ||
function memo_inaccessible($a, $b)[defaults]: mixed{ | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
<<__Memoize(#ICInaccessibleSpecialCase)>> | ||
function memo_inaccessible_sc($a, $b)[defaults]: mixed{ | ||
$context = ClassContext::getContext()->name(); | ||
echo "args: $a, $b name: $context\n"; | ||
} | ||
|
||
function f()[defaults]: mixed{ | ||
$klass_b = new B; | ||
$tryout = function($memo_function, $a, $b) use ($klass_b) { | ||
try { | ||
$memo_function($a, $b); | ||
} catch (Exception $e) { | ||
echo "Function $memo_function throws: ".$e->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
$klass_b->$memo_function($a, $b); | ||
} catch (Exception $e) { | ||
echo "Method B->$memo_function throws: ".$e->getMessage() . "\n"; | ||
|
||
} | ||
}; | ||
$tryout('memo_kbic', 1, 2); | ||
$tryout('memo_inaccessible', 3, 4); | ||
$tryout('memo_inaccessible_sc', 5, 6); | ||
} | ||
|
||
|
||
<<__EntryPoint>> | ||
function main(): mixed{ | ||
ClassContext::start(new A, f<>); | ||
} |
6 changes: 6 additions & 0 deletions
6
hphp/test/slow/implicit-context/ic-inaccessible-special-case.php.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
args: 1, 2 name: A | ||
args: 1, 2 name: A | ||
Function memo_inaccessible throws: Implicit context is set to inaccessible | ||
Method B->memo_inaccessible throws: Implicit context is set to inaccessible | ||
args: 5, 6 name: A | ||
args: 5, 6 name: A |