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

Side by Side Diff: src/isolate.cc

Issue 960273002: Move stack unwinding logic into the runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 (finally). Created 5 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
« no previous file with comments | « src/isolate.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1004 }
1005 1005
1006 // Save the message for reporting if the the exception remains uncaught. 1006 // Save the message for reporting if the the exception remains uncaught.
1007 thread_local_top()->has_pending_message_ = report_exception; 1007 thread_local_top()->has_pending_message_ = report_exception;
1008 1008
1009 // Do not forget to clean catcher_ if currently thrown exception cannot 1009 // Do not forget to clean catcher_ if currently thrown exception cannot
1010 // be caught. If necessary, ReThrow will update the catcher. 1010 // be caught. If necessary, ReThrow will update the catcher.
1011 thread_local_top()->catcher_ = 1011 thread_local_top()->catcher_ =
1012 can_be_caught_externally ? try_catch_handler() : NULL; 1012 can_be_caught_externally ? try_catch_handler() : NULL;
1013 1013
1014 // Set the exception being thrown.
1014 set_pending_exception(*exception_handle); 1015 set_pending_exception(*exception_handle);
1015 return heap()->exception(); 1016 return heap()->exception();
1016 } 1017 }
1017 1018
1018 1019
1019 Object* Isolate::ReThrow(Object* exception) { 1020 Object* Isolate::ReThrow(Object* exception) {
1020 bool can_be_caught_externally = false; 1021 bool can_be_caught_externally = false;
1021 bool catchable_by_javascript = is_catchable_by_javascript(exception); 1022 bool catchable_by_javascript = is_catchable_by_javascript(exception);
1022 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); 1023 ShouldReportException(&can_be_caught_externally, catchable_by_javascript);
1023 1024
1024 thread_local_top()->catcher_ = can_be_caught_externally ? 1025 thread_local_top()->catcher_ = can_be_caught_externally ?
1025 try_catch_handler() : NULL; 1026 try_catch_handler() : NULL;
1026 1027
1027 // Set the exception being re-thrown. 1028 // Set the exception being re-thrown.
1028 set_pending_exception(exception); 1029 set_pending_exception(exception);
1029 return heap()->exception(); 1030 return heap()->exception();
1030 } 1031 }
1031 1032
1032 1033
1034 Object* Isolate::FindHandler() {
1035 Object* exception = pending_exception();
1036
1037 // Determine target stack handler. Special handling of termination exceptions
1038 // which are uncatchable by JavaScript code, we unwind the handlers until the
1039 // top ENTRY handler is found.
1040 StackHandler* handler =
1041 StackHandler::FromAddress(Isolate::handler(thread_local_top()));
1042 if (!is_catchable_by_javascript(exception)) {
1043 while (!handler->is_js_entry()) handler = handler->next();
1044 }
1045
1046 // Restore the next handler.
1047 thread_local_top()->handler_ = handler->next()->address();
1048
1049 // Compute handler and stack unwinding information.
1050 // TODO(mstarzinger): Extend this to perform actual stack-walk and take into
1051 // account that TurboFan code can contain handlers as well.
1052 Code* code = handler->code();
1053 Context* context = handler->is_js_entry() ? nullptr : handler->context();
1054 int offset = Smi::cast(code->handler_table()->get(handler->index()))->value();
1055 Address handler_sp = handler->address() + StackHandlerConstants::kSize;
1056 Address handler_fp = handler->frame_pointer();
1057
1058 // Store information to be consumed by the CEntryStub.
1059 thread_local_top()->pending_handler_context_ = context;
1060 thread_local_top()->pending_handler_code_ = code;
1061 thread_local_top()->pending_handler_offset_ = offset;
1062 thread_local_top()->pending_handler_fp_ = handler_fp;
1063 thread_local_top()->pending_handler_sp_ = handler_sp;
1064
1065 // Return and clear pending exception.
1066 clear_pending_exception();
1067 return exception;
1068 }
1069
1070
1033 Object* Isolate::ThrowIllegalOperation() { 1071 Object* Isolate::ThrowIllegalOperation() {
1034 if (FLAG_stack_trace_on_illegal) PrintStack(stdout); 1072 if (FLAG_stack_trace_on_illegal) PrintStack(stdout);
1035 return Throw(heap_.illegal_access_string()); 1073 return Throw(heap_.illegal_access_string());
1036 } 1074 }
1037 1075
1038 1076
1039 void Isolate::ScheduleThrow(Object* exception) { 1077 void Isolate::ScheduleThrow(Object* exception) {
1040 // When scheduling a throw we first throw the exception to get the 1078 // When scheduling a throw we first throw the exception to get the
1041 // error reporting if it is uncaught before rescheduling it. 1079 // error reporting if it is uncaught before rescheduling it.
1042 Throw(exception); 1080 Throw(exception);
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 if (prev_ && prev_->Intercept(flag)) return true; 2589 if (prev_ && prev_->Intercept(flag)) return true;
2552 // Then check whether this scope intercepts. 2590 // Then check whether this scope intercepts.
2553 if ((flag & intercept_mask_)) { 2591 if ((flag & intercept_mask_)) {
2554 intercepted_flags_ |= flag; 2592 intercepted_flags_ |= flag;
2555 return true; 2593 return true;
2556 } 2594 }
2557 return false; 2595 return false;
2558 } 2596 }
2559 2597
2560 } } // namespace v8::internal 2598 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698