Reviewers: aandrey,
Description:
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]
Please review this at https://codereview.chromium.org/429453005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+30, -15 lines):
M src/runtime.cc
M test/mjsunit/es6/debug-promises-new-event.js
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
7afa3a6aa6e6122bc1932a2a320d3077684d18d9..96e07a71a0cf31c8047c4f8296a39ac19e45feef
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -11078,7 +11078,12 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
}
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);
}
@@ -11193,6 +11198,23 @@ RUNTIME_FUNCTION(Runtime_IsOptimized) {
}
+// Advances the iterator to 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
// args[0]: number: break id
// args[1]: number: frame index
@@ -11226,22 +11248,13 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
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.
Index: test/mjsunit/es6/debug-promises-new-event.js
diff --git a/test/mjsunit/es6/debug-promises-new-event.js
b/test/mjsunit/es6/debug-promises-new-event.js
index
b08077c5b884d7939ac8044b65b3b72c1d388b13..49346ada33fbb84404e7ca8b4d0e4e40bbf7cc59
100644
--- a/test/mjsunit/es6/debug-promises-new-event.js
+++ b/test/mjsunit/es6/debug-promises-new-event.js
@@ -21,6 +21,8 @@ function listener(event, exec_state, event_data, data) {
assertTrue(event_data.promise().isPromise());
new_promise = event_data.promise().value();
assertEquals("pending", event_data.promise().status());
+ assertEquals(1, exec_state.frameCount());
+ assertTrue(exec_state.frame(0).sourceLineText().indexOf("Event") > 0);
} catch (e) {
print(e + e.stack)
exception = e;
@@ -33,7 +35,7 @@ function resolver(resolve, reject) {
resolve(); // Token
}
-var p = new Promise(resolver);
+var p = new Promise(resolver); // Event
assertEquals(new_promise, p);
assertNull(exception);
--
--
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.