Commits on Aug 16, 2017
  1. Adding a syntactically correct file to full fidelity tests

    Summary: In this diff, I add a syntactically correct file to the full fidelity tests in order to increase their coverage.
    Differential Revision: D5566424
    fbshipit-source-id: cb56b9053f935ec62acbf3afbe144d6916159652
    Elena Polozova committed with hhvm-bot Aug 16, 2017
  2. re-enable apc-OOM.php unit test

    Summary: Unit test was disabled here: D5637163. Because D5512449 gives a wrong implementation that causing memory leak. We have unlanded D5512449, so it should be fine to re-enable the unit test again
    Reviewed By: alexeyt
    Differential Revision: D5641252
    fbshipit-source-id: add3668973a2ed6b534045f28e5dafa113662318
    Siqi Chen committed with hhvm-bot Aug 16, 2017
  3. Add SetWithRef{Int,Str} to array vtable

    Implement them directly instead of via Lval{Int,Str}.  This allows us to
    add missing index warnings to Lval*() while avoiding spew from a valid
    use case.
    We were also using Lval*() unconditionally when sometimes we were
    supposed to be using Lval*Ref().  Based on a quick audit of the
    callsites, this doesn't appear to have caused us to miss any Hack
    array compat notices, or Hack array exceptions, in practice.
    Reviewed By: alexeyt
    Differential Revision: D5587259
    fbshipit-source-id: 8365c76c8663ef183a7852cb4389791a792f0f31
    mxw committed with hhvm-bot Aug 16, 2017
  4. Refactor Lval and Set functions for PackedArray

    Summary: I'm adding a SetWithRef function and became displeased.
    Reviewed By: alexeyt
    Differential Revision: D5561727
    fbshipit-source-id: f5ee5b57d59088f91cf2019b95d44ebfeff5b170
    mxw committed with hhvm-bot Aug 16, 2017
  5. Changing variable names in require_token

    Summary: Simple cleanup: I noticed some unnecessary complexity in the variable inside this function, so I fixed it.
    Differential Revision: D5596677
    fbshipit-source-id: 8f187979ac61ad5fdf0ce2757c87d1b626b49a37
    Elena Polozova committed with hhvm-bot Aug 16, 2017
  6. Improving the implementation of the 'trivialise extra tokens' error r…

    …ecovery strategy
    In this diff, I strike a balance between a full implementation of drphil's suggestions for the extra-token-as-error-trivia infrastructure (done here for comparison: D5594163) and my previous implementation in D5465141.
    If you're curious about the design choices I make here, you can see D5594163 for more of my thought process.
    Points of note: names are far better now, and better boundaries are drawn around the engineering complexity involved. (For example, the programmer no longer has to consciously maintain the invariant that flush_extra is only called after carrying_extra is asserted (the next_token function now automatically does that bookkeeping) and it's no longer Full_fidelity_minimal_token's job to convert itself to trivia (the next_token function does that too).) However, unlike in D5594163, the list of skipped tokens remains the property of the context. (See D5594163 for my rationale behind that choice.)
    Differential Revision: D5596053
    fbshipit-source-id: 8ca4fa8343e240b0faf09854ee6229be5bfaf809
    Elena Polozova committed with hhvm-bot Aug 16, 2017
  7. Transfer unsafe boolean

    Summary: Preserves the value of the unsafe boolean from NAST to TAST.
    Reviewed By: andrewjkennedy
    Differential Revision: D5550295
    fbshipit-source-id: e53909c669c012cb336638752f44707e9d290026
    rameshvarun committed with hhvm-bot Aug 16, 2017
  8. Fixed Class_get node

    Summary: Class_get nodes are collapsed into an LVar in the TAST. This prevents that from happening.
    Reviewed By: jamesjwu
    Differential Revision: D5556364
    fbshipit-source-id: 6c49a13c908f4480bffea0cceedfab826077bd24
    rameshvarun committed with hhvm-bot Aug 16, 2017
  9. Barebones class support

    Add class output to HHAS and some basic support for method
    Still on the todo list:
     - Static method calls
     - Explicitly named implementations (e.g. `parent::foo()`) and forwarding calls
     - Properties
     - Class constants
    Reviewed By: mofarrell
    Differential Revision: D5625276
    fbshipit-source-id: 031d89be2c1722c8f62f39f9648659c8999cf647
    jjgriego committed with hhvm-bot Aug 16, 2017
  10. Add support for unnamed locals

    This wasn't needed until try/finally but here it is. I add a visitor
    that walks the CFG and extracts all named locals and unnamed local keys and
    then can be used to provide numeric IDs for the unnamed locals
    Reviewed By: mofarrell
    Differential Revision: D5577679
    fbshipit-source-id: 9cc02d1cc0d2b7accd8c67113b91c17547ae59ef
    jjgriego committed with hhvm-bot Aug 16, 2017
  11. Fix asyncstk

    Reviewed By: markw65
    Differential Revision: D5637350
    fbshipit-source-id: 06aa5e75bf9a93a1e46adfc635504a618fc3c986
    mxw committed with hhvm-bot Aug 16, 2017
  12. Backed out changeset b1c8f67f4b6b

    Reviewed By: mxw
    Differential Revision: D5638848
    fbshipit-source-id: 548f4e76b7d618afa80b5935a1093ac9389a3197
    ricklavoie committed with hhvm-bot Aug 16, 2017
  13. Help `` survive sigalrm

    On Linux and OS X, `Timer` and `Timeout` are based on sending sigalrm.
    If `` is blocking, then it will throw an `EINTR` exception. The best
    thing to do in this case is just to catch that exception and resume the
    This comes up if you set a periodic timer on the master thread.
    Reviewed By: alexchow
    Differential Revision: D5473272
    fbshipit-source-id: 436d1253a07bdb77455db9366528949c19472492
    gabelevi committed with hhvm-bot Aug 16, 2017
  14. Allow `var` type specifiers for XHP attributes (PHP support)

    Summary: Fail open with `var` type annotation of XHP attributes. The parser shouldn't reject this, but leave the decision to later stages.
    Reviewed By: vladima
    Differential Revision: D5611117
    fbshipit-source-id: 83e096a4ca8ceed4afa54acbfd1fceb63ab2ca25
    Philip Hölzenspies committed with hhvm-bot Aug 16, 2017
  15. Move includes to top-level

    Summary: System-provided headers should not be #included within our namespace.
    Reviewed By: yfeldblum
    Differential Revision: D5630354
    fbshipit-source-id: 11accf34cd7e3074bcdeb1f300a5519e632f2348
    WillerZ committed with hhvm-bot Aug 16, 2017
  16. Backed out changeset e0df3343da7f, There are some logical mistake mig…

    …ht cause memory leak
    Wrong implementation about replacing visible set with GCBits in revision D5512449, it causes memory leak and fail the unit test hphp/test/slow/apc-OOM.php. We disabled that unit test here: D5637163. This back out should enable that unit test again.
    (Note: this ignores all push blocking failures!)
    Reviewed By: ricklavoie
    Differential Revision: D5638843
    fbshipit-source-id: f64d6bbbfcffb8f27d8144e59c852c8d1a65c535
    Siqi Chen committed with hhvm-bot Aug 16, 2017
  17. disable the apc-OOM.php, it fail on interpreter mode when using dbgo …

    Summary: (Note: this ignores all push blocking failures!)
    Reviewed By: alexeyt
    Differential Revision: D5637163
    fbshipit-source-id: 3b43352f6e31582c7516826d548f6d81422eee26
    Siqi Chen committed with hhvm-bot Aug 16, 2017
  18. Add logging for hackfmt

    Summary: Add four logging function to know the time taken for each type of call
    Differential Revision: D5631663
    fbshipit-source-id: 39db6939f5a6f04d2566ee60a43519ed5670db90
    Runtian Zhou committed with hhvm-bot Aug 16, 2017
