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

Side by Side Diff: src/isolate.cc

Issue 2275293002: [WASM] Implements catch for the wasm low level exception mechanism. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test changes 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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1137
1138 Object* Isolate::UnwindAndFindHandler() { 1138 Object* Isolate::UnwindAndFindHandler() {
1139 Object* exception = pending_exception(); 1139 Object* exception = pending_exception();
1140 1140
1141 Code* code = nullptr; 1141 Code* code = nullptr;
1142 Context* context = nullptr; 1142 Context* context = nullptr;
1143 intptr_t offset = 0; 1143 intptr_t offset = 0;
1144 Address handler_sp = nullptr; 1144 Address handler_sp = nullptr;
1145 Address handler_fp = nullptr; 1145 Address handler_fp = nullptr;
1146 1146
1147 // Special handling of termination exceptions, uncatchable by JavaScript code, 1147 // Special handling of termination exceptions, uncatchable by JavaScript and
1148 // we unwind the handlers until the top ENTRY handler is found. 1148 // Wasm code, we unwind the handlers until the top ENTRY handler is found.
1149 bool catchable_by_js = is_catchable_by_javascript(exception); 1149 bool catchable_by_js = is_catchable_by_javascript(exception);
1150 bool catchable_by_wasm =
1151 FLAG_wasm_eh_prototype && is_catchable_by_wasm(exception);
1150 1152
1151 // Compute handler and stack unwinding information by performing a full walk 1153 // Compute handler and stack unwinding information by performing a full walk
1152 // over the stack and dispatching according to the frame type. 1154 // over the stack and dispatching according to the frame type.
1153 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { 1155 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) {
1154 StackFrame* frame = iter.frame(); 1156 StackFrame* frame = iter.frame();
1155 1157
1156 // For JSEntryStub frames we always have a handler. 1158 // For JSEntryStub frames we always have a handler.
1157 if (frame->is_entry() || frame->is_entry_construct()) { 1159 if (frame->is_entry() || frame->is_entry_construct()) {
1158 StackHandler* handler = frame->top_handler(); 1160 StackHandler* handler = frame->top_handler();
1159 1161
1160 // Restore the next handler. 1162 // Restore the next handler.
1161 thread_local_top()->handler_ = handler->next()->address(); 1163 thread_local_top()->handler_ = handler->next()->address();
1162 1164
1163 // Gather information from the handler. 1165 // Gather information from the handler.
1164 code = frame->LookupCode(); 1166 code = frame->LookupCode();
1165 handler_sp = handler->address() + StackHandlerConstants::kSize; 1167 handler_sp = handler->address() + StackHandlerConstants::kSize;
1166 offset = Smi::cast(code->handler_table()->get(0))->value(); 1168 offset = Smi::cast(code->handler_table()->get(0))->value();
1167 break; 1169 break;
1168 } 1170 }
1169 1171
1172 if (frame->is_wasm() && catchable_by_wasm) {
titzer 2016/09/28 12:53:31 Maybe inline this condition? Since frame->is_wasm(
John 2016/09/28 13:37:18 I am cargo-culting on the catchable_by_js. I also
1173 int stack_slots = 0; // Will contain stack slot count of frame.
1174 WasmFrame* wasm_frame = static_cast<WasmFrame*>(frame);
1175 offset = wasm_frame->LookupExceptionHandlerInTable(&stack_slots);
1176 if (offset >= 0) {
1177 // Compute the stack pointer from the frame pointer. This ensures that
1178 // argument slots on the stack are dropped as returning would.
1179 Address return_sp = frame->fp() +
1180 StandardFrameConstants::kFixedFrameSizeAboveFp -
1181 stack_slots * kPointerSize;
1182
1183 // Gather information from the frame.
1184 code = frame->LookupCode();
1185
1186 handler_sp = return_sp;
1187 handler_fp = frame->fp();
1188 break;
1189 }
1190 }
1191
1170 // For optimized frames we perform a lookup in the handler table. 1192 // For optimized frames we perform a lookup in the handler table.
1171 if (frame->is_optimized() && catchable_by_js) { 1193 if (frame->is_optimized() && catchable_by_js) {
1172 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame); 1194 OptimizedFrame* js_frame = static_cast<OptimizedFrame*>(frame);
1173 int stack_slots = 0; // Will contain stack slot count of frame. 1195 int stack_slots = 0; // Will contain stack slot count of frame.
1174 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr); 1196 offset = js_frame->LookupExceptionHandlerInTable(&stack_slots, nullptr);
1175 if (offset >= 0) { 1197 if (offset >= 0) {
1176 // Compute the stack pointer from the frame pointer. This ensures that 1198 // Compute the stack pointer from the frame pointer. This ensures that
1177 // argument slots on the stack are dropped as returning would. 1199 // argument slots on the stack are dropped as returning would.
1178 Address return_sp = frame->fp() + 1200 Address return_sp = frame->fp() +
1179 StandardFrameConstants::kFixedFrameSizeAboveFp - 1201 StandardFrameConstants::kFixedFrameSizeAboveFp -
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 // Then check whether this scope intercepts. 3306 // Then check whether this scope intercepts.
3285 if ((flag & intercept_mask_)) { 3307 if ((flag & intercept_mask_)) {
3286 intercepted_flags_ |= flag; 3308 intercepted_flags_ |= flag;
3287 return true; 3309 return true;
3288 } 3310 }
3289 return false; 3311 return false;
3290 } 3312 }
3291 3313
3292 } // namespace internal 3314 } // namespace internal
3293 } // namespace v8 3315 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698