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

Side by Side Diff: src/isolate.cc

Issue 2378773013: [WASM] Implements catch for the wasm low level exception mechanism. (Closed)
Patch Set: updates effect dependencies. Created 4 years, 2 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
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 "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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1142
1143 Object* Isolate::UnwindAndFindHandler() { 1143 Object* Isolate::UnwindAndFindHandler() {
1144 Object* exception = pending_exception(); 1144 Object* exception = pending_exception();
1145 1145
1146 Code* code = nullptr; 1146 Code* code = nullptr;
1147 Context* context = nullptr; 1147 Context* context = nullptr;
1148 intptr_t offset = 0; 1148 intptr_t offset = 0;
1149 Address handler_sp = nullptr; 1149 Address handler_sp = nullptr;
1150 Address handler_fp = nullptr; 1150 Address handler_fp = nullptr;
1151 1151
1152 // Special handling of termination exceptions, uncatchable by JavaScript code, 1152 // Special handling of termination exceptions, uncatchable by JavaScript and
1153 // we unwind the handlers until the top ENTRY handler is found. 1153 // Wasm code, we unwind the handlers until the top ENTRY handler is found.
1154 bool catchable_by_js = is_catchable_by_javascript(exception); 1154 bool catchable_by_js = is_catchable_by_javascript(exception);
1155 1155
1156 // Compute handler and stack unwinding information by performing a full walk 1156 // Compute handler and stack unwinding information by performing a full walk
1157 // over the stack and dispatching according to the frame type. 1157 // over the stack and dispatching according to the frame type.
1158 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { 1158 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) {
1159 StackFrame* frame = iter.frame(); 1159 StackFrame* frame = iter.frame();
1160 1160
1161 // For JSEntryStub frames we always have a handler. 1161 // For JSEntryStub frames we always have a handler.
1162 if (frame->is_entry() || frame->is_entry_construct()) { 1162 if (frame->is_entry() || frame->is_entry_construct()) {
1163 StackHandler* handler = frame->top_handler(); 1163 StackHandler* handler = frame->top_handler();
1164 1164
1165 // Restore the next handler. 1165 // Restore the next handler.
1166 thread_local_top()->handler_ = handler->next()->address(); 1166 thread_local_top()->handler_ = handler->next()->address();
1167 1167
1168 // Gather information from the handler. 1168 // Gather information from the handler.
1169 code = frame->LookupCode(); 1169 code = frame->LookupCode();
1170 handler_sp = handler->address() + StackHandlerConstants::kSize; 1170 handler_sp = handler->address() + StackHandlerConstants::kSize;
1171 offset = Smi::cast(code->handler_table()->get(0))->value(); 1171 offset = Smi::cast(code->handler_table()->get(0))->value();
1172 break; 1172 break;
1173 } 1173 }
1174 1174
1175 if (FLAG_wasm_eh_prototype) {
1176 if (frame->is_wasm() && is_catchable_by_wasm(exception)) {
1177 int stack_slots = 0; // Will contain stack slot count of frame.
1178 WasmFrame* wasm_frame = static_cast<WasmFrame*>(frame);
1179 offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots);
1180 if (offset >= 0) {
1181 // Compute the stack pointer from the frame pointer. This ensures that
1182 // argument slots on the stack are dropped as returning would.
1183 Address return_sp = frame->fp() +
1184 StandardFrameConstants::kFixedFrameSizeAboveFp -
1185 stack_slots * kPointerSize;
1186
1187 // Gather information from the frame.
1188 code = frame->LookupCode();
1189
1190 handler_sp = return_sp;
1191 handler_fp = frame->fp();
1192 break;
1193 }
1194 }
1195 }
1196
1175 // For optimized frames we perform a lookup in the handler table. 1197 // For optimized frames we perform a lookup in the handler table.
1176 if (frame->is_optimized() && catchable_by_js) { 1198 if (frame->is_optimized() && catchable_by_js) {
1177 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); 1199 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame);
1178 int stack_slots = 0; // Will contain stack slot count of frame. 1200 int stack_slots = 0; // Will contain stack slot count of frame.
1179 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr); 1201 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr);
1180 if (offset >= 0) { 1202 if (offset >= 0) {
1181 // Compute the stack pointer from the frame pointer. This ensures that 1203 // Compute the stack pointer from the frame pointer. This ensures that
1182 // argument slots on the stack are dropped as returning would. 1204 // argument slots on the stack are dropped as returning would.
1183 Address return_sp = frame->fp() + 1205 Address return_sp = frame->fp() +
1184 StandardFrameConstants::kFixedFrameSizeAboveFp - 1206 StandardFrameConstants::kFixedFrameSizeAboveFp -
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 // Then check whether this scope intercepts. 3317 // Then check whether this scope intercepts.
3296 if ((flag & intercept_mask_)) { 3318 if ((flag & intercept_mask_)) {
3297 intercepted_flags_ |= flag; 3319 intercepted_flags_ |= flag;
3298 return true; 3320 return true;
3299 } 3321 }
3300 return false; 3322 return false;
3301 } 3323 }
3302 3324
3303 } // namespace internal 3325 } // namespace internal
3304 } // namespace v8 3326 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698