Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/isolate.cc

Issue 1712003003: Add WasmFrame, backtraces reflect wasm's presence (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing test change. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/frames-inl.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index e9a237b412c7434c5ac30313c4b4e81c8e1987f2..481615ec3ef17b18501fbc05d03212c6606eefc2 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -338,6 +338,21 @@ static bool IsVisibleInStackTrace(JSFunction* fun,
return true;
}
+static Handle<FixedArray> MaybeGrow(Isolate* isolate,
+ Handle<FixedArray> elements,
+ int cur_position, int new_size) {
+ if (new_size > elements->length()) {
+ int new_capacity = JSObject::NewElementsCapacity(elements->length());
+ Handle<FixedArray> new_elements =
+ isolate->factory()->NewFixedArrayWithHoles(new_capacity);
+ for (int i = 0; i < cur_position; i++) {
+ new_elements->set(i, elements->get(i));
+ }
+ elements = new_elements;
+ }
+ DCHECK(new_size <= elements->length());
+ return elements;
+}
Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
Handle<Object> caller) {
@@ -364,51 +379,68 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
int frames_seen = 0;
int sloppy_frames = 0;
bool encountered_strict_function = false;
- for (JavaScriptFrameIterator iter(this);
- !iter.done() && frames_seen < limit;
+ for (StackFrameIterator iter(this); !iter.done() && frames_seen < limit;
iter.Advance()) {
- JavaScriptFrame* frame = iter.frame();
- // Set initial size to the maximum inlining level + 1 for the outermost
- // function.
- List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
- frame->Summarize(&frames);
- for (int i = frames.length() - 1; i >= 0; i--) {
- Handle<JSFunction> fun = frames[i].function();
- Handle<Object> recv = frames[i].receiver();
- // Filter out internal frames that we do not want to show.
- if (!IsVisibleInStackTrace(*fun, *caller, *recv, &seen_caller)) continue;
- // Filter out frames from other security contexts.
- if (!this->context()->HasSameSecurityTokenAs(fun->context())) continue;
- if (cursor + 4 > elements->length()) {
- int new_capacity = JSObject::NewElementsCapacity(elements->length());
- Handle<FixedArray> new_elements =
- factory()->NewFixedArrayWithHoles(new_capacity);
- for (int i = 0; i < cursor; i++) {
- new_elements->set(i, elements->get(i));
- }
- elements = new_elements;
- }
- DCHECK(cursor + 4 <= elements->length());
-
- Handle<AbstractCode> abstract_code = frames[i].abstract_code();
-
- Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this);
- // The stack trace API should not expose receivers and function
- // objects on frames deeper than the top-most one with a strict
- // mode function. The number of sloppy frames is stored as
- // first element in the result array.
- if (!encountered_strict_function) {
- if (is_strict(fun->shared()->language_mode())) {
- encountered_strict_function = true;
- } else {
- sloppy_frames++;
+ StackFrame* frame = iter.frame();
+
+ switch (frame->type()) {
+ case StackFrame::JAVA_SCRIPT:
+ case StackFrame::OPTIMIZED:
+ case StackFrame::INTERPRETED: {
+ JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame);
+ // Set initial size to the maximum inlining level + 1 for the outermost
+ // function.
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ js_frame->Summarize(&frames);
+ for (int i = frames.length() - 1; i >= 0; i--) {
+ Handle<JSFunction> fun = frames[i].function();
+ Handle<Object> recv = frames[i].receiver();
+ // Filter out internal frames that we do not want to show.
+ if (!IsVisibleInStackTrace(*fun, *caller, *recv, &seen_caller)) {
+ continue;
+ }
+ // Filter out frames from other security contexts.
+ if (!this->context()->HasSameSecurityTokenAs(fun->context())) {
+ continue;
+ }
+ elements = MaybeGrow(this, elements, cursor, cursor + 4);
+
+ Handle<AbstractCode> abstract_code = frames[i].abstract_code();
+
+ Handle<Smi> offset(Smi::FromInt(frames[i].code_offset()), this);
+ // The stack trace API should not expose receivers and function
+ // objects on frames deeper than the top-most one with a strict mode
+ // function. The number of sloppy frames is stored as first element in
+ // the result array.
+ if (!encountered_strict_function) {
+ if (is_strict(fun->shared()->language_mode())) {
+ encountered_strict_function = true;
+ } else {
+ sloppy_frames++;
+ }
+ }
+ elements->set(cursor++, *recv);
+ elements->set(cursor++, *fun);
+ elements->set(cursor++, *abstract_code);
+ elements->set(cursor++, *offset);
+ frames_seen++;
}
- }
- elements->set(cursor++, *recv);
- elements->set(cursor++, *fun);
- elements->set(cursor++, *abstract_code);
- elements->set(cursor++, *offset);
- frames_seen++;
+ } break;
+
+ case StackFrame::WASM: {
+ elements = MaybeGrow(this, elements, cursor, cursor + 4);
+ // TODO(jfb) Pass module object.
+ elements->set(cursor++, *factory()->undefined_value());
+ elements->set(cursor++,
adamk 2016/02/23 18:58:04 This line is causing a GCMole failure (https://bui
JF 2016/02/23 19:12:25 Fixed in: https://codereview.chromium.org/17240630
+ *factory()->NewFunction(
+ factory()->NewStringFromAsciiChecked("<WASM>")));
+ elements->set(cursor++, Internals::IntToSmi(0));
+ elements->set(cursor++, Internals::IntToSmi(0));
+ frames_seen++;
+ } break;
+
+ default:
+ break;
}
}
elements->set(0, Smi::FromInt(sloppy_frames));
@@ -419,7 +451,6 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSObject> error_object,
return result;
}
-
MaybeHandle<JSObject> Isolate::CaptureAndSetDetailedStackTrace(
Handle<JSObject> error_object) {
if (capture_stack_trace_for_uncaught_exceptions_) {
« no previous file with comments | « src/frames-inl.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698