headers_list should return an empty array when there are no
headers. There were already tests involving this in ext_network.php, but it's
being skipped (at least in the github repository).
Closes#1218
Reviewed By: @alexmalyshev
Differential Revision: D1030259
Pulled By: @scannell
The rpc server keeps the ExecutionContext alive across requests to
reduce startup costs. Unfortunately, we weren't clearing $_SESSION, $_GET,
etc... at the beginning of the request. This was making us think that most of
the http headers in most requests were duplicates, and emit a warning where the
option is enabled. It's also generally bad practice to leak this stuff between
different requests.
Reviewed By: @markw65
Differential Revision: D1010456
analyze needs to read live state, which is only
valid if this is the first tracelet in the region. For
subsequent tracelets, fall back to the interpreter.
Reviewed By: @ottoni
Differential Revision: D1028657
Modify one of the tests so it fails with the wrong options
and pass the right ones, add a similar test for static member
functions. It appears DynamicInvokeFunction is ignored for member
functions (but member functions are inspected for a "dyn_" prefix??),
so I added norepo for the ones that do intercept on member functions.
Reviewed By: @swtaarrs
Differential Revision: D1029398
ld on OS X 10.9 doesn't seem to be able to locate the ctype.h
functions (ex. isdigit) when they are used as function pointers, so wrap
them in lambdas.
Reviewed By: @markw65
Differential Revision: D1030137
yii leaves this file around which is a duplicate of its test. So the autoloader loads it twice. Kill it between runs.
Reviewed By: @JoelMarcey
Differential Revision: D1030682
The variable command, along with its clients the global command and the = command, obtained variable names and values from the server by asking for an map of variable name to variable values in a single request. If one or more of these variables have really large values, the serialization of the map exceeds the serialization limit and the entire command fails. This makes it difficult pin-point which variable causes the trouble and breaks the client commands in unexpected ways.
This diff changes the protocol of the variable command so that it first gets an array of variable names only and then separately gets the value of each variable. If such a separate get fails because of a serialization limit, the variable's value is printed as "...omitted".
Reviewed By: @mikemag
Differential Revision: D1021035
An IncRef that is marked as a candidate for sinking should
be removed from the sinking list only if the corresponding DecRefNZ
is live.
Reviewed By: @ottoni
Differential Revision: D1026155
We assert in DOMNode::{appendChild,insertBefore} that the node that
has been passed in is an orphaned node, however it's only orphaned if
it has no parent or its parent is also orphaned.
Fixes the last fatal in yii
Reviewed By: @ptarjan
Differential Revision: D1026211
This variable is entirely independent of the hdf, so it should be set even it there isn't one.
This came up when someone (me) was running `hhvm -m server` from the symphony directory trying to show it off, but PATH_INFO doesn't work unless the m_documentRoot is set. It just assumes that all files exist if there is no document root.
This shouldn't affect anything in FB since there is always a `.hdf`.
Reviewed By: @markw65
Differential Revision: D1025781
gdb traps calls to a function named __jit_debug_register_code,
and updates its internal symbol tables.
Apparently gdb-7.2 was prepared to demangle the name,
while gdb-7.6 is not.
Reviewed By: aravind
Differential Revision: D1026295
StoreImmPatcher is currently subtracting the wrong offset (not
taking into account the extra instruction emitted) when setting m_addr.
Closes#1210
Reviewed By: @markw65
Differential Revision: D1025861
When HHVM can't bind to a port it tries to shut down the
currently running instance using /stop on the admin port, but
RuntimeOption::ServerIP was blank (do we actually set this anywhere?)
and we weren't passing the admin password.
Reviewed By: @markw65
Differential Revision: D944849
Wow, our json parser has diverged so much from zend. This is basicaly what theirs does. More importantly, this is correct.
Sadly I don't think is the memory corruption bug.
Reviewed By: @scannell
Differential Revision: D1021678
The list command was using the the string "line2", cunningly disguised as the static string variable 'line1' to look for the line where a func/class/method starts. Also, the file name it got for systemlib.php was expected to always be exactly "systemlib.php" but it turns out this is no longer the case, or at least not always.
Reviewed By: @mikemag
Differential Revision: D1018535
Changed cmd_step to check at onBeginInterrupt if the file line is empty i.e. returns as ":0"
In this case continue stepping
Reviewed By: @mikemag
Differential Revision: D1017420
While processing tiff tags, the end pointer was not updated
after a realloc. Also, while processing IFD tag, end and begin pointers
were switched.
Closes#1154Closes#1193
Reviewed By: @ptarjan
Differential Revision: D1019738
Pulled By: @scannell
Fix clowny error in zend-strtod.cpp on ARM platforms that passed through the PHP internals mailing list
Reviewed By: @JoelMarcey
Differential Revision: D1019758
'brew update' to a newer icu4c on OS X exposed that we aren't
being consistent in how we include it resulting in linker errors due to
confusion regarding what the icu namespace is.
Reviewed By: @sgolemon
Differential Revision: D1019529
In ArrayInit constructor, n is defined as ssize_t, but negative values
are not handled in any way. We should point that out to callers by
making n of type size_t.
Reviewed By: @edwinsmith
Differential Revision: D1017631
This fixes a couple of asserts I hit running www in DEBUG mode with
-vEval.JitPGO=1 -vEval.JitRegionSelector=hottrace
-vEval.JitPGOHotOnly=0.
Reviewed By: @ottoni
Differential Revision: D1016284
* @ eval() was not being silenced correctly
* If the string passed to eval() hits a parse error, then the runtime
is not supposed to fatal. We currently do.
* Errors in eval() code did not print a valid file name, they now
print it as "$FILENAME($LINE1) : eval()'d code on line $LINE2"
Closes#945
Reviewed By: @jdelong
Differential Revision: D1006603
This function returned true if the type had isHHType(), which
it will always if EnableHipHopSyntax=1. The flag was 0x16 instead of
0x10, and isSoft() just does return m_flags & Soft.
Reviewed By: @dariorussi
Differential Revision: D1014812
We need to ensure that m_mode is reset after each
translation attempt.
There was already code in TranslatorX64::translate to reset
it, but after setting it in TranslatorX64::retranslateOpt,
its not certain that we'll get there.
Reviewed By: @swtaarrs
Differential Revision: D1012330
CMake uses rpath to make it easier to run built executables from the build
tree without installing prerequisite libraries first. This means that when
installing, CMake will re-link the binary in order to change the rpath so
it works properly in an install. Unfortunately, it's not smart enough to know
to re-embed the systemlib section, so the installed `hhvm` binary does not
have a systemlib section and doesn't work.
This commit adds a cmake function `HHVM_INSTALL` that effectively bypasses the
standard install command to ensure that the binary is not relinked. To help
with rpaths, this also checks for the existance of the `chrpath` tool. If it
exists, it uses it to either remove or replace the rpath entry in the file,
otherwise it just leaves the rpath entry alone.
This allows `make install` to work again.
JIT counterpart to {D984939}. Relies on a similar
partially-populated JIT-allocated ActRec passed to a C++ helper
technique used by methodCacheSlowPath.
Reviewed By: @jdelong
Differential Revision: D999262
The JIT helpers for isset() were erroneously returning true when a key was
present in a collection but the corresponding value was null. This diff
fixes the helpers appropriately.
Reviewed By: @elgenie
Differential Revision: D1013006
HPHP::Util::nextPower2(1) ends up calling __builtin_clz(0),
which has undefined behavior. In practice it can return any result.
None of the current callers seem to trigger the bug, but in addition to
fixing the bug this diff also reduces the compiled size and increases
the performance of the method.
Also, the attempt to use an arithmetic exception instead of an assert
doesn't seem to be working, so I replaced it with a regular assert.
Reviewed By: @andralex
Differential Revision: D1007106
- Relax more guards as a result of assertions from static analysis
- Add support for using DataTypeGeneric with PopC and friends
- Get guard relaxation-specific logic out of reflowTypes
- Refine/relax some type constraints
- Misc small bugfixes found along the way
Reviewed By: @bertmaher
Differential Revision: D988172
I was running into issues with complicated union types, so I decided
to clean this up a bit. Because the member helpers always operate on the inner
cell of a boxed type, we can just handle the inner type and outer type
separately, simplifying a few things.
Reviewed By: @markw65
Differential Revision: D1005835
HHVM has checks to make sure that 'yield' and 'await' are not both used
within in the same function/method body. However, HHVM was lacking a check
to make sure that 'yield' was not used inside a function decorated with the
'async' keyword. This diff adds the appropriate check for this, and it adds
some tests.
This check currently will attribute the parse error to the closing curly
brace of the function body. We can fix this later by adding the necessary
plumbing, but I wanted to get a quick fix out for now.
Reviewed By: @elgenie
Differential Revision: D1012387
So, I want to make `-d` work from the command line. I tried to make a `IniSettings` section of the `hdf` but it turns out you can't have `.`s in any of the names or else it makes it a nested config section and `.get()` won't traverse it. Supporting a `IniFile` was much easier.
I set a default in `/etc/hhvm/php.ini`. Thoughts?
Reviewed By: @markw65
Differential Revision: D1009092
Added mechanism to print out csv summary results for use in charting (--machine option). Using this option supresses all output except for the csv at thee end.
Show tests that do not give the expected output compared to a previous run.
Enhance help to describe what the colors mean for . and F during test runs.
Add a count of tests that will be compared.
Reviewed By: @ptarjan
Differential Revision: D1010936
Summary: The jemalloc version check needs to add the include directory
for jemalloc when compiling or it will incorrectly not find jemalloc in
some cases (ex. OS X.)
Reviewed By: @edwinsmith
The spec claimed these instructions stored to locals "as a
cell", which sounded to me like it should convert KindOfRef locals
into KindOfCell. What it meant is that it stored using a normal
assignment (we don't really specify how these work, so I just changed
it to say "with the semantics of SetL"). Also hoist discussion of the
assignment semantics out of the switch (%1) part of the spec.
Reviewed By: @edwinsmith
Differential Revision: D1009178
A couple unused variables/functions, and the mainReturn logic
sets up mainReturn even if you don't have a merge only unit, which I
don't think we should require, so changed it to make getMainReturn
require isMergeOnly as a precondition. (We could maybe indicate
merge-only-ness by whether the mainReturn is KindOfUninit later
instead of the bool.)
Reviewed By: @markw65
Differential Revision: D1009053
Generators and async functions become two functions when we compile them: the original function, and another with $continuation on the end of the name. With classic generators the original function is a mere stub which returns a Continuation which will use the $continuation function. That's not too interesting from a profiler perspective: the original function does pretty much no work. For Async, though, the original function may do significant work before the first await, and may even continue to do work depending on the disposition of the object awaited upon.
The hotprofiler extension was separating these two functions and reporting call counts and times separately. While technically correct, it's also pretty useless and in the Async world will hurt since the time spent in such a function is split in some unknown proportion. This will cause users of the data to devalue the const of async functions unless they realize this implementation detail.
This change ensures that all time spent in a generator or async function is aggregated under a single function name: the original one.
Reviewed By: @jano
Differential Revision: D1010450
If we are going to replace zend, we need a CLI that looks like theirs. This is a start. I'll do `-d` next.
Reviewed By: @markw65
Differential Revision: D1009086
"Get rid of refdata_after_decref_helper" added a new call to
smartFreeSize that should be smartFreeSizeLogged.
Reviewed By: @markw65
Differential Revision: D1011305
Right now we crash on the user-defined sort functions if the
function is not valid. Don't do that.
Closes#1165
Reviewed By: @markw65
Differential Revision: D1010050
Due to Symfony's use of autoload magic, the infinite recursion
detection is a bit too good and breaks their assumption of being able to
autoload circularly in what would overflow the stack if exit() wasn't
involved. Zend allows this so we probably need to as well.
Closes#1170Closes#1175
Reviewed By: @markw65
Differential Revision: D1009853
This made it different from all the other countables,
because instead of calling Foo::release, you had to call
refdata_after_decref_helper.
But the only direct calls to release were either using
it to free the memory (so add releaseMem to do that), or were
already checking m_cow. Rewrite release to check m_cow, which
makes the decRefFoo helpers uniform.
Reviewed By: @swtaarrs
Differential Revision: D1009974
Specifying numa_set_membind doesn't just set the default,
it sets a thread-wide limit on which nodes can provide memory. This
meant that the numa_interleave calls were ineffective.
It turns out that most of the unbalancing occurs during startup/warmup,
so just move the point at which we enable numa.
Reviewed By: @swtaarrs
Differential Revision: D1008356
using a "!" and a "===" are really dumb together. I think the old code was right anyways, but this was crazy.
Reviewed By: @alexmalyshev
Differential Revision: D1008302
Pretty much mechanical change, which will make it easier
to use the sign bit for RefCountStaticValue.
Reviewed By: @edwinsmith
Differential Revision: D1009397
Preparing for a bigger diff we are brining the APC files and objects to a common naming convention
Reviewed By: @jdelong
Differential Revision: D1007981
This takes care of all the quick tests that were hitting
the ##always_assert(!ni->interp)## in translator-x64.cpp. This means
that there all the IR opcodes that appear even when every bytecode is
being interped now have ARM codegen.
The remaining issues in test/quick are primarily complete codegen
failure -- i.e. translateTracelet returns Failure because no amount of
marking bytecodes as "interp" will result in successful codegen. I'll be
going after these next.
Other than that, there are a laundry list of other failures in other
parts of the system, like hhbc-translator, that I don't understand at a
glance. My guess is that interping every bytecode is stressing the
system in a way that exposes some previously-undetected fragility.
Reviewed By: @edwinsmith
Differential Revision: D1005940
This implement ReqBindJmp and associated machinery, and GuardRefs. It
also moves the jump-target-reading functions out of Asm and into
jump-smash.cpp.
GuardRefs is largely copied, but the codegen logic is nontrivially
different, because of differences like how ARM encodes immediates in
logical instructions, and how it can't do compares and tests with memory
operands.
Reviewed By: @jdelong
Differential Revision: D1005529
This broke the OSS build. I'm just splitting it up into multiple calls,
resulting in more, but less deep, template instantiations.
Reviewed By: @scannell
Differential Revision: D1009550
I'm getting to the point where it's helpful to see the ARM code being
emitted, and this is the most natural way to hook it up.
There's a little wrinkle here in that sometimes (e.g. smashable jumps),
there's stuff in the TC that isn't executable code. In this case the
disassembly is either "Unallocated" or some nonsense instruction. We
could avoid this with sufficient metadata, but I'm not convinced it's
necessary yet. (FYI, this pattern -- data embedded in code -- is common
in ARM code, to judge by the vixl assembler's inclusion of an
abstraction to do this very thing.)
In the process I had to convert vixl's printing facilities to use
std::ostream instead of FILE*. I converted it to use folly::format
instead of fprintf as part of this.
Also added an --arm flag to hhvm_wrapper.php to make my life easier.
Reviewed By: @edwinsmith
Differential Revision: D1006435
- Put a newline before the downloading message as it happened in the middle of the line a bunch of times
- Made the comparing message less verbose since it is printed all the time on every runner
- Renamed it "run" and made it execuatble (in line with `test/run`)
- Fixed a warning where the status is empty. Is that right to ignore it?
- Don't always generate `.expect` files
- Similarly, don't always generate the summary file. I don't really understand what you are trying to do with that one being checked in?
I don't really understand how to use this yet. My runs don't seem to give me the thumbs up, so either the expect files are too specific to @JoelMarcey's machine or the tests are flakey. Either way, we can't use this yet.
Reviewed By: @JoelMarcey
Differential Revision: D1009080
We can now convert any collection toFrozenvVector() and FrozenVector to
any collection.
unit tests pass, but show up as "postponed" in phabricator
Reviewed By: @dariorussi
Differential Revision: D1006767
Apparently, there's no exact equivalent in linux, so its
treated as a no-op. What we *want* here, however, is exactly what
linux's madvise does.
Reviewed By: @jdelong
Differential Revision: D1007545
BuiltinFile is supposed to be a wrapper around an existing FILE or
file descriptor, so it shouldn't close the underlying stream when being swept.
Reviewed By: @bertmaher
Differential Revision: D994199
ArrayIdx was treated as "consumesRC", when it really doesn't.
Also move the decref of the default argument to be explicit in the IR
so it can be paired with preceding increfs. If the default argument
is, in fact, used, it's the responsibility of the arrayIdx helper to
incref it.
Reviewed By: @swtaarrs
Differential Revision: D1008957
This diff adds support for checking and raising a warning when a soft type (@Alite404Exception) fails. Soft type hints are useful
when converting code from untyped code (php) to typed code (hack).
Discussion: https://www.facebook.com/groups/165748143439038/permalink/690858800927967/.
Reviewed By: @dariorussi
Differential Revision: D926433
We have a simplifier rule that does this now, and we want
CodeGenerator to work without relying on SSA form.
This also fixes a Str->Strb bug in ARM.
Reviewed By: @swtaarrs
Differential Revision: D1007836
ArrayInit based reservemap, add, and createmap is more efficient. Add them
to VariantController.h for extensions.
Reviewed By: andrii
Differential Revision: D1007534
Parses svn.php.net's docbook sources for an extension's API
and generates a Systemlib and Extension source file for it.
Reviewed By: @ptarjan
Differential Revision: D989163
Depends on D984939. Instead of copying the entire test,
ensures that in each case with an array() callable is followed
immediately by a direct call(). To start with, cases that cause
fatals are commented out. I also renamed "foo" and "bar" to
"meth" and "staticMeth", for readability.
Reviewed By: @jdelong
Differential Revision: D1002897
The first step is to merge SerializationPythonVariant and
UnserializationPythonVariant into PythonVariant. Even when the Variant
handles two different sets of types (Variant = object for unserialization
and Variant = PyObject* for serialization), FBSerializer was modified to
use templates instead of accessing types definitions in the Variant, so the
types defined in the PythonVariant are only used by Unserialization.
Next:
Specify a MutableStringType in the Variants (StringType in
old SerializerController is not necessarily equals to StringType in
VariantController).
Add PythonVariant as a trait.
Reviewed By: andrii
Differential Revision: D1003710
Abstract away the code for equality from Vector to BaseVector, so we can reuse it
in FrozenVector.
Reviewed By: @dariorussi
Differential Revision: D1006830
Miscellaneous cleanup, including:
- Only initializing the profile data structure if requested
- Save the profile to disk with some frequency
- Move internal functions out of the header
Reviewed By: @jdelong
Differential Revision: D921078
Summary: Suppress unused local typedef warning in GCC 4.8 because it is
currently triggered by multiple Boost (at least as of 1.53) headers.
Reviewed By: @sgolemon
Create a registry for per-extension systemlibs to be
loaded from the binary and parsed at InitModules() time.
Auto-embed runtime/ext/ext_foo.php as systemlib.ext.foo
loadSystemlib() looks for systemlib.ext.foo and calls
CompileSystemlib() which parses the section and merges
immediately as well as storing for later re-merging (if needed).
Enables the following <<__Native>> pattern:
virtual void moduleInit() {
HHVM_FE(myfunc);
loadSystemlib();
}
Where the extension systemlib has a declaration for myfunc().
Reviewed By: @jdelong
Differential Revision: D986853
Right now, SharedPtr works, because SharedStringData provides
atomic ref counting. But I need to make some changes to SharedPtr which
break it. Use AtomicSharedPtr instead (this is what AtomicSharedPtr is
for).
Reviewed By: @dariorussi
Differential Revision: D1006407
This is some reorganization I did to use FrameState in guard
relaxation. It cleans up the interface used to enter and exit blocks by using
startBlock and finishBlock instead of the old methods.
Reviewed By: bertrand
Differential Revision: D1005829
The catch trace map was being updated as we went along, instead of at
the end of translation along with all the other metadata. shouldIRInline was
treating the immediate vector for Switch and SSwitch as an m-vector.
Reviewed By: @ottoni
Differential Revision: D1005823
Because we re-sort the EHEnt table every time we load from
the repo, it's impossible to represent certain configurations of
fault/catch regions that are not made illegal in the spec. For
example, you can't have a Fault and Catch region with the same extents
where the Fault region should be considered "outer" to the Catch
region. This changes things to serialize parentIndexes to the repo,
and adds support to the FuncEmitter to tell it not to re-sort the
EHTab if a given user knows they've sorted it properly (and set up
parentIndexes) already. Also adds some assertions about the required
sorted properties.
Reviewed By: @dariorussi
Differential Revision: D1002108
The error message for a bad command is misleading. Added "Attempted to interpret unknown debugger command as PHP" into the error message
Reviewed By: @mikemag
Differential Revision: D989538
These functions are stubs in editline anyways, so in order to support Ubuntu 10.04 using editline 2.11-20080614-1build1 just ifdef them out
Reviewed By: @sgolemon
Differential Revision: D1006813
There were a few situations where the bcOff used in the ReqBindJmp at
the end of the trace was either for the wrong function or the wrong instruction
in the correct function. We can now explicitly pass it into HhbcTranslator::end
to make sure it's correct all the time.
Reviewed By: @bertmaher
Differential Revision: D1005831
Wanted to add PHPUnit to our list of frameworks to test. While doing so, I made a few extra changes such as making the hhvm build be in JIT mode. And re-ran the tests again to get a new baseline and summary file.
(Ignorning conflict markers because symfony uses 7+ = signs in some of their tests, which causes conflict marker errors here: diffusion/E/browse/admin/scripts/git/hosting/hooks/update.d/430.conflict_markers.sh)
@EntNotFoundException
Reviewed By: @ptarjan
Differential Revision: D1006290
I'm getting to the point where it's helpful to see the ARM code being
emitted, and this is the most natural way to hook it up.
There's a little wrinkle here in that sometimes (e.g. smashable jumps),
there's stuff in the TC that isn't executable code. In this case the
disassembly is either "Unallocated" or some nonsense instruction. We
could avoid this with sufficient metadata, but I'm not convinced it's
necessary yet. (FYI, this pattern -- data embedded in code -- is common
in ARM code, to judge by the vixl assembler's inclusion of an
abstraction to do this very thing.)
In the process I had to convert vixl's printing facilities to use
std::ostream instead of FILE*. I converted it to use folly::format
instead of fprintf as part of this.
Also added an --arm flag to hhvm_wrapper.php to make my life easier.
Reviewed By: @edwinsmith
Differential Revision: D1006435
We don't have a translation for Box, so we always interpOne it and all
of its inputs are marked dontGuard. If the input to the Box was produced in a
previous tracelet, this means we won't know its type in the jit, and it was
upsetting the code figuring out the output type of the interpOne. We know from
the bytecode that the input is always a Cell, so assert that before translating
the instruction.
Reviewed By: @ptarjan
Differential Revision: D1006328
This was (we think) accidentally disabled in non-debug builds a long
time ago, and some type shuffling I did a while ago broke KindOfRef
predictions. RuntimeType expects an inner type of KindOfAny instead of
KindOfNone.
Reviewed By: @kmafb
Differential Revision: D1004691
EndCatch was supposed to be terminal in some catch traces but not in
other. We know which is which at compile time, so now we use TryEndCatch for
the non-terminal case and EndCatch for the terminal case.
Reviewed By: @edwinsmith
Differential Revision: D1005802
This is needed for composer to install the dependancies for phpunit.
I also upgraded composer while I was in there.
Reviewed By: @JoelMarcey
Differential Revision: D1005174
Add FrozenVector as a collection.
Enable the following:
* frozen vector literals
* casting fvs to array and bool
* array_key_exists and isset with fv
Reviewed By: @paroski
Differential Revision: D988612
When jemalloc is used, the code for tracking out of memory situations conflicts with the code that figures out how much memory is actually in use. To solve this, I've introduced a new usage counter field in the memory manager. Presumably, this counter is less accurate than the one that is maintained by the jemalloc specific code in MemoryManager::refreshStatsImpl, but this should not matter because it's only role is to trigger an out of memory check, which is done using the usage field maintained by refreshStatsImpl. If this check is triggered, the new counter is updated to the presumably more accurate value.
Reviewed By: @edwinsmith
Differential Revision: D994503
We were incorrectly checking if JitPGO was enabled to skip some things
that are only intended to be skipped during profiling translations.
This was resulting in worse code to be generated in TransLive mode.
Reviewed By: @swtaarrs
Differential Revision: D1004077
Zend only has this sort of behavior when mysql.trace_mode is
enabled, but it's off by default. Since the mysql library is deprecated
and people should be using mysqli, it makes sense to emulate mysqli's
behavior here and not warn at all rather than trying to implement
mysql.trace_mode.
Closes#1140
Reviewed By: @markw65
Differential Revision: D1000998
Pulled By: @scannell
A `$var` containing a string, a closure, and (by
happenstance?) functor instance, worked when invoked directly by a
pair of parens afterwards. This diff extends that behavior to also
support the ##array($instance, 'method')## and ##array('Class',
'method')## callable syntaxes.
It would be nice if we had a facility for
explicitly creating function pointers in the runtime.
Reviewed By: @jdelong
Differential Revision: D984939
I ran test/quick and found a whole bunch of failures due to repeated
codegen failure, meaning there are some IR opcodes that have to appear
even when everything is interp-one'd. This implements a few of those.
This entailed implementing a few core bits of infrastructure, including
smashable jumps, which you can read all about in jump-smash.cpp. I came
to this approach because the jump offsets that ARM allows are too small
for our purposes. The fact that this skirts around the delicate parts of
concurrent modification and execution is a side benefit.
I'm putting off the implementation of GuardRefs for this diff because
it's very complex and I want to investigate factoring out shared logic.
But I stopped it from punting in codegen just so execution would get a
bit further.
Reviewed By: @ottoni
Differential Revision: D1002619
All values current as of PHP 5.5.4.
I also found two other constants on php.net (MYSQLI_CLIENT_MULTI_QUERIES
& MYSQLI_NEED_DATA), but outside of that mention I can't find them...
they're not in the 5.5.4 or master source, and I can't find any
supporting documentation for them (or that they've been
deprecated/removed).
Closes#1144
Reviewed By: @JoelMarcey
Differential Revision: D1003188
Pulled By: @scannell
xmlwriter_open_uri should return a Variant, not an Object (it
can return bool(false) which fixes some Zend tests.)
Reviewed By: @JoelMarcey
Differential Revision: D1003258
There were locals named clsName and className in this function, and
the call to setClosureClassName was using the wrong one. This could create two
classes with the same name: one in the file defining a trait with a closure and
any file with a class that uses the trait.
Reviewed By: @markw65
Differential Revision: D1002162
This test was reporting a memory leak with PGO because a retranslation
was triggered between consecutive calls to memory_get_usage(). So
bump the PGO threshold for this test to avoid the problem.
Reviewed By: @bertmaher
Differential Revision: D1001851
FrozenVector is a Vector with immutable entries. Specifically, it implements the ConstVector interface.
Abstract the functionality common to both Vector and FrozenVector in a BaseVector class.
TODO:
* enable literal syntax.
* make FrozenVector play nicely with var_dump
* make FrozenVector a collection.
Reviewed By: @paroski
Differential Revision: D986967
Predicted types for constants came from analyze, and
were thrown away before we got to the region translator.
Move the predictions to the same routine that does the rest
of them.
Reviewed By: @swtaarrs
Differential Revision: D1001083
We used to need this because when executing an Unwind
instruction we tried to find a PC to re-raise the fault at based on
the offset of the fault funclet. This didn't quite work (adjacent
fault regions weren't handled correctly), and was changed in D697005,
so I think we can drop this requirement now.
Reviewed By: @edwinsmith
Differential Revision: D1000915
Parts of the runtime other than codegen need to be able to read, write,
and smash jumps. I pulled this logic into its own module, jump-smash,
which hides platform-specific implementations behind a platform-agnostic
interface. This entailed a bunch of other Asm->CodeBlock changes too.
I can't be sure that I've found all the places where smashable jumps are
written -- we may have some places where it's just open-coded -- but we
can clean those up as we find them.
Reviewed By: @jdelong
Differential Revision: D997737
Gets rid of the dependency on google_base for atomic
increment. Works around the fact that AHM values must be copy
constructible (and std::atomics aren't) by creating a wrapper class
with non-atomic copy construction to hold counters.
Reviewed By: @jdelong
Differential Revision: D1000766
bindJmpccFirst is not idempotent. If two requests are running
through the service request at the same time, with opposite
conditions, we're extremely likely to generate incorrect code.
The rest are more-or-less idempotent, but since they have
reusable stubs they need to check whether its already run,
in order to avoid releasing the stub multiple times.
Finally, the bind* calls should avoid running more than
once because each time they call chainFrom, which adds another
IncomingBranch (harmless, but wasteful).
Reviewed By: @jdelong
Differential Revision: D997810
And, clean up the stackAdjust code by using PhysRegSaverStub.
The stub code ended with RET 8, but that wasn't actually
necessary and was requiring the JIT code to adjust for it.
Just end with RET, which keeps RSP evenly balanced.
Reviewed By: @jdelong
Differential Revision: D999380
Fix indentation of detail namespace and log strerror(errno)
if madvise fails. Add a constant for 16-byte alignment.
Reviewed By: @swtaarrs
Differential Revision: D997449
Just delete some unused stuff, simplify the Cache<> template
a lot. Delete some vestigial things in MethodCache (the Pair,
keyToPair function, etc). That's all I'm going to do here for now.
Reviewed By: @markw65
Differential Revision: D990840
Move the target caches back to JIT::, since they are now
mostly a JIT specific use case of RDS. Some target cache cleanup on
top in separate diff.
Reviewed By: @markw65
Differential Revision: D990837
Part two tries to sort out the different types of allocations
from RDS, and abstract the allocation pattern found in a few runtime
structures into an RDS::Link type, and simplify namedAlloc stuff (most
namespaces were dead, and it also did unnamed allocs). This also
allowed moving the unwind-specific parts of the header into a
dynamically-bound RDS::Link. (Which also reduced header dependencies
for this module.)
The comments in the header hopefully make the idea clear. A part 3 is
still coming, in which I plan to move the remaining actual "target
caches" back to JIT::, as just a use case of RDS. The rds.h itself is
still going to be a central place where different "symbol" types have
to be registered, but I think that is probably ok and still a bit more
modular than it was. (Ideally the symbols would have types associated
with them, but this would make rds.h depend on the JIT cyclically,
which is unfortunate, so I figure having helper functions for
different symbols that force the type is a reasonable enough thing.)
Reviewed By: @swtaarrs
Differential Revision: D990590
This diff adds declarations and implementations as needed to make
toValuesArray() and toKeysArray() part of Iterables and KeyedIterables
respectively.
Reviewed By: @elgenie
Differential Revision: D998700
For non-packed HphpArrays, CopyReserve() was blindly copying m_pos from the
source array to the new array. This is incorrect because tombstones are not
copied over to the new array. This diff adds appropriate logic to recompute
m_pos for the new array.
Reviewed By: @jdelong
Differential Revision: D998944
I want to use it outside of these guys for now. Also make
hphp-value.h #include'able without pulling all of complex-types.h
Reviewed By: @markw65
Differential Revision: D998305
These are populated from various worker threads during
compilation (in the FunctionScope::setParamSpecs code path they aren't
static strings), and it was hitting the checkPreFree assertions that
smart-freed memory came from the allocator it was being free'd to.
Reviewed By: @markw65
Differential Revision: D1000408
TraceBuilder is now only responsible for creating, optimizing, and
appending instructions, as well as high-level control flow
operations. updateTrackedState and all related methods and fields now live in
FrameState. This will let us use it in modules other than TraceBuilder where
the information it provides would be valuable.
Reviewed By: @edwinsmith
Differential Revision: D998255
Make hphpd compatible with both readline and libedit. Also fixes an issue with ctrl-c out of reverse history search. While searching, ctrl-c will now erase the current search result. Pressing enter will drop out of the search, but with the last match now presented on the hphpd command line. Ctrl-c again will erase the current command (as per usual) and leave a clean slate. Ideally, one ctrl-c during search would drop out of the search, but I've not found a way to get readline to do that for me. At least you can get out of history search without executing a command now, which is a big improvement.
Reviewed By: @scannell
Differential Revision: D993558
If a block isn't reachable, it will not be assigned a postorder
id in rpoSortBlocks(). The dominator algorithm incorrectly
used unreachable blocks postorder ids, which could lead to general
badness including crashes or miscompilations
Reviewed By: @jdelong
Differential Revision: D998809
FixedFuncCache was just one helper function which called
autoload. The translations used offsetofs on FixedFuncCache even
though they were using allocFixedFunction to get the Handle now. Move
the runtime helper out of the RDS namespace since it really didn't do
anything with RDS stuff (just calls loadFunc). Changed LdFuncCached*
implementations to use extra-data. Also I opted it back out of
native-calls, since it seems initially confusing to learn that it did
more than just a native call, and a cgCallHelper seemed clearer when
it does more than just a call: no need to go look up what it calls in
the other .cpp.
Reviewed By: @bertmaher
Differential Revision: D989157
Apparently there used to be an API to limit the renamable
functions to a particular set, but this no longer exists. Delete code
related to it.
Reviewed By: @bertmaher
Differential Revision: D989168
This is a quick start of cleaning up and documenting the RDS
(formerly target cache) module. This diff contains:
- a few renames to make things reasonable wrt the containing namespace
- make Class::wouldCall a non-member function
- various additional renames of "target cache" to "RDP"
- the start of some documentation about what it is
Reviewed By: @markw65
Differential Revision: D989135
If we want to keep the namespace, we should make the naming
such that using directives aren't needed. (Follow up diffs will make
the naming reasonable.)
Reviewed By: @edwinsmith
Differential Revision: D989131
All keyed collections (and KeyedIterables in general) have a keys() method,
but only Map and StableMap have a values() method. This diff adds values()
to all collections and the relevant traits and helper classes.
Reviewed By: @elgenie
Differential Revision: D990602
When we're building a repo in WholeProgram mode, create a
single unified Litstr table for all static strings that we encounter
in all units, and use this table when running in RepoAuthoritative
mode. This appears to save ~100MB of repo compared to the previous
method that stores strings for each unit separately in the UnitLitstr
table, since we had a lot of duplication.
Still use the UnitLitstr if we're not doing WholeProgram/RepoAuth,
because multiple processes attempting to use the same repo can try to
write the same string with different IDs, and that causes all sorts of
problems. We could maybe deal with that by getting the database
involved when try to get a litstr ID, but that seems more complicated
than it's worth.
Reviewed By: @markw65
Differential Revision: D985326
To do this I changed RefData::Make to take a TV. I like the
result, but feel free to disagree and I'll change it back.
Reviewed By: @jdelong
Differential Revision: D992097
This code was written before tvScratch existed, and this is exactly
what tvScratch is intended for.
Reviewed By: @markw65
Differential Revision: D995591
There is no code in php-src that relies on this, and the variable that holds it doesn't even have space for a 7th entry.
Reviewed By: @scannell
Differential Revision: D997179
The phpBB folks fixed their tests as a result of some of our findings. This precipitated a change in the git has we were using to download the source code. Also, this required us to check whether a git hash has changed and, if so, redownload the entire framework. Also added a capability to force a regeneration of an expected results for for a given framework. This could be useful after a redownload or other occasions.
Thanks @alexmalyshev for the heads up re: the phpBB source change.
Reviewed By: @ptarjan
Differential Revision: D996779
Once we start trying to run on ARM hardware, we'll need to start doing
some stuff differently. The idea here is to separate the questions "are
we emitting ARM code?" and "are we running the ARM simulator?".
Not all checks of the flag are gone; in particular, the stuff that reads
the simulator's stack pointer, and that sets it up in enterTC, should
actually be checking if we're simulating.
I'm open to suggestions on naming; I just wanted something terse.
Reviewed By: @jdelong
Differential Revision: D995817
This is starting to broach the thorny issue of what we do about all the
jump emitting and smashing machinery in the SrcDB family. I think I'll
end up factoring out all that logic into its own module which knows how
to emit and smash jumps on all platforms.
Reviewed By: @jdelong
Differential Revision: D995736
The region compiler was counting Type::None as an "uncounted"
type when deciding whether it should emit an inline sequence of
decrefs at the end of a function vs. calling a helper. In
cache_get_scb, this leads to a sequence of 52 DecRefLoc's in a row,
which just can't be good for icache.
Reviewed By: @edwinsmith
Differential Revision: D994936
A bit of a redesign and better user-experience.
This script runs one or more open source (oss) framework unit tests via PHPUnit. Run one or multiple tests by explicitly naming them at thecommand line, or specify --all to run all available tests. You will see various forms of output. The first time running a test suite for a framework, gray dots will appear to set the baseline for future runs. On subsequent runs, you will see green dots for tests that have the same status as the previous run. If something changes, you will see a red F if a test went from pass to something else. You will see a green F if a test went from something else to pass. You will see a blue F if a test stayed in the failing range, but went from something like E to I or F to S.
The summary for a test show the overall pass percentage of the unit test suite, irrespective of previous runs. The output and diff files for a test suite will show what tests pass or fail, and have why they failed.
Example output: P2777440
Future: Add number of total tests to be run at beginning in a clean way; fbmakify the runner
Reviewed By: @ptarjan
Differential Revision: D991614
Which gets rid of the last direct use of GrowableVector,
So move it inside GrowableVectorWrapper, and rename GrowableVectorWrapper
as GrowableVector.
Reviewed By: @edwinsmith
Differential Revision: D995169
Adds counters in the form of
http_response_200.rate.60
http_response_404.rate.60
http_response_500.rate.60
Reviewed By: bertrand
Differential Revision: D992473
File tests run in parallel should use independent paths to avoid creation/teardown interfering with each other
Reviewed By: @ptarjan
Differential Revision: D994417
Some of them used them and some didn't. Since NOV and NA
don't use them I went with no parens for anything taking zero args.
Reviewed By: bertrand
Differential Revision: D993735
It's for real this time. Sorry for the mega-diff, but this is all the
groundwork for simulated-ARM mode. This is the minimal amount of work I
had to do to get anything at all running.
I anticipate some requested changes on this diff, which I might
implement as updates, or as separate diffs that I then rebase this one
onto. But I would like to commit this diff once it's cleaned up.
Almost none of our tests pass in ARM mode yet, but I'd like to at least
get this out for review. I would like to commit without all the tests
passing -- I see that as a better alternative to going from zero to all
in a single diff, which would require an unmanageably large diff.
Next, I'll be working on getting all the tests to pass (by
implementing/fixing parts of the runtime infrastructure, not by
implementing real translation). Once they're all passing, we can set up
contbuilds, and then anyone who wants to can pitch in, implementing real
translation for more and more IR opcodes.
Reviewed By: @edwinsmith
Differential Revision: D979505
Function calls do not have left hand values, so such statements are not legal and absent the compile time error, the code generator generates bad code resulting in an assert.
Reviewed By: @markw65
Differential Revision: D991883
Now that mark found the issue with HPHPc not having ZendCompatMode classes removed this should be safe
Reviewed By: @markw65
Differential Revision: D989366
Now that mark found the issue with HPHPc not having `ZendCompatMode` classes removed this should be safe
Reviewed By: @markw65
Differential Revision: D989365
Implemented data stream wrapper, based on RFC 2397 and Zend
implementation.
While the patch can read the metadata of a stream, it does not save it
anywhere, and thus will not pass zend's stream meta data tests for RFC
2397.
Closes#1051Closes#1112
Reviewed By: @ptarjan
Differential Revision: D990460
Pulled By: @scannell
It was a good experiment in modularity, and I think we can do something
similar (but different) in HphpArray.
Reviewed By: @andralex
Differential Revision: D992945
Implement restore_include_path() and make the default include
path consistent with Zend
Closes#1105
Reviewed By: @ptarjan
Differential Revision: D989566
Pulled By: @scannell
Materialization methods were recently added to collections. This adds them
to the LazyIterableView and LazyKeyedIterableView as well so that these
methods will work when called on an object returned by lazy().
Reviewed By: @jdelong
Differential Revision: D990588
Adding VariantTraits and changing CacheClientSerializer to be parametrized by Variant.
Opensource commit message:
Moving VariantController into a separate file.
Reviewed By: zhuohuang
Differential Revision: D990915
When the VM crashes the crash reporter tries to generate a back trace for the error report. If the stack trace contains a call to a function with an argument that is an object that cannot be converted to a string, the routine for generating the stack trace will fail, which is not optimal. This difference adds a try-catch to that recovers from fatal errors that occur during back trace generation.
Adding this try-catch modifies the behavior of public PHP function debug_print_backtrace in an observable manner. Arguably it is a desirable improvement, but is a potentially breaking change.
Reviewed By: @markw65
Differential Revision: D992293
When an Xbox thread gets destroyed, the destructor for s_directory_data destroyes the Resource in defaultDirectory, which decreases the refcount to the Directory object, which is a sweepable and is reclaimed somewhere else. This leads to double trouble and caused flib/utils/thread/__tests__/ConcurrentThreadsTestCase.php to fail. (Sadly the test case got disabled, so contbuild did not pick this up.) To prevent the double deallocation, I've added a handler for request completion that detaches the Directory value from defaultDirectory. This seems to solve the problem.
Reviewed By: @markw65
Differential Revision: D991808
This is the first step of a larger campaign of eliminating goofy types from our codebase. Typedef-ing a reference is unrecommended because references are not first class types and therefore things like construction and copying may do unexpected things. In fact search this diff for 'reinterpret_cast' to see some very odd stuff.
Destroy!
Reviewed By: @jdelong
Differential Revision: D983915
Multiple threads can enter retranslate for a tracelet
simultaneously. This is not normally an issue, because only one
will get the write lease. But if we force blocking on the write
lease, they will all wait, and then generate potentially identical
translations (possibly pushing us over the 12 translation limit).
This adds an atomic flag to the SrcDB so that only one of the
threads will make a translation, and the others will re-enter
the head of the tracelet chain (and either find the new translation
or again hit the retranslate service request).
Reviewed By: @jdelong
Differential Revision: D991611
We had code for natural sorting, but we never set up the SORT_NATURAL
or SORT_FLAG_CASE PHP constants.
Closes#1090
Reviewed By: @ptarjan
Differential Revision: D986738
Add a GrowableVectorWrapper to make GrowableVector more
compatible with vector, and use it in SrcRec.
Use a CompactSizedPtr to hold the tca and tag for IncomingBranch.
Reviewed By: @edwinsmith
Differential Revision: D991310
This is pure code movement. After this the only runtime
functions left in code-gen are the ccmp_* family, which I haven't
figured out how I want to deal with yet.
Some of these can probably be cleaned up/killed (you'll notice a few
TODOs that have probably been around for a long time) but I want to
separate that from the code motion for easier review.
Reviewed By: @edwinsmith
Differential Revision: D991360
This was a spurious coupling; the only reason the assembler object was
used was to emit stats-counter increments. I agnostified the interface
to that as well, which turned out to be pretty easy. I'll put a branch
inside emitInc for ARM support.
I discovered that the cc parameter (which was another x64 coupling) was
unused, so I deleted it.
Reviewed By: @edwinsmith
Differential Revision: D991443
clearstatcache() does nothing, but the function signature is not
the same as Zend so unnecessary warnings are raised.
Closes#1115Closes#1117
Reviewed By: @JoelMarcey
Differential Revision: D991348
Pulled By: @scannell
mkdir should return false if the path already exists to match
Zend
Closes#1113Closes#1114
Reviewed By: @JoelMarcey
Differential Revision: D990897
Pulled By: @scannell
SPL autoload functions need to capture the context in which they are registered and be called in that context. This comes up when a class method is registered as an autoload handler that is private and/or calls private methods -- the accessibility checks fail without using the proper context. Thus, save off a CufIter and use that to invoke the function instead of just a function object. This fixes a Zend test as well.
Closes#1020
Reviewed By: @markw65
Differential Revision: D976387
big and nbody both have a substantial amount of time spent in
the JIT. Increase the iteration count to focus on generated code
perf.
Reviewed By: @ottoni
Differential Revision: D990726
matching zend. I killed all the uses of it in www and right before this pushes, I'll kill whatever is left on the wednesday.
Reviewed By: @paroski
Differential Revision: D804982
I thought running all the bad tests would be useful, but it turns out I've never done that. Lets just require you to have a zend checkout
Reviewed By: @scannell
Differential Revision: D988254
We weren't propagating type information from a CheckLoc in
the region translator, because we weren't updating m_locals to have a
new SSATmp with the proper type.
Reviewed By: @ottoni
Differential Revision: D989639
I think we can start sharing little things like this across platforms.
This makes it so that ARM code can call the same function as the x64
code, and we don't need to duplicate anything.
I also cleaned up emitNAryStub while I was at it, since it's only used
with Arity = 1. And the "unreachable" argument was never used.
Reviewed By: @jdelong
Differential Revision: D990058
When the compiler inserts an implicit function return statement, there is no source context for the return and the source context defaults to the context of the entire function. This causes execution to stop at implicit returns and the debugger to display a bizarre source context. It also causes every single line in a file to be considered a valid breakpoint location, even blank lines and lines with comments. The code for inserting implicit returns now overrides the source context with a dummy and the code for creating the source line map now ignores dummies.
Reviewed By: @mikemag
Differential Revision: D987159
These exception tests use stack overflow, but they were brittle. 5 and 6 were checking the line the overflow occurs on, and I think that was unnecessary. The point of those two is that something doesn't happen on overflow, not the line the overflow occurs on. 3 and 4 want to see that objects left on the stack are destructed. For those I switched to using some counts, and check them in a shutdown function.
With this change all tests in test/quick pass with ASAN on.
Reviewed By: @scannell
Differential Revision: D987024
The native collection classes aren't made to support derived classes, and it
would take some work to add such support. This diff adds a check to prevent
classes marked with <<__MockClass>> from deriving from a collection class.
Reviewed By: drussi
Differential Revision: D980050
We didn't need CodegenState::catchTrace because we could look
it up using m_curInst. isCatch() was easy to implement on
Block instead of trace, which enabled cleaning up IRTrace a bit
more. IRTrace::bcOff was only ever referenced for the main
trace, so I moved that field to IRUnit.
Reviewed By: @jdelong
Differential Revision: D988099
Use IRUnit as much as possible, starting at the Translator-x64
level, and plumbing it down through the call tree into individual
stages.
Reviewed By: @jdelong
Differential Revision: D987491
Since normally the inner types of boxed values are checked lazily, the
profile counters were being inserted before the inner types were
checked. This was causing translations with guards on boxed values to
be overcounted -- their profile count was being incremented even when
the inner-type mismatched.
This diff fixes the problem by adding an option to
guardType{Local,Stack} to request the inner types to be checked too.
This option is used to eagerly check the inner types in TransProfile
mode.
Reviewed By: @swtaarrs
Differential Revision: D985443
Makes a number of changes:
- Binds each server thread to a numa node, and
sets its default allocation mode to that node
- Allocates a jemalloc arena for each node,
and selects the right one at thread startup (
to ensure that we don't get memory that was
previously allocated on a different node)
- Changes thread scheduling to alternate between
nodes
- Sets the default allocation strategy for the
main thread (and non-server threads) to
interleaved.
Reviewed By: @jdelong
Differential Revision: D974085
Parser::onNamespaceStart already ignores T_DECLARE, but it also
appears to need to ignore ';'. By default, we do not add a
T_CLOSE_TAG for '?>' but we do append on a ';', and this was
throwing off the parser.
Fixes the last fatal in the composer unittest suite.
Reviewed By: @ptarjan
Differential Revision: D984844
Zend PHP ignores whatever the 'pipes' reference is pointing to
in proc_open, and just fills it with an array of resources, but
only if they are not null.
Also rename the ChildProcess's classname to lowercase 'process'
to match Zend's output.
This fixes a fatal in Symfony unit tests.
Reviewed By: @ptarjan
Differential Revision: D984996
This recently started failing on my devserver but not on contbuild. I
traced it down to a dependence on the iteration order of
ExecutionContext::m_liveBCObjs. Wrapping it in a function make the objects'
destruction order deterministic.
Reviewed By: @ptarjan
Differential Revision: D987785
The binary ringbuffer tracing had bitrotted a little with the
transition to the IR. I also reorganized RingBufferEntry a little to hold more
information and cleaned up the printing code to print more information about
SrcKeys.
Reviewed By: @jdelong
Differential Revision: D985433
One of the optimization passes in hphp can remove unreachable
(Yield|Await)Expressions. This leaves the FunctionScope's yield label count in
an inconsistent state, so relabel/count the yields on each pass.
Reviewed By: @markw65
Differential Revision: D982747
Changed '#include "..."' to '#include <...>' where possible.
Where not possible, and where the included file was not obviously local,
marked the include as being Open Source Software.
Reviewed By: @jdelong
Differential Revision: D986815
This is the first step in making IRFactory be the compilation
unit container for the IR. IRTrace is not a tree node; the
main trace has exits, but exit traces don't. Lots of code uses
the main trace as a container for the IR entry point block.
Reviewed By: @jdelong
Differential Revision: D985668
This diff implements support for profiling and regenerating prologues
in PGO mode. The new kind of profiling prologue ("Proflogue")
translations are generated in the aProf code region and include a
profile counter, but they don't trigger a retranslation. Instead, the
prologues are retranslated when the function body entry triggers
retranslation. At that point, all prologues that had been generated
for that function are regenerated, immediately before the new,
optimized function body is generated. The prologues are generated in
ascending order of profile count, so that the hottest prologues are
placed closer to the function entry. Also, for prologues with
associated DV funclets, the corresponding DV funclets are generated
right after the prologue.
Reviewed By: @swtaarrs
Differential Revision: D977255
I went through the latest "failed at step" emails and updated those tests to stop sharing filenames and ports.
Reviewed By: @markw65
Differential Revision: D985394
Moved nontrivial methods out of class definitions, and reduced what cse.h
includes to be closer to IWYU, and avoid circular dependencies in another
diff I'm working on, on top of this one. Also moved definitions of a few
functions declared in cfg.h from ir.cpp to a new cfg.cpp file.
Reviewed By: @jdelong
Differential Revision: D983927
Can you think of anything better to print than the ID? I can't figure out how to call the `o_toString` methods, and do we want to?
Reviewed By: @markw65
Differential Revision: D985495
hhir used to do a slow exit whenever a surprise flag check
succeeded. This is fine for most things, but can be all sorts of bad news for
PHProf. This diff adds support for calling the surprise flag hooks without
leaving the trace, and should restore some sanity to profiling results.
Reviewed By: @markw65
Differential Revision: D985446
{Packed,}ArrayInit is now the only way to create arrays while
assuming no write barriers are needed. To ensure it's safe, beef up
the assertions in their use. Fixed a few cases that had incorrect
size estimates.
Reviewed By: @markw65
Differential Revision: D980262
This was going to make Class 408 bytes, and it seemed
plausible that that could be causing some red cpu time numbers in a
early perflab, so as part of this diff change declInterfaces not to be
a std::vector to pay for it.
Reviewed By: @edwinsmith
Differential Revision: D979850
I had been thinking of changing these to get the information
out of the class without allocating an array (e.g. using special
bytecodes), but it turned out to be easier to do this without changing
that than I thought.
Reviewed By: @edwinsmith
Differential Revision: D979874
In defCns this adds one place where we'll do two lookups
instead of one; the whole thing appears to be on a cold path though.
Reviewed By: bertrand
Differential Revision: D978026
Instructions ultimately want a block to jump to, not a trace,
and the trace setter is in the way of untangling some header
dependencies I have in a separate diff. This was a big enough
change to factor out separately.
It's essentially a mechanical change, although I changed the
helper functions that create traces to return the first block
instead, for convenience.
Reviewed By: @swtaarrs
Differential Revision: D984304
Special constants conflict with unimplemented PHP ENT_*
constants in the htmlspecialchars function so raise their values to
avoid confusing frameworks into thinking these are implemented.
Closes#1085
Reviewed By: @markw65
Differential Revision: D980178
Pulled By: @scannell
TraceProfiler maintains a log of every function call and return. By adding the function name to return events we can ensure that a return matches a call when post-processing the log. Too keep the log size small I've stolen a bit out of the memory counter for the trace samples since it's not realistic that we'd need a full 64 bits there.
I've added a little bit of logic to detect a missing return and correct the stack imbalance to keep the rest of the report accurate.
Reviewed By: @swtaarrs
Differential Revision: D983012
fputcsv.php uses a temporary file named fgetcsv.csv,
just like fgetcsv.php does. They collide. Disable fputcsv
pending a fix.
Reviewed By: @jdelong
Differential Revision: D983981
The timeout was set at the start of each rpc request, but
not cleared at the end, so a timeout could occur between requests,
resulting in the timeout exception being thrown as soon as we
started to execute php code.
Clear the timeout, and the timed-out flag, at the end of each request.
We call http_session_exit at the end of normal http requests,
which already did that, so this issue is specific to rpc requests.
Reviewed By: bertrand
Differential Revision: D983623
I tried to make life nicer for us by having just a flat level of directories, but it turns out lots of zend tests depend on their directory structure. I think we should give up and just exactly mirror them.
Closes#1081
Reviewed By: @markw65
Differential Revision: D981964
Also, I think it's hard to imagine the assert that iterates
the slabs hitting when the magic one doesn't, so I removed that in the
name of debug perf.
Reviewed By: @markw65
Differential Revision: D976926
There were a couple of bugs that this diff fixes:
1) Relative SP offsets were being used although the SP was being
adjusted. This was fixed by keeping the post-conditions for stack
values relative to FP, and by keeping the SP offset relative to FP in
each Block. While doing this, I also realized that the region
translator was always using the live SP offset, so I fixed it to use
the SP offset for it's first block.
2) Values with types Gen and None were being dropped from the
post-conditions, with the effect that older values would be kept in
the accumulated post-conditions during hottrace region selection. I
changed getStackValue so that it only returns None for values that
were neither guarded nor written in the IR trace, and only these are
omitted by getKnownTypes.
3) The accumulated post-conditions was keeping stack values after they
had been popped.
Reviewed By: @swtaarrs
Differential Revision: D972665
This used to work around a bad O(N^2) blowup in TraceBuilder, but
the blowup was fixed by D830913. Removing the workaround.
Reviewed By: @jdelong
Differential Revision: D980277
The OSS PHP Framework test script now supports more tests. Added a custom test command field to tests that don't use the vanilla "phpunit" command to run the tests. Also the code now downloads Composer and PHPUnit instead of relying on them being available in our repo.
Future updates:
- Support the rest of the tests in the tests map
- Support our test/run framework
Reviewed By: @sgolemon
Differential Revision: D981565
This diff adds support for types like {Obj<C>|InitNull}, including all
the operators we have defined on Type. It's necessary in an upcoming region
translator diff. It's not currently used for anything but I thought it was
worth pulling out into a separate diff because of the complexity.
Reviewed By: @jdelong
Differential Revision: D973156
Fix issue and add test re: child attributes not matching upon
return from addChild and enumerating directly. This breaks two other
tests, but these are of lower priority.
Reviewed By: @ptarjan
Differential Revision: D982083
This diff removes the last direct uses of SQL queries for mapping source line information to byte code offsets.
Reviewed By: @mikemag
Differential Revision: D980213
We currently emit a "File not found" warning on empty files that
are include'd, whereas Zend PHP is silent.
Reviewed By: @markw65
Differential Revision: D977274
Set::toArray returns `array(val1 => val1, val2 => val2, ...)`. This
maintains set-like semantics in array() land: O(1) membership test
with `array_key_exists($key, $a)` or `$a[$key]` and iteration with `foreach($a as
$member)`. Int-like strings end up with numerical array keys.
For nice symmetry, the results of `$s->toArray()` are the same as those of
`array_combine(array_keys($s),array_values($s))`
Reviewed By: @paroski
Differential Revision: D970064
with classes, this needs to be passed down as a variable since many extensions just hard-code `this_ptr`.
Reviewed By: @paroski
Differential Revision: D976055
"Syntax error: unexpected T_PAAMAYIM_NEKUDOTAYIM" is a WTF
rite-of-passage for every PHP noob. Unlike Zend, we don't have
history to be beholden to, so HH syntax errors ought to be able to
complain about T_DOUBLE_COLON. For compatibility with any parsers
built on Zend, continue returning T_PAAMAYIM_NEKUDOTAYIM in
'token_name' results
Reviewed By: @jdelong
Differential Revision: D980141
Added in PHP5.5, this builtin is going to be useful as a
default argument for functions that expect a predicate callable.
It's better to implement it than force the user to create yet another
instance of `function ($var) { return (bool) $var; }`
Reviewed By: @markw65
Differential Revision: D980164
hphp/runtime/vm/native.cpp generates a combinatorial number of template instantiations (proportional to 4 to the power of maximum arguments allowed), which makes it extremely slow to compile - over 350 seconds on my machine. This change forces all types to a binary-compatible uint64_t, thus keeping the calls well formed binarily (wee, new word) whilst drastically reducing the number of instantiations involved.
Reviewed By: @jdelong
Differential Revision: D979860
On requestInit, if Arrays are null inited and reset during
shutdown, they shouldn't need to be reset again (it will just end up
doing redundant work) so just assert the expectation is the case.
Reviewed By: @markw65
Differential Revision: D978681
This fixes a traits bug involving instance props that use collection literal
initializers. Instances of a class are not supposed to share the collection;
they are supposed to each get their own copy.
Reviewed By: @andralex
Differential Revision: D979933
Map and StableMap already have these APIs, let's add them to Vector, Set,
and Pair for consistency.
Reviewed By: @elgenie
Differential Revision: D979552
The view() method has been phased out in favor of lazy() (which does the
same thing but is more obvious to developers). Let's remove it.
Also, the Vector::sort() method has been deprecated for a while and was
abandoned in favor of making the regular sort builtin functions work with
collections, let's get rid of that too while we're at it.
Reviewed By: drussi
Differential Revision: D979375
I finally figured out what the problem was when I tried to do this
before: comparing Asms for identity by taking addresses doesn't fly
anymore. You have to compare their bases. I grepped for "&m_as" and
"&as" and fixed everything I found.
Now, CodeGenerator takes CodeBlocks in its ctor. It still has Asm
members, but I think that's OK -- CodeGenerator is a pretty short-lived
object already, so the Asms inside it are transitively short-lived.
Reviewed By: @jdelong
Differential Revision: D978477
The SNI code was married to LibEventServer, which made it incompatible with ProxygenServer. Moved all the libevent specific code into LibEventServer, which actually simplified the Server::enableSSL interface I think.
Reviewed By: @paroski
Differential Revision: D966945
We don't need both. The 3-arg one is also nicer in a lot of
code-gen situations because it checks for InvalidReg.
Reviewed By: @edwinsmith
Differential Revision: D976482
We potentially create the AutoloadHandler during repro
creation, from various work threads. (Things are set up enough to
call builtins.) Then we shutdown the execution context and then run
OnThreadExit handlers. ~AutoloadHandler can access the memory manager
after it is destructed, triggering the post delete assertions.
Reviewed By: @markw65
Differential Revision: D979498
Hitting the SQL database with at least two queries every time the debugger needs to map from source line number to byte code offset, or vice versa, makes no sense. This diff adds a table to Unit that can be used instead of the database. Note that when running in repo authoritative mode, the table will be empty because a) it is created lazily when a unit is loaded form the repo and b) in this mode, the repo does not contain the source line information needed for this table. This does not matter too much because we don't support debugging when running in repo authoritative mode.
Note, this diff does not remove all uses of the SQL database. That will be done in a follow up diff.
Reviewed By: @mikemag
Differential Revision: D978834
In a more complex scenarios where sweep() may unregister() other
Sweepables, linked list was not maintained correctly.
Imagine this example:
HEAD <-> A <-> B <-> C <-> HEAD
If sweep(A) calls unregister(B) and unregister(A), the following
happens:
// Sweepable::SweepAll delists A:
HEAD <-> B <-> C <-> HEAD
HEAD <- A -> B
// and calls sweep(A), which calls unregister(B):
HEAD <-> C <-> HEAD
B <-> B
HEAD <- A -> B
// then unregister(A) that uses invalid pointers from A, creating this mess:
HEAD <-> B -> B
HEAD <- C <-> HEAD
A <-> A
// Sweepable::SweepAll then tries to incorrectly sweep(B), which
// crashes stuff
After this diff, Sweepable::SweepAll delists stuff correctly:
// Sweepable::SweepAll delists A:
HEAD <-> B <-> C <-> HEAD
A <-> A
// and calls sweep(A), which calls unregister(B):
HEAD <-> C <-> HEAD
B <-> B
A <-> A
// then unregister(A) does nothing:
HEAD <-> C <-> HEAD
B <-> B
A <-> A
// so Sweepable::SweepAll can correctly continue with sweep(C)
Reviewed By: bertrand
Differential Revision: D979013
@markw65 confirmed we shouldn't expect the warning in repo mode. Either I disable the test in repo mode or make the warning optional. I went with optional.
Reviewed By: @elgenie
Differential Revision: D978593
This allows us to treat XboxTasks as external threads in the ASIO
framework.
We template the ServerTaskEvent class so that it may be used in the
future with other similar server interfaces, e.g. PageletServer. We
expose XboxTransport for use in ServerTaskEvent.
Storing a Transport * in ServerTaskEvent instead of a Resource
Template; expose the Transport type from the Server
Also parametrize the Transport class
Expose XboxTransport
Reviewed By: @jano
Differential Revision: D975697
These methods provide a convenient way to materialize a lazy iterable into
a concrete collection, or to convert from one collection type to another.
Doing "$x->toX()" is equivalent to "new X($x)" (where $x is an Iterable
and 'X' is a collection type), but it's nice to have for the chaining use
case, ex:
$v = $m->lazy()
->map(..)
->filter(..)
->toVector();
Reviewed By: @elgenie
Differential Revision: D978191
We were blindly returning a DOMText object for
DOMDocument::getElementById when it should return a DOMElement.
Reviewed By: @ptarjan
Differential Revision: D967622
This has been wrong for two years (and I got it wrong originally :/ ).
It also turns out that it returns false instead of fataling if the class
isn't found.
Because PHP, get_class_methods doesn't work this way, in case you were
wondering. It returns NULL on error.
Reviewed By: @ptarjan
Differential Revision: D976416
I noticed a couple of issues:
- the stacksize returned by pthread_attr_getstack includes the
guard size, so we should adjust both the start and the size
- if you call pthread_attr_setstack, its your responsibility to
mprotect the guard region
Reviewed By: @jdelong
Differential Revision: D976923
for great consistency. Depends on D964614.
failure due to www test impacted by dependent commit (since fixed)
Reviewed By: @jdelong
Differential Revision: D976094
to simplify the migration story from array(), it makes sense
to be able to write idiomatic code like:
$x = $foo->getCollection();
if ($x) { // ... collection not empty }
As opposed to the current:
$x = $foo->getCollection();
if (0 !== count($x)) { // ... collection not empty }
The methodology here is very similar to what collection::ToArray does
(including helpers around static_cast and const access).
Failure due to broken logic www test that
I've disabled and the zend test disabled by jdelong in {D978088}
Reviewed By: @paroski
Differential Revision: D964614
I moved the top-level "emitServiceReq" functions (which don't output any
code themselves) into service-requests.h so they can be shared by the
ARM backend. They will conditionally call either X64::emitServiceReqWork
or (the to-be-written) ARM::emitServiceReqWork.
Reviewed By: @jdelong
Differential Revision: D977213
We're trying to make sure that destruction/sweeping of extensions is implemented properly. During sweeping there should be no reference decrementing and no smart memory freeing.
Reviewed By: @jdelong
Differential Revision: D932364
Right now, we wait until the first request that needs the
hash, and it stores it back to the shared StringData. This removes a
branch from hashHelper, but it doesn't seem to matter.
Reviewed By: @edwinsmith
Differential Revision: D970437
Adds support for text node attributes in SimpleXML. This is
needed by Symfony 2 unit tests.
Closes#1077
Reviewed By: @sgolemon
Differential Revision: D976401
Pulled By: @scannell
FCallBuiltin will still not reach this point
since IDL functions with double args/returns won't be
flagged for native calling. Native function calls
can still use this path via FCall with an ActRec, however.
Reviewed By: @jdelong
Differential Revision: D976614
I noticed this opportunity when reviewing D966781; even though
we have packed_tv turned off for now, there's no good reason we
can't make the DataType enum always be 8 bits.
Reviewed By: @markw65
Differential Revision: D976339
Use Packed and Array vs Vector and Map, to un-overload those
terms some more. Also rename fields, flags, and delete a
few clear methods.
Reviewed By: @jdelong
Differential Revision: D975067
A better version of the original script I sent out yesterday. Includes all our relevant frameworks in the framework map. Some are commentedout still since they need to be special-cased or has some other special requirement. A bit more robust as we are not hardcoding many paths to files like "composer.json". Refactored the code a bit. Also added a zend binary since hhvm balks at some of the dependency installs (e.g., symfony). Zend is there as a sort of failsafe mechanism.
Reviewed By: @ptarjan
Differential Revision: D975570
Every insert method for "Mixed" (set, setRef, etc) uses the
same code; factor it out. This approach to factoring avoids needing
to pass around strhash_t, which enables using a template;
string and int-specific key handling code is all inside the
overloaded insert() methods.
Reviewed By: @andralex
Differential Revision: D972465
so this test is actually busted in repo interp. We don't emit
-HipHop Notice: Undefined index: 1 in %s/test/slow/array_cse/537.php on line 53
I'll fix it but reverting it for now
Reviewed By: @elgenie
Differential Revision: D976067
ReadOnlyArena::allocate was using the alignment rounded-up
length instead of the original length when std::copying into the arena
Reviewed By: @meyering
Differential Revision: D974955
Adds a small script for surrounding the contents of a test/*.php file
with a main() function and a require_once, and a mode to the test
runner script to do so.
The script is not foolproof at the moment ... it doesn't deal well
with the $GLOBAL access, backtraces, etc. Future work will be
necessary to deal with (heuristic) recognition of such cases.
Reviewed By: @ptarjan
Differential Revision: D974395
While I was in there I cleaned up `SmartPtrPrinter` because I wanted to subclass it, but this turned out to be easier than I thought. Want those changes in here too or just `RefDataPrinter`?
Reviewed By: @markw65
Differential Revision: D975469
ASAN detected a read overflow here and I can't convince myself
this code is 100% safe. Since we're comparing StringData anyway, the
size is readily available without (re)calculating it so we mightaswell
use it.
Reviewed By: drussi
Differential Revision: D974599
The hotprofiler extension had its own code for asking jemalloc how much memory has been allocated and freed, which called into jemalloc every time. Switched to using the pointers to the actual data that MemoryManager also uses, exposing them from MemoryManager.
Reviewed By: @swtaarrs
Differential Revision: D973767
add a `<?php`. If I had to guess, the original test didn't have it by accident (back when tests were strings in C++).
Reviewed By: @elgenie
Differential Revision: D975031
* check the __construct "functionality" that ReflectionClass::getMethods relies on explicitly
* don't implicitly (string) convert a passed-in $instance if the method doesn't exist
Needed for {D964614}
Reviewed By: @paroski
Differential Revision: D973579
I keep doing these steps by hand so I made a script. This will evolve but it should be ok for now. Once newext.php exists for HNI (or there is a converter I run after) I'll change to that. If if this starts sucking I'll have to gen the signatures from the source code...
Reviewed By: @paroski
Differential Revision: D966326
This was a monster. I had to get all the class things working. I'm not perfectly happy with the solution (I haven't worked out if storing a handle in the ZendObjectData is correct or if the ZendObjectData should BE the handle) but as I see more class based extensions they should clarify.
Reviewed By: @paroski
Differential Revision: D957054
Set m_root properly when using __construct() or Clone()
Closes#1067Closes#1069Closes#1074
Reviewed By: @ptarjan
Differential Revision: D974502
Pulled By: @scannell
Use PackedArrayInit. Also, this function is only called when
there is no invName, but it was doing the magic call case in this case
(we null it first), so rename it and don't branch on that and move it
to the single caller. Also, it was using appendWithRef instead of
append, presumably because it used to be possible for it to be used
for non-magic calls or something. From what I can tell, __call can
never get the argument array with reference members (if it can, the
translator is the one doing it wrong).
Reviewed By: @markw65
Differential Revision: D972302
Also, adds task TODO's with all the remaining untracked array
uses that I could find (if there's more, they aren't findable via
grep, but I have a plan to catch them with assertions later).
Reviewed By: @edwinsmith
Differential Revision: D972299
Also, add comments on the other ones I've found for ->set().
The biggest thing here is sorting out static property initializers
(probably the answer there is to make them not even use arrays).
Reviewed By: @edwinsmith
Differential Revision: D972067
Summary: RepoAuthoritative test runs take longer than normal so split
them into two in order to avoid triggering the Travis timeouts
Reviewed By: @ptarjan
PHP 5.5 now supports arbitrary expressions inside the empty() construct. We want to match Zend's behaviour.
For the newly supported cases, empty(E) is equivalent to !(E).
Reviewed By: @paroski
Differential Revision: D966136
Add runtime support for implementing interfaces from traits.
e.g. if a class C uses a trait T that implements an interface I, then C is a subtype of I.
Reviewed By: @paroski
Differential Revision: D969512
xbuf_format_converter uses appendstring which currently
assumes its input is a null-terminated string and copies the NULL. The
result ends up being correct even though what xbuf_format_converter
passes to it isn't null-terminated because each extra byte is
overwritten by subsequent calls and the last byte is manually set to
NULL at the end of the function, but it's still trying to potentially
read garbage.
This caused three different extension tests to fail because of their use
of vspprintf which ultimately calls xbuf_format_converter.
Reviewed By: @edwinsmith
Differential Revision: D973694
I'm debuggin a thing that throws `Exception` subclasses and I saw this method is always protected by checking a bit on the `Class*`.
Reviewed By: @jdelong
Differential Revision: D973603
This is an initial verison of a script that will allow us to unit test all
of the OSS PHP frameworks that we care about for parity. A more detailed
summary is available at the top of the code, but here are some highlights:
- Autodownload of frameworks; not added to our official repo
- Mulit-process test runs
- Full phpunit stats in a file after each run
- Summary file for all tests run showing pass percentage. Appended with latest
result for multiple test runs of a given framework. Initial inspiration for
this file was for our MPK TV parity chart population.
Future:
- Integration with our "test/run" infrastructure
- Special case frameworks that don't use PHPUnit
- Enhance the script to allow "diff" stats that specify what changed from the
previous run of a test of a framework to the current test (beyond pass
percentage). For example, what tests caused the pass percentage to increase
or decrease.
New Files for this diff:
- oss_framework_test_script: The script
- phpunit.phar: Used to actually run the phpunit tests for each framework
- composer.phar: Used for installing framework dependencies for phpunit
- sample_multiple_test_config.cfg: A sample configuration file to run multiple, but
not necessarily all testsi
NOTE: I am only including 3 of the OSS frameworks as part of the code for this diff.
When this diff is accepted, I will send out another diff with the rest added. Having
just 3 makes for easier initial testing.
Another note: I removed the comment that command_line_lib does not support options with
arguments. It does. I am using that functionality in this script.
THANKS TO @ptarjan for process ideas from both running the tests and getting through
the proxy!
Reviewed By: @ptarjan
Differential Revision: D971897
This diff reworks the PHP extension compat layer to be more robust by
taking steps to reconcile the difference between mainstream PHP's way and
HHVM's way of representing program values and operating on program values.
This includes the shape of the object graph in the heap (what points to
what), how refcounting is done and how "reffiness" is handled, how copy-
on-write semantics are honored, and how values are stored into arrays.
One of the core ideas here is that HHVM supports "boxing" a program value
via the RefData type and that there's a reasonably clean mapping between
PHP's object graph and HHVM's object graph (when HHVM program values are
"boxed") that maps PHP "zval" objects onto HHVM RefData objects. For the
purposes of a compat layer for PHP extensions, it makes sense to use
RefData to represent "zvals". Of course, it is unreasonable to box every
program variable in HHVM since this would hurt performance. However, we
can make things work by boxing program values lazily as needed in the
right places to ensure that Zend PHP extensions only deal with boxed
values. Along the way I also fixed a bug where we were leaking all of
the arguments that were passed to Zend PHP extension functions.
The next issue involves "reffiness". At present, HHVM RefDatas are treated
as "reffy" when their refcount is 2 or greater, while Zend PHP zvals have a
separate flag (independent of the refcount) that indicates whether they
should be treated as "reffy". Zend PHP extensions are capable of setting
two or more program variable to point to the same zval where the zval's
"reffy" flag is set to false. In such cases, the program variables share
the zval using copy-on-write semantics, where the zval must be copied
before making a modification. To make this work, we need to change RefData
somehow so that we can keep track of whether copy-on-write is needed when
the refcount is 2 or greater. Adding "reffy" flag directly poses some
challenges in terms of performance, because it means that when a value's
refcount decreases from 2 to 1 we'll need to make sure the "reffy" flag
gets cleared. I was able to avoid this by adding two flags (m_cow and m_z)
and creating a scheme that maps the 3-tuple (m_count, m_cow, m_z) to the
2-tuple (realRefcount, reffy). Under this scheme decRef continues to work
as it does today, decrementing the m_count field and calling a helper
m_count reaches zero. Another neat thing about this scheme is that m_cow is
set to 1 iff copy-on-write would be required before modifying m_tv. (NOTE:
This diff does not implement copy-on-write yet for these cases, it will be
addressed in a later diff.)
Another issue is the relationship between strings/arrays and the
zvals/RefDatas that point to them. Under Zend PHP, it is assumed that a
zval exclusively owns the string or array and that nothing else points to
the string/array. A consequence of this is that Zend PHP extensions do not
perform any copy-on-write checks with the string or array's refcount before
modifying the string/array. HHVM on the other hand supports sharing strings
and arrays between multiple RefDatas and/or program variables. Thus, we
need some way to protect against Zend PHP extensions modifying a string or
array when its refcount is 2 or greater. This is achieved by putting checks
in the right places to lazily make a copy of the string or array (when
refcount >= 2) so that Zend PHP extensions only deal with strings and
arrays with a refcount of 1.
Finally, the Zend PHP APIs for adding values to an array are a little
different. Zend PHP extensions pass a zval to the API, and the appropriate
array slot is set to point at the zval. The API does not increment the
zval's refcount; it is the caller's responsibility to do this is needed.
New APIs were added to HphpArray to address this need.
With this in place, the next things to go after would be (1) Fixing up how
the Zend compat layer deals emulating Zend PHP string macros and
operations, this may require adding a new KindOfZStr type if StringData
can't be adapted without hurting HHVM performance; (2) Adding checks in the
right places to make a copy of a RefData if m_cow is 1, I've found most the
places where this is needed and it doesn't look like these checks will
noticably hurt performance; (3) improving support for resource types and
object types defined by Zend PHP extensions and interoperability with HHVM
extension classes, HHVM resources, and user-defined pure-PHP classes.
Reviewed By: @ptarjan
Differential Revision: D966781
If we previously read something into a buffer, but userland didn't consume it yet, we need to pretend that `stream_select()` has data. I took inspiration (and the comment) from php.
Reviewed By: @markw65
Differential Revision: D972453
Added parameter StreamContext* m_context in the File class. Implemented
function f_stream_context_*() functions mostly by delegating to
appropriate methods added in StreamContext class.
Reviewed By: @ptarjan
Differential Revision: D967885
This lets vixl::Assembler and HPHP::X64Assembler have something
resembling the same interface.
Including data-block.h from vixl exposed a bunch of header issues, so I
cleaned some of it up -- removing dependencies on boost and including
unistd.h in one place.
Reviewed By: @jdelong
Differential Revision: D971335
This was unlocked by separating resources and objects. is_object now
behaves normally (it's just a check for m_type == KindOfObject, instead
of needing to exclude resources), so all the special logic in codegen
and simplifier can go away.
I also replaced the string-type logic with an assert, and added an
equivalent one for array types; the special logic wasn't necessary in
practice because we always pass Type::Str as the tested type. This is
just future-proofing.
Type::Res doesn't need any special treatment because there's no opcode
for is_resource().
Reviewed By: @ottoni
Differential Revision: D970744
Without this patch, only the two-parameter signature is
supported, i.e. public void ReflectionProperty::setValue ( object
$object , mixed $value )
Closes#1056Closes#1057
Reviewed By: @ptarjan
Differential Revision: D970665
Pulled By: @scannell
If you use proc_open, we get `File` objects that don't have an underlying stream. This shouldn't segfault.
Reviewed By: @jdelong
Differential Revision: D972360
We need to create the catch trace before we pop the object,
since we're throwing with the marker set to before this instruction
has started. Also it needs Refs, because it can invoke the autoload
map code.
Reviewed By: @ottoni
Differential Revision: D970481
hphp/test/slow/ext_collator/1810.php produces output that is host specific. Renamed expect to expectf and replaced the host specific output with %s.
Reviewed By: @ptarjan
Differential Revision: D971536
The line table is a shorter version of the source location table and is needed for run time behavior beyond on-line debugging. When a unit is read from a repo, the line table is converted to a pseudo source location table, which is then converted back to a line table when the unit emitter creates the unit. This line table to source location table to line table conversion seems silly in itself. It also does not round trip faithfully, with the result that code that depends on the line table will behave differently the first time than the second time. This may have be the source of flaky tests in the past. Right now, the debugger's small step flow test fails if run a second time.
This diff gets rid of the conversion and directly propagates the line table from the repo to the unit.
Reviewed By: @mikemag
Differential Revision: D969062
Global constants pushed directly into the global constants table:
static const StaticString s_mpi("M_PI");
virtual moduleLoad(Hdf config) {
Native::RegisterConstantDouble(s_mpi.get(), 3.1415926535);
}
While Class constants are queued into a temporary table,
then picked up during PCE emit as Systemlib is parsed:
static const StaticString s_math("Math");
static const StaticString s_pi("PI");
virtual moduleLoad(Hdf config) {
Native::RegisterClassConstantDouble(s_math.get(), s_pi.get(),
3.1415926535);
}
.
<?php
class Math {
// PI will be injected here at emit time
}
Reviewed By: @jdelong
Differential Revision: D963642
For opcodes with a variable number of arguments, if the number
exceeds the number of argument registers, the precoloring hint code will
read overflow.
Reviewed By: @markw65
Differential Revision: D971071
Asserts that the thing being freed came from our allocator
and is not double-freed, and that the size it's being free'd with is
acceptable per the size it was allocated with.
Reviewed By: @edwinsmith
Differential Revision: D970449
When a string is big enough to go to malloc, we might as well
use the whole size class malloc gives back.
Reviewed By: @edwinsmith
Differential Revision: D969024
Was hoping to catch a bug from D891329. Only caught a benign
use-after-pop of an ActRec in the unwinder. Maybe worth it anyway?
Reviewed By: @edwinsmith
Differential Revision: D907772
StringData carry the hashcode once it has been computed once and it makes sense not to recompute it when accessing ConcurrentTableSharedStore for APC
Reviewed By: @jdelong
Differential Revision: D969504
These things can run user-level PHP and have to occur with a
still-functional ExecutionContext. Sara and I think it's reasonable
to consider it part of PSP. Intended to addresses a bug report from
yermo (https://gist.github.com/Yermo/6528678).
Reviewed By: @markw65
Differential Revision: D965421
This moves the emitBindJmp, emitBindJcc, and emitBindCall functions, as
well as some supporting players, into a new module
service-requests-x64.cpp. The two functions freeRequestStub and
getFreeStub are still in tx64, but I think that makes sense.
The way this structure is turning out still doesn't sit well with me,
but I can't quite pin down why. At least now all the nasty-looking
helpers for the emitBind* functions are behind a clean module boundary,
and the external interface (in service-requests-x64.h) is pretty clean.
Getting the new file compiling forced me to clean up some includes, and
move DataBlock up to the HPHP namespace (it was in Transl before).
Reviewed By: @jdelong
Differential Revision: D957725
Our custom unwinder code is something ASan knows it can't
analyze properly per Google's documentation. Add support for disabling
the checks (and cleaned up macro indentation to be consistent in
util.h.)
Reviewed By: @meyering
Differential Revision: D970675
We need it to be checking the return value of things like
lval even when passing false as the copy param. Use the shared code.
Reviewed By: @edwinsmith
Differential Revision: D970489
They're only called from one place, and manually inlining them allows
a little bit of code sharing; maybe more over time.
Reviewed By: @jdelong
Differential Revision: D970506
Blob Helper is used to serialize and deserialize metadata about
compiled PHP files. This diff introduces varint encoding rather
than fixed length encoding. It saves ~100 MB of the 700 MB sqlite
database.
Reviewed By: @jdelong
Differential Revision: D970359
They're used differently enough that this will aid streamlining each
one separately. Also, this way, key-type-specific logic in erase()
can be done earlier without extra branches.
Reviewed By: @jdelong
Differential Revision: D970271
Adds the ability to build with gcc 4.8.x ASan. When doing so,
build with -DENABLE_ASAN. (Right now, this disables jemalloc and our
custom memcpy and wordsame functions that read unused bytes and trigger
false positives.)
Reviewed By: @edwinsmith
Differential Revision: D969240
In freenode's #hhvm, yermo was asking for advice on how to
inspect hphp arrays from gdb. We should probably have this in the
repo anyway because it's nice.
Reviewed By: @markw65
Differential Revision: D968542
Gets HphpArrays into a flat mode using MM().objMalloc()
instead of SmartAllocator. Various optimizations were needed to the
Make functions to get this to work out ok. Growth still creates a
non-flat HphpArray (leaving a PromotedPayload behind so we know how
big the original allocation was).
Reviewed By: @edwinsmith
Differential Revision: D969431
The gdb registration of asm stubs was bitrotted;
semi-automate it. I'm removing the HIGH_OPCODES support for these
since it's a bit out of date anyway (we can add it back again at some
point if we need it).
Reviewed By: drussi
Differential Revision: D962710
- const correctness fix for AttachStringMode
- document almost all public functions
- move most implementations out of the interface
- rename mutableSlice to bufferSlice
I stopped short of sorting out toNumeric vs isNumericWithVal (I think
we need to delete Variant::toNumeric), and sorting out stuff with the
conversion functions for now.
Reviewed By: bertrand
Differential Revision: D968558
Make the catastrophic error message more clear for non-native
English speakers and make it less likely to occur by checking if the
binary exists first before spawning multiple threads.
Reviewed By: @JoelMarcey
Differential Revision: D969894
Fix constant size (otherwise treating them as a KindOfInt64 Variant overruns) as we don't support Int32 constants
Reviewed By: @jano
Differential Revision: D969285
our test runner outputs "failed" for tests that fail and grepping always comes up with this test. No need to have this pain.
Reviewed By: @andralex
Differential Revision: D969683
Summary:
Fixes build. I don't know why this didn't fail earlier, but it's
failing in the open source builds.
Closes#1058
Reviewed By: seanc
Differential Revision: D970243
Various cleanups that I factored out of other work.
Eliminate ElmInd; it's usefulness is pretty low since we rely on
int32_t for the hashtable storage and ssize_t for locals and
and parameters that pass around array positions.
Renamed a few things for brevity & clarity.
Moved some inline functions to hphp-array-defs.h.
More use of auto, replace Elm* with auto& in several places.
Eliminate a bunch of unnecessary ssize_t() casts.
s/ElmIndEmpty/invalid_index in several places.
Reviewed By: bertrand
Differential Revision: D968744
The proxygen server will use the same basic Worker/Job structure so I created server_worker with the shared logic. Had to make the templates somewhat complex to avoid the perf hit of virtual functions here.
Reviewed By: @markw65
Differential Revision: D922622
http_protocol was trying to assert that every body chunk was NULL terminated. libevent_server *thought* it was doing this by enlarging the buffer and adding a 0. POST body data can be binary though (images, video, etc) so if any code was actually relying on the 0 for termination, it was likely wrong.
The proxygen server will not add 0 termination to body chunks, so this assert has to go.
Reviewed By: @markw65
Differential Revision: D923553
This is so I can run test_server type tests for the proxygen server, which is not in the open source directories.
Reviewed By: @paroski
Differential Revision: D922589
I noticed that the first page of low memory never gets hugified,
because the arena gets setup before main, and we don't know what to
mark huge until we've initialized the runtime options.
By setting the high water mark to 1 below the start of the low memory
arena, and only updating it when we *are* marking pages huge, we can
ensure that the right pages get marked.
I also replaced some jemalloc magic that I had never previously understood
with a simpler (to me) equivalent.
Reviewed By: @jdelong
Differential Revision: D967121
Added the set command to the overall list of commands shown in the help. Removed extra equals sign from the tutorial printed when the output from '=' is too long, which was confusing people about how 'set cc' works.
Reviewed By: @hermanventer
Differential Revision: D967395
This diff updates the debugger to be able to debug async functions again, after the most excellent optimizations introduced in D946914. Minor updates to be able to identify an async func outside of the emitter, and minor adjustments to get breakpoints on async function names working again. Async stacks were fine, the test just needed to be updated. Stepping over await/yield used to decode the instruction stream around OpContSuspend to determine where execution would continue, but that was annoying and brittle. I recently gave c_Continuation the ability to predict its next execution offset, so I enhanced that a bit and switched to using that, so the debugger no longer cares about the codegen around OpContSuspend and doesn't care about anything around OpCreateAsync. This fixes stepping over suspends within a continuation. To get across the first await, we now notice a OpCreateAsync, step over that operation, then grab the c_Continuation off the top of the operand stack and ask it where the heck it's going.
Reviewed By: @hermanventer
Differential Revision: D965577
getStackValue is now being used to obtain the post-conditions at the
end of profiling translations, which requires supporting
SideExitGuardStk. This was not necessary before because getStackValue
was never used after the jump optimizations that produce
SideExitGuardStk.
Reviewed By: @swtaarrs
Differential Revision: D966360
Unit::getOffsetRange(Offset pc, OffsetRange& range) did two SQL queries to the byte code repository in order to map a PC (offset) to a range of offsets that provide all of the bytecode operations that correspond to a single source statement. The information needed for this map is already recorded in the m_lineTable field of the Unit, so there is no need for a SQL query.
Reviewed By: @mikemag
Differential Revision: D966164
Lint can't tell if something is a type alias or an object
unless it sees the file that defines the name. Check it's not in
WholeProgram mode.
Reviewed By: @markw65
Differential Revision: D965717
Style fix. Only class static methods should use
initial caps.
The few callsites we have don't need to be changed since they're
using the HHVM_FE/HHVM_ME macros which this diff also changes.
Reviewed By: @jdelong
Differential Revision: D965366
Using generic template-based fb_serialize/fb_unserialize implementation in HPHP.
Removing errcode from fb_unserialize API, since it's never used.
Reviewed By: alikhtarov
Differential Revision: D959470
I needed these constants to make the stream wrappers for phar. These seem to fit perfectly with the PHP naming convention so I'm not going to put HPHP_ in them since if PHP exposes them, I'm pretty sure these will be the values.
Reviewed By: @jdelong
Differential Revision: D905770
This was a nice hack since lots of arrays are packed, however now that
enough are actually kPackedKind, this test doesn't appear to pay for
itself (not called as often as before, and nearly always false).
Reviewed By: @jdelong
Differential Revision: D963530
Found this while writing some www code, was about to go OOoh found
something the HPHP team missed. Then I saw I wrote all of this in 2011.
Doh.
Catch invalid property and raise like Zend.
Reviewed By: @ptarjan
Differential Revision: D964511
Elem operations usually operate on arrays, so factor the
switch table dispatch into a NEVER_INLINE slow path, and do the array
case inline, guarded by a conditional branch.
Reviewed By: @swtaarrs
Differential Revision: D963594
Generically, this diff treats an uninit_null constant
as undefined. Currently, this only occurs with k_SID.
Closes#190
Reviewed By: @markw65
Differential Revision: D960974
There are two cases we don't handle correctly (see unittests). This diff adds a new flag to TypeConstraint to keep
track of type variables.
Reviewed By: @paroski
Differential Revision: D942949
Whenever the client sends a command to the proxy that includes a list of breakpoints, the proxy clobbers its list of breakpoints with the new list received from the client. Unfortunately it also uses its list of breakpoints to track which breakpoints are temporarily disabled because the debugger is currently stopped there. As a result, just listing the active breakpoints while stopped at a break point will cause the next continue command to hit the current break point if more byte codes have yet to be processed.
Reviewed By: @mikemag
Differential Revision: D962443
Summary: Parallelize four builds on the (JIT + Interpreter) X
(RepoAuthoritative + Not) matrix so we have parity on our test coverage
and people can get feedback that repo mode tests are failing on pull
requests
Reviewed By: sgolemon
Cleaning up the last Elem function of member-operations:
As far as I (or gcc) could tell, the isObj template parameter wasn't
used so I nuked it.
ElemIssetEmptyString was begging for a fast path when the key is an
Int64, so I obliged. I think there's a bit more fat there but I'll
get to it in a later diff.
Reviewed By: @edwinsmith
Differential Revision: D962556
None of these tests are fundamentally flakey - there
is just a danger of port collision (some had already been fixed
before they were disabled). Appropriate retries - and suppression
of warnings for the intermediate failures - should be sufficient to
make them solid.
Reviewed By: @jdelong
Differential Revision: D963009
Just set the BFD_DECOMPRESS flag on the bfd, and let
binutils propagate it when it follows .gnu_debuglink.
Reviewed By: @jdelong
Differential Revision: D962978
This is the last major piece of guard relaxation. It adds support for
reflowing the relaxed guard types, meaning it can be applied to a trace without
leaving it in an inconsistent state. The main benefit of this is that it allows
us to loosen/eliminate unnecessary predictions in the region translator.
Reviewed By: @ottoni
Differential Revision: D943543
stream_get_contents was assuming a default 0 for maxlen and offset.
Vanilla php uses -1 as the default for both.
Reviewed By: @ptarjan
Differential Revision: D954736
Mostly making File::readCSV look like the code from Zend PHP,
also required changes to how SplFileObject::fgetcsv() handled its
arguments
Reviewed By: @ptarjan
Differential Revision: D961647
Most of the Zend tests that work will work in repo mode, so
enable that. Create .norepo files for the rest.
Reviewed By: @sgolemon
Differential Revision: D961424
Make it so the the output doesn't depend on the version of
objdump that's available, so the test is more stable.
Reviewed By: @andralex
Differential Revision: D960736
Directories should be just like Files. I repurposed the `Directory` resource so it didn't just hold a `DIR`. I tried to copy `File` as much as I could.
I implemented the Phar `opendir` as a re-usable `ArrayDirectory`. It felt a bit weird passing an `Array` to the constructor and then not doing anything during open, but it seemed to match `MemFile`.
Reviewed By: @markw65
Differential Revision: D903572
There were two issues:
- you have to set BFD_DECOMPRESS on the bfd*, or it won't
decompress compressed sections,
- if the debug info is in a separate file, linked by
.gnu_debuglink, libbfd will follow the link, but won't
propagate the BFD_DECOMPRESS flag.
I changed the code to add the flag, and manually follow the
.gnu_debuglink sections, adding the flag as it goes.
Reviewed By: @jdelong
Differential Revision: D961365
Get the data representation all at the end, and keep all
privates non-data members at the end too. Private ctors (eventually
should be removed and replaced by the Make functions) so we can change
its allocation behavior. The public members are still in a mostly
random order for now, and I left the bulk of the non-static private
member functions alone.
Reviewed By: @edwinsmith
Differential Revision: D960965
Replaces use of copy with appropriate calls to Make (or
nothing in the case of class names, which are always static). Fix
copy construct bug in ImmutableObj, make its header not included in
shared-variant.h, some const correctness and other tweaks.
Reviewed By: @edwinsmith
Differential Revision: D960942
The StringData inside a SharedVariant caches the hash for the
shared string, but we wait until the first time it is accessed to load
it into the request-local string. Since we're already loading things
out of the shared memory at creation time, just eagerly load it there.
(It might be zero if no one has hashed it yet: we update it racily
from whichever request hashes it first.) This diff also shuffles some
code around to avoid extra checks for MaxSize, and removes a few
redundant loads that gcc couldn't remove in some Make functions. Also
move the code to shared-variant.o, and inline the fast path into its
only caller.
Reviewed By: @edwinsmith
Differential Revision: D960931
Modify the remaining mutation functions so they can
optionally return a new StringData*, and make a new rule that strings
created with MakeMalloc cannot have the mutation functions called.
Then reserve/escalate can both always create flat strings, and
MakeMalloc can create flat strings.
Reviewed By: @edwinsmith
Differential Revision: D960849
I want it to be able to reallocate. (This diff shouldn't
change any behavior, except adding a test on the return value that
can't ever succeed for now.)
Reviewed By: @edwinsmith
Differential Revision: D960724
Differential Revision: D963394
When using collection literals in property initializer the ref count is 2 instead of 1 and the collection leaks
Reviewed By: @jdelong
Differential Revision: D959451
These have always bothered me. They only exist as historical
baggage from back before Type was a real class. I also took this
opportunity to convert everything in the jit to use KindOfAny instead
of KindOfInvalid/KindOfUnknown, mostly to clean up conversions from
DataType -> JIT::Type.
Reviewed By: @jdelong
Differential Revision: D960018
Differential Revision: D963452
Fix comparison logic in TypeAnnotation::dataType(), which was causing
the result of f_hash_algos() to be type-punned from KindOfArray to
KindOfObject.
Reviewed By: @markw65
Differential Revision: D961159
Minor cleanup; IRInstruction and SSATmp have dedicated headers,
so might as well organize the function bodies that way too.
Reviewed By: @jdelong
Differential Revision: D960927
I want to make append() return a new StringData*, so removing
callsites that don't check for that. StringBuffer should be better
here anyway. Also fixes an exception safety bug.
Reviewed By: andrii
Differential Revision: D957816
It doesn't quite work, so maintaining it is not worthwhile.
We can fish it out of source control history if we want to use it as a
starting point for something later.
Reviewed By: @edwinsmith
Differential Revision: D959811
We were passing a garbage value to accept(), making it fail
intermittently. (A big value will silently pass and could
corrupt memory). Apparently the value got randomly smaller
with our switch to gcc 4.8.1
Reviewed By: @jdelong
Differential Revision: D960745
This is a good one. It doesn't need an external library and found a ton of corner cases I screwed up. It also got my stream handling much more solid.
I had to wrap other streams as they came into the extension and then unwrap them on the way out
Reviewed By: @sgolemon
Differential Revision: D945250
This started off as importing the enchant extension but since that library is horrible to work with, I'm not importing it. The resource stuff will be used by ftp and oauth. I can squash this into them or leave it out.
Reviewed By: @sgolemon
Differential Revision: D943019
I'm putting this in the facebook directory since I don't want to add yaml as a depedancy for the OSS version. This isn't even in the public version of php.net it is in pear, but I want this to set the precident of how to import pear extensions (until @sgolemon makes us a better way). At least this way we get the unit tests.
Reviewed By: @sgolemon
Differential Revision: D942072
1 I accidentally removed the %d which is needed since differnet filesystems report differnet sizes, and the other started emitting warnings since calling `get_class(null);` is bad
Differential Revision: D960488
The primary goal here: move the custom overloads for `hphp_raw_ptr` of static/dynamic cast in `Base.h` out of the boost namespace, into HPHP namespace (which already uses normal boost versions). This means all casting, to be consistent, should happen in the HPHP namespace
Differential Revision: D959867
Two custom flags for json_decode are added:
- FB_JSON_COLLECTIONS to output Vectors/Maps instead of arrays
- FB_JSON_STABLE_MAPS to output StableMaps instead of Maps
Differential Revision: D950743
Currently, a call to an async function returns a (Continuation)WaitHandle
object but the excution of the function body doesn't start before await
(or join()) on the WaitHandle is called. This changes it to start the
execution immediately and the control is returned to the caller only
after it's blocked.
Differential Revision: D946914
Turns out you can override collection classes, if you use the
__MockClass user attribute. We have to use instanceof instead of direct
m_cls comparison.
Also, not_reached() has surprising behavior in build configurations
where ##assert(false)## is a no-op -- because of the not_reached, the
compiler was optimizing out the final else-if branch of the chain,
assuming that it could only go one way. Replaced those
with ##always_assert(false)##.
The implementation of c_Pair::Clone wasn't quite right either -- it
wasn't checking for a user-defined __clone function. You have to go
really out of your way to observe incorrect behavior because of this,
but it's doable. Also the elm0 and elm1 members weren't necessarily
initialized (I think). This change can't hurt, anyway.
Differential Revision: D959327
Stream wrappers were not being destroyed properly at the end of
a request, resulting in strange behavior / crashes if the same wrapper
was registered across multiple requests. This affects Drupal. Sample
code:
<?php
class stream{
public $name;
}
stream_wrapper_register("public", "stream");
stream_wrapper_register("private", "stream");
stream_wrapper_register("AA", "stream");
var_dump(stream_get_wrappers());
Closes#849Closes#1032
Differential Revision: D959563
It wasn't checking, which means you can make a string bigger
than StringData::MaxLen---the length you ask for in reserve() the
first time is compared with the max length, but you may end up with
more capacity than that and later calls are only checked against
capacity(). StringBuffer will also use this capacity as if it is
within range. Also add a checkSane() assertion in the resize path.
Differential Revision: D954757
I keep adding tests in there and I hate that the warnings aren't in the output. This was pretty straightforward:
1) Delete the config.hdf
2) Run all the tests
3) `./tools/out2expectf.py test/slow/*/*.php test/slow/*/*/*.php`
4) `find test/slow -name "*.except" -exec rm {} \;`
5) Fix other broken things
The things I had to fix by hand were:
a) tests with invalid unicode in them that out2expectf choked on
b) tests whose output is too long for a .expectf file. Thankfully they didn't have any warnings.
c) `strtotime_leak.php` was somehow leaking with the default config
d) some tests are different in repo mode, I'm digging into those now
Differential Revision: D958390
Differential Revision: D959973
We weren't properly handling OutCInput or OutCInputL. In
practice this means if we interpOne an Unbox or CGetL3 of a reference
type we could generate code that will fail on a later run if it is not
monomorphic.
Differential Revision: D958269
It turns out the Ubuntu 12.04 image I thought was using 1.0.16
was using 0.44 and OSX was using 1.0.17. This should fix compilation on
libmemcached 1.0.8 - 1.0.16.
Closes#1022
Differential Revision: D957901
Travis only supports running a single commandline to run tests so provide a
mode where we can run JIT+interp X repo+non-repo now that contributors are
starting to submit contributions that only break in repo mode.
Differential Revision: D957147
This test is flaky on some dev boxes. Disabling it until task 2558262 is implemented. That should get rid of the flakiness.
Differential Revision: D957673
If a class defines method __toDebugDisplay, the variable serializer will call it when serializing with DebuggerSerialize. The resulting value is added as property __PHP_DebugDisplay to the serialized object. If an object with such a property is serialized with DebuggerDump, the serialization of the property is used as the serialization of the object with the property.
Differential Revision: D954810
Aside from instance bits this is pretty straight forward.
Most of the other friends were just directly accessing members instead
of using accessors.
Differential Revision: D953599
With the InSitu string mode, this means we can reuse free'd
ObjectDatas for string memory and vice versa. Putting both in there
seemed to be better than putting either one and not the other. It
seems plausible we should get ArrayData in on the situation too.
Differential Revision: D954003
Instead of a specific reserved small size, any string can be
allocated in situ when it is first created. For now this doesn't
remove the m_data pointer, and both Mode::InSitu and Mode::Shared will
still promote to the old Mode::Smart when you append.
Differential Revision: D953985
Adds a new API where you tell the manager the sizes of the
objects during free, so it doesn't need to track it internally. This
is for use with in situ string allocation and moving ObjectData
allocation into the shared free lists. There are a few things still
needing cleanup in the API here still (e.g. smartMallocSizeBig has to
add sizeof(SmallNode) just so it can be subtracted), but I plan to do
it on top of this diff stack to isolate it from causing any perf
impact.
Differential Revision: D953828
The way these are written makes them impossible to treat equally on
different platforms. I'm not sure if these should go in mainCode or
stubsCode, but I'll try perflabbing both permutations.
Differential Revision: D954716
Initially, I just wanted to add a test to make sure that the
results of token_name / token_get_all / defined T_* constants all
matched. After adding the test, I noticed some hilarity and fixed it:
- added T_INSTEADOF and T_YIELD (they're now defined in zend)
- fixed an off-by-two error in the value of T_COMPILER_HALT_OFFSET
- reversed T_GOTO and T_CONTINUE being defined with the other's value
That last one ... I don't even.
Differential Revision: D956958
Change the default value for the port in socket_sendto/recvfrom
from 0 to -1. A port is only required for AF_INET and AF_INET6 sockets,
and a port of 0 has special meaning, so use -1 to signify that a port
was not passed in as a function argument.
Differential Revision: D954831
"async" should be able to be listed in any order with other method modifiers
such as "public", "final", etc. Make it so.
Differential Revision: D941131
Very straightforward. I think these zend headers are working. The hardest part was getting my importer to pull in that directory. I think I have to stop flattening them.
Differential Revision: D939269
Some developers reported that "$x=$y?:foo();" failed to parse correctly
when EnableXHP=1. The problem happens because the lexer is a little too
aggressive with recognizing XHP class names and it treats ":foo" as an XHP
class name, and so the statement fails to parse.
This diff tweaks the lexer so that "$x=$y?:foo();" parses correctly when
EnableXHP=1. This was achieved by changing the lexer so that in ambiguous
situations where there is no whitespace before ":foo" it will not treat
":foo" as an XHP class name. This change only affects static method calls,
static property access, and class constant access that use an XHP class
name as a base. Note that this change does not affect how parsing works
when EnableXHP=0.
This diff also updates the regex for WHITESPACE_AND_COMMENTS to support
single line comments that begin with '#'.
Differential Revision: D952602
There's 4 wasted bytes inside the FixedStringMap, which we
can reuse for IndexedStringMap's size. Takes HPHP::Class down to 320
bytes.
Differential Revision: D953063
HPHP::Class is a bit of a mess. Regroup various members to
help see what the layout is a little better; mostly stop short of
trying to make the API clearer though. Made ~Class private and
noticed that AtomicSmartPtr calls incorrectly calls delete from a few
places (the m_parent.reset() in releaseRefs(), for e.g.). Change some
random junk in unit.h.
Differential Revision: D952969
__invoke calls were going to the interpreter---this adds a
translation that loads a Func* off of the Class, assuming it's
"normal". An __invoke is considered non-normal if it is not on a
closure and defined static. (PHP 5.5 gives a warning in this case,
but still runs the closure as expected.)
This was going to add 8 bytes to HPHP::Class, so I paid for that by
removing an unused hphp_hash_map in Class. This bumps sizeof(Class)
down to 440.
Differential Revision: D952952
mysql extension was incompatibly trying to use a connection that was a failed result of mysql_real_connect() for other APIs which is unsupported by mysqlclient. Fixed that.
Closes#1021
Differential Revision: D955216
I'm seeing a steady stream of core files from dev boxes with faults under TranslatorX64::addDbgGuards(). Inspecting some of the cores shows that we have a SrcKey with a FuncId which maps to a null Func*. This can happen if a Func is destroyed. Add a function to determine if a FuncId is valid, and use that to skip consideration of SrcKey's which are invalid.
Differential Revision: D954427
This is a pretty small thing, but better this way than as part of a
bigger diff.
One interesting thing here is that I'm now having to pass a FixupMap
into one of these stateless helpers, which raises the question of how,
in general, we're going to deal with helpers like this that need to
modify translator metadata (like the fixup map, SrcDB, debug info, ...).
I'm also cheating a bit inside emitCall, grabbing the global tx64
instance to possibly fetch a native trampoline. This is part of the same
problem: how can these stateless helpers cleanly affect global
translator state?
In this particular instance, it would have been easy to make the
fixup-map calls from the emitCheckSurpriseFlagsEnter callsites instead,
but I was uncomfortable with separating the actual assembly call from
the corresponding fixup-map entry.
I also opted to pass CodeBlocks into emitCheckSurpriseFlagsEnter,
instead of Asms, since it made the surrounding code cleaner.
Differential Revision: D954120
This is a wide-ranging refactor. We should not have long-lived (i.e.
member) X64Assemblers anymore.
A couple of these changes are non-mechanical, and I'll point them out in
inline comments.
There are a couple things left to do:
- CodeGenerator still has member assemblers. We'll need to apply similar
changes there, and it's just a ton of functions. I'm leaving that for
a separate diff.
- This gets us closer to being able to remove the frontier(), base(),
etc. member functions from X64Assembler, which will be the forcing
function to finally separate CodeBlock concerns from assembler
concerns.
Differential Revision: D950811
This adds mapWithKey() and filterWithKey() APIs to all keyed collections
(Vector, Map, and StableMap). These APIs are similar to map() and filter().
The key difference is that these APIs pass both the key and the value to
the user callback.
Differential Revision: D939972
The debugger client obtains objects via serialization from the server and then converts them to text on the client. This is the right design since it gives the IDE a structured object that it can present to users in a summarized format. Unfortunately this presents many problems with objects that do not serialize across process boundaries without loss of information. The way resource objects were serialized caused them to show up as empty objects in the client. This diff adds logic to serialization/deserialization to make resources show up as dummy resources in the client. Serializing those to text gives the information that show up when server to text serialization is used.
Differential Revision: D950605
- decreases ring buffer size to 512KB to better support calling the JVM from an extension (1 MB causes problems with Java's thread stack size assumptions)
Closes#1015
Differential Revision: D953256
The documentation and help for the set command was pretty useless. Made it convey what is possible. Also added and option for the maximum length allowed by the = command. Increased the print level from 3 to 5 since 3 seems too small for real life debugging examples.
Differential Revision: D953805
I need to use this instead of memcmp now for D938354. Doing
the function move in a separate diff to perflab independently.
Differential Revision: D943815
While working on TraceProfiler I kept hitting things that bugged me about the current code: bad names for things, classes with everything public, etc. This diff cleans a bunch of that up. There should be no semantic changes in this diff... yell if you see one.
I've also removed the TraceProfiler feature to serialize the trace with the results, and the function to deserialize the trace and produce results again. It's completely unused. The flag to turn it on was never exposed to PHP, as far back as the original diff, and there are no uses of the deserialize function in any repo.
Differential Revision: D950718
We appear to be handling bare $this differently in contexts
where it can actually do something, but it doesn't look like it should
matter: at JIT time InitThisLoc turns into nothing in a non-method
anyway. Static closures and non-static closures in non-methods with
bare $this end up with a different state for
FunctionScope::needsLocalThis, it was unclear how to fix that earlier
in the frontend that so I'm just quieting the assertion here.
Differential Revision: D952951
The set command can alter the values of some of the settings that are kept in the per user debugger configuration file. However, these settings do not get persisted back into the configuration file. Since the configuration file is affected by other user commands, this seems a tad strange. As we add more user options, I suspect that these options will be more discoverable if they are documented as part of the set command and if they persist in the configuration file.
Differential Revision: D952387
We were doing type inference on Native functions, which ended
up throwing away the return type, resulting in incorrect type annotations,
and bogus CodeError.js warnings.
Similarly, Native methods were treated as abstract (since they have no body),
resulting in CodeError.js warnings if you derived from classes containing
Native methods.
Differential Revision: D951860
Prevent memory corruption when a fatal/exception during PSP
triggers a flush() after data has already been sent and the transport
is in an invalid state.
Differential Revision: D953102
We only handle a few easy cases for these, but since these
operations renumber and compact elements on Mixed arrays,
there's no point in escalating from packed to mixed; we might
as well do memmove and leave the existing 0..N numbering.
Differential Revision: D945517
At present, there are some corner cases where hhvm doesn't parse command
line arguments properly. For example, doing "hhvm foo.php -u" causes a
'required argument missing' error even though "-u" is an argument intended
for the PHP application.
This diff fixes the problem by doing a manual pass over the args ahead of
time before invoking the boost command line parser. This seems to be the
only reliable way to prevent the boost command line parser from choking on
args intended for the PHP application.
Differential Revision: D952180
The constants were undefined, but are necessary for parity
with Zend and for the internal consistency of `token_get_all` and
`token_name`.
Differential Revision: D952502
This diff fixes some bugs with invokeFunc() and invokeFuncFew(), it removes
some dead code, and it converts more places to use cellDup() instead of
tvDup().
invokeFunc() had a bug where the VM stack did not get cleaned up properly
when a warning is raised and the user error handler threw an exception.
This diff adds a catch clause that will perform the appropriate cleanup and
then rethrow the exception.
invokeFuncFew() had a bug where in some cases it would pass a parameter by
reference when the callee required that the parameter be passed by value.
This was happening because TypedValues that were KindOfRef would get copied
onto the VM stack using operator=, and nothing was checking whether the
callee required the parameter to be passed by value. This diff fixes the
issue by reworking invokeFuncFew() and callers of invokeFuncFew().
Differential Revision: D949251
Right now these manifest themselves just as fatal. I think it then gets pumped
to log view. We don't do a good job monitoring these. Add counters so we can
track them better.
Differential Revision: D949107
Currently boost is guessing at command line options. We need to stop this so we can use --debug for phpunit and not get "Error in command line: option '--debug' is ambiguous and matches" errors from boost.
Differential Revision: D951632
Moved the shift to compute the position size in bytes out of the instruction LdElem and StElem. Leads to better optimizations
Differential Revision: D949770
Do not register automatically session shutdown function when
session_set_save_handler called in PHP <5.4 style.
PHP Manual: Note we additionally register the shutdown function
session_write_close() using register_shutdown_function() under PHP less
than 5.4.0. This is generally advised when registering objects as
session save handlers under PHP less than 5.4.0.
Closes#1001
Differential Revision: D949388
We currently don't have a way to type XHP's {} operator (i.e. to type $foo in
function ($foo) {
return <div>{$foo}</div>;
}
An XHPChild interface should solve this issue by having a type which is compatible with arrays, strings,
ints and doubles. We can then modify www to have :x:base implement XHPChild.
To me, this seems like the right step to get rid of the Xhp special casing.
Differential Revision: D886565
In PGO mode, we were punting when the profiling translation had an
inlined call. Properly supporting inlining was not difficult, but it
required the profile data to keep a region instead of a block for each
profiling translation.
Differential Revision: D944792
Added comments and did a tiny bit of cleanup to help understand a bug we currently have with multiple threads hitting breakpoints. Mostly comments and log changes. Any other changes should cause no semantic difference, and are for clarity only.
Differential Revision: D943943
Add a little more logging to the proxy, for error cases where the proxy declares a protocol violation on the part of the client and disconnects.
Differential Revision: D947864
In order to support existing Zend extensions, I'm introducting a source compatitblility layer. Since the extensions are all built around macros, the plan is just to redefine them to work on HHVM internals intead of Zend internals.
I've implemented the most common ones I've seen so far. The plan is to import all the builtin extensions from zend that we currently don't support and use them as a coverage test. So far, this diff includes calendar.
Differential Revision: D938776
I opened this can of worms while trying to devirtualize ObjectData, and
trying to understand how objects get destructed. It turned out that
every ObjectData and ResourceData subclass was defining its own operator
delete via several layers of macros, and they all did the same thing.
I deleted the one for ObjectData and let everything be handled by the
definition of operator delete in ObjectData itself. ResourceData makes
this harder: given a ResourceData*, we don't have quite enough
information handy to know how big its dynamic type is, so we're still
using the macro-generated override in every ResourceData derived class.
This more closely reflects reality, since ResourceData and ObjectData
are separate class hierarchies now.
Differential Revision: D943826
On some machines (such as mine or Drew's), `which objdump` finds /usr/local/bin/objdump, which in turn has version 2.21.1. That makes hphp/util/test/asm.cpp fail due to a different hexadecimal constant formatting convention than the one we expect. Fortunately, /usr/bin/objdump is still 2.17.50.0.6-6.el5 on said machines, which is what works. So this hardcodes that path at least as a stopgap until we figure a better solution. Long-term we should plop a sanctioned objdump version in ~engshare.
Differential Revision: D946553
Flatten ArrayIterator/ArrayObject when initializing them with
other array wrappers to produce arrays from respective getArrayCopy()
methods
Closes#1000
Differential Revision: D949379
Tests for async functions were originally just modified tests for
generators. The implementation will be changing soon (eager execution,
AsyncFunctionWaitHandle) and the test will be no longer sufficient.
These modifications are mostly based on problems I encountered while
working on optimizations.
Differential Revision: D943736
There was a race in defClass that could result in
a defClass on a different thread succeeding, before the original
had added the new Class to the NamedEntity's clsList. That could
result in a crash in compactMergeInfo.
Differential Revision: D949580
Purely mechanical. This is going to make an upcoming refactor a little
bit less painful. Also important: removing the friending of
X64Assembler so the protected members are actually protected.
Differential Revision: D949434
We are now investigating HipHop, but for that we need to port our
existing PHP extensions. I had to change two small things in hiphop
code, to be able to compile it together with one of our extensions. I
think these changes could be useful not only for us.
1) Renamed macro "field_type" to "hphp_field_type", because it was
making conflicts with mysqlpp library, which have public method
"field_type" in some class. It is pretty generic name, so I believe, it
could make also problems with other third party libraries in future.
2) At some moment I started to get error messages "error: 'size' is not
a member template function" in hiphop, not our code. Don't know exactly
why they started to appear, but after some googling I found
(http://stackoverflow.com/questions/10671406/c-confusing-attribute-name-for-member-template)
that this is known GCC bug and workaround is very simple - put
parenthesis around "old->size" in hphp/runtime/vm/tread-hash-map.h:203.
Closes#996
Differential Revision: D947510
Not much of the old API was left. Done in separate diff for
reviewability. Also fixed some incorrect comments in the
funcPrologueRedispatch stub.
Differential Revision: D942878
Translator modularization. Mostly mechanical code motion,
with addition of some documentation and better logging (disasm
support, etc). It's possible that the set of stubs for ARM vs x64
might not be exactly the same eventually, but it might, so for now
this is layed out with the assumption that a future
unique-stubs-arm.cpp will populate the same list of stubs. (I also
tried drawing the line on a per 'stub group' basis, but too many stubs
have tricks about layout and it seemed hard to predict whether that
would commonize anything other than the function call loop, so we can
do it later as needed.) Also rename the JIT::CodeGenHelpersX64
namespace to JIT::X64.
Differential Revision: D942874
libmemcached 1.0.8 still allows access to the fields we need
on the old structures (memcache_server_st) so allow building against
that [since it appears to be what Ubuntu 13.0.4 uses for
libmemcached-dev.]
Differential Revision: D947880
The tracelet region selector now supports creating regions with
inlined calls. When it sees an FCall with a known callee, it invokes a new
instance of the tracelet region selector on the callee. The callee is evaluated
using the same cost metric as Translator::analyze. If it passes, the callee is
inlined for real, which allows creation of longer tracelets based on the return
value from the callee.
Differential Revision: D909359
Service requests are part of the translator infrastructure and are
entirely[1] platform-agnostic. I factored out the definitions and the
argument-packing code into their own file.
Then I moved emitServiceReqWork into CodeGenHelpersX64. It was a little
difficult to untangle, since it had several direct uses of tx64 state. I
tried moving emitBindCall and friends too, but it got a lot more
difficult. I'll do that in another diff, to keep this one manageable.
I put this new header file in HPHP::JIT, so I had to introduce some
JIT:: line-noise elsewhere, but this is actually the lesser of two
evils. If I put it in HPHP::Transl, there ends up being Transl::
line-noise in a lot more places. Since JIT is where we're ultimately
headed to (right?), this seemed better.
[1] They're not entirely platform-agnostic, but they should be. Right
now they depend on the x64-specific ConditionCode enum. We use a very
limited set of x64 condition codes in this context, so we should be able
to define a platform-agnostic set of condition codes (a subset of the
intersection of ARM and x64 condition codes) and use it here. I'm
punting on that for now, though.
Differential Revision: D933753
evalPHPDebugger catches and suppresses all exceptions except debugger exceptions. Hence the catch clauses that follow its only call site are dead code, except for the catch all, which seems just wrong to me since it suppresses Debugger exceptions that are explicitly propagated by evalPHPDebugger.
Differential Revision: D945652
The code to print out the result of the expression following the = command has moved from inside the resulting eval block, to outside it in the debugger code itself. Hence, if the eval block fails, the value of $_ now prints out and this is confusion because it is the value that a previous = command put in there. With this change the eval block first unsets $_, so that the subsequent print value code will do nothing in the case of a failure.
Differential Revision: D944120
If redoHoistable is set, at least one defClass failed,
so we can't compact the unit.
This should prevent crashes - but something must have gone wrong
to get into this state. An AttrUnique class should never fail
to be defined.
Differential Revision: D946531
fCallArrayhelper smashes its return address, leading to
return branch mispredictions until we return enough times to get back
on track. Rewrite it as an asm stub so it can make a tail jump and
pop the proper return ip into the ActRec.
Differential Revision: D941930
FCallArray does a stack overflow check as part of its
"mini-prologue", so we can still consider functions that use it leaf
functions.
Differential Revision: D940120
The function blockUntilOwn() was not actually blocking threads before letting them into processInterrupt(), which allowed multiple threads hitting breakpoints to process their interrupts and communicate with the client, which is bad.
Also fixed an issue where interrupts processed during an eval would result in erasing the current thread's 'lock' on processing interrupts, resulting in the same issue.
Differential Revision: D945203
- ext_* functions that call Unit::lookupClass were not correctly
handling denormalized names (ex. \FooNS\Bar), this adds a wrapper for
this pattern and calling it.
- ReflectionClass::subclassOf should be using f_is_subclass_of
Closes#827
Differential Revision: D945363
HHVM's current implementation promotes internal state to possible
subclasses.
This is meant as preparation to support RegexIterator in a separate
commit, because the Zend tests rely heavily on the internal var-dump
representation of ArrayIterator.
Closes#989
Differential Revision: D943461
Currently, xpath just creates new elements. This means that any
modification done to the return object will not change its original
parent.
xpath can also traverse -up- the hierarchical node tree, so we cannot
just recursively go through children to find a matching node. this is
why an additional m_root was introduced, to keep track of the root node
of the current tree.
Closes#986
Differential Revision: D943404
The tracelet region selector was relaxing a guard that the normal
translator wasn't, exposing a bug in the register allocator: when a load
instruction has a label we care about its type, so we can't assign it to an xmm
register. We really shouldn't be guarding on this load at all, but that can be
fixed in a separate diff.
Differential Revision: D944937
We have a catch trace that does a SpillStack for both of
these helpers. Incidentally, zend raises a fatal if you try to throw
in this situation.
Differential Revision: D944079
Don't use DECLARE_BOOST_TYPES (use make_shared where
appropriate). Delete the broken (double-free) default copy
constructor and copy assignment operator. Also document some things
because a few points are more subtle than they seemed (unlike
StringBuffer, most functions have a precondition that the buffer is
valid, and the filename constructor does not report errors).
Differential Revision: D931752
@WizKid has been doing a few diffs on HHVM recently and he noticed that the path of the errors didn't match zend. This is totally right and I was being dumb trying to emulate the old perl script for our paths. Instead we should just match %s.
I also noticed you can't just run the bad tests from their directory since sometimes they need an `.inc` file. We should just duplicate those files in there so you can run the bad tests directly.
Differential Revision: D943288
www engineers would like to be able to provide the type for code which
takes a resource as input. This simple change is a first step in the right direction.
In the future, we might want to provide a way to specific the exact type of resource
(e.g. PlainFile vs CurlHandle).
Differential Revision: D873115
Privatize several public functions, remove some redundant
functions, make some things non-members (appendJSONEscape), remove
DECLARE_BOOST_TYPES, and document contracts; also some gratuitous
style changes. I was initially planning to make it include the null
in its capacity, but since capacity is not exposed anywhere I think
it's fine as is. (And eventually we don't want to require the null
when handing off to String---only when people call data()---but that
is a separate project.)
Differential Revision: D931746
Most of the hard work to support specialized types was getting guard
relaxation working, so this diff is pretty straightforward. The only big change
is collapsing GuardCls and GuardArrayKind back into GuardLoc. If that turns out
to be a noticeable perf regression I can investigate other options.
Differential Revision: D936145
This diff expands guard relaxation to relax all eligible
guards, not just guards for values that are never read. Specialized
types are still not supported yet; the tracelet region selector drops
all specializations.
Differential Revision: D934157
get_class_methods() was not including methods that came from traits.
This diff changes get_class_methods() to look at the Class' method
table, instead of the PreClass. With this approach, we could avoid
traversing the inheritance hierarchy. However, that changes the order
of the methods in the resulting array. So, in order to preserve the
order, this diff still traverses the inheritance hierarchy, and
methods are added to the array when visiting the class that declared
them.
This modification changed the order of methods for some "quick" tests
with classes derived from builtin classes. However, hhvm was not
matching Zend on these tests already, so I updated them.
Differential Revision: D940214
The C++ vtable pointers and the m_cls pointers in ObjectData are
redundant for C++ extension classes; they both indicate the ObjectData's
dynamic type.
This diff gives ObjectData the same treatment that the ArrayData
hierarchy got, replacing virtual functions with manual dispatch based on
attributes and m_cls. We can't do direct comparison against m_cls,
because of inheritance, except when we know inheritance is not in the
picture.
The vtable isn't gone yet, because I need to do something about C++
destructors, which still require virtual dispatch. That's going to
require a lot of grunt work, so I wanted to put this diff up to keep
that stuff separate.
I did, however, make ~ObjectData non-virtual and try to compile, to
flush out all the dynamic_casts of ObjectData.
- The type-casting functions and clone() are pretty straightforward. The
only trick is that specialized clone() functions now have to call
cloneImpl() instead of the base class' clone(), otherwise infinite
recursion. I added an ObjectData attribute to indicate whether clone()
is special.
- t___{sleep,wakeup} didn't even need to be virtual, it turns out.
ObjectData's implementation goes through the normal PHP-method lookup
path, which effectively does virtual dispatch and routes us to any
specialized implementations anyway.
Differential Revision: D940852
I liked the results of some cleanup of SetNewElem, so I
decided to extend it to many of the other Elem* functions in
member-operations.h. This diff really just moves code around to make
it easier to experiment with in the future.
Differential Revision: D932351
- Implement CachingIterator
- I ran the idl/sysdoc.php script on my file but it didn't do anything to it
- I started with https://github.com/php/php-src/blob/master/ext/spl/internal/cachingiterator.inc and then added everything that it was missing
- Some of the documentation at http://www.php.net/manual/en/class.cachingiterator.php is strange. All the offset function say that they take string arguments. But the class implements ArrayAccess which specify the arguments as mixed. So I went with mixed because otherwise I got a fatal
- I moved over all bad tests that are now passing
- The rest of the bad tests that test CachingIterator are passing too. It is just that error messages are different so I can't move them to good
Differential Revision: D942889
The AddLval methods were fairly cold, so reimplement them in
terms of lval(), but preserve the assert that ensures the keys
being added do not already exist. This reduces the number
of kind-specific methods we need to implement.
Added Array::setWithRef(key,value) to capture a common use
case for lvalAt(). Later this can implemented more efficiently
as a virtual method in ArrayData subclasses.
Differential Revision: D937227
At call sites, it was complaining because it thought an alias
parameter must be a name of an object. Also make a function less
nested.
Differential Revision: D942157
StringSlice{foo, bar} where bar is uint32_t produces an error
(in 4.7.1, 4.6 doesn't have this part of C++11 correct yet).
Differential Revision: D938436
They were just broken. Right now, even evaluating a unit
that is declaring one just leads to attempting to autoload the empty
string as a type alias (since it thinks the type alias was
KindOfObject). Changes them so they work just like normal <?hh
function typehints (currently unchecked).
Differential Revision: D942768
At present the 'string key not present' exception message can be misleading
when the string key is truncated (which happens when the string key exceeds
20 characters) and this has caused some confusion.
This diff improves the exception message in two ways. First, the string key
will only get truncated when the key exceeds 100 characters. Second, the
exception message will make it clear when the string was truncated by
printing "(truncated)" after the string key.
Differential Revision: D940984
Its the only way we have for reliably testing hard to repro edge
cases (such as timeouts during FunctionEnter/FunctionExit) and I find it
very useful for debugging complex code.
Differential Revision: D941226
Fire EventHook::FunctionExit() in the correct places for generators. This was happening during Continuation destruction, which is quite a while after we exit the continuation, and causing double notifications for continuation exits. Also fire the event when unwinding out of a generator, since that one was missing.
Differential Revision: D939893
libmemcached 1.0.8 broke the memcache/memcached extensions. It
is also missing some API support we need, so this should unbreak us as
of 1.0.9+. 1.0.8 plain won't work but earlier and later will.
Closes#934Closes#973
Differential Revision: D939850
This diff adds support for calling methods directly on collection literal
expressions (as long as the collection literal is wrapped in parentheses).
Differential Revision: D940562
When number_format receives 'null' for one of its separator parameters,
we must pass it back to t_number_format so it can decide whether or not
it should fallback to its default separators.
Currently, when passing NULL to a parameter that is defined as String,
it is implicitly converted to an empty string, and subsequently
str.isNull() will return false.
Instead, we use a Variant with a default string value.
Closes#982
Differential Revision: D940482
function foo($bar, $baz) { }
foo();
Currently raises two errors:
foo() expects exactly 2 parameters, 0 given
foo() expects exactly 2 parameters, 1 given
Only the first of these is either meaningful or correct.
Stop reporting once we've raised it.
Differential Revision: D939810
added error handling for bad serialized strings according to zend tests.
We cannot move the actual tests from "bad" to "good" because ATM they
rely on the internal serialized string format of SplObjectStorage, which
is not yet reimplemented.
Closes#969
Differential Revision: D935251
We have separate methods for parsing functions and methods
(onFunction/onMethod), which have a lot in common. On the other
hand, onClosure just calls onFunction with a special parameter
that modifies its behavior. Lets make this more consistent and
remove the duplicated code.
Differential Revision: D934034
Most strings used as keys are either small or not shared, where the
data pointers cannot be equal. Of the rest (shared), most could have
been small.
This diff copies small SharedVariant strings, so they don't refer
back to the SharedVariant, and don't need to be enlisted. Then,
this changes hitStringKey() to not check data pointers, making it
equivalent to StringData::same(). Lastly, hand-write the comparison
loop in StringData::same() so we compare words at a time, and the
loop can be inlined.
Differential Revision: D937233
The Facebook SDK unit tests fataled because ReflectionParameter::IsCallable() was not implemented. So, this implements it. Now the unit tests pass. Bad zend test now passes!
closes#931
Differential Revision: D938769
Vector has become too overloaded in this codebase. MInstrTranslator is
more accurate anyway; we have multiple different types of hhbc opcodes with
immediate vectors that aren't m-instrs.
Differential Revision: D935859
Here's a few minor changes in emitter that will be needed later for
eager execution of async functions. Just to make the upcoming diff
sipmler.
Differential Revision: D935301
Currently, hhvm interprets post-try blocks not necessarily
beginning with an actual finally token as finally blocks, and thus
produces an error message to the user telling them finally blocks
are disabled even if they misspelled something, for example.
This moves things so the "finally disabled" message only comes up
if you enter a syntactically valid finally block.
Differential Revision: D918867
It should be almost never true, and the assignment code is
already safe for self-assignment. Note if Variant V == uninit,
then V=V now converts to null, unlike before. IMHO this is
a bugfix but I don't know that we've seen it in the wild.
Differential Revision: D933229
When port-takeover is used, new instance of the process will be started but
something can call stop command for the old task. Given how `localhost:9099/stop?`
can affect hhvm that was just started, I want to limit stop command to be
specific to an instance ID.
This instance ID could be a random number, or container uuid of LXC.
Differential Revision: D932953
If re-entry triggers stack overflow, there is no FCall or FCallArray,
so the code to find the pc in REQ_STACK_OVERFLOW would fail. If it
managed to get through there, it would then try to DecRef the contents
of an ActRec, sometimes causing it to DecRef a Func.
In addition, if a "leaf" function resulted in re-entry we didn't
necessarily check the stack.
Differential Revision: D936843
Func::destoy needs to block on getting the write lease, so it
can smash the function prolog.
Also, the prolog array in cloned closures is used to redispatch to
the translation corresponding to the clone, since we never enter
such functions via their prolog. Since its not a true prolog, we
shouldn't smash it.
Differential Revision: D933704
This diff implements basic guard relaxation in hhir. Whenever we read
a local or pop/peek at HhbcTranslator's EvalStack, a DataTypeCategory is
specified. The source of the value is traced back as far as possible, and if we
end up at a guard instruction, the constraint for that guard is updated
appropriately. After IR generation, a pass is run to change the types of these
guard instructions to the least specific type allowed by their constraint. This
is currently only used to eliminate completely unused guards in the tracelet
region selector, so all the guards are either DataTypeGeneric or
DataTypeSpecific.
Differential Revision: D924955
The zRevRange function argument $withscore was referenced
within the function as $withscores. Changed argument name to $withscores
so they match.
Closes#941
Differential Revision: D934709
This is all stuff I did while working on guard relaxation
that isn't strictly related to guard relaxation:
- Stop using CheckType with Nullptr.
- Move a bunch of things from ir.cpp to extra-data.cpp and ssa-tmp.cpp.
- Turn DataTypeCategory into an enum class.
- Add folly::FormatValue specializations for JIT::Opcode,
DataTypeCategory, and any objects with a toString method.
- Kill the Eval.JitCompareHHIR runtime option. Most of the code using
it is already long gone.
- Add smart::flat_set.
- Clean up MInstrInfo constants, fixing a bug that missed some
undefined local warnings.
- Assert that the type of IRExtraData subclasses passed to gen()
matches what the opcode wants.
- Remove unused DontGuardLocal, DontBreakLocal, and DontBreakStack1
from translator inputs.
Differential Revision: D926849
Since D898769, all locals in generator bodies have the same ids
as in the corresponding 'create generator' methods, so the mapping
between these ids is no longer needed.
Differential Revision: D932354
Updating the NEWS file for our next release. These were some
highlights that I plucked from the commit log but I'm open to adding
or deleting some.
Differential Revision: D933280
Setting a breakpoint on a generator would work, but it would set it on the function which simply returns the continuation. That's not super-useful, and the intention is to set it on the beginning of the generator. Changed to do that. This change also gets the $continuation off of the function name when printing it at breakpoints.
Differential Revision: D931931
The = command has recently been changed to use standard debugger serialization rather than to invoke a customizable function, or print_r otherwise. In the process a bug crept in that made the output not colored. This fixes that bug. It also updates the help text to make it clearer that = truncates text. While looking at that I noticed that the help text for the print command suggested that it's output is formatted with print_r. Fixed the text as well, but while I was at it introduced the "print r" flag to make it possible to invoke print_r, analogously to the already existing "print v" command. While adding test cases, I noticed that the truncation logic appears to be broken, so I fixed that as well.
Differential Revision: D931565
This diff adds a toArray() method to the Iterable interface, as well as
adding some other methods that were missing from the interface (map(),
filter(), etc). It also deprecates IterableTrait and KeyedIterableTrait,
introduces LazyIterable and LazyKeyedIterable as replacements, and adds
strict versions of the traits called StrictIterable and StrictKeyedIterable.
Finally, it deprecates the view() method (since I want to introduce a new
method named "view" that is semantically different) and introduces lazy().
Differential Revision: D923036
I think the current situation is actually correct (we'll just
potentially have extra entries in the multimap), but this makes more
sense.
Differential Revision: D918976
The limit was still a bool, so we could only specify a limit
of 0 or 1. Since 1 was working fine, I've dropped the default from 200
to 32, and will test various values to see what works best.
Differential Revision: D929190
Add source file and line to async functions on the debugger async stack. This information is only added for async functions which are not actually being executed. Those exist on the normal stack, and their location information is visible there. The location added for async functions which are not running is that of the yield which has caused the continuation to pause.
Differential Revision: D930103
I deleted some dead code, but more importantly, organized the remaining
platform-specific declarations into thematic areas that I think can be
tackled (i.e. moved into explicitly platform-specific modules) as
self-contained units.
My determination of what's platform-specific was fairly loose. If it has
"emit" in the name it is for sure. Note that functionality that only
depends on the TCA type is *not* platform-specific: that was the point
of my diff to separate DataBlock and X64Assembler.
To be honest, I wasn't 100% rigorous on preserving access modifiers.
They're mostly the same, but some may have been changed in the shuffle.
I contend it doesn't matter that much since these members should be
moving to different modules soon, and also this class has so many
friends that most of its "private" members aren't really private as
such.
Because all the rearrangement makes the diff hard to read, here's the
list of declarations/definitions I found to be dead:
- emitDebugPrint, dumpStack, translatorAssert. Not used in the normal
course of things, but it's possible people have been using them to
debug; if so, I'll put them back.
- emitReRetransOpt (not dead, but since the definition was just a call
to emitServiceReq and there's one callsite, I collapsed the chain)
- m_createdTime. It's declared in Translator (and only used there).
- emitIncRef*. These were moved to CodeGenerator earlier.
- toStringHelper. Unused.
- emitChainTo and emitIncCounter. No definition.
- {acquire,drop}WriteLease. We have a different abstraction for this.
- packServiceReqArg with one argument. It's not needed; that template is
not recursive.
Differential Revision: D929657
Instead of having all the cases split out, this just goes
through the reserve/escalate paths. I added geometric growth only to
the Smart mode in reserve (after the capacity check). This makes it a
little easier to change how strings allocate (fewer allocation code
paths).
Differential Revision: D924293
After some changes I'm making locally, this will need to be
Mode::Malloc or Mode::Smart depending on the size of the new string,
which is easier to do from inside this same function. While at it,
let's make it reuse the buffer if it fits within the current
capacity(). (This allows small strings to stay small also; although
microbenchmarks on string increments are not particularly impressed by
it.)
Differential Revision: D920271
I want to store the smart allocator size class here, so we
don't need to store it at the front of the smart malloced memory. (We
can just tell smart_free how big it was, and possibly inline dropping
it on the appropriate free list.) This isn't necessarily required for
that, but I decided to do it independently to make the changes easier
to think about. (It's also maybe a marginal step toward not requiring
null terminators on the strings in general.)
Differential Revision: D917550
Per discussion, create a stateless class for emitter utils that
can be implemented per-platform (to move code out of code-gen and
translator-x64)
Differential Revision: D927917
Sandcastle flib testing may be missing some coverage for the
JIT because tests that fail to get the write lease can execute in
interpreted mode. Add a runtime option Eval.RequireWriteLease that
forces a thread to block on acquiring the write lease, so all test
code will be jitted.
Differential Revision: D921235
Mwilliams noticed an "obvious bug" in c_Closure::init, where
it always sets the late bound class to the context class in static
closures. But it turns out thats what zend actually does. This
behavior seems like a bug, so we're going to preserve the late bound
class.
Differential Revision: D814837
There seems to be some strangeness left over from tx64 days. When the IR
took a slow exit trace, it would go through a "retranslate/interpret"
service request, which generated a stub translation that did nothing but
make an "interpret" service request.
I got rid of the BIND_JMP_INTERPRET and RETRANSLATE_INTERPRET service
requests, and replaced them with uses of the INTERPRET service request,
interping a single instruction.
Differential Revision: D927642
We carefully "enhugen()" portions of the tc. The problem is that low_malloc
maintains a high water mark, and every time it crosses into a new huge page
it marks everything up to the new high water mark huge. Since we allocate the
tc using sbrk, which allocates above the high water mark, the next time
low_malloc extends its arena, we mark the whole tc huge.
This adds some code to update the high watermark around the tc, and adds a runtime option to limit the number of huge pages used by low memory.
Differential Revision: D912684
- pull fixup/sync code outside of translator-x64
- push codeblock related functions from asm-x64 down to codeblock to
enable this
Differential Revision: D924632
This stuff all just punts to the interpreter, and there isn't such a
thing as a no-IR translation anymore, so let's clear this up.
I started thinking that maybe one of these steps isn't strictly
necessary. Currently, when we take a "slow" exit trace, we make a
RETRANSLATE_INTERPRET service request, which ends up creating a
"translation" that is nothing but an INTERPRET service request. This
feels like one more step than necessary; I think ideally we'd write out
an INTERPRET service request right in the exit-slow trace, but the
trouble right now is that at the point where we need to write it, we
don't know how many instructions should be interped.
Differential Revision: D925897
fast absolute value computation and related optimizations
implemented Abs in interpreter
implemented Abs in codegen
added const folding for abs
updating docs
adding new test for abs()
Differential Revision: D896037
These seem to be the last bytecode instructions left
to be translated that deal with namespaces and lookups, so we
might be able to get an OSS perf win out of them.
Differential Revision: D922132
This file uses the ##getPercentileEstimate## templated function
without including the apprpriate header which defines it. I'm
not entirely sure why building with gcc-4.8 triggers this issue
but it appears legit regardless.
Differential Revision: D923985
gcc-4.8 exposed this issue via the end-of-array-subcript warnings.
The issue is that the top pointer is incremented before that check
to see if the push should happen. If the push failed, the top
pinter is left incremented.
Differential Revision: D923932
A new runtime option will allow you to run in client
mode, but hang the execution thread until pprof collects the
heap dump or the HHProf thread timeout expires.
Differential Revision: D918754
initialize thread locals first since static constant
initialzation assumes the memory manager is initialized
Differential Revision: D924209
Blame Revision: D915702
Every callsite of apc_unserialize constructed a String from a char*
and a length (involving at least one smart allocation, and a copy of the
data), passed it into apc_unserialize, which then extracted the char*
and length.
Just deal with the char*/length instead.
Differential Revision: D924015
php.net manual URLs transform the function names
to use hyphens insteaf of underscores. The autogenerated
docComments should reflect this.
Differential Revision: D922807
PHPUnit self-test suite calls get_included_files(). Right now we return an empty array. That's not right. Implement correctly. Add and modify some tests as well.
Differential Revision: D922888
This is one of the major spurious couplings I identified in my attempt
to get some code running in the ARM simulator. Currently, anything that
cares about the frontier of any of the code slabs is necessarily coupled to
X64Assembler, which doesn't make sense.
The solution in this diff is to remove DataBlock as a member of
X64Assembler. DataBlock is now in its own file, and TranslatorX64 has a
DataBlock member for each X64Assembler member. X64Assembler has a
pointer-to-DataBlock member. (I tried having it be a reference but that
doesn't work; in TranslatorX64::TranslatorX64() we have to construct
X64Assemblers without having their DataBlocks ready yet.)
I also discovered that the original reason for having DataBlock be a POD
type and having CodeBlock as a separate type seems to be gone, so I
consolidated the two classes and cleaned up some dead code.
There is more to be done here, which is to actually reap the benefits
and stop calling frontier() on X64Assemblers in translator-x64.cpp and
elsewhere. I'll do that in a separate diff because this state is a good
intermediate point.
Differential Revision: D918496
Expose the async stack in the debugger. This is the stack of, say, generators driven from the ASIO extension. This is a modification to the where command. The new command type accounts for back compat between old servers/clients. I've added a shortcut, "wa", which is a bit faster to type.
I also modified the normal stack trace to not print bogus lines for functions with no file/line info.
Differential Revision: D920910
We were reading uninitialized memory from tx64 member
variables and failing an assertion about the size of trampoline code.
(As far as I can tell, nothing really depends on the exact size of the
trampoline except for the guess about how many trampolines we can
fit.)
Differential Revision: D922916
In trying to track down performance regressions I found it
was useful to generate printir:1 logs and compare them (Ed's idea). I
figured others might find this useful so here's the test runner
support and script I used.
Differential Revision: D908406
Looking at uses of the collection constructors, addAll, and setAll, I
noticed that it would be convenient if these methods tolerated null.
Also update Set::difference to support arrays.
Differential Revision: D923013
HHVM was incorrectly allowing collections to be used in class constant
definitions. This diff fixes the bytecode emitter to throw a parse error
if a collection literal is used in a class constant definition.
Differential Revision: D922848
- segfault handler never panned out and has been off for 1.5
years; cheaper to resurrect later from git than refactor to take it out
of tx64
Differential Revision: D922900
When a diff that causes many tests to fail runs on contbuild,
it usually ends up timing out because the machine spends so much time
writing core files to disk. These files are almost never useful
anyway, so don't generate them.
Differential Revision: D922720
openssl_seal() and openssl_open() should both take an optional method parameter which allows you to select the symmetric cipher to use. This implementation is slightly different than Zend PHP, currently if you pass a cipher that requires an IV it segfaults in Zend, in this implementation it warns and returns false.
Differential Revision: D921384
The first implementation of async functions doesn't support
awaiting on expressions that are null. This adds support for this
in a way that the generator is not even suspended in these cases.
Differential Revision: D922499
The behavior of isset($x[$k]) and empty($x[$k]) where $x is a string has
changed in a recent version of PHP. This diff updates HHVM to match PHP
5.5's behavior. Note that HHVM still does not match Zend PHP 5.5 perfectly
in terms of warnings for these expressions; I've decided to put that off
into a separate diff.
This also brings HHVM up-to-date with respect to some edge cases for
automagically converting integer-like string keys to integer keys when
indexing into PHP arrays.
Differential Revision: D916630
I just went through the header and grepped for each member function
name, and it turns out a bunch of them were declared and not
implemented, or were implemented but not used.
This clarifies the picture of what assembler-coupled functionality
remains on TranslatorX64:
1. Func prologues and their transitive dependencies (including
unfortunate stuff like a duplicated implementation of emitIncRef).
2. One-time-use stub emitters.
3. Syncing VM registers.
This makes the project seems a little tamer. Func prologues are
definitely the biggest part of it.
Differential Revision: D921995
Lots of scripts running in cli mode can quickly use up the huge page pool. Its better to not do that by default.
Even in server mode, it seems very suspicious to have large, thread-private segments of huge
pages. This should place heavy demands on the system's huge page resources,
and more worryingly, demand that scales up as threads go active.
Differential Revision: D885896
Instead of manually constructing a cookie, use the setCookie method
provided by Transport. This prevents the following kind of condition:
Imagine:
application runs setcookie with null params to delete a cookie.
application runs session_regenerate_id to get a new session id.
session_regenerate_id then constructs a new header through
m_responseHeaders.
Eventually, Transport will generate headers, but will always put
m_responseCookies after m_responseHeaders in the full header.
Uh oh! Now we have accidentally deleted a cookie due to incorrect header
order.
Closes#950
Differential Revision: D921467
Enable guarding tracelets on ArrayKind when we can generate
better code for a specific kind.
Added specialized helpers for CGetM, FPassM, and IssetM of
vector-shaped arrays. This eliminates an indirect call and allows the
entire array-access call stack to be inlined into the helper
Differential Revision: D873631
In Zend, $_SESSION is undefined (i.e. reading it either directly or
through $GLOBALS results in an 'undefined' notice) until you call
session_start.
Right now we're not completely matching Zend on warnings, although we
get closer if you build with HHVM_MORE_WARNINGS (see
member-operations.h).
Differential Revision: D920224
There were two bugs:
- Methods from Systemlib traits that were imported into user
code were still marked as system methods, so we didnt run
type inference on them, so the parameter wasn't annotated correctly;
- If we couldn't determine whether a function argument was by reference
or not, we could end up marking *that* as being the thing that set
the parameter. If later we figured out which function was being called,
we marked it as *not* by reference, and then it looked like it was being
used without being set.
With this diff, we set the system/user flag correctly when cloning methods,
and always mark the "declaration" of a parameter as the parameter itself.
Differential Revision: D920269
We should only call values() when we absolutely have to (magic calls where the array is not a vector)
Differential Revision: D920504
Blame Revision: D917994
- Eliminate Util::safe_strerror and use folly::errnoStr instead since the former is less safe as it doesn't preserve errno
Differential Revision: D920282
Add a function to get the wait handle dependency stack to the native implementation of WaitableWaitHandle. This will be used by debuggers and profilers to get the stack of dependencies for generators driven from ASIO.
Differential Revision: D919486
Looking at the generated code for various StringData mode
dispatch cases, there were 64-bit immediates being put in registers
often to test the format value. We also did masks on the capacity
just to see that the string was small. This switches to just load the
byte that actually contains the mode, and use a 32-bit integer for
capacity (the largest string size fits in this). Small checks only
need to compare that byte with zero.
Differential Revision: D914034
This was busted in two ways:
1. SSL_OP_NO_TLSv1_1 wasn't guarded by an ifdef in one location
2. SSL_OP_NO_TLSv1_1 was used instead of SSL_OP_NO_TLSv1_2
in one location.
Differential Revision: D917255
We'll need the ability to call native functions (i.e. written in C++)
out of the simulated-ARM translation cache. VIXL already has support for
pseudo-opcodes that the simulator understands and treats specially (it's
a trap instruction with payload in some unallocated bits), so I added a
new one that will read a function address out of an inter-procedural
scratch register and arguments out of the usual argument registers, call
the native function, smash simulated caller-saved registers, and put the
return value in the simulated return value register.
Differential Revision: D916164
Some developers were a little confused by the warning message printed when
a sort comparator returns a boolean. This updates the messages to be more
clear and more explicit.
Differential Revision: D909645
Symfony relies on class_exist('Locale') to check if the intl extension is
enabled. By removing this Locale class, we let Symfony use the stubs they
provide.
Differential Revision: D908679
Add a new runtime option: Server.PspTimeoutSeconds.
If its zero, postsend gets the same timeout that the request was running under. If its less than zero, postsend will get min(time remaining for main thread, -Server.PspTimeoutSeconds), and if its greater than zero, it will get exactly Server.PspTimeoutSeconds.
In addition, fixed cli mode to respect Server.RequestTimeoutSeconds.
Differential Revision: D914478
Test cases inspired by zend test bug35239.phpt. I think
there are other cases where SETOP_BODY should be SETOP_BODY_CELL, but
I looked at them mainly to see if they would crash, not if they were
optimal. (Except I changed SetOpL which seemed to be doing tvToCell
twice for no reason.)
Differential Revision: D910025
We dereferenced some potentially-freed memory only in order
to return something no one needed. Remove the return value from
ObjectData::setProp.
Differential Revision: D909967
To implement a session module in PHP, add a small C++ class
in runtime/ext/ext_session.cpp
static class MySesionModule : public SystemlibSessionModule {
public:
MySessionModule() : SystemlibSessionModule('my', 'MySessionModuleImpl') {}
} s_my_session_module;
Where 'my' is the name of the session handler (as known by the ini setting)
'MySessionModuleImpl' is the Systemlib PHP class implementing SessionHandlerInterface
Differential Revision: D872889
The MySQL documention states that mysql_next_result's return
values are:
0 Successful and there are more results
-1 Successful and there are no more results
>0 An error occurred
However, we were casting it to a bool, meaning errors and "all done"
were mixed into the same result.
This diff brings back the full error range.
This diff requires D912547, which fixes unit tests to accept both the
new and old return value types.
Differential Revision: D912553
The old code was constructing a Variant on the stack just to
decref it via the destructor. Just call the decref directly and avoid
a few memory operations.
Differential Revision: D913228
Make the fb303 server work with port takeover. We need to give it the same
treatment as admin server / satellite servers. Sorry I missed this part before
and being lame.
Differential Revision: D897344
Strings are usually small, and failing that, usually smart
allocated. Also, release() doesn't need to check for a null pointer
now that it's not controlled by the DELETE macro. This just inlines
the small path and gets rid of the null check for now.
Differential Revision: D907960
This is a step toward having StringData take control over how
it talks to the smart allocator based on its constructor parameters.
For now nothing is done to prevent allocation without going through
the new proxy function, but the nested allocator type is renamed to
prevent adding new uses of NEW or DELETE.
Differential Revision: D907959
Why does this exist? Can't we just rely on the key being there? I've seen tons of functions with this flag and no comment...
Differential Revision: D909139
Adding basic support for async functions using continuations, which should be semantically fully equivalent to yield wait_for() etc.
Differential Revision: D911571
Let's move the type inference for generators from function scope to
function call, so that the original infered type is kept in func scope
and can be used later (will be useful especially for async functions
lates).
Differential Revision: D913970
Currently, normal functions are not allowed to have modifiers and
closures can be marked only with 'static' keyword, which needs special
treatment in the parser. Let's change it so that it's parsed in the same
way as method modifiers. This will help us later when introducing 'async'
modifier for both functions and closures.
Differential Revision: D913903
This replaces ArrayInit's vectorInit constructor. When we
know we're making a vector-shaped array, there's no need to
internally use the general array api; ArrayInit provides the
api, internally we do what's fastest.
Differential Revision: D903252
Create and use set[Val,Ref] and init[Val,Ref,Lval,WithRef]
helpers, to factor out tricky, repetitive code. These will
get even more airplay as we add more shapes.
This diff also fixes a bug in PopVec(): we need to erase the
value (and update the array's fields) completely before
calling decref on the value. Getting this wrong can mess
things up with array<->object cycles because calling decref
can reenter another array method, which would see the fields
in an invalid state.
Differential Revision: D905136
The units that result from Eval code injected by the debugger should always be interpreted because they are used once only, however, any code invoked by these units should be JITtable. This diff moves the test for disabling the JIT from VMExecutionContext to Translator::isSrcKeyInB. It also fixes a cut&paste error that inverted the logic for Unit::isInterpretOnly().
Differential Revision: D913723
Blame Revision: D904873
The PHPUnit test suite calls get_defined_constants(true), for categorization. We threw. Now we don't. Now we actually do something sort of correct, but not fully correct. We have a "user" and "core" constant categorization. Function cleanup and consolidation. That's good. But Zend categorizes even more into extensions. This is a first step. And two (2) tests now move from zend/bad to zend/good.
Differential Revision: D909942
Breakpoints correspond to source lines, not byte code operations, so more than one operation may correspond to a break point. Each operation checks for breakpoints, so breakpoints are disabled when encountered, otherwise commands such as continue and next would get stuck on a line until all the byte code operation for a line have been carried out. Such break points are re-enabled as soon as a byte code for another line is executed. This does not work if no other byte codes are carried out (i.e. if JITted code runs) until control loops back to the disabled break point. Consequently the disable logic now keeps track of the offset of the byte that first triggered disablement. If the break point is still disabled by the time control comes back to that byte code, the break point is temporarily enabled.
Differential Revision: D909092
The region selector will now refrain from choosing paths
through the translation CFG where the postconditions of the
sequence of blocks chosen up until that point have no chance of
passing guards.
Differential Revision: D907313
The debugger's API mode added a lot of extra complexity to the debugger client for minimal value. It also had a bunch of bugs, and unnecessarily tied alternate debugger clients to the command line client implementation. Deleting it.
Differential Revision: D912729
This will let us use TLSv1.2 or specialized cipher suites on internal
requests while avoiding breaking Microsoft and other partners on
external requests.
Differential Revision: D912541
We need a way to configure which cipher suites are used when
we are acting as a TLS client using Curl. This option accepts
the standard OpenSSL cipher suite spec, which will allow us
to turn off some cipher suites.
Upgrading OpenSSL without this will cause us to send too many
cipher suites in the client hello, crashing Bing's F5 load
balancers.
Differential Revision: D911814
This was a little weird: I deleted the definition first, and everything
compiled because all the usages now are behind ifdefs that we don't test
regularly. In the interest of not ruffling feathers over deleting this
code, I just went ahead and made the changes. I would like to suggest
deleting all this stuff, especially the GOOGLE_HEAP_PROFILER stuff, for
which the make target has been deleted for a long time.
Again, all the usage sites are using the default memory order specifier,
which is memory_order_seq_cst. They could stand to be relaxed, but I
didn't find it worthwhile.
I'd also like to replace atomic_acquire_load and atomic_release_store
with portable and correct alternatives. We really just shouldn't be
rolling our own atomic primitives.
Differential Revision: D909903
As I try to include vixl from the jit backend, these macros are clashing
with ours. Codemod them all to use our macros from util/assertions.h.
Differential Revision: D912687
The vector shape code calls addVal() in more ways than
before, so there might be client code seeing uninit when
they used to see null before.
Differential Revision: D912686
Blame Revision: D879416
Request Start has no activation record on the stack, but Next is quite valid and should still work. Modified to tollerate the lack of act rec.
Differential Revision: D908499
Incrementally renaming foo_bar.* to foo-bar.*. runtime/vm
is nearly done, getting started on runtime/base. This does
a dozen or so files, will do more in separate diffs.
Differential Revision: D910489
This seems to get JitRegionSelector=hottrace working in perflab. I
still left all functions being profiled in non-server mode, so that we
can run tests and measure benchmarks.
Differential Revision: D908942
If a URL doesn't exist and is going to 404, we set `m_originalURL` to the 404 handler, but don't update the boolean to the fact that it hasn't been rewritten yet.
Differential Revision: D911365
I slipped and locked the wrong mutex on the signal polling thread with a recent diff, allowing two threads to send to the client at the same time. Fix that, and remove the other similar lock which was superflous.
Differential Revision: D911162
Blame Revision: D897309
We can call faster helpers for intermediate m-ops when we
know the base is an array, saving us a switch-table dispatch in
Elem(). In practice this only applies to the first intermediate m-op,
because subsequent ops won't have known type. At least for now.
Differential Revision: D903464
As far as I know we haven't used this in a while, we don't build with it
regularly, and in fact the Makefile with the commands to build with it
has been deleted since right around the fbcode transition.
It turned out to be the only thing holding LeakDetectable in the
codebase, as well as a runtime option.
We should just use jemalloc's profiling now if we need heap profiling,
and maybe a bit of valgrind too.
Differential Revision: D910760
When the user provides a custom SessionHandler via the function
session_set_save_handler, we need to cache the current SessionModule,
as it will be the one called by the user's SessionHandler.
Also added a check to make sure we don't call set_save_handler when
the current handler is already a user-defined one.
Differential Revision: D910794
I've implemented type profiling in the jit, I added an ir opcode that will log one parameter or return value of a function. I emit that opcode during an FCall, and during a RetC. Each Func object maintains an array of atomic hashmaps (for each parameter), and the atomic hashmaps are basically just counters for each type at runtime.
Differential Revision: D890038
A number of debugger commands end up doing an eval inside the VM. These eval's are ad-hoc and are performed in human time scales. There is no need to cache them. Consequently, call compile_string directly, rather than call it via compileEvalString (which does caching). Also make sure that the result of compile_string is always interpreted so that no JIT caching happens.
In principle, caching ought not to matter, but another bug is causing the JIT to fail an assertion if a cached eval string is recompiled in a context where variables that were bound are no longer bound.
Differential Revision: D904873
Modify ctrl-c handling in the debugger to give up and kill the client after three presses, rather than 10 seconds. Change the wording as ctrl-c is pressed to hopefully be more clear.
Differential Revision: D908728
Resurrecting this thing I did ages ago. It's mostly similar and
mechanical, except for the stuff in SharedVariant. I got rid of the
anonymous union and struct because that doesn't play nice with the
std::atomic constructor. The static asserts below should give us all the
same guarantees we had before.
Note that I'm freely using operator++ and operator--, which use the
sequentially-consistent memory order for their underlying ops. However,
I've looked on both x64 and ARMv8, and these ops in particular do the
exact same thing regardless of what memory order specifier you pass.
Differential Revision: D909344
When we hit a breakpoint while processing a CmdEval, we print the line that we hit the breakpoint (which we see), then we send a nested CmdList to the proxy to get the source file. There is no handling of exceptions in CmdList::onServer(), so any exception would bubble out of the server-side command execution. Normally an exception at such a point would cause the proxy to shutdown, but there is a ton of quite general error handling around eval, and it looks like it will swallow the exception and merrily attempt to complete the processing of outstanding CmdEval, thus sending a CmdEval to the client and generating the output we see.
This diff adjusts the code in the catch(...) block in DebuggerProxy::processInterrupt() to log instead of trace, and introduce a similar catch of Exception to dump what we can about the exception. That would give us more data to start to track this very transient problem down.
Differential Revision: D908369
The behavior of isset($x[$k]) and empty($x[$k]) where $x is a string has
changed in a recent version of PHP. This diff updates HHVM to match PHP
5.5's behavior. Note that HHVM still does not match Zend PHP 5.5 perfectly
in terms of warnings for these expressions; I've decided to put that off
into a separate diff.
This also brings HHVM up-to-date with respect to some edge cases for
automagically converting integer-like string keys to integer keys when
indexing into PHP arrays.
Closes#844https://github.com/facebook/hiphop-php/issues/844
Differential Revision: D905081
Guards on object class (and, eventually, array kind) need to
load the ObjectData to get at the class. This is the same operation
as a LdLoc, so if we use that IR instruction to implement the class
guard we can CSE the LdLoc where the object is actually used.
Differential Revision: D906267
Factor destType and the destination register/ssa situation
into one parameter instead of a family of up to 3. Remove the TCA
overload (casting to TCA at every callsite is no more convenient than
making a CppCall at every callsite).
Differential Revision: D903862
Skip little wrapper functions for few non-virtual member
functions, and add support for immediates to native-calls so we can
call StringData::toInt64 directly with the defaulted argument.
Differential Revision: D903835
I did this because I thought we couldn't call member
functions the way things are, but apparently the direct interface
check stuff was already doing it, just with appropriate casting
through Util::getMethodPtr. This still seems nice though, so I'm
putting it up (less casting in the actual table...).
Differential Revision: D903831
The MySQL documention states that mysql_next_result's return
values are:
0 Successful and there are more results
-1 Successful and there are no more results
>0 An error occurred
However, we were casting it to a bool, meaning errors and "all done"
were mixed into the same result.
This diff brings back the full error range.
Differential Revision: D907075
StringData::getPrecomputedHash was unused. The
isValidVariableName thing was a thin wrapper on a zend function that
is hardly used, and it shouldn't be a member function anyway. The
convert_double_helper and convert_integer_helper also shouldn't be
member functions, and the former duplicated buildStringData(double)
too much for me so I removed it.
Differential Revision: D903915
String::set was one of two users of StringData::Escalate.
Leaving the remaining use alone for now until I know where it'll go.
Reordered some members and updated some comments.
Differential Revision: D903882
- Per Github, URL/code filters, if specified, actually filtered
out only the code/URL as opposed to restricting it to the URL/code of
interest
Closes#912
Differential Revision: D906156
You can now cancel profiling by sending a GET request to
/hhprof/stop. I also added an extra thread to the server so you
can un-hose yourself if one thread is waiting on a profile, but
it's still possible to deadlock if multiple clients try to get
the profile.
Differential Revision: D897271
/hhprof/start will now also take parameters:
type = "next" (default) or "global"; "next" will profile the
next request or the next request to a particular URL if the url
parameter is present, and global will profile all requests until
stopped (but waits for at least one)
url = <some url>; if present and the request type is "next", then
it will get a profile for the next request to the given URL.
Differential Revision: D896989
hhvm will now respond to pprof requests. Start up a
server, curl /hhprof/start to put in a request to profile, then
fire pprof at /pprof/heap to get a heap profile.
Differential Revision: D896906
This diff fixes a bunch of issues with interpOne of vector
instructions that only show up when the rest of the trace is
translated normally. I ran into them trying to perflab turning off the
vector translator.
Differential Revision: D901267
A couple of developers on github have reported that they've hit errors at
parse time with certain expressions that work under Zend PHP, or that they
have gotten output unexpected tokens from token_get_all(). A lot of this
is related to the lexer/grammar rules for XHP, so an easy solution to fix
a lot of these issues is to set EnableXHP=0 by default and to make some
changes to the lexer to make it more Zend PHP compatible when EnableXHP=0.
Closes#740Closes#846https://github.com/facebook/hiphop-php/issues/740https://github.com/facebook/hiphop-php/issues/846
Differential Revision: D905986
Something was just missed in an overall conversion effort. Found this in PHPUnit testing. @ptarjan was quick to diagnose!
Differential Revision: D907670
Generators are natively represented by 2 functions, which are now generated
by parser. Not only it's more natural to do this only when we emit bytecode,
but it will also allow us to reuse this logic for implementation of async
functions.
Differential Revision: D898769
Currently, check registers works by traversing down the dominator
tree. Effects on registers from a dominator block can be seen
in each dominator child. This will miss a rogue assignment that
happens in a block that does not dominate one of its successors.
For example if we mis-assign to a register in one arm of an if-
then-else block, we won't notice.
This diff changes checkRegisters() to propagate register state
along flow edges, so we can catch such rogue assignments.
Differential Revision: D903949
The fallback for repo-schema and compiler-id
generation when not building from git was to use the system
microtime. Unfortunately, using a '.' in the repo-schema
leads to bad SQL table names. Use an underscore instead.
Differential Revision: D906623
We're seeing that some opt builds crash if you throw from
__sleep. After a lot of debugging, it looks like the eh_frame section
contains a bogus entry for php_sleep (in addition to the correct one),
and eh_frame_hdr's entry points to the wrong one (if I intervene in
gdb and point it to the right one, everything works).
I'm pretty sure this is a bug in gold (the eh_frame data appears
to be correct in object_data.o), and changes to unrelated code
make the bug appear and disappear.
I'm not sure exactly what the issue is, but php_sleep is basically a
hangover from hphpc days, so I'm killing it (and modifying the meaning
of HasSleep slightly - it now means what you expect). Not very satisfying
but hopefully it will work...
Differential Revision: D906292
This new static API will allow the coming pprof server
to request and fetch profiles, and VM threads to offer profiles
if they fulfill the currently active request. Some cleanup was
also performed to refrain from repeating stuff.
Differential Revision: D896872
pprof will request symbols from a running HHVM via
POST request when you try to run it in remote mode. This adds
the ability to format SrcKeys in a reasonably human-readable
format so pprof can deal with them, and it can be manually used
by turning on TRACE=heap:3.
Differential Revision: D895234
Heap profiles can now be dumped in pprof format using
ProfileDump::toString. The memory profile instrumentation now
dumps this data at the end of every request when TRACE=heap:2
is set.
Differential Revision: D894112
When converting a Tracelet that contains an inlined FCall,
flag its block and then insert block(s) from the callee between the
FCall and the next instruction in the caller. The region translator
also required a few changes to support the inlined blocks.
Differential Revision: D863939
Pretty straightforward. I renamed all the Op<name> opcodes to
just <name> to avoid collisions with the bytecode Op<name> constants.
Differential Revision: D867723
I haven't completely figured out what's going on here, except
that we're running the same Func with and without the global varenv
attached. This was confusing the guard code and so we weren't emitting
guards for a local. This diff fixes up things so we do emit the
guards, but the global varenv issue still needs to be sorted out
before the new assert in translateTracelet can be left on.
Differential Revision: D899963
Pushes the sqrt builtin down to codegen for ints and
doubles, which might help on some microbenchmarks, and adds
sqrtsd to the assembler.
Differential Revision: D898146
`rewind()` is an overridable method in children. composer does just that, and expects the objects to be fully formed by the time it is called. Lets use a private helper instead, so user-code isn't called in the constructor.
Differential Revision: D904037
Apparently printir is so slow because of the symbol lookups
here. Let's just leak a memoized table (we probably don't actually
have that many distinct symbols to look up). Also, it looks like this
code writes one byte further than it's supposed to in the output
buffer (the docs for the xed callback say the buffer_length includes
the null terminator).
Differential Revision: D902605
This check in the prologue didn't make sense to me---I'm
pretty sure it's impossible for the branch to be taken, since we've
already set up c_Closure::m_thisOrClass such that it will contain a
Cctx. Am I missing something?
Differential Revision: D894574
Inline some of the things into the TC so it can be
specialized on the closure type. Also avoids spilling everything to
the stack to call init (which just pulls it back off and puts it into
the heap), and uses AllocObjFast instead of newInstance. (We can't
quite get the super-fast-path version of AllocObjFast because closures
are extension objects and for now trying to convince it not to use the
m_InstanceCtor is a bit lame---we should probably just generate the
classes as php-level classes at some point so that'll just work.)
Differential Revision: D894569
As bodies of closures are not part of standard syntax tree, doOptimize
doesn't optimize them; this diff will fix this. It should have no
impact on performace as doOptimize is not used in WholeProgram mode.
Differential Revision: D904216
getKeyTypeI/S/IS were artifacts of how keys were passed in
TranslatorX64 and no longer serve a useful purpose. emitVGetProp had
the same issue that was fixed in D902733 (no helper for Int keys).
Differential Revision: D904487
Zend 5.5 allows you to unpack arrays into the key and
value expressions in a foreach loop. This implements the same
functionality in HHVM.
Differential Revision: D900264
Implement PHP_BINDIR PHP core predefined constant. PHPUnit (via PEAR) uses this constant in its self-test suite, causing many of them to fail on HHVM (possibly only because of the lack of this constant). Try to ninitially implement in such a way that it can be nimble enough for open-source, cross platform.
Differential Revision: D900077
Use exec("curl ...") instead of the curl API to make server requests, so that every interaction with the server can be traced and logged.
Differential Revision: D902614
We had both "prologue" and "prolog" all over the place, and it was
starting to drive me nuts. I picked "prologue" because it seems to be
the more standard spelling. Both are valid in American English, but in
the rest of the English-speaking world, only "prologue" is standard.
Differential Revision: D904232
I was having trouble gettig the binary into phabricator so the test wouldn't pass, so I committed the phar anyways. Now that the phar is in, a test should see it.
Add priority to hphp's job queue. Basically internally we keep multiple
queues. Whenever a worker gets notified of a job, it'll look at each queue in
order from highest pri to the lowest pri. This is inefficient if we have a large
number of priorities. But in reality we'll only have a handful of priorities. So
this should be faster than a heap implementation.
Add a runtime option to be able to specify a set of end points to be prioritized
over regular requests.
In practice, we'll only have 2 priorities, high and normal. For high, we only
plan to put status.php there. This is so the web server can respond to health
check even under high load.
StackTraceProfiler.count() captures a stack trace at the point you call
it. It's also useful to create a stacktrace, then add it to a profiler
later on. For example, create a stacktrace when you allocate an array,
then count it when the array reaches some state (destruction, growing,
changing shape, etc).
At present, "$obj -> class" (with spaces) causes a parse error under HHVM
but it parses okay on Zend. The problem is that HHVM's lexer treats "class"
as a keyword when there are spaces after the "->". This diff fixes HHVM's
lexer appropriately.
Closes#833
This fixes https://github.com/facebook/hiphop-php/issues/833 .
I added this in hopes it would make it easier to do parser
development faster---in practice I find myself preferring to just wait
on the build times for compiler/parser instead. Changes to the parser
too often involve the need to fix the crazy callback interface over
there, and it's not worthwhile to maintain it in two places. Oh well.
Making the parser more modular to develop on is probably worthwhile
but I'm calling this a failed attempt.
In case it scares anyone that I'm deleting tests: this test suite
wasn't really intended to find bugs, but I think it's unlikely it
would (the normal tests have to parse everything anyway).
The implementation was trying to look up a specialization for
ints, but there isn't one, so it would hit an assertion on opFunc in
debug and call to a null address in release.
In HHVM we've been piggybacking resources on the KindOfObject machinery.
At the language level, resource is considered to be a different type than
object, and there are a number of differences in behavior between objects
and resources (ex. resources don't allow for dynamic properties, resources
don't work with the clone operator, the "(object)" cast behaves differently
for resources vs. objects, etc).
Piggybacking resources on the KindOfObject machinery has some downsides.
Code that deals with KindOfObject values often needs to check if the value
is a resource and go down a different code path. This makes things harder
to maintain and harder to keep parity with Zend. Also, these extra branches
hurt performance a little, and they make it harder for the JIT to do a good
job in some cases when its generating machine code that operates on objects.
This diff introduces a new DataType called "KindOfResource", it separates
ResourceData from ObjectData's inheritance hierarchy, introduces a new
smart pointer types called "Resource" and "SmartResource", updates the
runtime as appropriate, and kills some more dead code in ObjectData and
ResourceData. I've tried to keep behavior the same for the most part and
resisted the urge to fix existing bugs with resources.
Push the remaining time through to the pagelet's HttpRequestHandler,
and fix HttpRequestHandler::handleRequest to use the timeout we pass in
(the latter was an inadvertent omission from my previous timeout diff).
In the name of making incremental builds faster when headers
change, I've pulled NormalizedInstruction out of translator.h and
replaced it with a forward decl.
We can never make the ctrl-c portion of the debugger server test 100% reliable. Removing that portion of the test. I'll replace it with something else soon. See task 2656173.
curUnit and friends are evil and have been the source of many bugs
I've had to track down in the region translator. Time to force an audit of all
callsites. Most of the uses of curUnit() could be changed to grab the unit from
somewhere else, and the few where that wasn't reasonable use liveUnit to make
the intent more clear.
Server-side cleanup was all driven by having a request thread see that either the connection with the client is closed, or the stopped flag on the proxy is set. However, if a debugger's in the run state and there's just no incoming requests against the right sandbox, then that would never happen. However, the signal polling thread is perfect to notice, there were just issues coordinating the cleanup of the proxy.
Modified stop() on the proxy to be callable from any thread, and to initiate cleanup of the proxy but pass the final cleanup off to another thread which can complete it. The signal polling and dummy sandbox threads are owned by the proxy, so they can't complete the work themselves. There was logic to queue cleanup just for the dummy sandbox, so I turned that into proxy cleanup and have it cleanup both.
I'll investigate making a unit test using the new framework that will test this, but that will come in a later diff since this diff is already quite involved.
During a segfault, we continue to accept incoming connections. This is
bad as the web server is unlikely to do a good job of serving these well.
Here we close the listen socket as soon as we discover the server is crashing.
A more robust way to do this might have been to have an array of FDs that
are listening for incoming connections. We could have then closed those
from the signal handling thread. This would complete the operation more
quickly and also handle a case where the libevent thread wasn't running.
However, this version was quicker to write.
I didn't understand why some signals didn't trigger the Segfaulting variable.
Does anybody have insight into that?
Add an option to hhvm to 503 requests if they have been sitting on the select
queue for too long. Threshold is configurable via runtime option and default off
for now. This works with either LIFO or FIFO mode. Basicallly before worker
dequeues a request, it peek at the beginning of queue to see if it's expired. If
so, it takes that off the queue and aborts the request without executing
anything.
The = command uses formatting that is user customizable and subtly different, by default, from the formatting used by the print command and the variable command. This has historical roots. It seems that the debugger used to use print_r, which is brittle, and the customization hook was introduced to work around this brittleness. This work around is no longer necessary since the debugger now has its own, robust way of formatting values as strings. Also, the difference between = and print is a perennial source of confusion for debugger users.
I had previously made the error handling in DebuggerCommand::Receive() too strict, and we'd fail to read available data from the socket when it was closed right after the data was sent. Loosened it, so if there appears to be data present we'll let the thrift layer have a chance to read the data.
I also moved the remaining log messages in that function to traces. There are cases where it is nice to see such a log message printed, but those are very rare and have not happened in the wild in the past many months. Log messages here particularly from the signal polling thread make our test output non-deterministic, and there's higher value in having stable tests :)
This diff fixes a crashing bug that can happen when multiple properties are
declared in a single statement and some of the properties are initialized
using collection literals, for example:
public $x = Set {}, $y = 1;
We did not properly export NULL values as null; instead they
appeared as empty strings. In addition, we returned all ints, floats,
etc, as strings rather than properly typed.
This diff adds support for typed return values (ie, ints, floats, etc)
rather than just strings. It also changes returned maps and vectors to
have actual null values when the underlying result set returned nulls.
The debugger tests that are run via hphp/test/ext/test have now been replaced by tests that run via hphp/test/run, so they can be deleted as they test nothing additional and appear to be flaky.
This diff generalizes the AHotSelector (now called AsmSelector) to
select an assembler among 'a', 'ahot', and 'aprof'. 'aprof' is only
allocated and used in JitPGO mode, and it's used for TransProfile
translations.
Memory profiling is going to rely on these things not getting
destroyed, so we are intentionally going to leak them in this case.
The use case of this is that the memory profiler is going to store
a stack trace as a bunch of SrcKeys, which can be used with D892173
to look up the original Func the stack trace goes through. Since we are
looking up the Func potentially much later than the SrcKey was
originally recorded, there is no guarantee that the Func will still be
around, or that we won't grab a pointer to it only to find that it is
in the middle of destructing and is thus full of garbage.
Dumps information about allocation events in smart
allocator, and aggregates some information such as bytes
allocated per callsite in the current request (or across
requests). This information can be gathered in the heaptrace
command, and the information collected during the trace is
enough to find how much memory an object is responsible for
(i.e. keeping reachable).
It's all conditionally compiled because perflab showed a pretty
significant instruction regression if it was a runtime option.
You'll need to fbconfig with --extra-cxxflags=-DMEMORY_PROFILING
in order to use it.
This isn't done, but I wanted to get some feedback on where I
should take this (general design, what to log, where to dump
stuff, etc)
These structs will eventually hold the heap profiling data
for PHP request heaps, so that it can be gathered and displayed
using the pprof tool.
This was tested by layering the smart allocator stuff on top and
making sure everything worked as planned. Nothing uses the structs
in this diff, so it's kind of difficult to test otherwise.
This brings the tracelet region selector to 100% coverage,
though perf is still not at parity. Guard relaxation/specialization
and inlining are the big remaining features that will help perf.
In one of my pending region compiler diffs, I added code to forget the
values/types of locals after some FCalls (not doing so was wrong but we were
mostly getting away with it). This exposed an issue where the known type of a
local in the IR was less specific that what Translator::analyze was using. The
more specific type came from metadata on instructions after the FCall, so this
diff applies metadat to the IR before translating each instruction, using the
same code I wrote for the region compiler.
The changes to apply the metadata are pretty small; most of the
changes in this diffs are real bugs I found while attempting an
alternate solution.
We were fataling when passing a list assignment expression with an
array-element RHS (like "$arr[0]") as an argument that the callee
expected to take by reference. Zend allows this, but with a warning. I
figured out the rules as best I can (this is one of those corners of
Zend where layers of insanity have piled up over time). I won't swear
that I got it 100% right w.r.t. whether we warn or not, but I'm pretty
sure we're closer to 100% right w.r.t. whether we fatal or not.
Pulling the trigger; it's unused post-tx64. This diff preserves the
ability to mark units as merge-only when the pseudomain only contains
assignments to known globals. When the unit is being merged, the set
operation goes directly to the global varenv instead of through the
targetcache (GlobalCache stored pointers into the global varenv's
NameValueTable).
Another RecursiveDirectoryIterator bug :( This time, subPath was totally wrong. It should only be adding on a little bit each time, not the whole path.
This was coming up when installing Symphony using composer, and while I was in there I fixed a zend mode bug. We weren't doing the warning in the interpreter (and we were doing null instead of uninit). That was enough to move most of the tests over. The other problem is tasked.
There's a race in the emitter, where if we emit a unit (because,
it wasn't in the repo) fail to commit it, and then find the unit in the repo,
we destroy the unit we just emitted, and read the one from the repo instead.
This typically happens at RankFileRepo. A new change to Func::~Func makes
it grab the write lease in DEBUG builds, which is a lock rank violation.
Newly created Funcs never need the write lease, however, so aquire it
lazily.
This was happening running slow tests, because some tests are run multiple
times (potentially in parallel) with different runtime options (in fact, the
test code is duplicated in separate files).
This diff is intended primarily as a medium for everyone to look at and
discuss the code I'm planning to use as our ARMv8 in-memory assembler
and simulator. This is what I was about to spend weeks and weeks writing
myself, but thankfully ARM has done all that for us!
To get an idea of what it looks like to use VIXL, look at
test-assembler-a64.cc, at lines that begin with "__". Superficially, it
looks very similar to clients of X64Assembler. Things like x0, w1, etc.
are registers. "Operand" is a struct that encapsulates some of the extra
stuff tacked on to ARMv8 instructions -- e.g. when comparing against an
immediate, you can include a left-shift amount for the immediate, and it
will look like "Operand(x1, LSL, 1)" or similar.
The simulator is similarly easy to use. You set initial register values,
give it an instruction pointer, and say go. It runs until it hits a ret
instruction that takes it out of the top level, and then you can read
register values out of it. It can access memory just like native code
can.
VIXL includes its own abstraction for registers, and it's structurally
quite similar to our PhysReg. (It's defined in assembler-a64.h.) One of
the most nontrivial parts of this effort will be to figure out how to
unify these two abstractions.
The instruction coverage is internally consistent (i.e. the simulator
and disassembler can deal with any instruction the assembler can output)
and is almost certainly enough for our needs. Even if it's not, the code
is pretty clean, and it won't be hard to add whatever we need.
The big thing I'm not yet sure about is the implementation of nonlocal
jumps. The usage examples that come with VIXL (but I'm not including
here; see the original github) use jumps, but only within the small
snippets they emit. There's nothing that resembles our jumps between a
and astubs. This might be something we have to hack in, but it shouldn't
be too hard. The one potentially tricky part will be to support jump
smashing. If we have to encode a jump as multiple instructions, we won't
be able to smash it atomically. The only viable alternative I can think
of is to have a "jump target table" on the side, emit an indirect jump
in code, and smash the table entries instead of the code.
The open-source distribution of VIXL is built with scons, but it was
near-trivial to get it building with our internal system. To build the
library, I just had to change the include paths. To build the tests, I
deleted the custom test driver that came with VIXL and converted the
test files themselves to use gtest. This was mostly a matter of tweaking
the macros to use gtest asserts.
I also fixed lint errors (NULL -> nullptr, include ordering, static at
namespace scope, ...)
About licensing. The code is under a 3-clause BSD license, and the
license header is preserved in all the files I pulled in.
Pulled from https://github.com/armvixl/vixl at ad96eda894.
This lets us move parsing of runtime options
to the extensions which actually use them.
Nobody is currently using this functionality, so changing
what gets passed isn't a BC break worth worrying about.
I'll post some followup diffs pulling things out of
RuntimeOptions.
This diff adds an initial framework for profile-guided optimizations
in the JIT. Two new translation modes are added, effectively creating
a multi-gear JIT:
1. Profile: this collects profiling data, which includes execution
counters and type information.
2. Optimize: this uses data collected by Profiling translations to
produce optimized translations.
Right now, the Optimize gear is solely used to produce larger
compilation regions (traces), which increase the scope of
optimizations exposed to the JIT (compared to tracelets). This is
still work in progress, and it's disabled by default.
This diff also fixes a number of bugs exposed by trace regions, gets
tools/reduce working again, and makes a number of improvements to
tc-print related to the new translation modes.
Function prologues guard on Func* pointers rather on funcId.
This can cause a recycled Func* (with a different funcId) to
pass the prologue guard. Change it so that the Func* destructor
smashes the func prologue guard immediate.
Use timer events instead. A side effect is that we now
support timeout in client mode. We also get much more
accurate timeouts. Previously starting a server with
a timeout of 4s, and GETing an endpoint that just looped,
would timeout somewhere between 3.5(!) and 8 seconds. Now
it times out between 4.0001 and 4.02s.
This will also make fixing pagelet timeouts much easier.
Copy assignment operators should generally take const lvalue
references and return non-const lvalue references to the lhs. It's
unclear why these don't (probably no reason), so fix it.
This function used memcpy on TypedValues where it doesn't
know the storage location, which is dangerous if the target lives in a
HphpArray (or anything else that uses m_aux). It also just seems like
it's now an unnecessary/redundant entry point in the typed value API.
Several uses of it are on things that can't be KindOfRef anyway (I
fixed constants, but where I wasn't sure I used tvToCell first).
I should've used unique_ptr::release() instead of unique_ptr::reset(),
but I decided to stop using unique_ptr altogether since gcc generated nicer
code without it. I also eliminated a redundant load of m_next.
Breakpoints of the form func() used the same routine to scan names as breakpoints of the form filename:lineno. This meant that you could write something like obj->func() and not get an error message. To fix this I've added a validation routine that is invoked when it has been determined that a name is part of a function name.
Most callsites use the defaults, and I can't figure out which callsites should and should not use it. Lets just have different functions for each use-case.
Needed for phars. People are doing
file_exists('phar://a.phar/b.php');
I didn't do all syscalls like `chmod` or `symlink`. Think I should bite the bullet, or do it piecemeal when needed?
I went through all the tests that mentioned this and looked at them. All of them don't pass because of other missing SPL problems not related to this class (and this class is simple so I wouldn't assume them to blame to it).
Closes#766
When there's an instance ctor, it's not necessary to do the
memcpy for properties or other ObjectData-initialization duties (the
instance ctor does this). Also, use extra data for the compile-time
constant Class*.
Most CPP extension classes don’t think about serialization, and some require more initialization than the default contractor provides. The result is that on deserialization we end up with a partially initialized object, and undefined behavior after that.
Modified the serializer to emit __PHP_Unserializable_Class instead, and just the class name for the debugger case. Modified the deserializer to create a __PHP_Unserializable_Class, too, if we are given a string with a CPP extension instance in it, so we're safe on both sides. I do not raise a warning; the results are pretty clear, I think, and it's also unlikely that most such warnings could (or should) be corrected. Finally, I also removed the odd behavior of emitting "dummy" classes for Closure and Continuation. I found no use of these in any source tree. Closure had no implementation at all, and Continuation had an implementation that simply raised a fatal on any method call. Thus we can safely assume that even if someone was serializing one of these types, they were receiving an object that was useless to them, or would fatal. So I believe this transformation is safe.
This allows us to swap TypedValue.m_type and m_aux, which puts
m_type at offset 8 and simplifies the necessary code for passing
TypedValue by value. It also makes the m_type and m_data fields
of TypedValue contiguous.
EmitterVisitor::emitPostponedMeths was terribly long and disorganized.
Let's split it into more methods that can be later reused for emitting
generator body in FuncEmitter.
This diff adds AtomicVector (see comment in atomic_vector.h
for what it is) and uses it to maintain a mapping from funcIds to the
corresponding Func*. This is then used in sktrace instead of
curUnit(), since curUnit() isn't guaranteed to be the Unit the SrcKey
in question came from.
HphpArray::CreateLvalPtr does the same thing as LvalStr(). SharedMap
and NameValueTableWrapper::CreateLvalPtr just fatal, and aren't called
anyway. GetLvalPtr is only called from one place which suppresses COW
and thus can also be done with nvGet, leaving getLvalPtr dead.
On Linux, fadvise forces unwritten pages to be flushed to disk before
returning. This means that under heavy disk IO, all threads could be
waiting on the fadvise call.
This diff uses atomic operations to ensure that only one thread can
do IO at any given time. In addition, it makes any fadvise calls
tail the end of the file by 1 MB. This reduces the chance that
fadvise will trigger IO at all.
Our request shutdown procedure cleared the autoload handler
before running destructors of any remaining objects. This was causing
fatals when some of those destructors tried to use a
class/function/constant that hadn't already been autoloaded.
And, several helper functions with the prefix "var" were changed
to the prefix "ref". I reworded the bytecode spec; the flavor letter
for PHP references is still 'V', but I reworded parts of it to use
the term 'pointer' instead of 'reference' in places where reference
was too overloaded. Renamed 'var' to 'ref' throughout.
This is some carnage left over from the Vector & devirtualize-ArrayData
work. Several places I left the original call to copyImpl(), where a
more specific call would have been ok. In one place, I called the wrong
function, which would assert in debug and potentially crash in opt.
Convert remaining virtual methods to static methods dispatched
by kind. This makes ArrayData a non-virtual class, so shuffle
fields and adjust static_asserts.
Moves about half of ArrayData virtual methods to g_array_funcs as
static functions instead of virtual functions. This is mostly a
mechanical factor, except a handful of methods that are specialized
for Vector instead of generic HphpArray.
Pulling the trigger; it's unused post-tx64. This diff preserves the
ability to mark units as merge-only when the pseudomain only contains
assignments to known globals. When the unit is being merged, the set
operation goes directly to the global varenv instead of through the
targetcache (GlobalCache stored pointers into the global varenv's
NameValueTable).
Supersedes D891179 -- I was overly aggressive in that one.
Most of the values stored in TypedValue in ext_asio are always Cells.
Let's use Cell type alias to improve code readability, pass them by
reference where null is not allowed and use Cell-specific functions
from tv_helpers.h.
Implement PHP_BINARY PHP core predefined constant. PHPUnit uses this constant in its self-test suite, causing many of them to fail on HHVM (possibly only because of the lack of this constant). Try to ninitially implement in such a way that it can be nimble enough for open-source, cross platform.
PHPUnit calls json_last_error. We need to implement it. Also implemented a simple json_last_error_msg to bring it up to 5.5 parity in that regard. This current implementation does not bring all the json zend tests to passing. But 2 out of the 22 bad tests now pass. And, this allows the PHPUnit self test to run as well.
Debugger tests that run hphp in non local mode (i.e. with the "-h some-server:some-port" option specified) currently use a clunky specialized C++ test harness that invokes PHP scripts that talk to the debugger client via the obsolete client API. This revision moves those tests to the new PHP only framework. The debugger client is now controlled by piping in commands, just like the other debugger tests. The main difference is that the debugger client is connected to a server instance and a separate PHP driver is used to load the server, load the client, and then load pages from the server so that the client can hit breakpoints. It also checks that the client can respond to ctrl-c by actually sending a SIGINT signal to the client process.
I keep seeing problems with this test. Lets see if opening less sockets helps? The last few have failed on `socket_get_option($s, SOL_SOCKET, SO_TYPE)` which this does't fix though...
I ran into this problem with the region JIT. Without this fix, an
IncRef may appear to be dead in the main trace during ref-counting
optimization (performed along with DCE).
A real breakpoint makes entries in the breakpoint filter for all offsets at the given line. Various flow control commands will also use the breakpoint filter to add and remove temporary "internal breakpoints" required during the flow operation. Ensure that we never remove a breakpoint filter entry if there was already one there due to a breakpoint (or really any other reason).
When the proxy's signal polling thread gets a signal from the debugger client, it would normally wait one second for another thread to recognize and consume the signal. This is pretty reasonable, but with a debug build on a heavily loaded system it's very rarely possible for one second to not be long enough. Added a runtime option to extend this, and set it to 3s for the existing debugger server tests.
Newlines in expectf files don't necessarily match
newlines output by tests. In the case of the bug55273 test,
the expectf file has unix (\n) newlines, but chunk_split()
produces DOS (\r\n) newlines by default. This pattern
normalizes all expected newlines to accept unix, DOS, or old-style
Mac (\r) newlines.
Since variable break/continue is gone, we don't need this jonx anymore,
since the target of any break or continue is statically known. The
regular break/continue handling deals with this case appropriately.
We use ArrayKind as a simple unsigned integer, its an index, we do
range-based comparisons, and in the future we'll likely do bit-ops
for fast sub-kind tests. Just be honest that this is an old-school enum.
The shell builtin implementation of echo on MacOSX
doesn't respect the -n flag. This is the only usage of it
in our stack so far and we can avoid it by hiding the generated
token from the linter in a different way.
Introduces a new m_kind for vector-shaped HphpArray instances.
A vector has integer indexes in the range [0..size), and no
tombstones. Internally it does not store the integer keys or
hashtable, although this version still allocates space for it.
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.
The the code is being translated, we statically know offset of
Continuaton from its ActRec. Use this knowledge to emit data fetches
relative to ActRec rather than relative to Continuation loaded from
local 0.
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.
The exit path for the debugger client has always been a little odd. We'd call a shutdown function which would destroy the client, then later call a stop function which would first make a new client, then stop it, then that one would get destroyed later. Made it so we stop and destroy just one client.
Flow control commands should not evaluate the conditions of conditional breakpoints when enabling and disabling breakpoints during stepping. Also, all breakpoints, rather than just the first matching breakpoint should be enabled/disabled.
There was a race in the debugger protocol tests which send bad commands to the proxy and expect it to disconnect. If the proxy thread was fast enough it would mark the client as stopped, and we'd skip trying to get a new message after sending the bad command. This means missing one line of output in very rare cases. I've put in a wait to ensure that the client settles in the stopped state before continuing, to remove the race.
This is exactly what Zend's parser does now. I'm a little sad about
adding the bool parameter, but all the checking code was exactly
duplicated otherwise, and that seemed like the worse alternative.
Fixes#854
We'd like to start using ##mixed## instead of ##var## for attribute types to be consistent with Hack. As a followup to this (once released), we would codemod all ##var## to ##mixed##.
A client couldn't break execution during eval. There used to be a lot of barriers to making that right, but I fixed most of them with a previous diff on unifying client-side event loops. Now the only barrier was that a server-side thread processing an interrupt was blocking the signal polling thread by holding a mutex while processing the interrupt. Changed to set a flag to disable polling when starting to process the interrupt (and unsetting it when done), while still synchronizing with the signal polling thread to ensure only one thread is sending the client messages at a time. Added logic to re-enable polling while executing PHP for eval, print, etc. Plumbed the proxy thru to the point where we check the clause on conditional breakpoints, too, since that's the third (and final) place we do this.
When the client sends a list of breakpoints over to the server, the logic that applies the breakpoints as soon as a file is loaded is broken. It stops looking at breakpoints as soon as it finds the first one. It should carry on and look at all of them.
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.
"foo" | "f" is meant to yield a string of length
max(strlen("foo"), strlen("f")) by bitwise ORing each byte
of one string against the corresponding byte of the other.
When the strings are of differing lengths, however, we get unknown
garbage data from past the end of the buffer. This data is
often '\0', however under memory pressure we can get any
value and the behavior becomes undefined.
Having everybody and their uncle reading and writing fields out
of a.code and stubs.code was making assembler work hard. This replaces most
reads with accessors, and all writes with structured friends of
X64SAssembler.
This is an incremental step towards moving it all the way
to hphp/server. This flattens base but doesn't untangle
the server files from lib_hphp_runtime
Often I happen not to be running under a debugger when a
crash occurs. In my debugging workflow, I'd prefer our crash handler to
preserve the broken state and spin waiting for gdb to attach rather than
dump core, attempt its own little sad stacktraces, etc. Driven via a
default-false config flag.
I broke the operation of CmdMachine when we attach with the force flag with https://phabricator.fb.com/D851880. I consolidated some error handling logic around broken connections, etc., and in particular pulled throwing of an exception into forceQuit(). I failed to realize there was a single call site of forceQuit() that did not in fact throw an exception afterwards… the logic underneath of force attach. Switching the forceQuit() call there to stop() replaces the logic that was there previously, and restores the behavior.
break start/end/psp currently always report themselves as unbound. If the client is connected to a sanbox, these should instead be treated as bound. Also, break clear all currently removes breakpoints without running their destructors in the right order, which causes the break point counter to not reset to 1.
Fix a long-standing bug where if you step off of the end of pseudo main we'd segfault in the interpreter loop. To get this we have to have a breakpoint in the final TC in pseudo main, and have that called from another TC, then Step or Next off the end. We'd end up with a PC of zero after the ret, which makes sense, but the logic after interpreting a block of code to stay in the interpreter when debugging was blind to this case.
The goal of this diff is to clean up the current work-in-progress and check
it in so that others may contribute if they have time.
The program currently outputs the HHVM tree as well as the xhpast-like
json, for ease of debugging. There is a little helper program jsonpretty.py
to make the trees more readable, e.g.
_build/dbg/hphp/util/parser/xhpast/xhpast2 <some php file> | hphp/util/parser/xhpast/xhpast2/jsonpretty.py
We'd love to have your help in making HipHop better. If you run into problems, please open an [issue](http://github.com/facebook/hiphop-php/issues), or better yet, fork us and send a pull request.
If you want to help but don't know where to start, try fixing some of the [Zend tests that don't pass](hphp/test/zend/bad). You can run them with [hphp/test/run](hphp/test/run). When they work, move them to [zend/good](hphp/test/zend/good) and send a pull request.
All the open issues tagged [Zend incompatibility](https://github.com/facebook/hiphop-php/issues?labels=zend+incompatibility&page=1&state=open) are real issues reported by the community in existing PHP code and [frameworks](https://github.com/facebook/hiphop-php/wiki/OSS-PHP-Frameworks-Unit-Testing:-General) that could use some attention.
## Submitting Pull Requests
Before changes can be accepted a [Contributor Licensing Agreement](http://developers.facebook.com/opensource/cla) ([pdf](https://github.com/facebook/hiphop-php/raw/master/hphp/doc/FB_Individual_CLA.pdf) - print, sign, scan, link) must be signed.
Please add appropriate test cases as you make changes; see [here](hphp/test) for more information. Travis-CI is integrated with this GitHub project and will provide test results automatically on all pulls.
## Additional Resources
* IRC:[#hhvm on freenode](http://webchat.freenode.net/?channels=hhvm)
@@ -4,6 +4,10 @@ HipHop VM (HHVM) is a new open-source virtual machine designed for executing pro
HipHop is most commonly run as a standalone server, replacing both Apache and modphp.
## FAQ
Our [FAQ](https://github.com/facebook/hiphop-php/wiki/FAQ) has answers to many common questions about HHVM, from [general questions](https://github.com/facebook/hiphop-php/wiki/FAQ#general) to questions geared towards those that want to [use](https://github.com/facebook/hiphop-php/wiki/FAQ#users) or [contribute](https://github.com/facebook/hiphop-php/wiki/FAQ#contributors) to HHVM.
## Installing
You can install a [prebuilt package](https://github.com/facebook/hiphop-php/wiki#installing-pre-built-packages-for-hhvm) or [compile from source](https://github.com/facebook/hiphop-php/wiki#building-hhvm).
@@ -22,12 +26,21 @@ For anything more complicated, you'll want to make a [config.hdf](https://github
## Contributing
We'd love to have your help in making HipHop better. If you run into problems, please open an [issue](http://github.com/facebook/hiphop-php/issues), or better yet, fork us and send a pull request. Join us on [#hhvm on freenode](http://webchat.freenode.net/?channels=hhvm).
We'd love to have your help in making HipHop better.
Before changes can be accepted a [Contributor License Agreement](http://developers.facebook.com/opensource/cla) ([pdf](https://github.com/facebook/hiphop-php/raw/master/hphp/doc/FB_Individual_CLA.pdf) - print, sign, scan, link) must be signed.
If you run into problems, please open an [issue](http://github.com/facebook/hiphop-php/issues), or better yet, [fork us and send a pull request](https://github.com/facebook/hiphop-php/pulls). Join us on [#hhvm on freenode](http://webchat.freenode.net/?channels=hhvm).
If you want to help but don't know where to start, try fixing some of the [Zend tests that don't pass](hphp/test/zend/bad). You can run them with [hphp/test/run](hphp/test/run). When they work, move them to [zend/good](hphp/test/zend/good) and send a pull request.
Before changes can be accepted a [Contributors Licensing Agreement](http://developers.facebook.com/opensource/cla) ([pdf](https://github.com/facebook/hiphop-php/raw/master/hphp/doc/FB_Individual_CLA.pdf) - print, sign, scan, link) must be signed.
All the open issues tagged [Zend incompatibility](https://github.com/facebook/hiphop-php/issues?labels=zend+incompatibility&page=1&state=open) are real issues reported by the community in existing PHP code and [frameworks](https://github.com/facebook/hiphop-php/wiki/OSS-PHP-Frameworks-Unit-Testing:-General) that could use some attention. Please add appropriate test cases as you make changes; see [here](hphp/test) for more information. Travis-CI is integrated with this GitHub project and will provide test results automatically on all pulls.
## Licence
## License
HipHop VM is licensed under the PHP and Zend licenses except as otherwise noted.
## Reporting Crashes
See [Reporting Crashes](https://github.com/facebook/hiphop-php/wiki/Reporting-Crashes) for helpful tips on how to report crashes in an actionable manner.
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff
Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.