Gráfico de Commits

152 Commits

Autor SHA1 Mensagem Data
Paul Tarjan 63fc74a751 reflection for namespaced constants
In repo mode this does the right thing and returns the right constant, but for non-repo it thinks it is an undefined non-namespace constant. I'll have to do something more hardcore if that starts to matter

While I was in there, I made the correct name for `ReflectionParameter` that was added in 5.4 instead of the draft we copied.
2013-06-25 12:22:52 -07:00
Mirek Klimos 56ddbc6bd3 CreateCont opcode optimization - avoid unnecessary reference counting.
Continuation argument values are copied to the continuation object and the locals are unset - in this way we don't need to change the reference coutners.
2013-06-25 12:22:51 -07:00
Mike Magruder b7d2212723 Remove useless interpreting flag from execution context
We were maintaining a flag that said if we were interpreting on the EC. It was only used in the implementation of hphp_break(), for pretty minimal benefit. I yanked it… it seems fine to me to throw the switch exception if someone steps out of the hard break even if we're already interpreting.

Also yank out a vestige of the previous stepping and breakpoint logic from the dispatch loop I noticed today. I'd previously missed it, but I made a change a while ago to put the state of the last location filter into the hands of the flow control commands. This was unnecessary and should have been removed then.
2013-06-21 16:37:12 -07:00
Sean Cannella 51ce8d138a remove tx64 dependencies from runtime/vm
Refactor platform-independent/interface methods into translator
so runtime doesn't depend on tx64 directly
2013-06-21 16:37:10 -07:00
Jan Oravec 621a7d9c55 Pass generator body Func* to c_Continuation::alloc()
Pass generator body Func* to c_Continuation::alloc(), which is then
passed to the new helper that computes ActRec offset.
2013-06-21 11:19:33 -07:00
Owen Yamauchi 49269952c8 Move everything out of GlobalNameValueTableWrapper
This is to clear the runway for getting rid of
GlobalNameValueTableWrapper. It moves aside these three items that were
in there for no particular reason other than convenience. I moved them
aside into another struct that I arena-allocate and initialize at the
same time as the global VarEnv (which initializes the GlobalNVTW).

I called the struct where these live "EnvConstants" since they look like
constants to PHP but their values are determined at startup time (by the
environment, like whether we're in server mode). lvalProxy doesn't fit
that mold, but oh well.
2013-06-18 16:23:27 -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 613295121f make debug_backtrace 5.4 compatible
This was spewing on mediawiki and we need to update. It is backwards compat.

I tried to put the constants in PHP but failed. I spent 30 mins on it. I'll come back to it next time I get the itch.

Closes #812
2013-06-15 23:32:07 -07:00
Drew Paroski e6b6aa0b09 Clean up the hphp/system folder
I noticed that directorty structure of hphp/system was a bit scattered, so
I consolidated things to reduce the total number of folders and to put
related things together with each other.

This diff moves the contents of "hphp/system/classes_hhvm" into
"hphp/system", it moves the contents of "hphp/system/lib" into
"hphp/system", moves "hphp/idl" to "hphp/system/idl", and moves the
contents of "hphp/system/globals" into "hphp/system/idl".
2013-06-15 23:29:49 -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
Owen Yamauchi e3ddc77159 Kill InclOpLocal
This one's an artifact of ReqMod and ReqSrc, which don't exist anymore.
2013-06-15 19:33:44 -07:00
mwilliams 866290d835 Fix crashes/assertions related to fb_intercept and reentry
If a function was called via (re)enterVM, and it didn't yet
have a prolog, and it was unable to get the write lease, and it was
intercepted, and the intercept handler asked for the original function
to be skipped, fcallHelper didn't return correctly, typically resulting
in the original function being re-executed, and then re-intercepted -
except that it was one level deeper in the vm-nesting hierarchy.

Eventually, it crashed.
2013-06-15 19:33:44 -07:00
Jordan DeLong 960f36f836 Restructure the unwinder a bit; use visitStackElems and simplify some things
Hopefully a little bit simpler, and duplicating less logic
with Stack::toString.  Contains some fixes to visitStackElems to make
it work for this (it is printing some stacks slightly incorrectly
right now, too ... :)
2013-06-13 10:25:38 -07:00
Jordan DeLong b01043bf3c Move the unwinder out of bytecode.cpp
Move all the stack unwinding code to its own module, delete
some redundant enumerations, document a few things.  Gets rid of most
of the remnants of the old setjmp/longjmp-based implementation at the
enterVM level but doesn't do much to the unwinder itself (coming in
separate diff to hopefully be easier to review).
2013-06-13 10:25:38 -07:00
Jordan DeLong 9e56c78038 Remove Variant::GetTypedAccessor
This stuff almost is an abstraction layer, but it's in a
strange place.  Also, the layout of TypedValue isn't something we've
been using through an abstraction layer, and if we want to later I
think we won't want to do so using this one.
2013-06-13 10:25:37 -07:00
Jordan DeLong d145ce88e3 Remove less, more, and equal functions from Variant
Re-implement them in terms of TypedValue and Cell helpers.
2013-06-13 10:25:37 -07:00
Jordan DeLong cca68a7f91 Remove two unused builtin_functions.h things, collapse print() into echo() 2013-06-13 10:25:36 -07:00
Jan Oravec 8491515257 Kill InlineCreateCont
Remove unnecessary optimization that can be achieved in a more general
way and simplify continuation creation code.

