Gráfico de Commits

58 Commits

Autor SHA1 Mensagem Data
Jordan DeLong 67bf707768 Fixes and improvements for type aliases
Replace NameDef with a new struct of runtime-resolved typedef
information.  This needs to include more than Class* or Typedef*,
because we might have nullable type aliases, or a non-nullable alias
to a nullable typedef, or vice versa.  Switch to the new
TypeAnnotation stuff in TypedefStatement instead of just strings so
support for this isn't weird (shapes are outside of this for now
though---see the hack in parser.cpp).  Also fixes support for type
aliases to mixed.
2013-06-27 15:14:22 -07:00
Sean Cannella 9849079ee4 fix print flag mismatch build warning on other platforms
- fix mismatch between %lu and uint64_t in printf flags
2013-06-27 15:14:17 -07:00
Jordan DeLong f828a7af6d Never allow typedefs with the same names as classes
Right now, we allowed it as long as the typedef was for the
same class.  (Oversight.)  This involved a few error message changes
in existing tests.
2013-06-27 10:50:13 -07:00
Bert Maher bb7dff89d9 Make unit.cpp not take forever to compile
The AtomicHashMap constructor seems to be causing
Unit::GetNamedEntity to take forever to compile in the opt build, so I
moved the initialization out of that function and marked it #pragma
GCC optimize ("O0") to prevent whatever crazy optimization is freaking
gcc out.
2013-06-27 10:39:17 -07:00
bsimmers 6d91f8195a Turn HPHP::Op into an enum class
Because stronger types are better types, and this will make
future refactoring easier. I considered trying to purge the Opcode
type from the codebase too but that would be a much bigger project.
2013-06-25 13:19:08 -07:00
Sean Cannella 303ea58976 convert enums to enum classes, part 2
C++11 cleanup (clean up easy enums)

Since sandcastle is failing:
2013-06-25 13:19:05 -07:00
Paul Tarjan 0714b4e389 use a flag instead of isdigit
Instead of doing name-based checks, using a flag in the runtime seems better. I tried to have a flag on the FuncEmitter that was set when you made these weird functions, but there was a few situations that needed to do name-based checks

* .hhas files have no control over anything but the name
* the parser would have to pass the info through the AST to the emitter

Instead I opted for the simpler approach for now until we want to solve those.
2013-06-15 23:30:25 -07:00
Ben Maurer 69143a273c Possible Leak in UnitEmitter
I was looking at a jemalloc profile of HPHP ram and noticed
250 MB of RAM allocated from UnitEmitter::UnitEmitter. This
doesn't make sense since the memory is released on destruction.
I think that we're calling setBc which leaks the memory
2013-06-15 19:33:44 -07:00
Jordan DeLong bf72004e0e Remove some confusing assignments to NamedEntity::m_cachedClassOffset
Assigning this field is actually protected by the target
cache lock, and allocKnownClass does the assignment.
2013-06-12 17:10:26 -07:00
Jan Oravec e8acd400ac Remove unused UnitEmitter::m_feMap
The value of m_feMap is never used. Keys are used to assert when there
is an attempt to define a function with already existing name. It does
this job poorly because it is not an authoritative source of existing
function names. When the top-level function is defined, setCached() is
called, which already checks for duplicates, so let's rely on it.
2013-06-12 11:34:39 -07:00
Paul Tarjan 269ec416d5 Rename closures and generators - take 3
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.
2013-06-12 11:34:39 -07:00
Paul Tarjan d5ee17487a allow constants in systemlib
The problem was a few:

