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

Side by Side Diff: runtime/vm/exceptions.cc

Issue 2341523002: VM: Better handling of OOM errors in the background compiler (Closed)
Patch Set: fix comment Created 4 years, 3 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 | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/exceptions.h" 5 #include "vm/exceptions.h"
6 6
7 #include "platform/address_sanitizer.h" 7 #include "platform/address_sanitizer.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
11 #include "vm/debugger.h" 11 #include "vm/debugger.h"
12 #include "vm/flags.h" 12 #include "vm/flags.h"
13 #include "vm/log.h" 13 #include "vm/log.h"
14 #include "vm/longjump.h"
14 #include "vm/object.h" 15 #include "vm/object.h"
15 #include "vm/object_store.h" 16 #include "vm/object_store.h"
16 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
17 #include "vm/stub_code.h" 18 #include "vm/stub_code.h"
18 #include "vm/symbols.h" 19 #include "vm/symbols.h"
19 #include "vm/tags.h" 20 #include "vm/tags.h"
20 21
21 namespace dart { 22 namespace dart {
22 23
23 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, 24 DEFINE_FLAG(bool, print_stacktrace_at_throw, false,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // exception handler. Once found, set the pc, sp and fp so that execution 140 // exception handler. Once found, set the pc, sp and fp so that execution
140 // can continue in that frame. Sets 'needs_stacktrace' if there is no 141 // can continue in that frame. Sets 'needs_stacktrace' if there is no
141 // cath-all handler or if a stack-trace is specified in the catch. 142 // cath-all handler or if a stack-trace is specified in the catch.
142 static bool FindExceptionHandler(Thread* thread, 143 static bool FindExceptionHandler(Thread* thread,
143 uword* handler_pc, 144 uword* handler_pc,
144 uword* handler_sp, 145 uword* handler_sp,
145 uword* handler_fp, 146 uword* handler_fp,
146 bool* needs_stacktrace) { 147 bool* needs_stacktrace) {
147 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 148 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
148 StackFrame* frame = frames.NextFrame(); 149 StackFrame* frame = frames.NextFrame();
149 ASSERT(frame != NULL); // We expect to find a dart invocation frame. 150 if (frame == NULL) return false;
rmacnak 2016/09/13 23:29:56 // No Dart frame.
Florian Schneider 2016/09/14 00:13:21 Done.
150 bool handler_pc_set = false; 151 bool handler_pc_set = false;
151 *needs_stacktrace = false; 152 *needs_stacktrace = false;
152 bool is_catch_all = false; 153 bool is_catch_all = false;
153 uword temp_handler_pc = kUwordMax; 154 uword temp_handler_pc = kUwordMax;
154 while (!frame->IsEntryFrame()) { 155 while (!frame->IsEntryFrame()) {
155 if (frame->IsDartFrame()) { 156 if (frame->IsDartFrame()) {
156 if (frame->FindExceptionHandler(thread, 157 if (frame->FindExceptionHandler(thread,
157 &temp_handler_pc, 158 &temp_handler_pc,
158 needs_stacktrace, 159 needs_stacktrace,
159 &is_catch_all)) { 160 &is_catch_all)) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 bool handler_exists = false; 321 bool handler_exists = false;
321 bool handler_needs_stacktrace = false; 322 bool handler_needs_stacktrace = false;
322 if (use_preallocated_stacktrace) { 323 if (use_preallocated_stacktrace) {
323 stacktrace ^= isolate->object_store()->preallocated_stack_trace(); 324 stacktrace ^= isolate->object_store()->preallocated_stack_trace();
324 PreallocatedStacktraceBuilder frame_builder(stacktrace); 325 PreallocatedStacktraceBuilder frame_builder(stacktrace);
325 handler_exists = FindExceptionHandler(thread, 326 handler_exists = FindExceptionHandler(thread,
326 &handler_pc, 327 &handler_pc,
327 &handler_sp, 328 &handler_sp,
328 &handler_fp, 329 &handler_fp,
329 &handler_needs_stacktrace); 330 &handler_needs_stacktrace);
331 if (handler_pc == 0) {
332 // No Dart frame.
333 ASSERT(!thread->IsMutatorThread());
rmacnak 2016/09/13 23:29:56 Maybe assert that incoming_exception is the preall
Florian Schneider 2016/09/14 00:13:21 Done.
334 const UnhandledException& error = UnhandledException::Handle(
335 zone, isolate->object_store()->preallocated_unhandled_exception());
336 thread->long_jump_base()->Jump(1, error);
337 UNREACHABLE();
338 }
330 if (handler_needs_stacktrace) { 339 if (handler_needs_stacktrace) {
331 BuildStackTrace(&frame_builder); 340 BuildStackTrace(&frame_builder);
332 } 341 }
333 } else { 342 } else {
334 // Get stacktrace field of class Error. This is needed to determine whether 343 // Get stacktrace field of class Error. This is needed to determine whether
335 // we have a subclass of Error which carries around its stack trace. 344 // we have a subclass of Error which carries around its stack trace.
336 const Field& stacktrace_field = 345 const Field& stacktrace_field =
337 Field::Handle(zone, LookupStacktraceField(exception)); 346 Field::Handle(zone, LookupStacktraceField(exception));
338 347
339 // Find the exception handler and determine if the handler needs a 348 // Find the exception handler and determine if the handler needs a
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } 725 }
717 726
718 return DartLibraryCalls::InstanceCreate(library, 727 return DartLibraryCalls::InstanceCreate(library,
719 *class_name, 728 *class_name,
720 *constructor_name, 729 *constructor_name,
721 arguments); 730 arguments);
722 } 731 }
723 732
724 733
725 } // namespace dart 734 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698