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

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

Issue 1299653003: Migrate LongJumpScope to Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Assert current isolate. Created 5 years, 4 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/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"
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_ = Isolate::Current()->top_resource(); 20 top_ = Thread::Current()->top_resource();
21 return &environment_; 21 return &environment_;
22 } 22 }
23 23
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 Isolate* isolate = Isolate::Current(); 28 Thread* thread = Thread::Current();
29 uword jumpbuf_addr = Isolate::GetCurrentStackPointer(); 29 uword jumpbuf_addr = Isolate::GetCurrentStackPointer();
30 #if defined(USING_SIMULATOR) 30 #if defined(USING_SIMULATOR)
31 uword top_exit_frame_info = isolate->simulator()->top_exit_frame_info(); 31 {
32 Isolate* isolate = thread->isolate();
33 ASSERT(isolate->MutatorThreadIsCurrentThread());
34 uword top_exit_frame_info = isolate->simulator()->top_exit_frame_info();
35 }
32 #else 36 #else
33 uword top_exit_frame_info = isolate->top_exit_frame_info(); 37 uword top_exit_frame_info = thread->top_exit_frame_info();
34 #endif 38 #endif
35 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info)); 39 return ((top_exit_frame_info == 0) || (jumpbuf_addr < top_exit_frame_info));
36 } 40 }
37 41
38 42
39 void LongJumpScope::Jump(int value, const Error& error) { 43 void LongJumpScope::Jump(int value, const Error& error) {
40 // A zero is the default return value from setting up a LongJumpScope 44 // A zero is the default return value from setting up a LongJumpScope
41 // using Set. 45 // using Set.
42 ASSERT(value != 0); 46 ASSERT(value != 0);
43 ASSERT(IsSafeToJump()); 47 ASSERT(IsSafeToJump());
(...skipping 11 matching lines...) Expand all
55 // Remember the error in the sticky error of this isolate. 59 // Remember the error in the sticky error of this isolate.
56 isolate->object_store()->set_sticky_error(error); 60 isolate->object_store()->set_sticky_error(error);
57 61
58 // Destruct all the active StackResource objects. 62 // Destruct all the active StackResource objects.
59 StackResource::UnwindAbove(thread, top_); 63 StackResource::UnwindAbove(thread, top_);
60 longjmp(environment_, value); 64 longjmp(environment_, value);
61 UNREACHABLE(); 65 UNREACHABLE();
62 } 66 }
63 67
64 } // namespace dart 68 } // 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