Commits on Aug 15, 2017
  1. Propagate user attributes for type aliases of classes and enums

    Reviewed By: ricklavoie
    Differential Revision: D5579372
    fbshipit-source-id: 7a949e8c5ae111e0efad5b73eda317213630789f
    paulbiss committed with hhvm-bot Aug 15, 2017
  2. Fixes various issues with HackC codegen

    This diff fixes the following issues:
    1) Do not create numiters for wrappers of memoized methods
    2) `$this::x` should not be assigned to a temporary and then create a class ref slot
    3) Allow array keys that start with an integer but end with a string to be accepted as strings not casted into ints by dropping the string part
    Reviewed By: vladima
    Differential Revision: D5625433
    fbshipit-source-id: 00b9354768a9f7e2a6fc45f4aa623229f18b8094
    oulgen committed with hhvm-bot Aug 15, 2017
  3. Attempt to fix flaky timeout_test

    is pretty flaky. Looking at failing test runs, the failing tests tend to look
    like this:
    1. Spawn another process that is supposed to timeout after X seconds
    2. Wait Y seconds (where Y > X)
    3. Fail when child process hasn't exited yet.
    I'm guessing that these spurious failures are due to spawning a child process
    taking surprisingly long when the machine is under stress (like running all the
    We probably could just delete these tests. It's probably sufficient to test
    that timeouts work in the current process, without testing that they work in
    spawned processes too. However, I'm first going to try and fix this by making
    the parent process wait for the child process to start before it starts the
    Yes, this does kind of bias things the other direction - that is now the parent
    might start its timer too late instead of too early if the host is slow to
    resume the parent process. So it's possible this test will start being flaky in
    the other direction (parent process timers failing to fire in time). But let's
    try this and see how it does.
    Reviewed By: dabek
    Differential Revision: D5602215
    fbshipit-source-id: 5c56b4d63f26b8b969297c876efd2919eeed0dba
    gabelevi committed with hhvm-bot Aug 15, 2017
  4. Add support for finally

    What it says on the tin. This is pretty hairy because PHP is really
    flexible with what it allows you to do in a try block *and* in a finally block.
    To be general, we have to pessimize things a bit and replace exits from the try
    block with jumps to the finally handler, and then a switch to return control to
    where it should be. An alternative approach would be to just duplicate the
    finally code at every exit. This isn't great but it's largely the same approach
    as the current emitter built into HHVM.
    We could combine this approach with something to optimize the simple cases (no
    returns from finally, or no return/goto/breka/continue in try) to get rid of
    some of this pessimization
    Reviewed By: swtaarrs
    Differential Revision: D5575402
    fbshipit-source-id: a5c163110c87e6bd4b4e0170fb4c7e7b867660e7
    jjgriego committed with hhvm-bot Aug 15, 2017
  5. Add try/catch (no finally support yet)

    This adds support for exception regions and also emitting try/catch
    blocks. I've explicitly left out finally since it's its own big can of worms
    Most of this code actually just adds support for regions and tweaks the asm
    output to correctly order the blocks in light of keeping regions together
    Reviewed By: mofarrell
    Differential Revision: D5575163
    fbshipit-source-id: 120f0611cf11e784d679a4ec29f65732c3b7a6b1
    jjgriego committed with hhvm-bot Aug 15, 2017
  6. Preserve linebreaks for shape expressions as well as shape types

    Before, we were preserving linebreaks in shape type literals, such as this:
    type Foo = shape(
      'foo' => int,
    But we were not doing so for shape expressions, such as this:
      'foo' => 1,
    This commit adds support for that.
    This commit also renames the test case files from `collection_literal_newlines.php` to `container_literal_newlines.php`, since that's what the function is called in the source code.
    Differential Revision: D5624998
    fbshipit-source-id: ba21437ca9907b8589534504b85a5c1c1173cb74
    arxanas committed with hhvm-bot Aug 15, 2017
  7. Fix assert node dropping expression

    Summary: Right now, we drop the expression in assert nodes. This adds it back.
    Reviewed By: jamesjwu
    Differential Revision: D5555247
    fbshipit-source-id: 76771f4ee077a5fee15d82f716aa891466024bda
    rameshvarun committed with hhvm-bot Aug 15, 2017
  8. Avoid Building `anyByRef` in HHBBC Index in Non-repo Mode

    `method_ref_params_by_name` is a global bit map used for checking if there is any function that uses its n-th function by-ref. This is used in resolving param prep kind.
    However, in non-repo mode, without global knowledge, this bitmap is of no use. We avoid building it in non-repo mode. The resolution of prep kind is fixed in D5452355.
    Reviewed By: markw65
    Differential Revision: D5611635
    fbshipit-source-id: b8818fcd1b59d8e36e542c7d85fd4d0e1cde9007
    Hanwen Wu committed with hhvm-bot Aug 15, 2017
  9. Only Manually Mark Closures to be Unique

    D5389104 marks both closures and anon classes as AttrUnique. But since anon classes can have conditionally defined parents, we may end up having more than one cinfos.
    Thus we only mark closures as unique, not anon classes.
    Reviewed By: markw65
    Differential Revision: D5612422
    fbshipit-source-id: c7634a2cce49ad8b3847adbc0ed843ecc1c1695a
    Hanwen Wu committed with hhvm-bot Aug 15, 2017
  10. Add --filter-positions option in hh_single_type_check

    Summary: Adds a new command-line option `--filter-positions`, which filters position information in printed data structures. Also refactors `handle_mode` to allow an options struct to be passed in.
    Reviewed By: jamesjwu
    Differential Revision: D5580591
    fbshipit-source-id: ef447ca2df21fb9e8cc78c3c6fdbb54b5222a06b
    rameshvarun committed with hhvm-bot Aug 15, 2017
  11. Fix Uref in foreach loop

    Summary: When a Uref is in a foreach loop, the Uref node is collapsed into an Lvar. This diff preserves the Uref node.
    Reviewed By: jamesjwu
    Differential Revision: D5554699
    fbshipit-source-id: 524cf07a52017e6244378d37110ab5b5bfdc92b7
    rameshvarun committed with hhvm-bot Aug 15, 2017
  12. Show [Pos.none] instead of [L0:-1-L0:-1]

    Summary: There is special sentinel called Pos.none, primarily used for anonymous functions and similar situations. This prints it as `[Pos.none]` instead of `[L0:-1-L0:-1]`.
    Reviewed By: jamesjwu
    Differential Revision: D5580408
    fbshipit-source-id: 62e8cf839abd3c7282488bf6d8faac0771dc9aaa
    rameshvarun committed with hhvm-bot Aug 15, 2017
  13. Paralellize analyzeProgram

    A few analysis steps needed cleaning up, and a few locks were
    required, but it was mostly ready to go.
    To help find places we were modifying global state in the
    AnalysisResult, I canged the AnalysisResultPtr argument of
    Construct::analyzeProgram to an AnalysisResultConstPtr. Once done,
    this only decreased the time for analyze all by about 15% on a 56 core
    machine, so clearly something was not parallelizing well.
    Running perf showed there was no lock contention, and very little
    context switching; but all the time was being spent in
    AnalysisResult::analyzeProgram(ConstructPtr), which is really just a
    recursive walk calling Construct::analyzeProgram as it goes.
    A while ago ricklavoie had mentioned that passing shared_ptrs around was
    very expensive; I'd expermented with that a long time ago, and after
    one huge win (replacing vectors of shared_ptrs that got copied around
    a lot with vectors of hphp_raw_ptrs), was unable to get any
    others. But based on perf, I rewrote all the getNthKid functions to
    return ConstructRawPtr and analyzeProgram to take a ConstructRawPtr,
    and it made no difference at all.
    Then I realized the problem is with the AnalysisResultPtr we were
    passing around. Most of the shared pointers don't really matter; its a
    bit more expensive, but only one thread is using any given pointer at
    any given time so its only an extra couple of memory operations. But
    the AnalysisResultPtr is global; every single thread is doing atomic
    incs and decs the same shared pointer, so almost all are missing in
    the cache. So I changed all the AnalysisResultConstPtrs that I'd just
    added to AnalysisResultConstRawPtrs, and got a 6x win.
    There's clearly more available - it should have been a 30x win, but
    I'll do that in a followup (which will probably help preOptimize too).
    Reviewed By: alexeyt
    Differential Revision: D5619284
    fbshipit-source-id: b1c8f67f4b6b4a88164997dc379d238b218c59bb
    markw65 committed with hhvm-bot Aug 15, 2017
  14. s/darray_or_varray/varray_or_darray

    find hphp/hack/ -type f -print0 \
        | xargs -0 sed -i 's/darray_or_varray/varray_or_darray/g'
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_or_varray_where_dict_like_array_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_or_darray_where_dict_like_array_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_or_varray_where_dict_like_array_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_or_darray_where_dict_like_array_is_required.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_value_type_where_darray_or_varray_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_value_type_where_varray_or_darray_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_value_type_where_darray_or_varray_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_value_type_where_varray_or_darray_is_required.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_or_varray_where_vect_like_array_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_or_darray_where_vect_like_array_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_or_varray_where_vect_like_array_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_or_darray_where_vect_like_array_is_required.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_dict_where_darray_or_varray_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_dict_where_varray_or_darray_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_dict_where_darray_or_varray_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_dict_where_varray_or_darray_is_required.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_darray_or_varray_is_required_in_non_strict_mode.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_varray_or_darray_is_required_in_non_strict_mode.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_darray_or_varray_is_required_in_non_strict_mode.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_varray_or_darray_is_required_in_non_strict_mode.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_darray_or_varray_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_varray_or_darray_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_darray_or_varray_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_darray_with_wrong_key_type_where_varray_or_darray_is_required.php.exp
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_with_wrong_value_type_where_darray_or_varray_is_required.php hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_with_wrong_value_type_where_varray_or_darray_is_required.php
    mv hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_with_wrong_value_type_where_darray_or_varray_is_required.php.exp hphp/hack/test/typecheck/array/safe_vector_array/disallow_varray_with_wrong_value_type_where_varray_or_darray_is_required.php.exp
    Reviewed By: KendallHopkins
    Differential Revision: D5625168
    fbshipit-source-id: b881894d77006310df1b8d16e79d4fef75fd5574
    Michael Tingley committed with hhvm-bot Aug 15, 2017
  15. Allow missing type in catch clause (PHP support)

    PHP allows for untyped catch clauses, i.e.
    try {
      throw new Exception();
    } catch (/* nothing here */ $_) {
    Previously, even in non-strict modes, the full fidelity parser would consume `$_` as the type and produce an error. We still produce the error, but now we rewind the lexer, to allow the type to be missing. Errors are dealt with later (or not, because PHP).
    Reviewed By: andrewjkennedy
    Differential Revision: D5592283
    fbshipit-source-id: 85591e22a7210a8e469637de1e51bfb343194b65
    Philip Hölzenspies committed with hhvm-bot Aug 15, 2017
  16. Kill informClosuresAboutScopeClone

    My last lambda analysis diff killed off all existing uses, but
    introduced a new one. It turns out to be responsible for about 15% of
    the trait flattening time, so this delays some of the lambda analysis
    until after all files have been processed; at which point we don't
    need it at all.
    Reviewed By: alexeyt
    Differential Revision: D5619272
    fbshipit-source-id: 0163b54de3d5bfe15306266095a23e3429ea060f
    markw65 committed with hhvm-bot Aug 15, 2017
  17. Kill some scope dependencies

    hphpc maintains a dependency graph between scopes. Each dependency has
    a mask of use-kinds which reflect the kind of dependency. Most of
    these were for type-inference, or post-type-inference optimizations,
    so we can drop them.
    UseKindCaller is a slightly odd case, however. It was used to indicate
    that not only should callers be re-evaluated, but that the scope
    itself should be too. So although we can drop all explicit
    UseKindCaller dependencies, we still need to keep track of when
    "UseKindCaller" changes are made to the scope, so that we'll iterate
    on it. Since the flag no longer has anything to do with calls, rename
    it to UseKindSelf.
    Reviewed By: ricklavoie
    Differential Revision: D5616105
    fbshipit-source-id: b8a5107494dde3e56a498446246b364fb45d3a1d
    markw65 committed with hhvm-bot Aug 15, 2017