Gráfico de Commits

43 Commits

Autor SHA1 Mensagem Data
Mirek Klimos 90b7170582 Remove Continuation from local 0
No emitted bytecode relies on Continuation being stored in local 0
anymore. Stop using local 0 for this purpose and compute offset
to the Continuation at JIT time. 16 bytes of memory freed.

At this point all locals of Continuation construction wrapper share the
same indices with their respective locals of Continuation body, which
should allow further optimizations.
2013-07-18 17:28:42 -07:00
bsimmers 4665b068d4 Initial tracelet region selector
This diff renames the Tracelet -> RegionDesc conversion mode to
"legacy" (since it's going away eventually) and changes "tracelet" to use the
new region selection mode. It attempts to select a region that will be the same
length as what Translator::analyze would come up with, using HhbcTranslator for
all of the type flow logic. It generates longer tracelets in some cases due to
more precise type information. Once this new mode is no longer a perf
regression it can become the new default, replacing all the code in
Translator::analyze and the "legacy" region mode. This version doesn't support
inlining or tracking of known Func*s; those will come in later diffs.
2013-07-18 17:28:41 -07:00
bsimmers a9e58686ab Pull Translator's translate* methods into a separate class
This diff creates IRTranslator, which creates and uses an
HhbcTranslator to implement the translate* methods. It can be used
independently of Translator or TranslatorX64 (it isn't yet but my next
region compiler diff uses it). I also moved a bunch of methods out of
inappropriate classes and changed the type guard/assert methods in
HhbcTranslator to use RegionDesc::Location instead of Transl::Location
and fixes a local tracking issue in translateRegion.
2013-07-18 17:28:34 -07:00
Eric Caruso b94ab7709f Translate FPushFuncU
We were punting on this, but it's a pretty easy
translation, and it makes calling functions from inside namespaces
much faster.

Closes #814
2013-07-11 15:11:13 -07:00
Guilherme Ottoni 244d4da93a Replace _ with - in file names under runtime/vm/jit/
Makes things more consistent, at least within this directory.
2013-07-11 15:11:11 -07:00
bsimmers 182ced3575 Remove operator==(Op, Opcode) and friends
I added them to ease the transition but since Opcode is just
uint8_t, they remove a lot of the safety of making Op an enum class.
2013-07-10 11:16:52 -07:00
Dario Russi 54b8a31c6f relax guard change to allow for specialized guards
Unified code for relax and specialize guards and removed type propagation on relaxation
2013-07-09 12:24:22 -07:00
mwilliams 795aa1309c Cleanup lifetime management for translation units
For PhpFiles, there was a mixed management system, where references from
translated code were held until the code was made unreachable, while
references from interpreted code were held for the duration of the
current request. Under the new scheme, PhpFiles are always treadmilled.
They are owned by the FileRepository, and so need to be ref-counted
because the FileRepository can have the same PhpFile under multiple
paths. But we don't ref-count the *uses* of PhpFiles anymore.

Classes still need to be ref-counted, but as soon as their Unit
goes away, most of their internals can be freed. We just need to
hold onto them if derived classes are referencing them. Even in
that case, the next time we try to instantiate the derived class,
we can kill any that reference this Class.

There were also lots of holes where references were not dropped,
or owned data structures were not destroyed. eg a Class's methods
were not destroyed when the Class was destroyed; there were
several paths where an entry was erased from the file map, but the
corresponding PhpFile was not decRef'd - or worse, a null entry
was left in the map (something we had asserts to check for).

This tries to make the handling more consistent.
2013-07-08 10:30:58 -07:00
Paul Bissonnette 0d5d5bca72 Added IterBreakV, MIter{Init,InitK,Next,NextK,Free} and fixed memory tracking bug.
Added IR opcodes to perform MIter* instructions in JIT.  Added IterBreakV bytecode
operation to break out of multiple loops containing iterators.  Emitter and assembler
were modified to support such use.
2013-07-06 11:12:28 -07:00
Mirek Klimos 5a98277b6c Replace ContSend by CGetL+CUnsetL
The behavior of ContSend is equivalent to CGetL+CUnsetL. Let's kill this
unnecessary opcode. Let's remove this logic from ContRaise opcode as
well.
2013-07-02 11:46:25 -07:00
Sean Cannella c891ec4d62 annotate printf-like functions
- added annotations to a few more functions
- fixed a few bugs exposed by the annotations
2013-07-01 13:41:02 -07:00
Eric Caruso 97a23e5ea7 Support for yield k => v;
Updates continuations to allow yielding of a key-value
pair from a generator. Adds bytecode instructions (PackContK,
ContKey) for using the new feature, and adds IR instructions
(ContUpdateIdx, ContIncKey) to help get it down to the metal
(in particular, ContIncKey attempts to keep the current use-cases
as fast as possible).
2013-07-01 13:41:00 -07:00
Eric Caruso d6fd9de236 Push modular division down to codegen
InterpOne sucks. Let's see if we can do this right.
2013-07-01 13:40:59 -07:00
bsimmers b7d178e674 Eliminate Marker instructions
This diff removes the Marker opcode, replacing it with a BCMarker
struct in each IRInstruction. This gives us fewer redundant lines in IRTrace
dumps and allows for more straightforward control of which IRInstructions are
associated with which bytecodes. I took this opportunity to do some more
cleanup of ir dumps as well, and it's now possible to interpOne every codegen
punt.
2013-06-28 10:33:51 -07:00
Mirek Klimos eddef7ffc0 Replacing PackCont and ContExit opcodes with ContSuspend.
PackCont opcode is always followed by ContExit so let's join them into ContSuspend. ContResume counterpart may come later (replacing ContNext/Send/Raise/Enter).
2013-06-28 10:33:50 -07:00
Sean Cannella 9849079ee4 fix print flag mismatch build warning on other platforms
- fix mismatch between %lu and uint64_t in printf flags
2013-06-27 15:14:17 -07:00
Jan Oravec f0dcca8b29 Kill m_received, transfer values thru stack
Continuation's m_received field is used to transfer values and
exceptions to the Continuation by send() and raise() methods. It has a
valid value only for a short duration of time, between
ContNext/ContSend/ContRaise and UnpackCont opcodes, when no other
operations could possibly occur. Let's free these 16 bytes of memory and
pass the value thru the VM stack.

To achieve this goal, ContEnter was modified to accept a value to be
transferred on the stack. The existence of the value on the stack is
then acknowledged by the UnpackCont opcode, which is the first opcode
executed after ContEnter enters the continuation body.

ContNext then becomes a trivial Null and is thus removed, ContSend just
teleports the value from local 0 to the stack (I will experiment in a
follow up diff with replacing ContSent by CGetL+UnsetL). ContRaise has
to update the label, but the eventual plan is to enter into unwinder
directly from the raise() method.
2013-06-27 10:50:00 -07:00
Jan Oravec 2a1d59c286 Move Continuation state check to ContCheck opcode
Add ContCheck opcode that moves away responsibility of checking
Continuation status from Cont{Next,Send,Raise} opcodes.

This check needs to run outside of try/catch in next()/send()/raise()
methods and moving it to a separate opcode lets us merge
Cont{Next,Send,Raise} with ContEnter.
2013-06-27 10:49:58 -07:00
bsimmers 26c74bf8e9 Pass known Func*s through in the region translator
Pretty straightforward, since the hard part of figuring out
when the Func* is known is still handled in Translator::analyze.
2013-06-27 10:38:22 -07:00
bsimmers f928f1b320 Support interpOne in translateRegion
This was going to be easy, but then it wasn't. The existing
interpOne relied heavily on the outputs of NormalizedInstruction, and
those are only populated by code that we want to kill soon. It also
didn't properly deal with bytecodes that wrote to more than one local,
or more than one stack cell. So the bulk of this diff is rewriting
interpOne to not rely on the NI outputs, then it was simple to hook it
into the region translator. I also cleaned things up so we don't
attempt to translate instructions that have no hope of succeeding; we
just interp them on the first try now.
2013-06-27 10:38:22 -07:00
bsimmers d99c6b0c58 Handle parameter reffiness in translateRegion
This diff stops the region translator from punting on
instructions that may be prepped by ref (FPass*) or Tracelets with
reffiness guards. It increased coverage and exposed a few more
bugs. The only significant one was that some Tracelets depend on type
prediction for their length, so I had to hook it into translateRegion
to avoid generating worse code (or punting).
2013-06-27 10:38:21 -07:00
bsimmers 6d91f8195a Turn HPHP::Op into an enum class
Because stronger types are better types, and this will make
future refactoring easier. I considered trying to purge the Opcode
type from the codebase too but that would be a much bigger project.
2013-06-25 13:19:08 -07:00
Sean Cannella 3d0c614b9a convert enums to enum classes, part 3
C++11 cleanup (clean up easy enums)

This is for runtime/base/... and ended up touching a lot of files
because it turns out we have a lot of reasonably behaved enums.
2013-06-25 13:19:06 -07:00
Sean Cannella 303ea58976 convert enums to enum classes, part 2
C++11 cleanup (clean up easy enums)

Since sandcastle is failing:
2013-06-25 13:19:05 -07:00
Sean Cannella 4872a71b36 convert enums to enum classes, part 1
C++11 cleanup (clean up easy enums)

Since sandcastle is failing:
2013-06-25 13:19:04 -07:00
Dario Russi a94e453dd6 Complete work for CGetM, SetM, FPassM and IssetM applied to collections
Added helper for the remaining collection types, emit guards and call specialized helper for the above opcodes
2013-06-21 16:37:11 -07:00
Sean Cannella e1b843862d runtime/base should not depend directly on tx64
remove dependencies on tx64 for runtime/base (by refactoring platform-independent code into translator)
2013-06-21 11:45:53 -07:00
Sean Cannella 6b2f9631b3 enable inlining for (most) static functions
- Enables inlining for existing function shapes for static calls except:
  1) static calls with a 'this' (as the refcounts become wrong)
