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

Side by Side Diff: src/top.cc

Issue 6606002: Merge revision 6500-6600 from bleeding_edge to the isolates branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 !(Script::cast(script)->source()->IsUndefined())) { 613 !(Script::cast(script)->source()->IsUndefined())) {
614 int pos = frame->LookupCode(this)->SourcePosition(frame->pc()); 614 int pos = frame->LookupCode(this)->SourcePosition(frame->pc());
615 // Compute the location from the function and the reloc info. 615 // Compute the location from the function and the reloc info.
616 Handle<Script> casted_script(Script::cast(script)); 616 Handle<Script> casted_script(Script::cast(script));
617 *target = MessageLocation(casted_script, pos, pos + 1); 617 *target = MessageLocation(casted_script, pos, pos + 1);
618 } 618 }
619 } 619 }
620 } 620 }
621 621
622 622
623 bool Isolate::ShouldReturnException(bool* is_caught_externally, 623 bool Isolate::ShouldReportException(bool* can_be_caught_externally,
624 bool catchable_by_javascript) { 624 bool catchable_by_javascript) {
625 // Find the top-most try-catch handler. 625 // Find the top-most try-catch handler.
626 StackHandler* handler = 626 StackHandler* handler =
627 StackHandler::FromAddress(Isolate::handler(thread_local_top())); 627 StackHandler::FromAddress(Isolate::handler(thread_local_top()));
628 while (handler != NULL && !handler->is_try_catch()) { 628 while (handler != NULL && !handler->is_try_catch()) {
629 handler = handler->next(); 629 handler = handler->next();
630 } 630 }
631 631
632 // Get the address of the external handler so we can compare the address to 632 // Get the address of the external handler so we can compare the address to
633 // determine which one is closer to the top of the stack. 633 // determine which one is closer to the top of the stack.
634 Address external_handler_address = 634 Address external_handler_address =
635 thread_local_top()->try_catch_handler_address(); 635 thread_local_top()->try_catch_handler_address();
636 636
637 // The exception has been externally caught if and only if there is 637 // The exception has been externally caught if and only if there is
638 // an external handler which is on top of the top-most try-catch 638 // an external handler which is on top of the top-most try-catch
639 // handler. 639 // handler.
640 *is_caught_externally = external_handler_address != NULL && 640 *can_be_caught_externally = external_handler_address != NULL &&
641 (handler == NULL || handler->address() > external_handler_address || 641 (handler == NULL || handler->address() > external_handler_address ||
642 !catchable_by_javascript); 642 !catchable_by_javascript);
643 643
644 if (*is_caught_externally) { 644 if (*can_be_caught_externally) {
645 // Only report the exception if the external handler is verbose. 645 // Only report the exception if the external handler is verbose.
646 return thread_local_top()->TryCatchHandler()->is_verbose_; 646 return thread_local_top()->TryCatchHandler()->is_verbose_;
647 } else { 647 } else {
648 // Report the exception if it isn't caught by JavaScript code. 648 // Report the exception if it isn't caught by JavaScript code.
649 return handler == NULL; 649 return handler == NULL;
650 } 650 }
651 } 651 }
652 652
653 653
654 void Isolate::DoThrow(MaybeObject* exception, 654 void Isolate::DoThrow(MaybeObject* exception,
655 MessageLocation* location, 655 MessageLocation* location,
656 const char* message) { 656 const char* message) {
657 ASSERT(!has_pending_exception()); 657 ASSERT(!has_pending_exception());
658 658
659 HandleScope scope; 659 HandleScope scope;
660 Object* exception_object = Smi::FromInt(0); 660 Object* exception_object = Smi::FromInt(0);
661 bool is_object = exception->ToObject(&exception_object); 661 bool is_object = exception->ToObject(&exception_object);
662 Handle<Object> exception_handle(exception_object); 662 Handle<Object> exception_handle(exception_object);
663 663
664 // Determine reporting and whether the exception is caught externally. 664 // Determine reporting and whether the exception is caught externally.
665 bool is_caught_externally = false;
666 bool is_out_of_memory = exception == Failure::OutOfMemoryException(); 665 bool is_out_of_memory = exception == Failure::OutOfMemoryException();
667 bool is_termination_exception = exception == heap_.termination_exception(); 666 bool is_termination_exception = exception == heap_.termination_exception();
668 bool catchable_by_javascript = !is_termination_exception && !is_out_of_memory; 667 bool catchable_by_javascript = !is_termination_exception && !is_out_of_memory;
669 // Only real objects can be caught by JS. 668 // Only real objects can be caught by JS.
670 ASSERT(!catchable_by_javascript || is_object); 669 ASSERT(!catchable_by_javascript || is_object);
671 bool should_return_exception = 670 bool is_caught_externally = false;
672 ShouldReturnException(&is_caught_externally, catchable_by_javascript); 671 bool should_report_exception =
673 bool report_exception = catchable_by_javascript && should_return_exception; 672 ShouldReportException(&is_caught_externally, catchable_by_javascript);
673 bool report_exception = catchable_by_javascript && should_report_exception;
674 674
675 #ifdef ENABLE_DEBUGGER_SUPPORT 675 #ifdef ENABLE_DEBUGGER_SUPPORT
676 // Notify debugger of exception. 676 // Notify debugger of exception.
677 if (catchable_by_javascript) { 677 if (catchable_by_javascript) {
678 debugger_->OnException(exception_handle, report_exception); 678 debugger_->OnException(exception_handle, report_exception);
679 } 679 }
680 #endif 680 #endif
681 681
682 // Generate the message. 682 // Generate the message.
683 Handle<Object> message_obj; 683 Handle<Object> message_obj;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 thread_local_top()->simulator_ = Simulator::current(this); 922 thread_local_top()->simulator_ = Simulator::current(this);
923 #endif 923 #endif
924 #endif 924 #endif
925 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { 925 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) {
926 RuntimeProfiler::IsolateEnteredJS(this); 926 RuntimeProfiler::IsolateEnteredJS(this);
927 } 927 }
928 return from + sizeof(ThreadLocalTop); 928 return from + sizeof(ThreadLocalTop);
929 } 929 }
930 930
931 } } // namespace v8::internal 931 } } // namespace v8::internal
OLDNEW
« src/ast.cc ('K') | « src/scanner-base.cc ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698