Initial support for new member instructions
commitf9734104d71f11077d97fde5412f529bb3678637
authorBrett Simmers <bsimmers@fb.com>
Thu, 27 Aug 2015 03:18:35 +0000 (26 20:18 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Thu, 27 Aug 2015 03:30:34 +0000 (26 20:30 -0700)
treeccb10e24461b9a326ce34b6aa2230aa84e9c612b
parent099bd432364eefb77e087fe65e1cd2dca1db4814
Initial support for new member instructions

Summary: This diff introduces the first set of new member bytecodes, along with
supporting infrastructure. I've added enough to support any CGetM with a local
or $this base. The new instructions are heavily suboped, partially to save
bytecode space but also because a lot of these operations have the same
signatures and very similar implementations. It might make sense to subop them
even with infinite bytecode space.

The main missing parts are that the JIT only knows enough about them to
correctly interpOne them and HHBBC support is nonexistent, both of which can
come in later diffs.

Each member instruction has been broken up into three main parts:
- A Base* instruction (BaseL, BaseH, ...). This corresponds to the location
  code from the member vector.
- Any number of intermediate Dim* instructions, which cover elements of the
  member vector before the final operation.
- A final operation. This diff adds QueryM* which handles CGetM, IssetM, and
  EmptyM; a few more will be added for SetM and the other minstrs.

If this three-way split sounds familiar, it's because it already exists in the
implementation of the current member instructions, both in the interpreter and
the jit.

One rough edge is that we need to keep any stack inputs on the stack until the
end of the final operation, so all final operations take an IVA immediate
indicating how many stack elements they should pop. These stack elements are
all a new flavor, CR, which could be a Cell or a return value. The current
member instructions can get the exact flavor of each element by reading through
the member vector, but not having the exact flavor should have no practical
downsides. We could replace all stack inputs to the member operations with
unnamed locals and clean this up a little but it's not necessary yet.

I've also added some tracing and did some minor cleanup in the emitter along
the way, to make debugging easier. I could probably be convinced to make those
a separate diff. And since I added the first bytecodes with more than one
subop, all the subop members in hhbbc instructions now have index suffixes.

Reviewed By: @alexmalyshev

Differential Revision: D2328347
25 files changed:
hphp/compiler/analysis/emitter.cpp
hphp/compiler/analysis/emitter.h
hphp/compiler/construct.cpp
hphp/compiler/construct.h
hphp/doc/bytecode.specification
hphp/hhbbc/bc.h
hphp/hhbbc/emit.cpp
hphp/hhbbc/interp-minstr.cpp
hphp/hhbbc/interp.cpp
hphp/hhbbc/parse.cpp
hphp/hhbbc/show.cpp
hphp/runtime/base/runtime-option.cpp
hphp/runtime/base/runtime-option.h
hphp/runtime/base/tv-helpers.h
hphp/runtime/base/unit-cache.cpp
hphp/runtime/vm/as.cpp
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/hhbc.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/jit/irgen-interpone.cpp
hphp/runtime/vm/jit/translator.cpp
hphp/runtime/vm/jit/translator.h
hphp/runtime/vm/minstr-state.h
hphp/runtime/vm/verifier/check-func.cpp
hphp/util/trace.h