Gráfico de Commits

95 Commits

Autor SHA1 Mensagem Data
ptarjan fca7a90240 Rename test directories
These names don't make sense now that we run both suites the same
way.
2013-04-17 09:08:16 -07:00
ptarjan 503f75d08b Rename test directories
These names don't make sense now that we run both suites the same
way.
2013-04-17 09:06:51 -07:00
mikemag 602b1bd64f Ensure C++ exceptions eventually propagate out of destructors.
This diff addresses what we called "step 1" in the task: simply ensure that any C++ exceptions that escape a destructor get rethrown and can continue to propagate naturally. The exception is remembered on the thread, and rethrown when we check for surprises later. If multiple destructors let C++ exceptions escape the last one to escape will be the one rethrown at the next surprise check.

This also ensures that C++ exceptions prevent more PHP code from running, by omitting calls to __destruct methods as we unwind the stack.

Finally, this also enables surprise checks for OnFunctionExit unless we're unwinding, in which case surprises remain unchecked so they can propagate later.

This is different than Zend's behavior, where destructors do run as fatals unwind.
2013-04-17 08:54:58 -07:00
mikemag b677c776df Fix bug in heredoc processing
My recent change to now/heredoc processing resulted in variables in heredocs mistakenly being tacked onto the end of the previous line in the output. This tends not to be a problem when emitting things that get parsed by something else, like emitting PHP. But it's noticable when emitting raw text.
2013-04-17 08:54:58 -07:00
kma 197305cc45 HHIR mod. 2013-04-12 12:03:57 -07:00
seanc 0840deb71a Use name to be consistent with Zend in backtraces
Generators should specify function names as the name instead of the
full name for consistency with Zend 5.5 (and more importantly because
this breaks PHPUnit), this was exposed by the backtrace removal of
file and line info
2013-04-11 12:13:43 -07:00
mwilliams 26cf67d974 Fix interface1.php's expected output
Somewhere in the .filter consolidation and cleanup,
the bit that stripped the function name was removed. Add it
back.
2013-04-11 12:13:42 -07:00
ptarjan 4dfde31584 remove support for .exp
I left in a message to read the README, but I don't know if people will see it mixed into the output.
2013-04-11 10:58:54 -07:00
ptarjan ac1d69902e name anonymous continuations as Class::Method$continuation
As a user, this often annoyed me that I couldn't get any debugging info
out of the name and then @ahupp asked for it.

I didn't really know what to name closure ones as the name is done at
emission time. So I went with ##{closure}##. I'm not sure how I feel
about that since it will be uncorrelated with the emitted name.

While I was in there, I deleted a lot of unused code.

I'm totally open to other names and ideas.
2013-04-11 10:58:54 -07:00
ptarjan 8b3bb26b22 kill default.filter and switch everything to .expect or .expectf 2013-04-11 10:52:48 -07:00
ptarjan 27dc48a6bf kill all .filter files
.expectf can do everything these do in a more readable way.
2013-04-11 10:52:18 -07:00
jdelong 9dc66f2f40 Fix an exception safety issue for undefined properties in vectortranslator
I think the only case where we currently don't spillstack as
part of a vector translation is CGetM of a defined property.  However,
this can still raise exceptions in the unlikely case of an unset
property.  For now, just spill before any vector translation---a
follow up diff relaxes this to not do it in cases where we know the
property can't be undefined.  Presumably later we'll push the
spillstacks into the unlikely paths for these translations (or put
them in unwind handlers)---currently we can't handle control flow
where the join point has a different stack.
2013-04-09 15:32:17 -07:00
mikemag ab9e26f8af Avoid stack overflow on super-large expressions of binary operators.
A small change to optimize very simple binary operators in the parser. This avoids building very large parse trees for super-large expressions and folds binary operators involving two scalars directly in the parser. I've limited this to simple scalars since it's easy to prove they don't have anything too interesting going on in the other analysis phases leading up to BinaryOpExpression's normal folding. This works for all binary operators.
2013-04-09 15:31:40 -07:00
drussi bf740ca345 expose return type constraint (aka hint) from the AST to the runtime and reflection
This is the first part of the work to expose type constraint and generic all the way to reflection. This first DIFF exposes the return type with generic types coming next.
2013-04-09 15:31:40 -07:00
Owen Yamauchi 2755ecc9e5 Someone might want to run this test in another timezone 2013-04-09 15:31:40 -07:00
jdelong 6faa7cbea1 @override-unit-failures Initial support for <?hh typedefs and shapes
Adds runtime support for non-class typehints.  Typedefs are
introduced using type statements, and autoloaded via a new autoload
map entry.  Shapes are parsed but the structure is currently thrown
away and treated as arrays at runtime.  This extends the NamedEntity
structure to sometimes cache 'NameDefs', which are either Typedef*'s
or Class*'s.  VerifyParamType now has to check for typedefs if an
object fails a class check, or when checking non-Object types against
a non-primitive type name that isn't a class.
2013-04-09 13:01:46 -07:00
seanc b1e00e219b Add original filepath for continuations in backtrace 2013-04-04 15:39:04 -07:00
mwilliams c4b56e312d Fix UnsetM with global base
If the global was not defined, it would try to return
a pointer into the MInstrCtx, which was not passed in.