2013-06-18 16:23:28 -07:00
bsimmers 351d40d3d2 Transl::Tracelet -> JIT::RegionDesc converter
This converter enables much more thorough testing of the
region translator. It currently passes all tests, though it does punt
on one or more Tracelets in roughly 1/6th of them. The two big
unimplemented features for the whole pipeline are interpOne (should be
pretty easy) and parameter reffiness checks (probably
nontrivial). I'll attack those in separate diffs next.
2013-06-18 16:23:27 -07:00
Paul Tarjan 872c1d1bcf disambiguate symbols for Transl killing
I got stuck while trying to kill the `Transl` namespace, but these were the 'by-hand' changes I did before I got stuck. They get us closer so I think doing them will be helpful regardless.

Most were making longer names, but I also had to kill `Immed` (since there was another `Immed`in the other namespace). Originally I renamed it, but since them someone killed the last use of it.
2013-06-17 11:01:27 -07:00
Paul Bissonnette c6ca429a5e Changed lookupIR in targetcache.cpp to not require a VMRegAnchor
Updated lookupIR functions in StaticMethodCache and StaticMethodFCache
to accept the FP as an argument.
2013-06-15 19:33:45 -07:00
Sean Cannella db9197d7a9 enable more failed inline shape printing
- profile inline shapes that fail due to IR compat reasons
2013-06-15 19:33:44 -07:00
bsimmers cf87b7eec3 Basic region translator
This diff adds a very, very basic region translator. Together with
-vEval.JitRegionSelector=method, it is capable of translating very simple
methods without using a Tracelet. It takes in a RegionDesc struct and creates
NormalizedInstructions on the stack to drive the translate* methods in
irtranslator.cpp. I started trying to get all tests passing with
JitRegionSelector=method (by replacing lots of asserts with punts) but decided
it's not worth it right now.

