| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 int new_capacity = JSObject::NewElementsCapacity(elements->length()); | 384 int new_capacity = JSObject::NewElementsCapacity(elements->length()); |
| 385 Handle<FixedArray> new_elements = | 385 Handle<FixedArray> new_elements = |
| 386 factory()->NewFixedArrayWithHoles(new_capacity); | 386 factory()->NewFixedArrayWithHoles(new_capacity); |
| 387 for (int i = 0; i < cursor; i++) { | 387 for (int i = 0; i < cursor; i++) { |
| 388 new_elements->set(i, elements->get(i)); | 388 new_elements->set(i, elements->get(i)); |
| 389 } | 389 } |
| 390 elements = new_elements; | 390 elements = new_elements; |
| 391 } | 391 } |
| 392 DCHECK(cursor + 4 <= elements->length()); | 392 DCHECK(cursor + 4 <= elements->length()); |
| 393 | 393 |
| 394 | |
| 395 Handle<Code> code = frames[i].code(); | 394 Handle<Code> code = frames[i].code(); |
| 396 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); | 395 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); |
| 397 // The stack trace API should not expose receivers and function | 396 // The stack trace API should not expose receivers and function |
| 398 // objects on frames deeper than the top-most one with a strict | 397 // objects on frames deeper than the top-most one with a strict |
| 399 // mode function. The number of sloppy frames is stored as | 398 // mode function. The number of sloppy frames is stored as |
| 400 // first element in the result array. | 399 // first element in the result array. |
| 401 if (!encountered_strict_function) { | 400 if (!encountered_strict_function) { |
| 402 if (fun->shared()->strict_mode() == STRICT) { | 401 if (fun->shared()->strict_mode() == STRICT) { |
| 403 encountered_strict_function = true; | 402 encountered_strict_function = true; |
| 404 } else { | 403 } else { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 433 | 432 |
| 434 void Isolate::CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object, | 433 void Isolate::CaptureAndSetSimpleStackTrace(Handle<JSObject> error_object, |
| 435 Handle<Object> caller) { | 434 Handle<Object> caller) { |
| 436 // Capture stack trace for simple stack trace string formatting. | 435 // Capture stack trace for simple stack trace string formatting. |
| 437 Handle<Name> key = factory()->stack_trace_symbol(); | 436 Handle<Name> key = factory()->stack_trace_symbol(); |
| 438 Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller); | 437 Handle<Object> stack_trace = CaptureSimpleStackTrace(error_object, caller); |
| 439 JSObject::SetProperty(error_object, key, stack_trace, STRICT).Assert(); | 438 JSObject::SetProperty(error_object, key, stack_trace, STRICT).Assert(); |
| 440 } | 439 } |
| 441 | 440 |
| 442 | 441 |
| 442 Handle<JSArray> Isolate::GetDetailedStackTrace(Handle<JSObject> error_object) { |
| 443 Handle<Name> key_detailed = factory()->detailed_stack_trace_symbol(); |
| 444 Handle<Object> stack_trace = |
| 445 JSObject::GetDataProperty(error_object, key_detailed); |
| 446 if (stack_trace->IsJSArray()) return Handle<JSArray>::cast(stack_trace); |
| 447 |
| 448 if (!capture_stack_trace_for_uncaught_exceptions_) return Handle<JSArray>(); |
| 449 |
| 450 // Try to get details from simple stack trace. |
| 451 Handle<JSArray> detailed_stack_trace = |
| 452 GetDetailedFromSimpleStackTrace(error_object); |
| 453 if (!detailed_stack_trace.is_null()) { |
| 454 // Save the detailed stack since the simple one might be withdrawn later. |
| 455 JSObject::SetProperty(error_object, key_detailed, detailed_stack_trace, |
| 456 STRICT).Assert(); |
| 457 } |
| 458 return detailed_stack_trace; |
| 459 } |
| 460 |
| 461 |
| 462 class CaptureStackTraceHelper { |
| 463 public: |
| 464 CaptureStackTraceHelper(Isolate* isolate, |
| 465 StackTrace::StackTraceOptions options) |
| 466 : isolate_(isolate) { |
| 467 if (options & StackTrace::kColumnOffset) { |
| 468 column_key_ = |
| 469 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("column")); |
| 470 } |
| 471 if (options & StackTrace::kLineNumber) { |
| 472 line_key_ = |
| 473 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("lineNumber")); |
| 474 } |
| 475 if (options & StackTrace::kScriptId) { |
| 476 script_id_key_ = |
| 477 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptId")); |
| 478 } |
| 479 if (options & StackTrace::kScriptName) { |
| 480 script_name_key_ = |
| 481 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName")); |
| 482 } |
| 483 if (options & StackTrace::kScriptNameOrSourceURL) { |
| 484 script_name_or_source_url_key_ = factory()->InternalizeOneByteString( |
| 485 STATIC_CHAR_VECTOR("scriptNameOrSourceURL")); |
| 486 } |
| 487 if (options & StackTrace::kFunctionName) { |
| 488 function_key_ = factory()->InternalizeOneByteString( |
| 489 STATIC_CHAR_VECTOR("functionName")); |
| 490 } |
| 491 if (options & StackTrace::kIsEval) { |
| 492 eval_key_ = |
| 493 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); |
| 494 } |
| 495 if (options & StackTrace::kIsConstructor) { |
| 496 constructor_key_ = factory()->InternalizeOneByteString( |
| 497 STATIC_CHAR_VECTOR("isConstructor")); |
| 498 } |
| 499 } |
| 500 |
| 501 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, |
| 502 Handle<Code> code, Address pc, |
| 503 bool is_constructor) { |
| 504 Handle<JSObject> stack_frame = |
| 505 factory()->NewJSObject(isolate_->object_function()); |
| 506 |
| 507 Handle<Script> script(Script::cast(fun->shared()->script())); |
| 508 |
| 509 if (!line_key_.is_null()) { |
| 510 int script_line_offset = script->line_offset()->value(); |
| 511 int position = code->SourcePosition(pc); |
| 512 int line_number = Script::GetLineNumber(script, position); |
| 513 // line_number is already shifted by the script_line_offset. |
| 514 int relative_line_number = line_number - script_line_offset; |
| 515 if (!column_key_.is_null() && relative_line_number >= 0) { |
| 516 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| 517 int start = (relative_line_number == 0) ? 0 : |
| 518 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; |
| 519 int column_offset = position - start; |
| 520 if (relative_line_number == 0) { |
| 521 // For the case where the code is on the same line as the script |
| 522 // tag. |
| 523 column_offset += script->column_offset()->value(); |
| 524 } |
| 525 JSObject::AddProperty(stack_frame, column_key_, |
| 526 handle(Smi::FromInt(column_offset + 1), isolate_), |
| 527 NONE); |
| 528 } |
| 529 JSObject::AddProperty(stack_frame, line_key_, |
| 530 handle(Smi::FromInt(line_number + 1), isolate_), |
| 531 NONE); |
| 532 } |
| 533 |
| 534 if (!script_id_key_.is_null()) { |
| 535 JSObject::AddProperty(stack_frame, script_id_key_, |
| 536 handle(script->id(), isolate_), NONE); |
| 537 } |
| 538 |
| 539 if (!script_name_key_.is_null()) { |
| 540 JSObject::AddProperty(stack_frame, script_name_key_, |
| 541 handle(script->name(), isolate_), NONE); |
| 542 } |
| 543 |
| 544 if (!script_name_or_source_url_key_.is_null()) { |
| 545 Handle<Object> result = Script::GetNameOrSourceURL(script); |
| 546 JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result, |
| 547 NONE); |
| 548 } |
| 549 |
| 550 if (!function_key_.is_null()) { |
| 551 Handle<Object> fun_name(fun->shared()->DebugName(), isolate_); |
| 552 JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); |
| 553 } |
| 554 |
| 555 if (!eval_key_.is_null()) { |
| 556 Handle<Object> is_eval = factory()->ToBoolean( |
| 557 script->compilation_type() == Script::COMPILATION_TYPE_EVAL); |
| 558 JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); |
| 559 } |
| 560 |
| 561 if (!constructor_key_.is_null()) { |
| 562 Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); |
| 563 JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, |
| 564 NONE); |
| 565 } |
| 566 |
| 567 return stack_frame; |
| 568 } |
| 569 |
| 570 private: |
| 571 inline Factory* factory() { return isolate_->factory(); } |
| 572 |
| 573 Isolate* isolate_; |
| 574 Handle<String> column_key_; |
| 575 Handle<String> line_key_; |
| 576 Handle<String> script_id_key_; |
| 577 Handle<String> script_name_key_; |
| 578 Handle<String> script_name_or_source_url_key_; |
| 579 Handle<String> function_key_; |
| 580 Handle<String> eval_key_; |
| 581 Handle<String> constructor_key_; |
| 582 }; |
| 583 |
| 584 |
| 585 Handle<JSArray> Isolate::GetDetailedFromSimpleStackTrace( |
| 586 Handle<JSObject> error_object) { |
| 587 Handle<Name> key = factory()->stack_trace_symbol(); |
| 588 Handle<Object> property = JSObject::GetDataProperty(error_object, key); |
| 589 if (!property->IsJSArray()) return Handle<JSArray>(); |
| 590 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); |
| 591 |
| 592 CaptureStackTraceHelper helper(this, |
| 593 stack_trace_for_uncaught_exceptions_options_); |
| 594 |
| 595 int frames_seen = 0; |
| 596 Handle<FixedArray> elements(FixedArray::cast(simple_stack_trace->elements())); |
| 597 int elements_limit = Smi::cast(simple_stack_trace->length())->value(); |
| 598 |
| 599 int frame_limit = stack_trace_for_uncaught_exceptions_frame_limit_; |
| 600 if (frame_limit < 0) frame_limit = (elements_limit - 1) / 4; |
| 601 |
| 602 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
| 603 for (int i = 1; i < elements_limit && frames_seen < frame_limit; i += 4) { |
| 604 Handle<Object> recv = handle(elements->get(i), this); |
| 605 Handle<JSFunction> fun = |
| 606 handle(JSFunction::cast(elements->get(i + 1)), this); |
| 607 Handle<Code> code = handle(Code::cast(elements->get(i + 2)), this); |
| 608 Handle<Smi> offset = handle(Smi::cast(elements->get(i + 3)), this); |
| 609 Address pc = code->address() + offset->value(); |
| 610 bool is_constructor = |
| 611 recv->IsJSObject() && |
| 612 Handle<JSObject>::cast(recv)->map()->constructor() == *fun; |
| 613 |
| 614 Handle<JSObject> stack_frame = |
| 615 helper.NewStackFrameObject(fun, code, pc, is_constructor); |
| 616 |
| 617 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); |
| 618 frames_seen++; |
| 619 } |
| 620 |
| 621 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 622 return stack_trace; |
| 623 } |
| 624 |
| 625 |
| 443 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 626 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
| 444 int frame_limit, StackTrace::StackTraceOptions options) { | 627 int frame_limit, StackTrace::StackTraceOptions options) { |
| 628 CaptureStackTraceHelper helper(this, options); |
| 629 |
| 445 // Ensure no negative values. | 630 // Ensure no negative values. |
| 446 int limit = Max(frame_limit, 0); | 631 int limit = Max(frame_limit, 0); |
| 447 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 632 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
| 448 | 633 |
| 449 Handle<String> column_key = | |
| 450 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("column")); | |
| 451 Handle<String> line_key = | |
| 452 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("lineNumber")); | |
| 453 Handle<String> script_id_key = | |
| 454 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptId")); | |
| 455 Handle<String> script_name_key = | |
| 456 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("scriptName")); | |
| 457 Handle<String> script_name_or_source_url_key = | |
| 458 factory()->InternalizeOneByteString( | |
| 459 STATIC_CHAR_VECTOR("scriptNameOrSourceURL")); | |
| 460 Handle<String> function_key = | |
| 461 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("functionName")); | |
| 462 Handle<String> eval_key = | |
| 463 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isEval")); | |
| 464 Handle<String> constructor_key = | |
| 465 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("isConstructor")); | |
| 466 | |
| 467 StackTraceFrameIterator it(this); | 634 StackTraceFrameIterator it(this); |
| 468 int frames_seen = 0; | 635 int frames_seen = 0; |
| 469 while (!it.done() && (frames_seen < limit)) { | 636 while (!it.done() && (frames_seen < limit)) { |
| 470 JavaScriptFrame* frame = it.frame(); | 637 JavaScriptFrame* frame = it.frame(); |
| 471 // Set initial size to the maximum inlining level + 1 for the outermost | 638 // Set initial size to the maximum inlining level + 1 for the outermost |
| 472 // function. | 639 // function. |
| 473 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); | 640 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 474 frame->Summarize(&frames); | 641 frame->Summarize(&frames); |
| 475 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 642 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
| 476 Handle<JSFunction> fun = frames[i].function(); | 643 Handle<JSFunction> fun = frames[i].function(); |
| 477 // Filter frames from other security contexts. | 644 // Filter frames from other security contexts. |
| 478 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && | 645 if (!(options & StackTrace::kExposeFramesAcrossSecurityOrigins) && |
| 479 !this->context()->HasSameSecurityTokenAs(fun->context())) continue; | 646 !this->context()->HasSameSecurityTokenAs(fun->context())) continue; |
| 480 | 647 |
| 481 // Create a JSObject to hold the information for the StackFrame. | 648 Handle<JSObject> stack_frame = helper.NewStackFrameObject( |
| 482 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function()); | 649 fun, frames[i].code(), frames[i].pc(), frames[i].is_constructor()); |
| 483 | |
| 484 Handle<Script> script(Script::cast(fun->shared()->script())); | |
| 485 | |
| 486 if (options & StackTrace::kLineNumber) { | |
| 487 int script_line_offset = script->line_offset()->value(); | |
| 488 int position = frames[i].code()->SourcePosition(frames[i].pc()); | |
| 489 int line_number = Script::GetLineNumber(script, position); | |
| 490 // line_number is already shifted by the script_line_offset. | |
| 491 int relative_line_number = line_number - script_line_offset; | |
| 492 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { | |
| 493 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | |
| 494 int start = (relative_line_number == 0) ? 0 : | |
| 495 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; | |
| 496 int column_offset = position - start; | |
| 497 if (relative_line_number == 0) { | |
| 498 // For the case where the code is on the same line as the script | |
| 499 // tag. | |
| 500 column_offset += script->column_offset()->value(); | |
| 501 } | |
| 502 JSObject::AddProperty( | |
| 503 stack_frame, column_key, | |
| 504 handle(Smi::FromInt(column_offset + 1), this), NONE); | |
| 505 } | |
| 506 JSObject::AddProperty( | |
| 507 stack_frame, line_key, | |
| 508 handle(Smi::FromInt(line_number + 1), this), NONE); | |
| 509 } | |
| 510 | |
| 511 if (options & StackTrace::kScriptId) { | |
| 512 JSObject::AddProperty( | |
| 513 stack_frame, script_id_key, handle(script->id(), this), NONE); | |
| 514 } | |
| 515 | |
| 516 if (options & StackTrace::kScriptName) { | |
| 517 JSObject::AddProperty( | |
| 518 stack_frame, script_name_key, handle(script->name(), this), NONE); | |
| 519 } | |
| 520 | |
| 521 if (options & StackTrace::kScriptNameOrSourceURL) { | |
| 522 Handle<Object> result = Script::GetNameOrSourceURL(script); | |
| 523 JSObject::AddProperty( | |
| 524 stack_frame, script_name_or_source_url_key, result, NONE); | |
| 525 } | |
| 526 | |
| 527 if (options & StackTrace::kFunctionName) { | |
| 528 Handle<Object> fun_name(fun->shared()->DebugName(), this); | |
| 529 JSObject::AddProperty(stack_frame, function_key, fun_name, NONE); | |
| 530 } | |
| 531 | |
| 532 if (options & StackTrace::kIsEval) { | |
| 533 Handle<Object> is_eval = | |
| 534 script->compilation_type() == Script::COMPILATION_TYPE_EVAL ? | |
| 535 factory()->true_value() : factory()->false_value(); | |
| 536 JSObject::AddProperty(stack_frame, eval_key, is_eval, NONE); | |
| 537 } | |
| 538 | |
| 539 if (options & StackTrace::kIsConstructor) { | |
| 540 Handle<Object> is_constructor = (frames[i].is_constructor()) ? | |
| 541 factory()->true_value() : factory()->false_value(); | |
| 542 JSObject::AddProperty( | |
| 543 stack_frame, constructor_key, is_constructor, NONE); | |
| 544 } | |
| 545 | 650 |
| 546 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); | 651 FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame); |
| 547 frames_seen++; | 652 frames_seen++; |
| 548 } | 653 } |
| 549 it.Advance(); | 654 it.Advance(); |
| 550 } | 655 } |
| 551 | 656 |
| 552 stack_trace->set_length(Smi::FromInt(frames_seen)); | 657 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 553 return stack_trace; | 658 return stack_trace; |
| 554 } | 659 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 // Find code position if recorded in relocation info. | 1010 // Find code position if recorded in relocation info. |
| 906 JavaScriptFrame* frame = it.frame(); | 1011 JavaScriptFrame* frame = it.frame(); |
| 907 int pos = frame->LookupCode()->SourcePosition(frame->pc()); | 1012 int pos = frame->LookupCode()->SourcePosition(frame->pc()); |
| 908 Handle<Object> pos_obj(Smi::FromInt(pos), this); | 1013 Handle<Object> pos_obj(Smi::FromInt(pos), this); |
| 909 // Fetch function and receiver. | 1014 // Fetch function and receiver. |
| 910 Handle<JSFunction> fun(frame->function()); | 1015 Handle<JSFunction> fun(frame->function()); |
| 911 Handle<Object> recv(frame->receiver(), this); | 1016 Handle<Object> recv(frame->receiver(), this); |
| 912 // Advance to the next JavaScript frame and determine if the | 1017 // Advance to the next JavaScript frame and determine if the |
| 913 // current frame is the top-level frame. | 1018 // current frame is the top-level frame. |
| 914 it.Advance(); | 1019 it.Advance(); |
| 915 Handle<Object> is_top_level = it.done() | 1020 Handle<Object> is_top_level = factory()->ToBoolean(it.done()); |
| 916 ? factory()->true_value() | |
| 917 : factory()->false_value(); | |
| 918 // Generate and print stack trace line. | 1021 // Generate and print stack trace line. |
| 919 Handle<String> line = | 1022 Handle<String> line = |
| 920 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 1023 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
| 921 if (line->length() > 0) { | 1024 if (line->length() > 0) { |
| 922 line->PrintOn(out); | 1025 line->PrintOn(out); |
| 923 PrintF(out, "\n"); | 1026 PrintF(out, "\n"); |
| 924 } | 1027 } |
| 925 } | 1028 } |
| 926 } | 1029 } |
| 927 | 1030 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 1102 |
| 1000 static int fatal_exception_depth = 0; | 1103 static int fatal_exception_depth = 0; |
| 1001 | 1104 |
| 1002 | 1105 |
| 1003 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, | 1106 Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception, |
| 1004 MessageLocation* location) { | 1107 MessageLocation* location) { |
| 1005 Handle<JSArray> stack_trace_object; | 1108 Handle<JSArray> stack_trace_object; |
| 1006 if (capture_stack_trace_for_uncaught_exceptions_) { | 1109 if (capture_stack_trace_for_uncaught_exceptions_) { |
| 1007 if (IsErrorObject(exception)) { | 1110 if (IsErrorObject(exception)) { |
| 1008 // We fetch the stack trace that corresponds to this error object. | 1111 // We fetch the stack trace that corresponds to this error object. |
| 1009 Handle<Name> key = factory()->detailed_stack_trace_symbol(); | 1112 // If the lookup fails, the exception is probably not a valid Error |
| 1010 // Look up as own property. If the lookup fails, the exception is | 1113 // object. In that case, we fall through and capture the stack trace |
| 1011 // probably not a valid Error object. In that case, we fall through | 1114 // at this throw site. |
| 1012 // and capture the stack trace at this throw site. | 1115 stack_trace_object = |
| 1013 LookupIterator lookup(exception, key, | 1116 GetDetailedStackTrace(Handle<JSObject>::cast(exception)); |
| 1014 LookupIterator::OWN_SKIP_INTERCEPTOR); | |
| 1015 Handle<Object> stack_trace_property; | |
| 1016 if (Object::GetProperty(&lookup).ToHandle(&stack_trace_property) && | |
| 1017 stack_trace_property->IsJSArray()) { | |
| 1018 stack_trace_object = Handle<JSArray>::cast(stack_trace_property); | |
| 1019 } | |
| 1020 } | 1117 } |
| 1021 if (stack_trace_object.is_null()) { | 1118 if (stack_trace_object.is_null()) { |
| 1022 // Not an error object, we capture at throw site. | 1119 // Not an error object, we capture at throw site. |
| 1023 stack_trace_object = CaptureCurrentStackTrace( | 1120 stack_trace_object = CaptureCurrentStackTrace( |
| 1024 stack_trace_for_uncaught_exceptions_frame_limit_, | 1121 stack_trace_for_uncaught_exceptions_frame_limit_, |
| 1025 stack_trace_for_uncaught_exceptions_options_); | 1122 stack_trace_for_uncaught_exceptions_options_); |
| 1026 } | 1123 } |
| 1027 } | 1124 } |
| 1028 | 1125 |
| 1029 // If the exception argument is a custom object, turn it into a string | 1126 // If the exception argument is a custom object, turn it into a string |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 promise_reject_callback_ = callback; | 2361 promise_reject_callback_ = callback; |
| 2265 } | 2362 } |
| 2266 | 2363 |
| 2267 | 2364 |
| 2268 void Isolate::ReportPromiseReject(Handle<JSObject> promise, | 2365 void Isolate::ReportPromiseReject(Handle<JSObject> promise, |
| 2269 Handle<Object> value, | 2366 Handle<Object> value, |
| 2270 v8::PromiseRejectEvent event) { | 2367 v8::PromiseRejectEvent event) { |
| 2271 if (promise_reject_callback_ == NULL) return; | 2368 if (promise_reject_callback_ == NULL) return; |
| 2272 Handle<JSArray> stack_trace; | 2369 Handle<JSArray> stack_trace; |
| 2273 if (event == v8::kPromiseRejectWithNoHandler && value->IsJSObject()) { | 2370 if (event == v8::kPromiseRejectWithNoHandler && value->IsJSObject()) { |
| 2274 Handle<JSObject> error_obj = Handle<JSObject>::cast(value); | 2371 stack_trace = GetDetailedStackTrace(Handle<JSObject>::cast(value)); |
| 2275 Handle<Name> key = factory()->detailed_stack_trace_symbol(); | |
| 2276 Handle<Object> property = JSObject::GetDataProperty(error_obj, key); | |
| 2277 if (property->IsJSArray()) stack_trace = Handle<JSArray>::cast(property); | |
| 2278 } | 2372 } |
| 2279 promise_reject_callback_(v8::PromiseRejectMessage( | 2373 promise_reject_callback_(v8::PromiseRejectMessage( |
| 2280 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), | 2374 v8::Utils::PromiseToLocal(promise), event, v8::Utils::ToLocal(value), |
| 2281 v8::Utils::StackTraceToLocal(stack_trace))); | 2375 v8::Utils::StackTraceToLocal(stack_trace))); |
| 2282 } | 2376 } |
| 2283 | 2377 |
| 2284 | 2378 |
| 2285 void Isolate::EnqueueMicrotask(Handle<Object> microtask) { | 2379 void Isolate::EnqueueMicrotask(Handle<Object> microtask) { |
| 2286 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo()); | 2380 DCHECK(microtask->IsJSFunction() || microtask->IsCallHandlerInfo()); |
| 2287 Handle<FixedArray> queue(heap()->microtask_queue(), this); | 2381 Handle<FixedArray> queue(heap()->microtask_queue(), this); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 if (prev_ && prev_->Intercept(flag)) return true; | 2496 if (prev_ && prev_->Intercept(flag)) return true; |
| 2403 // Then check whether this scope intercepts. | 2497 // Then check whether this scope intercepts. |
| 2404 if ((flag & intercept_mask_)) { | 2498 if ((flag & intercept_mask_)) { |
| 2405 intercepted_flags_ |= flag; | 2499 intercepted_flags_ |= flag; |
| 2406 return true; | 2500 return true; |
| 2407 } | 2501 } |
| 2408 return false; | 2502 return false; |
| 2409 } | 2503 } |
| 2410 | 2504 |
| 2411 } } // namespace v8::internal | 2505 } } // namespace v8::internal |
| OLD | NEW |