We dont actually need it though, because in that case we can
just return a pointer to init_null_variant.
2013-04-04 15:39:03 -07:00
mwilliams 016c4abe84 Fix issues with dead locals in backtraces
The specialized RetC sequence in tx64 destroyed each local,
and then set it to null in case onFunctionExit captured a
backtrace. But if the destructor of a sub-object captures
a backtrace, its already too late.

The same code in hhir didn't null out the local at all.
2013-04-04 15:39:00 -07:00
ptarjan 6e2868de3e allow recursive test running
I found a bajillion more tests in the Zend repo, and I'm going to have to namespace things. I think this solution will also be nice for the porting our C++ strings. One directory per package and then when you want to run them all you run the top-level.
2013-04-04 15:38:59 -07:00
ptarjan f7b2fac580 become consistent with zend for too few param error
I've been fighting with these in the importer. What do you think about being consistent? It gives an extra param of info too.
2013-04-04 15:38:49 -07:00
jdelong c5db7e39ab Fix a bug with boxed static/counted types
When we box things, we need to forget whether we knew it was
static or not because we don't track when that might change.
2013-04-02 15:01:37 -07:00
mwilliams 1c329e4ba8 Add a test case for the scope of a closure generator 2013-04-02 15:00:53 -07:00
mikemag e8c06b0312 Fix heredoc/nowdoc bugs with large docs, docs crossing buffer boundaries
Fixed a few issues in the lexer for heredocs and nowdocs. The source file is read in 64k chunks, and any time a doc was split across a buffer boundary the lexer would fail to consume the doc properly. Modified the lexer to refill the file buffer when it is used, or when more data is needed in a variety of cases. Also fixed a number of other corner cases where we'd fail to recognize the doc end label or other special characters. The old code was also a bit over- and under-flowy.
2013-04-02 15:00:45 -07:00
ptarjan be704f1faf import zend tests
This is a first pass looking for suggestions.

    348 / 1268 passed (27.44%)

I modified the script, then ran:

    ./tools/import_zend_test.py /tmp/php-5.4.11/

which created all the zend tests. When they send out a new update, this script is idempotent so running it on the new tests should just make the working directory in a good enough state to commit.
2013-04-01 13:48:31 -07:00
mwilliams ec4e62d602 Fix closure dispatch when there's more than one Func*
We need to make sure that we execute the code
corresponding to the actual Func*. This re-uses the
prolog array to hold the entry points for the cloned
Func*.
2013-04-01 13:47:50 -07:00
bsimmers 66a84f861d Implement VectorTranslator::UnsetElem
Fairly straightforward. The only interesting part is the
addition of ElemUX, which behaves similarly to ElemDX in terms of
side-effects (but not exactly the same).
2013-04-01 13:47:50 -07:00
seanc c6d10ce255 Add HPHP support for newInstanceWithoutConstructor
Add support for PHP >=5.4 ReflectionClass::newInstanceWithoutConstructor
2013-04-01 13:46:30 -07:00
bsimmers 7d7edb8be2 Implement all of VerifyParamType in hhir
TranslatorX64 interps cases that it expects to fail but I
didn't like that, so the hhir version never punts or interps. The fast
path code reuses the stuff Jordan added for InstanceOfD and should be
the same as tx64's, modulo some branch fusing that doesn't appear to
matter in perflab.
2013-04-01 13:46:30 -07:00
bsimmers 88f1bcf907 Strengthen filepath.filter and make it run for all tests
It now handles filenames in strings that have been
var_dumped, without having to special case them. I also renamed it to
default.filter and changed verify to run it on every test. This lets us
remove a lot of symlinks that used to point to filepath.filter and
changed the expected output for a bunch of tests.
2013-04-01 13:46:30 -07:00
seanc 4a6ae52f5d Generators should show original name in backtrace
Use the original name instead of the outer name for generator
functions in backtraces
2013-04-01 13:46:30 -07:00
ptarjan a2c5921413 fix double space after notice and warnings
We are inconsistent with how many spaces happen after ##:## Errors have one, but warnings and notices have 2. I went with 1 because that is what Zend does.
2013-04-01 13:46:30 -07:00
mwilliams ed6ac5d10f Fix refcounting issues with string SetM
The code was assuming that the result of the assignment
would be the value assigned, but its actually a new string
containing the first character of the value assigned. The result
was that the SetM had already decRef'd the rhs, and then the
jitted code decRef'd it again. Since that last decRef was a decRefNZ,
we would often get away with simply leaking both the original rhs and
the value of the SetM. But the new testcase crashes in a DEBUG build
without the fix.
2013-04-01 11:51:38 -07:00
mwilliams 0ddaed959d Fix assert in CodeGenerator::emitTypeCheck
The vector translator produced a type that was
boxed-array-or-string, which we couldnt guard on.

