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

Side by Side Diff: vm/exceptions.cc

Issue 10915295: Instead of aborting with an assert, exit with an error when we get an OOM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 14 matching lines...) Expand all
25 // exception handler. Once found, set the pc, sp and fp so that execution 25 // exception handler. Once found, set the pc, sp and fp so that execution
26 // can continue in that frame. 26 // can continue in that frame.
27 static bool FindExceptionHandler(uword* handler_pc, 27 static bool FindExceptionHandler(uword* handler_pc,
28 uword* handler_sp, 28 uword* handler_sp,
29 uword* handler_fp, 29 uword* handler_fp,
30 const GrowableObjectArray& func_list, 30 const GrowableObjectArray& func_list,
31 const GrowableObjectArray& code_list, 31 const GrowableObjectArray& code_list,
32 const GrowableObjectArray& pc_offset_list) { 32 const GrowableObjectArray& pc_offset_list) {
33 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 33 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
34 StackFrame* frame = frames.NextFrame(); 34 StackFrame* frame = frames.NextFrame();
35 ASSERT(frame != NULL); 35 if (frame == NULL) {
36 // We have no dart invocation frames and hence cannot find a handler
37 // to return to.
38 return false;
39 }
36 Function& func = Function::Handle(); 40 Function& func = Function::Handle();
37 Code& code = Code::Handle(); 41 Code& code = Code::Handle();
38 Smi& offset = Smi::Handle(); 42 Smi& offset = Smi::Handle();
39 while (!frame->IsEntryFrame()) { 43 while (!frame->IsEntryFrame()) {
40 if (frame->IsDartFrame()) { 44 if (frame->IsDartFrame()) {
41 func = frame->LookupDartFunction(); 45 func = frame->LookupDartFunction();
42 code = frame->LookupDartCode(); 46 code = frame->LookupDartCode();
43 offset = Smi::New(frame->pc() - code.EntryPoint()); 47 offset = Smi::New(frame->pc() - code.EntryPoint());
44 func_list.Add(func); 48 func_list.Add(func);
45 code_list.Add(code); 49 code_list.Add(code);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 const GrowableObjectArray& code_list = 154 const GrowableObjectArray& code_list =
151 GrowableObjectArray::Handle(GrowableObjectArray::New()); 155 GrowableObjectArray::Handle(GrowableObjectArray::New());
152 const GrowableObjectArray& pc_offset_list = 156 const GrowableObjectArray& pc_offset_list =
153 GrowableObjectArray::Handle(GrowableObjectArray::New()); 157 GrowableObjectArray::Handle(GrowableObjectArray::New());
154 bool handler_exists = FindExceptionHandler(&handler_pc, 158 bool handler_exists = FindExceptionHandler(&handler_pc,
155 &handler_sp, 159 &handler_sp,
156 &handler_fp, 160 &handler_fp,
157 func_list, 161 func_list,
158 code_list, 162 code_list,
159 pc_offset_list); 163 pc_offset_list);
164 if (handler_pc == 0) {
165 // There are no dart invocation frames on the stack so we do not
166 // have a caller to return to. This is a case where we would have
167 // to call the Isolate error handler and let it deal with the shutdown.
168 // We report an error and shutdown the process as a temporary solution
169 // until the isolate error handler stuff is implemented.
170 ASSERT(!handler_exists);
171 OS::PrintErr("Exception '%s' thrown:\n", exception.ToCString());
172 OS::PrintErr("Exiting the process\n");
173 OS::Exit(255);
174 }
160 // TODO(5411263): At some point we can optimize by figuring out if a 175 // TODO(5411263): At some point we can optimize by figuring out if a
161 // stack trace is needed based on whether the catch code specifies a 176 // stack trace is needed based on whether the catch code specifies a
162 // stack trace object or there is a rethrow in the catch clause. 177 // stack trace object or there is a rethrow in the catch clause.
163 Stacktrace& stacktrace = Stacktrace::Handle(); 178 Stacktrace& stacktrace = Stacktrace::Handle();
164 if (pc_offset_list.Length() != 0) { 179 if (pc_offset_list.Length() != 0) {
165 if (existing_stacktrace.IsNull()) { 180 if (existing_stacktrace.IsNull()) {
166 stacktrace = Stacktrace::New(func_list, code_list, pc_offset_list); 181 stacktrace = Stacktrace::New(func_list, code_list, pc_offset_list);
167 } else { 182 } else {
168 stacktrace ^= existing_stacktrace.raw(); 183 stacktrace ^= existing_stacktrace.raw();
169 stacktrace.Append(func_list, code_list, pc_offset_list); 184 stacktrace.Append(func_list, code_list, pc_offset_list);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 case kIsolateSpawn: 447 case kIsolateSpawn:
433 library = Library::IsolateLibrary(); 448 library = Library::IsolateLibrary();
434 class_name = Symbols::New("IsolateSpawnException"); 449 class_name = Symbols::New("IsolateSpawnException");
435 break; 450 break;
436 } 451 }
437 452
438 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments); 453 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments);
439 } 454 }
440 455
441 } // namespace dart 456 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698