Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index e9a237b412c7434c5ac30313c4b4e81c8e1987f2..4973a8efff62f27e17a1010d5896f444be7dbbc6 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, |
Michael Starzinger
2016/02/19 21:15:27
nit: Function name is not following V8 style.
JF
2016/02/19 21:43:51
Done.
|
+ 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,64 @@ 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 (VisibleFrameIterator 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++; |
+ VisibleFrame* frame = iter.frame(); |
+ |
+ switch (frame->type()) { |
+ case StackFrame::JAVA_SCRIPT: |
+ case StackFrame::OPTIMIZED: |
+ case StackFrame::INTERPRETED: { |
+ // 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; |
Michael Starzinger
2016/02/19 21:15:27
nit: Please put curly braces around body if condit
JF
2016/02/19 21:43:51
Done. Auto-format doesn't auto-curl :-(
|
+ // Filter out frames from other security contexts. |
+ if (!this->context()->HasSameSecurityTokenAs(fun->context())) |
+ continue; |
Michael Starzinger
2016/02/19 21:15:27
nit: Please put curly braces around body if condit
JF
2016/02/19 21:43:51
Done.
|
+ 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++, *factory()->undefined_value()); |
Michael Starzinger
2016/02/19 21:15:27
I don't think it is OK to pass undefined as the re
JF
2016/02/19 21:43:51
What would be OK instead?
Michael Starzinger
2016/02/19 21:55:23
The "recv" value, as it was before. I am on referr
titzer
2016/02/21 09:01:54
In a previous comment I had advised passing "undef
JF
2016/02/22 18:29:40
Oh right, sorry about that! Too much look-alike co
|
+ 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); |
+ elements->set(cursor++, *caller); // TODO(jfb) Pass module object. |
+ elements->set(cursor++, |
+ *factory()->NewFunction( |
+ factory()->NewStringFromAsciiChecked("<WASM>"))); |
+ elements->set(cursor++, Internals::IntToSmi(0)); |
+ elements->set(cursor++, Internals::IntToSmi(0)); |
+ frames_seen++; |
+ } break; |
+ |
+ default: |
+ UNREACHABLE(); |
} |
} |
elements->set(0, Smi::FromInt(sloppy_frames)); |