Since applying a SetM to a string will almost always produce
a string, change it to report string instead (which will still
be guarded on).
2013-04-01 11:51:30 -07:00
jdelong 2c72411dae Don't use LdClsPropAddrCached for properties that might not be accessible
Tx64 only translates CGetS when you do it with the context
class the same as the class being looked up, to avoid the need for
accessibility checks.  The IR can translate it more often, but was
using its fast path even when it was not safe to do so: if a previous
(safe) access had allocated a targetcache entry, later accesses would
be able to get to the property without an access check.  For now just
limit the optimiation to safe cases.
2013-03-27 17:39:41 -07:00
mwilliams 46fe09ca5e IncDec bool needs to push a value
In the ir, it didnt, resulting in crashes/bogus values
2013-03-27 17:39:18 -07:00
mwilliams b387d70e70 RetC needs to zero ActRec::m_this before destroying it
In the case where m_this was already in a register,
and known to be non-zero, we would fail to zero the ActRec's
m_this field, which could result in a dangling reference
to $this being captured by debug_backtrace.

Put the store on the presumably cold path. Fix DecRefThis to
do the same.
2013-03-25 13:31:16 -07:00
ptarjan a5b7b243d6 add test
Never shall this happen again
2013-03-25 13:31:16 -07:00
ottoni 659da8c6b1 Fix assertion in ref-count optimization
MemElim may transform the source of a DecRefNZ into a constant,
so we shouldn't assert that it's coming from an IncRef.
2013-03-25 13:31:16 -07:00
ptarjan 6b61441bd9 more isStatic fixed for closures
The interpreter fix was different than the jit/ir fix because ##translateFPushObjMethodD()##'s ##i.inputs[0]->rtt.valueClass()## is null (with a TODO in the code to make it not null). It then goes into the slowpath.

Another one like this and I think I should have a different attribute for static closures :(
2013-03-25 12:44:12 -07:00
bsimmers 7219dec255 Implement more final operations in VectorTranslator
Most of this is pretty boring and mechanical. I added
VectorProp and VectorElem flags to help deal with the increasing
number of vector-related opcodes.
2013-03-22 11:48:50 -07:00
ptarjan a6d70040fa fix static closures
I added the check for this in the interpreter but ##f_array_map## re-enteres the VM via a different path than FCall. Here is the equivilent check for the VM.
2013-03-21 16:51:06 -07:00
ptarjan a1802db1d2 allow static keyword before closure
PHP added this in 5.4 so that you can say your closure shouldn't capture ##$this##. https://wiki.php.net/rfc/closures

Should we add it? Many of their unit tests use it.

Instead of putting a boolean somewhere I used the same attr framework and set the static bit there. Thoughts? It only needs one change in the ##FPushFunc##.
2013-03-21 16:50:55 -07:00
ptarjan 4d7004e955 :Allow $this on closures
In Zend 5.3 they decided that closures should inherit the ##$this## from the containing scope. This brings us close to paraity with them. The remaining thing is to make

    function() use ($this) {}

fatal after we purge it from WWW.
2013-03-21 16:50:12 -07:00
hermanv 186882bae7 Add more unit tests for conversion operations.
A batch of small sanity tests for the new conv instructions.
2013-03-21 16:13:21 -07:00
ptarjan cc37fe637a add Callable typehint
php-5.4 has it http://www.php.net/manual/en/language.types.callable.php
2013-03-21 16:13:20 -07:00
jdelong 6f82cce043 Update Setprofile test 2013-03-21 15:17:33 -07:00
ottoni d996ae0065 Fix HHIR simplification for missing bool-to-int promotions
The simplifier was not promoting the boolean to integer in some
cases. I hit this for the add-zero case, and code inspection revealed
similar bugs in sub-zero and multiply-one cases.
2013-03-21 15:17:24 -07:00
bsimmers 02e0774721 Implement support for stack bases in VectorTranslator
Any vector instructions that take a pointer to a base and might modify
it are now flagged with MayModifyStack. Any that actually do modify the stack
(this can be determined by looking at the input types) will produe two dests:
their original result and a new StkPtr. getStackValue calls into VectorEffects
to extract the new type and/or value. The instructions currently assume that
the stack cell they might be modifying is already synced to memory. This may
change in the future when we don't have to do a full SpillStack before the
helpers.
2013-03-19 14:11:16 -07:00
bsimmers ea56a8383e Implement specialized array setting in VectorTranslator
This mimics what TranslatorX64 does in translateSetMArray,
but it does it with fewer helpers and (often) fewer instructions in
translated code. I also found a bug in both jits and the interpreter
when dealing with arrays that hold refs to themselves. The new test
case exercises the fix, which involved a bit of refactoring of the
refcounting logic.

Enabling VectorTranslator while punting to tx64 is no longer a
regression so I removed the punt in emit().
2013-03-19 14:11:16 -07:00