Revision: 22849
Author: [email protected]
Date: Tue Aug 5 08:16:02 2014 UTC
Log: Do not include native Javascript in ExecutionState frames.
When a debug event is triggered, the ExecutionState object should not
expose native JS code.
[email protected]
Review URL: https://codereview.chromium.org/429453005
http://code.google.com/p/v8/source/detail?r=22849
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/es6/debug-promise-events.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Mon Aug 4 15:06:28 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Tue Aug 5 08:16:02 2014 UTC
@@ -11048,7 +11048,12 @@
}
for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) {
- n += it.frame()->GetInlineCount();
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ it.frame()->Summarize(&frames);
+ for (int i = frames.length() - 1; i >= 0; i--) {
+ // Omit functions from native scripts.
+ if (!frames[i].function()->IsFromNativeScript()) n++;
+ }
}
return Smi::FromInt(n);
}
@@ -11161,6 +11166,23 @@
JavaScriptFrame* frame = it.frame();
return isolate->heap()->ToBoolean(frame->is_optimized());
}
+
+
+// Advances the iterator to the frame that matches the index and returns
the
+// inlined frame index, or -1 if not found. Skips native JS functions.
+static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int
index) {
+ int count = -1;
+ for (; !it->done(); it->Advance()) {
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ it->frame()->Summarize(&frames);
+ for (int i = frames.length() - 1; i >= 0; i--) {
+ // Omit functions from native scripts.
+ if (frames[i].function()->IsFromNativeScript()) continue;
+ if (++count == index) return i;
+ }
+ }
+ return -1;
+}
// Return an array with frame details
@@ -11196,22 +11218,13 @@
return heap->undefined_value();
}
- int count = 0;
JavaScriptFrameIterator it(isolate, id);
- for (; !it.done(); it.Advance()) {
- if (index < count + it.frame()->GetInlineCount()) break;
- count += it.frame()->GetInlineCount();
- }
- if (it.done()) return heap->undefined_value();
+ // Inlined frame index in optimized frame, starting from outer function.
+ int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index);
+ if (inlined_jsframe_index == -1) return heap->undefined_value();
- bool is_optimized = it.frame()->is_optimized();
-
- int inlined_jsframe_index = 0; // Inlined frame index in optimized
frame.
- if (is_optimized) {
- inlined_jsframe_index =
- it.frame()->GetInlineCount() - (index - count) - 1;
- }
FrameInspector frame_inspector(it.frame(), inlined_jsframe_index,
isolate);
+ bool is_optimized = it.frame()->is_optimized();
// Traverse the saved contexts chain to find the active context for the
// selected frame.
@@ -13585,14 +13598,11 @@
return heap->undefined_value();
}
- int count = 0;
JavaScriptFrameIterator it(isolate, id);
- for (; !it.done(); it.Advance()) {
- if (index < count + it.frame()->GetInlineCount()) break;
- count += it.frame()->GetInlineCount();
- }
- if (it.done()) return heap->undefined_value();
-
+ int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index);
+ if (inlined_jsframe_index == -1) return heap->undefined_value();
+ // We don't really care what the inlined frame index is, since we are
+ // throwing away the entire frame anyways.
const char* error_message = LiveEdit::RestartFrame(it.frame());
if (error_message) {
return *(isolate->factory()->InternalizeUtf8String(error_message));
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/debug-promise-events.js Tue
Aug 5 07:42:06 2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/es6/debug-promise-events.js Tue
Aug 5 08:16:02 2014 UTC
@@ -32,6 +32,7 @@
// New promise.
assertEquals("pending", event_data.promise().status());
result.push({ promise: event_data.promise().value(), status: 0 });
+ assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event")
0);
} else if (event_data.status() !== undefined) {
// Resolve/reject promise.
updatePromise(event_data.promise().value(),
@@ -43,6 +44,7 @@
assertTrue(event_data.parentPromise().isPromise());
updatePromise(event_data.promise().value(),
event_data.parentPromise().value());
+ assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event")
0);
}
} catch (e) {
print(e + e.stack)
@@ -52,15 +54,15 @@
Debug.setListener(listener);
-function resolver(resolve, reject) {
- resolve();
-}
+function resolver(resolve, reject) { resolve(); }
-var p1 = new Promise(resolver);
-var p2 = p1.then().then();
-var p3 = new Promise(function(resolve, reject) { reject("rejected"); });
-var p4 = p3.then();
-var p5 = p1.then();
+var p1 = new Promise(resolver); // event
+var p2 = p1.then().then(); // event
+var p3 = new Promise(function(resolve, reject) { // event
+ reject("rejected");
+});
+var p4 = p3.then(); // event
+var p5 = p1.then(); // event
function assertAsync(b, s) {
if (b) {
--
--
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.