Skip to content

Commit

Permalink
[Fix] Only optimize dynamicNamedCall when its known to be dynamic
Browse files Browse the repository at this point in the history
Summary: There was a small optimization for the case of a dynamic call through
a derived-from-redeclared class. But its only valid when the call is known to be
dynamic. The objCall flag is used to indicate dynamic (>0) possibly-dynamic
(<0), and static (0), but we were just testing for non-zero. Replace with a test
for >0 instead.

Test Plan: fast_tests slow_tests

Reviewers: myang, kma

Reviewed By: myang

CC: ps, mwilliams, myang

Differential Revision: 342326
  • Loading branch information
mwilliams authored and macvicar committed Oct 18, 2011
1 parent 3c4b4b6 commit 680a86e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/expression/simple_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ bool SimpleFunctionCall::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
}
}

if (objCall && !isUnknown() && !m_classScope) {
if (objCall > 0 && !isUnknown() && !m_classScope) {
// class must be redeclaring, and cant be the originalClass
// (because then m_classScope would not be null).
// so we can start the search by following the redeclared parent.
Expand Down
14 changes: 14 additions & 0 deletions src/test/test_code_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12232,6 +12232,20 @@ bool TestCodeRun::TestRedeclaredClasses() {
"var_dump(get_class_methods('X'));"
"var_dump(get_class_methods('Y'));");

MVCR("<?php "
"if (isset($g)) {"
" class X { function foo() { var_dump(__METHOD__); } }"
" class Y extends X {}"
"} else {"
" class X { function foo() { var_dump(__METHOD__); } }"
" class Y {}"
"}"
"class Z extends Y {"
" function foo() { var_dump(__METHOD__); }"
" function bar() { X::foo(); }"
"}"
"Z::bar();");

return true;
}

Expand Down

0 comments on commit 680a86e

Please sign in to comment.