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

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

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

Powered by Google App Engine
This is Rietveld 408576698