Revision: 21933
Author: [email protected]
Date: Mon Jun 23 11:47:20 2014 UTC
Log: Run JS micro tasks in the appropriate context.
[email protected]
BUG=385349
LOG=Y
Review URL: https://codereview.chromium.org/332923003
http://code.google.com/p/v8/source/detail?r=21933
Modified:
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/src/isolate.cc Mon Jun 23 09:46:58 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc Mon Jun 23 11:47:20 2014 UTC
@@ -2292,12 +2292,10 @@
void Isolate::RunMicrotasks() {
- // TODO(adamk): This ASSERT triggers in mjsunit tests which
- // call the %RunMicrotasks runtime function. But it should
- // never happen outside of tests, so it would be nice to
- // uncomment it.
- //
- // ASSERT(handle_scope_implementer()->CallDepthIsZero());
+ // In some mjsunit tests %RunMicrotasks is called explicitly, violating
+ // this assertion. Therefore we also check for --allow-natives-syntax.
+ ASSERT(FLAG_allow_natives_syntax ||
+ handle_scope_implementer()->CallDepthIsZero());
// Increase call depth to prevent recursive callbacks.
v8::Isolate::SuppressMicrotaskExecutionScope suppress(
@@ -2317,6 +2315,8 @@
if (microtask->IsJSFunction()) {
Handle<JSFunction> microtask_function =
Handle<JSFunction>::cast(microtask);
+ SaveContext save(this);
+ set_context(microtask_function->context()->native_context());
Handle<Object> exception;
MaybeHandle<Object> result = Execution::TryCall(
microtask_function, factory()->undefined_value(),
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Jun 23 09:11:45
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Jun 23 11:47:20
2014 UTC
@@ -20826,6 +20826,37 @@
}
isolate->SetAutorunMicrotasks(true);
}
+
+
+static void DebugEventInObserver(const v8::Debug::EventDetails&
event_details) {
+ v8::DebugEvent event = event_details.GetEvent();
+ if (event != v8::Break) return;
+ Handle<Object> exec_state = event_details.GetExecutionState();
+ Handle<Value> break_id = exec_state->Get(v8_str("break_id"));
+ CompileRun("function f(id) { new FrameDetails(id, 0); }");
+ Handle<Function> fun = Handle<Function>::Cast(
+ CcTest::global()->Get(v8_str("f"))->ToObject());
+ fun->Call(CcTest::global(), 1, &break_id);
+}
+
+
+TEST(Regress385349) {
+ i::FLAG_allow_natives_syntax = true;
+ v8::Isolate* isolate = CcTest::isolate();
+ HandleScope handle_scope(isolate);
+ isolate->SetAutorunMicrotasks(false);
+ Handle<Context> context = Context::New(isolate);
+ v8::Debug::SetDebugEventListener(DebugEventInObserver);
+ {
+ Context::Scope context_scope(context);
+ CompileRun("var obj = {};"
+ "Object.observe(obj, function(changes) { debugger; });"
+ "obj.a = 0;");
+ }
+ isolate->RunMicrotasks();
+ isolate->SetAutorunMicrotasks(true);
+ v8::Debug::SetDebugEventListener(NULL);
+}
static int probes_counter = 0;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.