VMExecutionContext::createContinuationHelper was renamed to
VMExecutionContext::createCont{Func,Meth}. The createContFunc no longer
takes this/class arguments, the createContMeth transfers them in one
Type::Ctx pointer that is used natively by ActRec's m_this. Since the
whole logic of this function is to set this single field, the logic is
now simpler.

Interpreter: iopCreateCont() just passes the m_this field of the parent
ActRec.

Translator: CreateCont opcode loads m_this field using LdCtx opcode.
This opcode optimizes into LdThis, which optimizes into
DefInlineFP->SpillFrame->object and allows frame to be eliminated, a
case previously covered by InlineCreateCont.

This diff uncovered a bug in trace builder, where LdCtx in static
methods could be optimized into LdThis, if the method was called thru
object. Fixed.
2013-06-12 14:04:05 -07:00
Jan Oravec 9662396bf0 Store variable arguments in optional local
Save 8 bytes of m_args and its initialization for Continuations without
func_get_args() call (does not save real memory due to 16-byte alignment).
Store variable arguments in optional local.
2013-06-11 11:48:06 -07:00
Paul Bissonnette d8df647b38 Fixed cleanup/exception handling for vector operations.
Vector statements ending with a SetProp now properly free
         memory when run with JIT enabled.  Additionally, in both
         JIT and interpreted mode memory will still be freed if
         exceptions are thrown during evaluation of vector operations.
2013-06-11 11:47:47 -07:00
Paul Tarjan 8cf6ccb00a use TRACE_SET_MOD
I found this macro while refactoring and since I like consistency, I used it everywhere.
2013-06-10 10:14:13 -07:00
Herman Venter fcf0c7533c Remove assertion that is no longer true and that does not do anything useful.
This assertion should have been removed with an earlier diff that made it no longer true.
2013-06-10 10:14:12 -07:00
Mike Magruder 96d6bab291 Cleanup flow control around exceptions
There were multiple issues with flow control when exceptions occur. Fixed these by ditching the reliance on the exception thrown interrupt and introduce an exception handler interrupt, which indicates control is about to pass to a catch clause. This gives us much better insight into how execution is flowing and how we might need to adjust an in-flight stepping operation.
2013-06-10 10:14:11 -07:00
Jan Oravec 1d90b368dc Kill m_localsOffset and free another 16 bytes of memory
Users of m_localsOffset used this offset to calculate pointer where
local variables starts. Since they are stored in the reverse order, the
equation was:

  cont_ptr + m_localsOffset + num_locals - local_id - 1

We are already storing pointer to ActRec (m_arPtr), which is equal to:

  cont_ptr + m_localsOffset + num_locals

