Skip to content

Commit

Permalink
Optimize lookup_param_prep
Browse files Browse the repository at this point in the history
Summary:
I half fixed this a while ago; if no method takes the param by ref, we
already take a fast path, but if at least one takes it by ref, we end
up going down the slow path, even though we're guaranteed to return
unknown. We only need to take the slow path for parameters beyond the
first 64, which we don't bother to memoize.

Reviewed By: ricklavoie

Differential Revision: D5619473

fbshipit-source-id: c97fc181f870c2efc359f4c378b3945088b1fa29
  • Loading branch information
Mark Williams authored and hhvm-bot committed Aug 13, 2017
1 parent 25f6207 commit 1e849e5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions hphp/hhbbc/index.cpp
Expand Up @@ -2810,21 +2810,20 @@ PrepKind Index::lookup_param_prep(Context /*ctx*/, res::Func rfunc,
// by reference. // by reference.
return PrepKind::Val; return PrepKind::Val;
} }
if (paramId < sizeof(it->second) * CHAR_BIT &&
!((it->second >> paramId) & 1)) {
// no method by this name takes this parameter by reference
return PrepKind::Val;
}
auto const kind = prep_kind_from_set(
find_range(m_data->methods, s.name),
paramId
);
/* /*
* If we think it's supposed to be PrepKind::Ref, we still can't be sure * If we think it's supposed to be PrepKind::Ref, we still can't be sure
* unless we go through some effort to guarantee that it can't be going * unless we go through some effort to guarantee that it can't be going
* to an __call function magically (which will never take anything by * to an __call function magically (which will never take anything by
* ref). * ref).
*/ */
if (paramId < sizeof(it->second) * CHAR_BIT) {
return ((it->second >> paramId) & 1) ?
PrepKind::Unknown : PrepKind::Val;
}
auto const kind = prep_kind_from_set(
find_range(m_data->methods, s.name),
paramId
);
return kind == PrepKind::Ref ? PrepKind::Unknown : kind; return kind == PrepKind::Ref ? PrepKind::Unknown : kind;
}, },
[&] (borrowed_ptr<FuncInfo> finfo) { [&] (borrowed_ptr<FuncInfo> finfo) {
Expand Down

0 comments on commit 1e849e5

Please sign in to comment.