OLD | NEW |
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 <errno.h> | 5 #include <errno.h> |
6 #include <pthread.h> | 6 #include <pthread.h> |
7 | 7 |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 pthread_key_t isolate_key = PTHREAD_KEY_UNSET; | 22 pthread_key_t isolate_key = PTHREAD_KEY_UNSET; |
23 | 23 |
24 | 24 |
25 void Isolate::SetCurrent(Isolate* current) { | 25 void Isolate::SetCurrent(Isolate* current) { |
26 ASSERT(isolate_key != PTHREAD_KEY_UNSET); | 26 ASSERT(isolate_key != PTHREAD_KEY_UNSET); |
27 int result = pthread_setspecific(isolate_key, current); | 27 int result = pthread_setspecific(isolate_key, current); |
28 VALIDATE_PTHREAD_RESULT(result); | 28 VALIDATE_PTHREAD_RESULT(result); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 // Empty isolate init callback which is registered before VM isolate creation. | |
33 static void* VMIsolateInitCallback(void* data) { | |
34 return reinterpret_cast<void*>(1); | |
35 } | |
36 | |
37 | |
38 void Isolate::InitOnce() { | 32 void Isolate::InitOnce() { |
39 ASSERT(isolate_key == PTHREAD_KEY_UNSET); | 33 ASSERT(isolate_key == PTHREAD_KEY_UNSET); |
40 int result = pthread_key_create(&isolate_key, NULL); | 34 int result = pthread_key_create(&isolate_key, NULL); |
41 // Make sure creating a key was successful. | 35 // Make sure creating a key was successful. |
42 VALIDATE_PTHREAD_RESULT(result); | 36 VALIDATE_PTHREAD_RESULT(result); |
43 ASSERT(isolate_key != PTHREAD_KEY_UNSET); | 37 ASSERT(isolate_key != PTHREAD_KEY_UNSET); |
44 init_callback_ = VMIsolateInitCallback; | 38 create_callback_ = NULL; |
45 } | 39 } |
46 | 40 |
47 } // namespace dart | 41 } // namespace dart |
OLD | NEW |