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.
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##.
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.
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
XML comment syntax for XHP is one of the top wishlist items within the UIE group (+ some other people).
Currently, the only way to have comments inside XHP blocks is to use expressions and block comments, e.g.
<div>{/* comment */}</div>
After this change, you can use the more familiar syntax. This syntax is limited to XHP child contexts:
// Only single-line, doc, block comments work outside XHP
$xhp =
<div>
<!--XML comments only work within XHP children contexts-->
</div>;
Based on http://www.w3.org/TR/REC-xml/#sec-comments - except we ignore the rule about double hyphens ('--') within a comment because we don't care about SGML.
We can get rid of all the lock contention by using
tbb::concurrent_hash_map. Unfortunately tbb::concurrent_hash_map doesn't let us
iterate over it while we concurrently do inserts. Work around this limitation by
keeping a copy of all the counter keys in a concurrent_vector which does let us
concurrently insert and iterate.
On lookup / insert, we first look into concurrent_hash_map for the key. If key
already exists, return the value. Otherwise, we insert into both the map and the
list.
On export, we iterate over the list and look up each key from the map.
The autoload_map.hdf doesn't support backslashes when it's on the LHS.
This broke an intern build last week when we pushed out namespace
support for third-party.
Looked like:
```functions {
GlobalNamespace\Class = flib/intern/third-party/test.php
}```
Adds an extension command to the debugger which provides
heap tracing functionality, and adds the framework needed to get
heap traces. The heaptrace command can dump the current heap to the
debugger session or it can save a GraphViz specification to a file.
I'm hoping to add a backend which can put the graph in GML format,
so it can be explored interactively. I also hope at some point to
see this integrated into FBIDE if we can do that.
A BoolProfiler uses two StackTraceProfilers to take profiled samples of
a boolean value. At shutdown it prints the %false, %true, and a profile
for each case.
An IntProfiler is similar, but profiles buckets of 0, 1, 2, 4, and 5+.
Add an option to allow hphp's request queue dynamically switch between FIFO and
LIFO. By default everything is still FIFO like today. Setting
ServerThreadJobLIFO to true turns everything to LIFO like today. If
ServerThreadJobLIFOThreshold is also set, then we do FIFO up until the queue
length hits the threshold. Once the threshold is crossed, workers will take
quests from the end of the queue. Once the queue size shrink below the
threshold, we resume FIFO order.
This behavior helps us prioritize newer requests when the server is loaded.
This a simpler / cleaner version of fbcode's ServiceData for hphp. Currently we
support only flat counters, MultiLevelTimeSeries and Histograms. We can add more
stats types later on as needed.
ServiceData is a global entry point for all this stuff. The current idea is to
completely decouple data input and export. ServiceData internally has three
separate maps tracking flat counters, timeseries and histograms. These maps are
wrapped by spin locks and protected by folly::Synchronized.
ServiceData provides three functions to create/retrive counter objects. The
counter objects are thread safe (protected again by spin locks and
folly::Synchronized).
Updates continuations to allow yielding of a key-value
pair from a generator. Adds bytecode instructions (PackContK,
ContKey) for using the new feature, and adds IR instructions
(ContUpdateIdx, ContIncKey) to help get it down to the metal
(in particular, ContIncKey attempts to keep the current use-cases
as fast as possible).
I keep reintroducing these by hand. My workflow is usually:
1. Have an idea to optimize X.
2. Realize I don't even know if X is important or not.
3. Instrument X to slow it down, to see if it makes a difference in
perflab.
After this diff, 3 is a simple matter of inserting a call to
cycleDelay(1000) (or what have you) in the path of interest.
Some simple changes for HPHP to help make it clang friendly
---hphp/compiler/package.cpp
---hphp/compiler/package.h
---hphp/runtime/ext/ext_curl.cpp
---hphp/runtime/ext/pdo_mysql.cpp
---hphp/tools/tc-print/offline-x86-code.h
---hphp/util/async_func.cpp
---hphp/util/async_func.h
---hphp/util/compression.cpp
---hphp/util/compression.h
---hphp/util/db_conn.cpp
---hphp/util/db_conn.h
Deleted unused private fields
~~~hphp/compiler/analysis/symbol_table.h
Static assert had to be outside the union
+++hphp/runtime/TARGETS
Added clang specific flag to supress unneded declaration warning
~~~hphp/runtime/base/datatype.h
Use of logical '&&' with constant operand. Added !=0 to remove warning,
~~~hphp/runtime/base/string_data.h
Static fields cannot be declared in an anonymous struct/union
~~~hphp/runtime/ext/bcmath/TARGETS
Moved gcc specific flag from preprocessor_flags to compiler_specific_flags
~---hphp/runtime/ext/pdo_mysql.cpp
Removed unnecessary self asignment for row_count
~~~hphp/runtime/vm/bytecode.h
Added default return statement
~---hphp/runtime/vm/jit/codegen.cpp
spillSlotsToSize was unused
~~~hphp/runtime/vm/jit/irtranslator.cpp
~~~hphp/runtime/vm/jit/linearscan.cpp
The c++ standard states default arguments shall not be specified in the
parameter-declaration-clause of a lambda-declarator.
~~~hphp/runtime/vm/jit/vectortranslator-internal.h
Clang had some issues determining the correct cast when these macros were used
A simple '!= 0' check was added to make things explicit for clang.
~~~hphp/tools/tc-print/perf-events.h
Added parens to make clang happy
+++hphp/util/asm-x64.h
The constexpr needed to be initialized
+++hphp/util/base.h
Clang also supports tr1 libraries
~~~hphp/util/bits.h
Again, clang had issues with implicit casting to bool.
added != 0 check
~~~hphp/util/malloc_size_class.h
Ambiguous operator precedence. Added parentheses.
~~~hphp/util/thread_local.h
Misspelled function
The [z]end command in hphpd runs the last manually entered snippet of php in "zend". If you typed 'z' before actually entering any php, it would segfault. Fixed a minor bug in Process::Exec, and present help if none entered. Also clarified that it will simply use your system's default php, and made it so you can override which exe to use with a hphpd config variable. The default is "php", since that is most commonly used.
This was going to be easy, but then it wasn't. The existing
interpOne relied heavily on the outputs of NormalizedInstruction, and
those are only populated by code that we want to kill soon. It also
didn't properly deal with bytecodes that wrote to more than one local,
or more than one stack cell. So the bulk of this diff is rewriting
interpOne to not rely on the NI outputs, then it was simple to hook it
into the region translator. I also cleaned things up so we don't
attempt to translate instructions that have no hope of succeeding; we
just interp them on the first try now.
This diff stops the region translator from punting on
instructions that may be prepped by ref (FPass*) or Tracelets with
reffiness guards. It increased coverage and exposed a few more
bugs. The only significant one was that some Tracelets depend on type
prediction for their length, so I had to hook it into translateRegion
to avoid generating worse code (or punting).
More changes for HPHP to help make it clang friendly
~~~hphp/compiler/expression/constant_expression.h
~~~hphp/compiler/expression/function_call.h
rfind returns a size_t/unsigned int
~~~hphp/runtime/base/server/http_protocol.cpp
Switched to std::to_string. Assuming [] was not intended here
~~~hphp/runtime/base/ref_data.h
These fields were accessed in a public manner, assuming public was intended
instead of private
~~~hphp/runtime/base/variable_serializer.cpp
Switched to using [] and & to make clang happy. Assuming this was to either
take or drop the first char.
~~~hphp/runtime/ext/asio/asio_external_thread_event_queue.h
~~~hphp/runtime/ext/asio/asio_external_thread_event_queue.cpp
Cast which performs the conversions of a reinterpret_cast is not
allowed in a constant expression. This is been moved to a macro as a temporary
fix.
+++hphp/runtime/ext/ext_misc.cpp
Added std::atomic to supress warnings
~~~hphp/runtime/vm/jit/simplifier.cpp
Chosen constructor is explicit in copy-initialization
~~~hphp/runtime/vm/jit/translator-asm-helpers.S
Ambiguous instructions require an explicit suffix
Changed cmp to cmpl
~~~hphp/runtime/vm/jit/translator-x64-helpers.cpp
Clang does not support global register variables
+++hphp/runtime/vm/unwind.cpp
describeFault was only used when DEBUG or USE_TRACE was defined
~~~hphp/runtime/vm/verifier/check_unit.cpp
Made fmt pointer const to avoid string format issues/warnings
~~~hphp/util/stack_trace.cpp
Clang does not support variable-length arrays.
Uniqe_ptr is used instead to take advantage runtime-sized arrays, a
restriced form of variable-length arrays
~~~hphp/util/thread_local.h
Clang seems to be supporting the __thread attribute, or at the very least
it is not complaining about it.
~~~hphp/util/tiny_vector.h
Clang does not like the flexible array here, since T is not always POD.
I have reimplemented the array here by just sticking one value in the struct
and calculating the offset from its address manually.
Alterinatively, we could change the the non-POD types to be pointers, or
we could edit their implemenations.
+++hphp/util/util.h
Created a template for the union,
A function declared with the constexpr specifier cannot contain
type declarations that do not define classes or enumerations
+++hphp/runtime/vm/jit/x64-util.h
Added a TODO
The way hphp/runtime/vm/jit/x64-util.h is currently implemented, it only
works if USE_GCC_FAST_TLS is defined
Retry of D848605 which doesn't segfault the open-source build.
Formerly, this change caused the assembler to emit an opsize
prefix before ret instructions taking a 16-bit immediate, which
worked on our machines but caused problems for Travis CI.
poll can set both POLLIN and POLLHUP. We were checking for
POLLHUP first, which meant we often missed the "exit" command. This
meant the LightProcess would incorrectly report that it was exiting
because it lost its parent, rather than because it was told to exit.
Fixing this so its easier to diagnose what was going on.
Otherwise, the SIGCHLD handler will trigger a server shutdown.
The only time this is bad is when LightProcess::Close is called
from the segfault handler, because it triggers a server shutdown
while we're dealing with the initial crash, which almost always
leads to misleading core dumps.
There was a confusing comment left in the assembler
that said that we can't encode a decl r32 instruction, because
the opcode is the same as a REX byte. This is untrue in our
assembler, because we use the FF /1 encoding, rather than the
48 one (which is a REX byte and would be a problem).
Some tests were added to show that this is fine.
Formerly, trying to emit a 16-bit instruction, such as
with test_imm16_disp_reg64(...) would actually emit a testl
instead of a testw. This would emit an 8-byte instruction
(ex. 41 f7 45 0e 01 01 00 00) and possibly be testing the wrong
thing. Now, when you emit a word-size instruction, it will prefix
with 66 and use the correct operand size, saving us a byte
(ex. 66 41 f7 45 0e 01 01).
I also converted the instruction emission in ContPreNext to
use the new style assembly emission.
I noticed that directorty structure of hphp/system was a bit scattered, so
I consolidated things to reduce the total number of folders and to put
related things together with each other.
This diff moves the contents of "hphp/system/classes_hhvm" into
"hphp/system", it moves the contents of "hphp/system/lib" into
"hphp/system", moves "hphp/idl" to "hphp/system/idl", and moves the
contents of "hphp/system/globals" into "hphp/system/idl".
Move all the stack unwinding code to its own module, delete
some redundant enumerations, document a few things. Gets rid of most
of the remnants of the old setjmp/longjmp-based implementation at the
enterVM level but doesn't do much to the unwinder itself (coming in
separate diff to hopefully be easier to review).
This is gone as of Zend 5.4: as far as I can tell, anything other than a
positive integer literal is a parse error (including constants, "1 + 1",
etc.) Let's get rid of it. The mere fact that this construct ever
existed in any programming language is deeply horrifying.
This lets us get rid of all the goofy code that subtracts 1 from the top
value on the stack, does IterFree if needed, and jumps to the next
level. Now, we can hardcode the necessary IterFrees and do a single
jump, right where the break/continue actually is.
The error message for using a non-integer expression is less helpful
than Zend's (Zend says "non-constant operand not supported"; ours is
"unexpected T_VARIABLE" or whatever). It wouldn't be that hard to do in
our parser, if we think that's helpful. I don't think it matters,
though.
This reverts commit 2e9677b7c3f37e9627b9cbc9a6ddec82a10e7215.
Third time is the charm. I hid it from reflection, but I missed `get_class_methods`.
The diff betweenn this and what was reverted is https://phabricator.fb.com/P2217891 and then I did https://phabricator.fb.com/P2217904 because it looked like it should be done.