This diffs kills m_localsOffset and uses m_arPtr to simplify
calculations. Continuation fields were rearranged so that
sizeof(c_Continuation) is reduced by 16 bytes.
2013-06-07 12:41:30 -07:00
Jordan DeLong e05dd4e9ff Make stack walking logic from Stack::toString reusable
I need to walk a live eval stack, handling FPI regions and
generators, and duplicating that logic in yet another place seems
wrong.  This makes the Stack::toString stuff use a reusable one---at
some point I'll see if the unwinder can use it as well, but it works
also for my use case.  Also, Stack::toString was broken for mutable
array iterators---fixes that.  And use a union now for struct Iter.
And don't include bytecode.h from func.h.
2013-06-06 15:58:14 -07:00
Jan Oravec 1e48e96bbe Remove m_obj from c_Continuation
m_obj in c_Continuation is redundant. It is only used at the time
Continuation is created. First, it is set in init() call. Few
instructions later, it is read so that $this in the Continuation's
ActRec can be populated.

Kill it.
2013-06-06 15:57:06 -07:00
Edwin Smith 3515793e74 Remove ArrayData::nvSet() wrappers and several dead Array helpers.
nvSet() only casts the value from TypedValue* to const Variant&; do it
at callsites.  Inlined array_setm_ik1_v0() and array_setm_s0k1_v0() into
their only remaining callsites in translator-runtime.cpp.
2013-06-06 15:57:05 -07:00
Edwin Smith fe32089a67 Reduce use of AttachLiteral StringData construction
This is the first results from profiling callsites of
StringData::initLiteral.  This diff converts a handful more
string literals to StaticString, removes overloaded Variant
comparison operators (operator==, etc), and avoids
constructing new strings in a few cases in tvCastToString
and tvCastToStringInPlace.
2013-06-06 12:00:06 -07:00
mwilliams d62fddec07 Fix crash in array_filter/array_map with a bad function
interp only
2013-06-04 17:53:38 -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
Alexandru Suhan 93edca4397 Smaller c_Continuation
Save 16 bytes in c_Continuation by moving running and done flags to o_subclassData and making labels 2-byte.
2013-06-03 23:54:41 -07:00
Jan Oravec e6bd76e3fd Kill m_should_throw
Do not check for m_should_throw from ContReceive. Add a label used by
ContRaise pointing to Throw emitted by the Yield instead.
2013-06-03 23:54:39 -07:00
Mike Magruder 609abd866f Fix step out bugs (also effects Next)
We had a lot of odd behavior with both Next and Out. Previously the debugger would interpret the world until it saw that it was no longer on a specific line, or at a specific stack depth. I changed it recently to let the program run normally, and use an internal breakpoint to control step outs. Next's become like a step out temporarily when you descend into a function and need to get back out to the original line, so some bugs with out showed as bugs with Next, too.

Specifically, any time more PHP code was executed as a "side-effect" of a non-fcall instruction, step out would get lost. In these cases the stack trace gives us the offset of the instruction causing the PHP to run, not the instruction that control will return to as is the case with a Fcall. A breakpoint set there would get missed. This changes the step out logic to recognize such cases (via the fact that a nested VM state was pushed to execute the code) and step out more intelligently. We look at the instruction in question, and determine where execution may go, which might be multiple places. I also made a small change to ensure that we don't stop in generated functions when stepping out, which cleans up the iterator experience quite a bit, and sets us up for proper generator stepping, which will come next.
2013-06-03 23:54:35 -07:00
Owen Yamauchi 9494a366b5 Move runtime/eval/runtime/file_repository.* to runtime/base
runtime/eval is a relic of a bygone era. As long as we're cleaning up
our directory structure, let's move FileRepository (the only remaining
thing in runtime/eval/runtime) to where it makes sense.

runtime/eval still contains the debugger, which would probably make more
sense as runtime/debugger, but I don't want to throw a wrench in the
works for @mikemag and @hermanv unnecessarily.
2013-06-03 23:54:34 -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
Jordan DeLong d3f443efdf Remove unused member function 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
aravind a686bd4ca1 Remove BPass* instructions 2013-06-03 10:54:40 -07:00
bsimmers 991c1e3bdb Rip out preconsts
This was barely a demonstrable win in sandbox mode when I first wrote
it and it's not even used in hhir. It's probably been bitrotting and is causing
crashes for some people. Time to say goodbye.
2013-06-03 10:54:40 -07:00
bsimmers 8733cdc4f3 Run hhir exit traces during unwinding; don't spillstack before most helpers
Most of the SpillStacks we do are just to keep the in-memory VM stack
clean in case a helper call throws an exception. Many of these exceptions are
vanishingly rare, so let's stop making the fast path slower for them. This diff
adds support for catch traces, which are just like normal exit traces with one
major exception: they're never jumped to from translated code. If we're
unwinding a TC frame and discover that the current rip has a catch trace
registered, the unwinder will execute it before resuming unwinding.

