Commit 01560f9c authored by yangguo@chromium.org's avatar yangguo@chromium.org

Do not include native Javascript in ExecutionState frames.

When a debug event is triggered, the ExecutionState object should not
expose native JS code.

R=aandrey@chromium.org

Review URL: https://codereview.chromium.org/429453005

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22849 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 88ce4eb5
...@@ -11048,7 +11048,12 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) { ...@@ -11048,7 +11048,12 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
} }
for (JavaScriptFrameIterator it(isolate, id); !it.done(); it.Advance()) { 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); return Smi::FromInt(n);
} }
...@@ -11163,6 +11168,23 @@ RUNTIME_FUNCTION(Runtime_IsOptimized) { ...@@ -11163,6 +11168,23 @@ RUNTIME_FUNCTION(Runtime_IsOptimized) {
} }
// 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 // Return an array with frame details
// args[0]: number: break id // args[0]: number: break id
// args[1]: number: frame index // args[1]: number: frame index
...@@ -11196,22 +11218,13 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) { ...@@ -11196,22 +11218,13 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
return heap->undefined_value(); return heap->undefined_value();
} }
int count = 0;
JavaScriptFrameIterator it(isolate, id); JavaScriptFrameIterator it(isolate, id);
for (; !it.done(); it.Advance()) { // Inlined frame index in optimized frame, starting from outer function.
if (index < count + it.frame()->GetInlineCount()) break; int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index);
count += it.frame()->GetInlineCount(); if (inlined_jsframe_index == -1) return heap->undefined_value();
}
if (it.done()) 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); 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 // Traverse the saved contexts chain to find the active context for the
// selected frame. // selected frame.
...@@ -13585,14 +13598,11 @@ RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { ...@@ -13585,14 +13598,11 @@ RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) {
return heap->undefined_value(); return heap->undefined_value();
} }
int count = 0;
JavaScriptFrameIterator it(isolate, id); JavaScriptFrameIterator it(isolate, id);
for (; !it.done(); it.Advance()) { int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index);
if (index < count + it.frame()->GetInlineCount()) break; if (inlined_jsframe_index == -1) return heap->undefined_value();
count += it.frame()->GetInlineCount(); // We don't really care what the inlined frame index is, since we are
} // throwing away the entire frame anyways.
if (it.done()) return heap->undefined_value();
const char* error_message = LiveEdit::RestartFrame(it.frame()); const char* error_message = LiveEdit::RestartFrame(it.frame());
if (error_message) { if (error_message) {
return *(isolate->factory()->InternalizeUtf8String(error_message)); return *(isolate->factory()->InternalizeUtf8String(error_message));
......
...@@ -32,6 +32,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -32,6 +32,7 @@ function listener(event, exec_state, event_data, data) {
// New promise. // New promise.
assertEquals("pending", event_data.promise().status()); assertEquals("pending", event_data.promise().status());
result.push({ promise: event_data.promise().value(), status: 0 }); result.push({ promise: event_data.promise().value(), status: 0 });
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
} else if (event_data.status() !== undefined) { } else if (event_data.status() !== undefined) {
// Resolve/reject promise. // Resolve/reject promise.
updatePromise(event_data.promise().value(), updatePromise(event_data.promise().value(),
...@@ -43,6 +44,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -43,6 +44,7 @@ function listener(event, exec_state, event_data, data) {
assertTrue(event_data.parentPromise().isPromise()); assertTrue(event_data.parentPromise().isPromise());
updatePromise(event_data.promise().value(), updatePromise(event_data.promise().value(),
event_data.parentPromise().value()); event_data.parentPromise().value());
assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
} }
} catch (e) { } catch (e) {
print(e + e.stack) print(e + e.stack)
...@@ -52,15 +54,15 @@ function listener(event, exec_state, event_data, data) { ...@@ -52,15 +54,15 @@ function listener(event, exec_state, event_data, data) {
Debug.setListener(listener); Debug.setListener(listener);
function resolver(resolve, reject) { function resolver(resolve, reject) { resolve(); }
resolve();
}
var p1 = new Promise(resolver); var p1 = new Promise(resolver); // event
var p2 = p1.then().then(); var p2 = p1.then().then(); // event
var p3 = new Promise(function(resolve, reject) { reject("rejected"); }); var p3 = new Promise(function(resolve, reject) { // event
var p4 = p3.then(); reject("rejected");
var p5 = p1.then(); });
var p4 = p3.then(); // event
var p5 = p1.then(); // event
function assertAsync(b, s) { function assertAsync(b, s) {
if (b) { if (b) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment