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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 | 1138 |
1139 Object* Isolate::UnwindAndFindHandler() { | 1139 Object* Isolate::UnwindAndFindHandler() { |
1140 Object* exception = pending_exception(); | 1140 Object* exception = pending_exception(); |
1141 | 1141 |
1142 Code* code = nullptr; | 1142 Code* code = nullptr; |
1143 Context* context = nullptr; | 1143 Context* context = nullptr; |
1144 intptr_t offset = 0; | 1144 intptr_t offset = 0; |
1145 Address handler_sp = nullptr; | 1145 Address handler_sp = nullptr; |
1146 Address handler_fp = nullptr; | 1146 Address handler_fp = nullptr; |
1147 | 1147 |
1148 // Special handling of termination exceptions, uncatchable by JavaScript code, | 1148 // Special handling of termination exceptions, uncatchable by JavaScript and |
1149 // we unwind the handlers until the top ENTRY handler is found. | 1149 // Wasm code, we unwind the handlers until the top ENTRY handler is found. |
1150 bool catchable_by_js = is_catchable_by_javascript(exception); | 1150 bool catchable_by_js = is_catchable_by_javascript(exception); |
1151 bool catchable_by_wasm = | |
1152 FLAG_wasm_eh_prototype && is_catchable_by_wasm(exception); | |
1151 | 1153 |
1152 // Compute handler and stack unwinding information by performing a full walk | 1154 // Compute handler and stack unwinding information by performing a full walk |
1153 // over the stack and dispatching according to the frame type. | 1155 // over the stack and dispatching according to the frame type. |
1154 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { | 1156 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { |
1155 StackFrame* frame = iter.frame(); | 1157 StackFrame* frame = iter.frame(); |
1156 | 1158 |
1157 // For JSEntryStub frames we always have a handler. | 1159 // For JSEntryStub frames we always have a handler. |
1158 if (frame->is_entry() || frame->is_entry_construct()) { | 1160 if (frame->is_entry() || frame->is_entry_construct()) { |
1159 StackHandler* handler = frame->top_handler(); | 1161 StackHandler* handler = frame->top_handler(); |
1160 | 1162 |
1161 // Restore the next handler. | 1163 // Restore the next handler. |
1162 thread_local_top()->handler_ = handler->next()->address(); | 1164 thread_local_top()->handler_ = handler->next()->address(); |
1163 | 1165 |
1164 // Gather information from the handler. | 1166 // Gather information from the handler. |
1165 code = frame->LookupCode(); | 1167 code = frame->LookupCode(); |
1166 handler_sp = handler->address() + StackHandlerConstants::kSize; | 1168 handler_sp = handler->address() + StackHandlerConstants::kSize; |
1167 offset = Smi::cast(code->handler_table()->get(0))->value(); | 1169 offset = Smi::cast(code->handler_table()->get(0))->value(); |
1168 break; | 1170 break; |
1169 } | 1171 } |
1170 | 1172 |
1173 if (frame->is_wasm() && catchable_by_wasm) { | |
titzer
2016/09/28 17:09:14
What about nesting this whole thing inside a if(FL
John
2016/09/29 13:28:31
Done.
| |
1174 int stack_slots = 0; // Will contain stack slot count of frame. | |
1175 WasmFrame* wasm_frame = static_cast<WasmFrame*>(frame); | |
1176 offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots); | |
1177 if (offset >= 0) { | |
1178 // Compute the stack pointer from the frame pointer. This ensures that | |
1179 // argument slots on the stack are dropped as returning would. | |
1180 Address return_sp = frame->fp() + | |
1181 StandardFrameConstants::kFixedFrameSizeAboveFp - | |
1182 stack_slots * kPointerSize; | |
1183 | |
1184 // Gather information from the frame. | |
1185 code = frame->LookupCode(); | |
1186 | |
1187 handler_sp = return_sp; | |
1188 handler_fp = frame->fp(); | |
1189 break; | |
1190 } | |
1191 } | |
1192 | |
1171 // For optimized frames we perform a lookup in the handler table. | 1193 // For optimized frames we perform a lookup in the handler table. |
1172 if (frame->is_optimized() && catchable_by_js) { | 1194 if (frame->is_optimized() && catchable_by_js) { |
1173 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); | 1195 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); |
1174 int stack_slots = 0; // Will contain stack slot count of frame. | 1196 int stack_slots = 0; // Will contain stack slot count of frame. |
1175 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr); | 1197 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr); |
1176 if (offset >= 0) { | 1198 if (offset >= 0) { |
1177 // Compute the stack pointer from the frame pointer. This ensures that | 1199 // Compute the stack pointer from the frame pointer. This ensures that |
1178 // argument slots on the stack are dropped as returning would. | 1200 // argument slots on the stack are dropped as returning would. |
1179 Address return_sp = frame->fp() + | 1201 Address return_sp = frame->fp() + |
1180 StandardFrameConstants::kFixedFrameSizeAboveFp - | 1202 StandardFrameConstants::kFixedFrameSizeAboveFp - |
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3291 // Then check whether this scope intercepts. | 3313 // Then check whether this scope intercepts. |
3292 if ((flag & intercept_mask_)) { | 3314 if ((flag & intercept_mask_)) { |
3293 intercepted_flags_ |= flag; | 3315 intercepted_flags_ |= flag; |
3294 return true; | 3316 return true; |
3295 } | 3317 } |
3296 return false; | 3318 return false; |
3297 } | 3319 } |
3298 | 3320 |
3299 } // namespace internal | 3321 } // namespace internal |
3300 } // namespace v8 | 3322 } // namespace v8 |
OLD | NEW |