The unwinder parts were fairly straightfoward, then I ran into a bunch of
issues with SetM. The SetElem instruction sometimes consumes a reference to one
of its inputs, which is bad news for our optimizations. To make everything work
again, I changed SetElem to throw an exception in cases where it would've
previously decreffed the value input. This is a special exception that the new
unwinding code recognizes. When one of these is caught, the catch trace
executed for that TC frame will finish up the vector instruction and push the
value provided by the exception on the stack. This allows us to optimize most
traces under the assumption that SetM's output is the same as its input,
letting the catch trace clean things up if the helper decides that's not the
case and throws.

There is one common case where SetM's output isn't the same as its input:
setting an offset in a string base returns a new String. Luckily, we can detect
most of these at compile time so SetElem returns a new StringData* when the
base is known to be a string. If the base might be a string, SetElem will
return nullptr if the base wasn't a string, and a StringData* if it was. We
test the output in these cases and side exit if the return value of SetElem is
non-null (I have yet to see this side exit happen outside of artificially
created test cases).

Once I got things working in the vector translator, I went through every other
call to spillStack and exceptionBarrier, replacing them with catch traces as
appropriate.
2013-05-30 17:39:25 -07:00
mwilliams 78ca8ecbaa Add bytecodes to decode a function, and push an actrec for a decoded function
array_filter and friends only need to evaluate the callback once,
so add bytecodes to support that.

Depends on D817883
2013-05-30 17:33:05 -07:00
mwilliams c12714e2bb Add bytecodes for some "withRef" operations
Functions like array_filter and array_map need "withRef" semantics,
and while it can be simulated in php via copy-on-write, doing so
is very inefficient.

This adds

  SetWithRefLM
  SetWithRefRM
    - similar to SetM but binds the value if it was a reference. L reads a local, R reads a return value

  WIterInit
  WIterInitK
  WIterNext
  WIterNextK
    - essentially the same as the corresponding opcodes without W, but the value local is set by reference if the array element was a reference.
2013-05-30 17:33:04 -07:00
mwilliams 71859e5566 Add support for .hhas files in systemlib
Will be needed for array_filter/array_map etc

This sets things up so that if we define a builtin in systemlib, we rename
the corresponding c++ builtin with the prefix __builtin_, so its still available
(in case the php builtin wants to delegate some edge cases, and to make
it easy to run comparisons between the php and c++ implementations).

Also did a little reorganization to get rid of Func::isPHPBuiltin,
and use an Attr to identify functions as builtins. C++ builtins can
still be identified by checking the Func::info() method. This is needed
to allow builtin methods defined in php (such as array_map) to lookup their
arguments in the correct context.
2013-05-30 17:33:02 -07:00
Jordan DeLong 42a6039125 Fix a bug with debug_backtrace during an unwind
The change to stop zeroing locals during RetC was too
aggressive---we stopped doing it during unwinding also.  When
unwinding, we need to zero locals and $this because another
destructing object may still run debug_backtrace, and we won't have
the *pc == OpRet{C,V} trick to tell us to ignore the junk.
2013-05-28 10:30:27 -07:00
Alexandru Suhan eb5d2d1f00 CGetS output type prediction 2013-05-23 21:03:04 -07:00
Sean Cannella 685af88ccf fix file/class in backtraces involving traits
- non-repo mode: use fullName() instead of flawed logic in type constraint failures
- repo mode: save the original filename when flattening traits
2013-05-23 21:03:04 -07:00
Guilherme Ottoni f3f3e0b48e Optimize ContSend, ContRaise, and ContNext for m_received being null
Make sure m_received is always null at ContSend, ContRaise,
and ContNext, and this information to generate better code for these
bytecode instructions.
2013-05-23 20:02:41 -07:00
aravind fec5acd7ec Treadmill for shared variants
Avoids atomic incRefs and decRefs. StringData no longer needs to
be sweepable for SharedVariants.
2013-05-23 20:02:40 -07:00