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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/longjump.h ('k') | runtime/vm/longjump_test.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/longjump.h" 5 #include "vm/longjump.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 13 matching lines...) Expand all
24 24
25 bool LongJumpScope::IsSafeToJump() { 25 bool LongJumpScope::IsSafeToJump() {
26 // We do not want to jump past Dart frames. Note that this code 26 // We do not want to jump past Dart frames. Note that this code
27 // assumes the stack grows from high to low. 27 // assumes the stack grows from high to low.
28 Thread* thread = Thread::Current(); 28 Thread* thread = Thread::Current();
29 uword jumpbuf_addr = Thread::GetCurrentStackPointer(); 29 uword jumpbuf_addr = Thread::GetCurrentStackPointer();
30 #if defined(USING_SIMULATOR) 30 #if defined(USING_SIMULATOR)
31 Simulator* sim = Simulator::Current(); 31 Simulator* sim = Simulator::Current();
32 // When using simulator, only mutator thread should refer to Simulator 32 // When using simulator, only mutator thread should refer to Simulator
33 // since there can be only one per isolate. 33 // since there can be only one per isolate.
34 uword top_exit_frame_info = thread->IsMutatorThread() ? 34 uword top_exit_frame_info =
35 sim->top_exit_frame_info() : 0; 35 thread->IsMutatorThread() ? sim->top_exit_frame_info() : 0;
36 #else 36 #else
37 uword top_exit_frame_info = thread->top_exit_frame_info(); 37 uword top_exit_frame_info = thread->top_exit_frame_info();
38 #endif 38 #endif
39 if (!thread->IsMutatorThread()) { 39 if (!thread->IsMutatorThread()) {
40 // A helper thread does not execute Dart code, so it's safe to jump. 40 // A helper thread does not execute Dart code, so it's safe to jump.
41 ASSERT(top_exit_frame_info == 0); 41 ASSERT(top_exit_frame_info == 0);
42 return true; 42 return true;
43 } 43 }
44 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info)); 44 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info));
45 } 45 }
46 46
47 47
48 void LongJumpScope::Jump(int value, const Error& error) { 48 void LongJumpScope::Jump(int value, const Error& error) {
49 // A zero is the default return value from setting up a LongJumpScope 49 // A zero is the default return value from setting up a LongJumpScope
50 // using Set. 50 // using Set.
51 ASSERT(value != 0); 51 ASSERT(value != 0);
52 ASSERT(IsSafeToJump()); 52 ASSERT(IsSafeToJump());
53 53
54 Thread* thread = Thread::Current(); 54 Thread* thread = Thread::Current();
55 55
56 #if defined(DEBUG) 56 #if defined(DEBUG)
57 #define CHECK_REUSABLE_HANDLE(name) \ 57 #define CHECK_REUSABLE_HANDLE(name) \
58 ASSERT(!thread->reusable_##name##_handle_scope_active()); 58 ASSERT(!thread->reusable_##name##_handle_scope_active());
59 REUSABLE_HANDLE_LIST(CHECK_REUSABLE_HANDLE) 59 REUSABLE_HANDLE_LIST(CHECK_REUSABLE_HANDLE)
60 #undef CHECK_REUSABLE_HANDLE 60 #undef CHECK_REUSABLE_HANDLE
61 #endif // defined(DEBUG) 61 #endif // defined(DEBUG)
62 62
63 // Remember the error in the sticky error of this isolate. 63 // Remember the error in the sticky error of this isolate.
64 thread->set_sticky_error(error); 64 thread->set_sticky_error(error);
65 65
66 // Destruct all the active StackResource objects. 66 // Destruct all the active StackResource objects.
67 StackResource::UnwindAbove(thread, top_); 67 StackResource::UnwindAbove(thread, top_);
68 longjmp(environment_, value); 68 longjmp(environment_, value);
69 UNREACHABLE(); 69 UNREACHABLE();
70 } 70 }
71 71
72 } // namespace dart 72 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/longjump.h ('k') | runtime/vm/longjump_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698