Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 | 494 |
| 495 case StackFrame::BUILTIN_EXIT: { | 495 case StackFrame::BUILTIN_EXIT: { |
| 496 BuiltinExitFrame* exit_frame = BuiltinExitFrame::cast(frame); | 496 BuiltinExitFrame* exit_frame = BuiltinExitFrame::cast(frame); |
| 497 Handle<JSFunction> fun = handle(exit_frame->function(), this); | 497 Handle<JSFunction> fun = handle(exit_frame->function(), this); |
| 498 | 498 |
| 499 // Filter out internal frames that we do not want to show. | 499 // Filter out internal frames that we do not want to show. |
| 500 if (!helper.IsVisibleInStackTrace(*fun)) continue; | 500 if (!helper.IsVisibleInStackTrace(*fun)) continue; |
| 501 | 501 |
| 502 Handle<Object> recv(exit_frame->receiver(), this); | 502 Handle<Object> recv(exit_frame->receiver(), this); |
| 503 Handle<Code> code(exit_frame->LookupCode(), this); | 503 Handle<Code> code(exit_frame->LookupCode(), this); |
| 504 int offset = | 504 const int offset = |
| 505 static_cast<int>(exit_frame->pc() - code->instruction_start()); | 505 static_cast<int>(exit_frame->pc() - code->instruction_start()); |
| 506 | 506 |
| 507 // TODO(jgruber): The offset should be strictly non-negative. This is | |
| 508 // not the case on win64_rel. Find out why. | |
|
ulan
2016/08/30 10:15:56
Are planning to fix it before landing?
jgruber
2016/08/30 12:11:33
This was fixed already in https://codereview.chrom
| |
| 509 | |
| 507 int flags = 0; | 510 int flags = 0; |
| 508 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict; | 511 if (helper.IsStrictFrame(*fun)) flags |= FrameArray::kIsStrict; |
| 509 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor; | 512 if (exit_frame->IsConstructor()) flags |= FrameArray::kForceConstructor; |
| 510 | 513 |
| 511 elements = FrameArray::AppendJSFrame(elements, recv, fun, | 514 elements = FrameArray::AppendJSFrame(elements, recv, fun, |
| 512 Handle<AbstractCode>::cast(code), | 515 Handle<AbstractCode>::cast(code), |
| 513 offset, flags); | 516 offset, flags); |
| 514 } break; | 517 } break; |
| 515 | 518 |
| 516 case StackFrame::WASM: { | 519 case StackFrame::WASM: { |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 | 1391 |
| 1389 Object* Isolate::PromoteScheduledException() { | 1392 Object* Isolate::PromoteScheduledException() { |
| 1390 Object* thrown = scheduled_exception(); | 1393 Object* thrown = scheduled_exception(); |
| 1391 clear_scheduled_exception(); | 1394 clear_scheduled_exception(); |
| 1392 // Re-throw the exception to avoid getting repeated error reporting. | 1395 // Re-throw the exception to avoid getting repeated error reporting. |
| 1393 return ReThrow(thrown); | 1396 return ReThrow(thrown); |
| 1394 } | 1397 } |
| 1395 | 1398 |
| 1396 | 1399 |
| 1397 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1400 void Isolate::PrintCurrentStackTrace(FILE* out) { |
| 1398 StackTraceFrameIterator it(this); | 1401 for (StackTraceFrameIterator it(this); !it.done(); it.Advance()) { |
| 1399 while (!it.done()) { | 1402 if (!it.is_javascript()) continue; |
| 1403 | |
| 1400 HandleScope scope(this); | 1404 HandleScope scope(this); |
| 1401 // Find code position if recorded in relocation info. | 1405 JavaScriptFrame* frame = it.javascript_frame(); |
| 1402 StandardFrame* frame = it.frame(); | 1406 |
| 1403 AbstractCode* abstract_code; | 1407 Handle<Object> receiver(frame->receiver(), this); |
| 1404 int code_offset; | 1408 Handle<JSFunction> function(frame->function(), this); |
| 1405 if (frame->is_interpreted()) { | 1409 Handle<AbstractCode> code(AbstractCode::cast(frame->LookupCode()), this); |
| 1406 InterpretedFrame* iframe = reinterpret_cast<InterpretedFrame*>(frame); | 1410 const int offset = |
| 1407 abstract_code = AbstractCode::cast(iframe->GetBytecodeArray()); | 1411 static_cast<int>(frame->pc() - code->instruction_start()); |
| 1408 code_offset = iframe->GetBytecodeOffset(); | 1412 |
| 1409 } else { | 1413 JSStackFrame site(this, receiver, function, code, offset); |
| 1410 DCHECK(frame->is_java_script() || frame->is_wasm()); | 1414 Handle<String> line = site.ToString().ToHandleChecked(); |
| 1411 Code* code = frame->LookupCode(); | |
| 1412 abstract_code = AbstractCode::cast(code); | |
| 1413 code_offset = static_cast<int>(frame->pc() - code->instruction_start()); | |
| 1414 } | |
| 1415 int pos = abstract_code->SourcePosition(code_offset); | |
| 1416 JavaScriptFrame* js_frame = JavaScriptFrame::cast(frame); | |
| 1417 Handle<Object> pos_obj(Smi::FromInt(pos), this); | |
| 1418 // Fetch function and receiver. | |
| 1419 Handle<JSFunction> fun(js_frame->function(), this); | |
| 1420 Handle<Object> recv(js_frame->receiver(), this); | |
| 1421 // Advance to the next JavaScript frame and determine if the | |
| 1422 // current frame is the top-level frame. | |
| 1423 it.Advance(); | |
| 1424 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); | |
| 1425 // Generate and print stack trace line. | |
| 1426 Handle<String> line = | |
| 1427 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | |
| 1428 if (line->length() > 0) { | 1415 if (line->length() > 0) { |
| 1429 line->PrintOn(out); | 1416 line->PrintOn(out); |
| 1430 PrintF(out, "\n"); | 1417 PrintF(out, "\n"); |
| 1431 } | 1418 } |
| 1432 } | 1419 } |
| 1433 } | 1420 } |
| 1434 | 1421 |
| 1435 bool Isolate::ComputeLocation(MessageLocation* target) { | 1422 bool Isolate::ComputeLocation(MessageLocation* target) { |
| 1436 StackTraceFrameIterator it(this); | 1423 StackTraceFrameIterator it(this); |
| 1437 if (it.done()) return false; | 1424 if (it.done()) return false; |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3179 // Then check whether this scope intercepts. | 3166 // Then check whether this scope intercepts. |
| 3180 if ((flag & intercept_mask_)) { | 3167 if ((flag & intercept_mask_)) { |
| 3181 intercepted_flags_ |= flag; | 3168 intercepted_flags_ |= flag; |
| 3182 return true; | 3169 return true; |
| 3183 } | 3170 } |
| 3184 return false; | 3171 return false; |
| 3185 } | 3172 } |
| 3186 | 3173 |
| 3187 } // namespace internal | 3174 } // namespace internal |
| 3188 } // namespace v8 | 3175 } // namespace v8 |
| OLD | NEW |