I'm planning on writing a Tracelet -> RegionDesc converter next and expanding
translateRegion to handle everything that throws at it.
2013-06-12 11:34:41 -07:00
Dario Russi f6de025eab Optimize FPassM for Vector and Map
Added FPassM to the instruction optimized for Vector and Map. It reuses the code for CGetM.
2013-06-11 11:47:48 -07:00
Dario Russi fe8b84f542 vector and map get/set/isset specialization in IR
specialized the IR instruction CGetM/SetM/IssetM for Vector and Map. IR now generates specialized code in those situation similar to what is done with Array.
2013-06-11 11:47:07 -07:00
bsimmers aa509ef3b9 Clean up TranslatorX64
This is a bunch of cleanup I've done for my work on the
region translator that isn't strictly releated to the region
translator.

- Move irTranslate* methods up to Translator and rename them
  translate*.
- Remove a bunch of friend declarations from TranslatorX64.
- Remove emitVariantGuards. We don't translate pseudomains so it was
  never doing anything anyway.
- Remove the unused REQ_BIND_REQUIRE.
2013-06-07 12:41:30 -07:00
Paul Tarjan b369aa91bc compile with -Wunused-but-set-variable
Our open-source build compiles with these warnings, so they cause spew when building from github. And I think they are good to catch programmer error.
2013-06-04 17:53:37 -07:00
Jan Oravec 8834f9211b Embed ContReceive into UnpackCont
Hoist ContReceive to the beginning of continuation body and make it part
of UnpackCont. This is a preparation for passing m_received thru the
stack.
2013-06-03 23:54:41 -07:00
bsimmers 8987de3e84 Remove immstack.cpp
It's dead but I missed it in my previous diff
2013-06-03 23:54:37 -07:00
Tim Starling 998951619f update copyright date
We did not intend to imply our copyrights last forever

Closes #759
2013-06-03 12:43:56 -07:00
Jordan DeLong f008eafffe Move SrcKey out of translator.h and Transl:: @override-unit-failures
I was going to #include translator.h in a header I had for
talking to the region selector thing and decided to just get this over
with instead.  (It shouldn't need to #include that.)  Found a few
other unused things to remove while at it.
2013-06-03 10:55:04 -07:00
mwilliams b1eedaa49f Change semantics of DecodeCufIter
Previously it returned a bool to say whether or not it had
succeeded, but always initialized the iter. The other iterators
branch on failure.

This adds the branch target which brings it closer to the other
iterators, and avoids the need to do a (pointless) CIterFree on
the failure path just to keep the validator happy.

I've also added a translation for it.
2013-06-03 10:54:44 -07:00
bsimmers cf197fee81 Collapse runtime/vm/translator's contents into runtime/vm/jit
Facebook: ~bsimmers/bin/move-vm-files.sh
2013-06-03 10:54:43 -07:00