Permalink
Browse files

Optimize lookup_param_prep

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...
markw65 authored and hhvm-bot committed Aug 13, 2017
1 parent 25f6207 commit 1e849e53f497a5933d75151bce851562dc8d582f
Showing with 8 additions and 9 deletions.
  1. +8 −9 hphp/hhbbc/index.cpp
View
@@ -2810,21 +2810,20 @@ PrepKind Index::lookup_param_prep(Context /*ctx*/, res::Func rfunc,
// by reference.
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
* 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
* 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;
},
[&] (borrowed_ptr<FuncInfo> finfo) {

0 comments on commit 1e849e5

Please sign in to comment.