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 #ifndef VM_DART_API_IMPL_H_ | 5 #ifndef VM_DART_API_IMPL_H_ |
6 #define VM_DART_API_IMPL_H_ | 6 #define VM_DART_API_IMPL_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/native_arguments.h" | 9 #include "vm/native_arguments.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 friend class ApiNativeScope; | 285 friend class ApiNativeScope; |
286 }; | 286 }; |
287 | 287 |
288 class IsolateSaver { | 288 class IsolateSaver { |
289 public: | 289 public: |
290 explicit IsolateSaver(Isolate* current_isolate) | 290 explicit IsolateSaver(Isolate* current_isolate) |
291 : saved_isolate_(current_isolate) { | 291 : saved_isolate_(current_isolate) { |
292 } | 292 } |
293 ~IsolateSaver() { | 293 ~IsolateSaver() { |
294 Isolate::SetCurrent(saved_isolate_); | 294 // TODO(koda): Audit users; they should know whether they're in an isolate. |
| 295 if (saved_isolate_ != NULL) { |
| 296 Thread::EnterIsolate(saved_isolate_); |
| 297 } |
295 } | 298 } |
296 private: | 299 private: |
297 Isolate* saved_isolate_; | 300 Isolate* saved_isolate_; |
298 | 301 |
299 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); | 302 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); |
300 }; | 303 }; |
301 | 304 |
302 // Start a scope in which no Dart API call backs are allowed. | 305 // Start a scope in which no Dart API call backs are allowed. |
303 #define START_NO_CALLBACK_SCOPE(isolate) \ | 306 #define START_NO_CALLBACK_SCOPE(isolate) \ |
304 isolate->IncrementNoCallbackScopeDepth() | 307 isolate->IncrementNoCallbackScopeDepth() |
305 | 308 |
306 // End a no Dart API call backs Scope. | 309 // End a no Dart API call backs Scope. |
307 #define END_NO_CALLBACK_SCOPE(isolate) \ | 310 #define END_NO_CALLBACK_SCOPE(isolate) \ |
308 isolate->DecrementNoCallbackScopeDepth() | 311 isolate->DecrementNoCallbackScopeDepth() |
309 | 312 |
310 #define CHECK_CALLBACK_STATE(isolate) \ | 313 #define CHECK_CALLBACK_STATE(isolate) \ |
311 if (isolate->no_callback_scope_depth() != 0) { \ | 314 if (isolate->no_callback_scope_depth() != 0) { \ |
312 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 315 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
313 } \ | 316 } \ |
314 | 317 |
315 #define ASSERT_CALLBACK_STATE(isolate) \ | 318 #define ASSERT_CALLBACK_STATE(isolate) \ |
316 ASSERT(isolate->no_callback_scope_depth() == 0) | 319 ASSERT(isolate->no_callback_scope_depth() == 0) |
317 | 320 |
318 } // namespace dart. | 321 } // namespace dart. |
319 | 322 |
320 #endif // VM_DART_API_IMPL_H_ | 323 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |