Gráfico de Commits

15 Commits

Autor SHA1 Mensagem Data
jan a131e5232e Handle invalid Continuation state at start time
In an unlikely situation a user of ext_asio may tamper with Continuation
before passing it to the ext_asio extension. Let's fail with an
exception if this happens. Previously, a user bug would stay unnoticed,
but would not harm the ext_asio code.

This check will be needed once we implement optimistic execution. With
optimistic execution, we iterate continuation and defer construction of
ContinuationWaitHandle until the first blocking event occurs. During
this phase, a standard dependency loop detection is skipped and the code
would try to iterate a continuation that is already being iterated.
2013-03-27 11:40:17 -07:00
jan 06aefe7e37 Remove deprecated support for priority in ContinuationWaitHandle::start()
PHP code does not use this anymore. Let's remove the support.
2013-03-21 17:31:09 -07:00
jan 6d3f04d0a9 Remove deprecated yield array(...), try #2
Our PHP code no longer yields arrays. Remove.
2013-03-21 16:51:06 -07:00
Alex Suhan 1742a79189 Add on started callback to AsioSession
The PHP code using Awaitable interface will need this.
2013-03-21 15:55:58 -07:00
mwilliams ba0cc6be65 Better instanceof checks
o_instanceof was doing class lookups on statically known classes.
Use the statically known Class* instead.
2013-03-09 14:44:00 -08:00
mwilliams 6c87ecb74e Remove dynamic_table_class.cpp
We only used it to get the values of certain class constants,
and to define the ObjectStaticCallbacks for every class.

We can put the class constants directly into the class_map
(we should have done that before for perf reasons), and then
the only remaining use of ObjectStaticCallbacks is to proxy
the Class* for each builtin class. So just use the Class*
directly.

Once this is in, Im just a small step away from eliminating
make -C hphp/system - so Im leaving a lot of dead code here.
Its going to be easier to delete it en masse, rather than
try to pick and chose now.
2013-03-08 08:50:45 -08:00
mwilliams 2f3f5f3c5a Get rid of FrameInjection 2013-03-07 22:04:08 -08:00
jan 883a11fbef Fix consistency issue with cross-context cycle exceptions
enterContext() throws an exception when cross-context cycle is found.
The problem is that it modifies state before the exception is thrown,
assuming that the call will succeed.

When an exception is thrown, a dependency is left in invalid state, with
parent being in more specific context. This breaks exitContext()
algorithm and results in either internal invariant violations as seen
in #2091939, or memory corruptions and crashes as seen in #2125762.

Let's fix it by modifying state after returning back from recursive call
instead of before doing such call. This was previously unsafe in case we
tried to import dependency loop. Once D720506 is committed, dependency
loops will not exist anymore.
2013-03-05 22:28:42 -08:00
jan c6475efbec Detect cycles online and fix part of #2125762
Currently, we detect dependency loops by waiting until there is nothing
else to execute. If the wait handle we are waiting for did not finish,
it means it is in a cycle. We find the cycle by simply following the
dependency chain. Once the cycle is found, one edge is eliminated and an
exception is injected.

There are multiple problems with this approach:

1. Unability to exit contet safely

We are unable to exit context safely. When a context is exited, all wait
handles in that context must be kicked out. But we maintain only
references to the SCHEDULED wait handles + BLOCKED wait handles that
recursively depend on them.

If we do not kick out all unfinished wait handles, we end up in
corrupted state.

2. Unability to break edge that caused the cycle

Once the cycle is detected, we don't know which edge caused the cycle to
be formed. We can only use heuristics to eliminate the edge that likely
formed the cycle, we cannot be sure. This may make it very hard to fix
the PHP code that caused the cycle.

Solution:

This diff implements online cycle detection with a naive approach of
visiting the dependency chain from child at a time new edge between
parent and child is being added. If a parent is visited, a cycle is
found. Otherwise we eventually reach non-BLOCKED wait handle as it is
guaranteed the rest of the graph is cycle-free.
2013-03-05 22:28:41 -08:00
jan a1baf2d540 Access context by index
Currently, wait handles store pointer to the context they are in. This
pointer is not protected with reference counting, as it is expected that
whenever a context is exited, references to it are cleaned thru
exitContext() mechanism.

If a bug is present that violates this assumption, it is impossible to
guard against invalid pointer access and a hard to debug memory
corruption occurs.

Since the structure of contexts is a simple stack, let's reference them
by index instead of by pointer.

As a bonus, one pointer worth of memory is saved for every non-trivial wait handle.

The actual bugs will be fixed by the next 2 diffs that do:
1. implement online cycle detection
2. do enterContext() atomically and properly handle failure
2013-03-05 22:28:41 -08:00
jan cee31f4412 RescheduleWaitHandle: management of execution priority
Abstract away execution priority management from ContinuationWaitHandle
and create RescheduleWaitHandle.
2013-02-19 06:53:40 -08:00
jan aee58ac19e Allow null dependency in tail call
If a continuation yields null in a tail call, we end up failing on
throw_null_pointer_exception. Fix it.
2013-02-13 06:42:47 -08:00
jan 28116234fb Use o_instanceof instead of dynamic_cast<>
Avoid dynamic_cast<> on fast paths, use o_instanceof(StaticString)
instead. Saves about ~0.2-0.3% of CPU time.

Once HPHPc is gone, we will convert these calls to HHVM-specific API.

Thanks @bmaurer for discovery and @mwilliams for suggestion how to fix
it.
2013-02-11 12:04:10 -08:00
jan 03c8d47acb Unbox references in CWH::markCurrentAsSucceeded()
Seems that the calling convention allows values to be passed by
reference and it's up to the extension to unbox them.
2013-02-11 08:13:21 -08:00
Jordan Delong 363d1bb20f Code move src/ -> hphp/
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.
2013-02-11 02:10:41 -08:00