* All constant declarations were wrapped in a statement list. The merge-only check was allowing top-level `define()`s but not top level statement lists. I unwrapped them. I have no idea why it was done. Probalby just cargo cult programming.
* When converting a UnitEmitter to a Unit we only allowed constants in RepoAuthoritative mode and not systemlib mode.
* Systemlib constants weren't being set as UnitMergeKindPersistentDefine
* UnitMergeKindPersistentDefine constants weren't being marked mergeOnly when pulling out of a repro
2013-06-11 11:47:28 -07:00
Paul Tarjan 8cf6ccb00a use TRACE_SET_MOD
I found this macro while refactoring and since I like consistency, I used it everywhere.
2013-06-10 10:14:13 -07:00
Jordan DeLong fa6f3f7e12 Implement most of class_alias
Throws the aliased class into a target cache slot for the new
name.  Handles errors when you try to re-alias a class, but doesn't
restrict a few other cases zend does:

  - If you implement an interface twice, zend complains (one of the
    alias tests checks this).  I tried turning it on, but we violate
    it in systemlib currently so I left it off.

  - class_alias_014.php does some namespace stuff I don't quite grok.
    (@ptarjan let me know what to do if it's easy).

  - inter_007.php uses class_alias, but is testing a warning that
    happens even with out it.  (We don't raise this warning.)

  - zend raises a warning if you try to class_alias a non-user-defined
    class; I left this out.
2013-06-06 12:00:05 -07:00
Sean Cannella 64e24977ca STD* streams should not be defined in server mode
- Zend doesn't define STDIN/STDERR/STDOUT in server mode, neither should
  we
2013-06-06 11:08:39 -07:00
Jordan DeLong 4e547faa8f Verifier: disable iterator checks, turn verifier on for systemlib @override-unit-failures
It's better to have some checks than none.  The only checks
failing in systemlib are iterator lifetime things, which it seems like
we're not about to fix.  Run the verifier on systemlib but only in
debug builds.
2013-06-06 11:07:59 -07:00
Jordan DeLong 82095e9227 Unconditionally run the verifier on hhas files; fix various errors @override-unit-failures 2013-06-04 17:53:38 -07:00
Owen Yamauchi 9494a366b5 Move runtime/eval/runtime/file_repository.* to runtime/base
runtime/eval is a relic of a bygone era. As long as we're cleaning up
our directory structure, let's move FileRepository (the only remaining
thing in runtime/eval/runtime) to where it makes sense.

runtime/eval still contains the debugger, which would probably make more
sense as runtime/debugger, but I don't want to throw a wrench in the
works for @mikemag and @hermanv unnecessarily.
2013-06-03 23:54:34 -07:00
Tim Starling 998951619f update copyright date
We did not intend to imply our copyrights last forever

Closes #759
2013-06-03 12:43:56 -07:00
Jordan DeLong f008eafffe Move SrcKey out of translator.h and Transl:: @override-unit-failures
I was going to #include translator.h in a header I had for
talking to the region selector thing and decided to just get this over
with instead.  (It shouldn't need to #include that.)  Found a few
other unused things to remove while at it.
2013-06-03 10:55:04 -07:00
bsimmers cf197fee81 Collapse runtime/vm/translator's contents into runtime/vm/jit
Facebook: ~bsimmers/bin/move-vm-files.sh
2013-06-03 10:54:43 -07:00
bsimmers 991c1e3bdb Rip out preconsts
This was barely a demonstrable win in sandbox mode when I first wrote
it and it's not even used in hhir. It's probably been bitrotting and is causing
crashes for some people. Time to say goodbye.
2013-06-03 10:54:40 -07:00
mwilliams 71859e5566 Add support for .hhas files in systemlib
Will be needed for array_filter/array_map etc

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

Also did a little reorganization to get rid of Func::isPHPBuiltin,
and use an Attr to identify functions as builtins. C++ builtins can
still be identified by checking the Func::info() method. This is needed
to allow builtin methods defined in php (such as array_map) to lookup their
arguments in the correct context.
2013-05-30 17:33:02 -07:00
Paul Tarjan c02df18f78 don't show Closure in get_declared_classes()
This was the fastest thing I could think of. Would string searching the name be better?

No user class can extend from Closure, so we're ok on that front.
2013-05-23 21:03:05 -07:00
Sean Cannella 05a8a8d7ca Rewrite idx in PHP using IR instruction for hot path
- Do the actual work of implementing idx() in PHP
- Remove the old C++ builtin (which needs to be done at the same time)
- Remove OSS test dependencies on idx()
2013-05-21 11:17:35 -07:00
Mark Williams 5c491af2de Don't reinitialize native funcs
The Func*'s in the native func unit are all persistent, which means
that we can strip them, and skip the Unit::merge call on every
request. But we didnt set the flag to compact the unit if the only
things that needed stripping were Func*'s. Fixed that, and also fixed
it so all the builtins are marked persistent even in non-repo-auth
mode (funcs are not if rename function is enabled, because we implement
fb_rename_function by swapping target cache entries).
2013-05-20 13:52:29 -07:00
Paul Tarjan 99fcd4295e canonicalize \print_r to print_r at runtime
builds on D795509.

This copies all the callsites where we autoload.
2013-05-20 13:52:26 -07:00
Andrei Alexandrescu 2baabea1ae new considered harmful
I'm committing my work on HphpArray in bite-sized pieces for easier review. This piece replaces calls to NEW with a factory method. There are many problems with operator new, starting with the fact that the allocator cannot communicate properly with the constructor.

The newly introduced factory method should return ArrayData but that causes many issues right now, so I left that step to a future diff.
2013-05-20 13:52:25 -07:00
Mark Williams 1489c698dc Use AtomicHashMap for NamedEntities and StaticStrings
Its faster as long as you have a good starting point.
Add RuntimeOptions to specify initial sizes.
2013-05-20 12:04:09 -07:00
Mark Williams 86d9acaf6e Undo some #include renames
sys/*.h should use angle brackets.
Also, fix most of the lint errors for the affected files
2013-05-15 13:05:10 -07:00
Jordan DeLong dfbf27d243 Fix a bug with null constants
We end up with uninit nulls in the repo for unit constants.
In RepoAuthoritative mode, we will use m_type == KindOfUninit during
constant lookup to decide whether to cast TypedValue::m_data.pref to a
ConstantInfo*, and then call a function pointer that it contains.  (We
should probably also clean that up to not cast RefData*'s to
ConstantInfo*'s, but I left that out of this diff.)
2013-05-15 13:05:06 -07:00
Sara Golemon 6ec64e8bf9 make #includes consistent
I was learning from @jdelong and he said that you should use
double quotes for local includes and angle brackets for library
includes. I asked why our code was the way it was, and he said he wanted
to clean it up. I beat him to it :)

Conflicts:

	hphp/runtime/base/server/admin_request_handler.cpp
	hphp/runtime/vm/named_entity.h
2013-05-15 13:05:06 -07:00
Paul Tarjan fef62f03a2 kill VM namespace
Now that HHVM is the default runtime, this namespace doesn't mean anything.
2013-05-15 13:05:05 -07:00
Paul Tarjan 994ce35b82 cleanup lookupFunc
This func took 2 params and ignored the second one. While I was there I made the functions call eachother. Hopefully inlining is smart enough to let me clean this code.

I got a bit carried away, but I think this is better.
2013-05-15 13:05:01 -07:00
Mark Williams bf0dd20fef Rewrite fb_intercept to use the FunctionEnter hook
This cleans up the code a lot, and takes it out of various hot
paths. It will impact perf for requests where intercepts are used,
but no longer penalizes requests that don't use intercepts.
2013-05-09 11:37:39 -07:00
bsimmers 8436050f1f Use traceRelease for Eval.DumpBytecode
This shouldn't be restricted to debug builds.
2013-05-07 10:55:32 -07:00
Mark Williams 6f4b1c76a8 Fix issue with call_user_func_array and by-ref params
We can't box a non-ref value for a ref param because
we could be modifying an array with refCount != 1.

zend warns, skips the call and returns null. For now, this
makes us warn, but do the call (without modifying the array).

A file scope flag controls whether to skip the call or not,
and should be changed (and eliminated) once all our tests pass.

With the flag turned on, we still dont match zend's behavior,
because its happy to go ahead and call the function with no
warning in the case of a literal array parameter
(cuf('foo', array(1))), even though it warns and skips it when
the array is in a variable ($a=array(1); cuf('foo', $a)).
2013-04-30 09:58:57 -07:00
Keith Adams 98483c74d6 Lift a lot of stuff out of HPHP::VM.
This is a partial step towards merging the HPHP::VM namespace
up into its parent. To keep it reviewable/mergeable I'm not doing
everything at once here, but most of the code I've touched seems
improved. I've drawn an invisible line around the jit, Unit and
its cohort (Class, Func, PreClass, etc.); we'll get back to them
soon.
2013-04-25 00:50:01 -07:00
Sean Cannella 54efa29d5f Fix off-by-one in multi-line function call traces
Fixes off-by-one in line number reporting in multi-line function calls
2013-04-24 22:32:36 -07:00
Mark Williams 3e75f5b7e4 Fix issue with Unit::merge
A recently introduced bug could cause classes and
interfaces to be silently dropped in repo-authoritative mode.
2013-04-24 17:13:58 -07:00
Mike Magruder 76db66ec82 Add comments to some of the debugger code to aid in understanding it more clearly, plus minor code cleanup.
Add a lot of comments to the debugger based on my current understanding of it. These may change in the future as we learn more, but they're helpful right now.

Also moved a few small things around in the code to clarify their purpose or scope. I.e., making a few things private, renaming a few functions, etc. No real logic changes, though. Also minor dead code removal. Also a few lint errors.
2013-04-23 09:52:57 -07:00
mwilliams 5f9df0e7c6 Rework constants to use the target cache exclusively
Make the targetcache the one true home for constants,
so we dont need to (also) insert them all into
VMExecutionContext::m_constants (which is now gone).

By also making "non-volatile" constants persistent, we save
initializing most of them at all in RepoAuthoritative mode.
2013-04-18 12:19:05 -07:00
mwilliams 4842f4ee1d Flatten fast path in GetNamedEntity
While investigating why gcc-4.7.1 is slower than gcc-4.6.2,
I noticed that under 4.6.2 the tbb code was being inlined into
Unit::GetNamedEntity, but under 4.7.1 it wasn't. Perf showed that
the inclusive time for GetNamedEntity was about .4% higher under
gcc-4.7.1.

Meanwhile, after various code changes, gcc-4.6.2 is no longer
inlining the tbb code either. Playing with the inlining options,
I wasnt able to get either version of gcc to inline it anymore,
but using __attribute__((__flatten__)) works for both. But that
also causes a bunch of other, slow-path code to be inlined, so
split it into a hot and a cold function, and flatten the hot
function.

Perf shows about a .2% win for Unit::GetNamedEntiry under gcc-4.6.2
2013-04-17 10:12:45 -07:00
jdelong d432f19ae1 Allocate unit bytecode and metadata in a read-only memory region
Only in RepoAuthoritative mode, where units can't be
deallocated.  I have a semi-reproducable bug where a unit's m_bc
region is getting corrupted (only occasionally in perflab).
Presumably moving it out of the malloc'd heap will make the bug
corrupt something else, so this probably doesn't really help much, but
it seemed like having a separate region for some cold, read-only,
process-lifetime metadata might make sense.
2013-04-12 11:22:45 -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
Owen Yamauchi 9c453b1ad0 Get rid of ext_hhvm_noinline.cpp, part 2
unserialize() and call_user_func_array() were straightforward. They were
called from all over the runtime, but I renamed those implementations
and codemodded the runtime.

The is_* functions were only ever being called by the CVarRef signature,
so I deleted all the other ones (same for f_gettype). Only some of the
is_* functions were being called from the runtime, so I made inline
versions of those without the f_ prefix.
2013-04-08 21:16:48 -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
mwilliams 4514a79c60 Remove ReqSrc and ReqMod
They can no longer be generated. Also remove all the associated
code from the emitter.
2013-03-13 09:53:58 -07:00
smith 6434422e85 Encapsulate access to m_aux in TypedValueAux subclass.
Access to TypedValue.m_aux must now be via TypedValueAux.  For now,
TypedValueAux is an empty subclass with accessors to m_aux, which is
now private.  Once RefData.m_tv is moved out from under RefData._count,
we can move TypedValue.m_aux to TypedValueAux.

Removed unnecessary initialization of m_aux.u_hash from c_Vector.
2013-03-11 21:19:20 -07:00
smith 1569061e8c Rename TypedValue._count to m_aux; Variant extends TypedValue.
This diff removes initializing stores to TypedValue._count, renames
_count to m_aux, and makes m_aux a union with members typed
and named according to their specialized uses.   The few remaining
uses of that field for random tweaks are more obvious and easy to
grep for.

TypedValue no longer extends Value, (allowing m_data to move to a
different offset in the future), and Variant now extends TypedValue,
so we only have to maintain one definition.

HphpArray now explicitly uses TypedValue.m_pad instead of overlapping
TypedValue with an anonymous struct, again so we don't have to maintain
another structure to match TypedValue's layout.

The JIT's were using offsetof(TypedValue, _count) all over the place
for access to String/Array/Object/RefData::_count.  Instead, use
FAST_REFCOUNT_OFFSET.
2013-03-09 15:07:37 -08:00