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

Unified Diff: runtime/vm/dart_api_impl.h

Issue 8733011: Add the CHECK_ISOLATE macro, which validates that the current isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.h
===================================================================
--- runtime/vm/dart_api_impl.h (revision 1989)
+++ runtime/vm/dart_api_impl.h (working copy)
@@ -14,10 +14,53 @@
class LocalHandle;
class PersistentHandle;
+const char* CanonicalFunction(const char* func);
+
+#define CURRENT_FUNC CanonicalFunction(__FUNCTION__)
+
+// Checks that the current isolate is not NULL.
+#define CHECK_ISOLATE(isolate) \
+ do { \
+ if ((isolate) == NULL) { \
+ FATAL1("%s expects there to be a current isolate. Did you " \
+ "forget to call Dart_CreateIsolate or Dart_EnterIsolate?", \
+ CURRENT_FUNC); \
+ } \
+ } while (0)
+
+// Checks that the current isolate is NULL.
+#define CHECK_NO_ISOLATE(isolate) \
+ do { \
+ if ((isolate) != NULL) { \
+ FATAL1("%s expects there to be no current isolate. Did you " \
+ "forget to call Dart_ExitIsolate?", CURRENT_FUNC); \
+ } \
+ } while (0)
+
+// Checks that the current isolate is not NULL and that it has an API scope.
+#define CHECK_ISOLATE_SCOPE(isolate) \
+ do { \
+ Isolate* tmp = (isolate); \
+ CHECK_ISOLATE(tmp); \
+ ApiState* state = tmp->api_state(); \
+ ASSERT(state); \
+ if (state->top_scope() == NULL) { \
+ FATAL1("%s expects to find a current scope. Did you forget to call " \
+ "Dart_EnterScope?", CURRENT_FUNC); \
+ } \
+ } while (0)
+
+#define DARTSCOPE_NOCHECKS(isolate) \
+ Isolate* __temp_isolate__ = (isolate); \
+ ASSERT(__temp_isolate__ != NULL); \
+ Zone zone(__temp_isolate__); \
+ HANDLESCOPE(__temp_isolate__);
+
#define DARTSCOPE(isolate) \
- ASSERT(isolate != NULL); \
- Zone zone(isolate); \
- HANDLESCOPE(isolate); \
+ Isolate* __temp_isolate__ = (isolate); \
+ CHECK_ISOLATE_SCOPE(__temp_isolate__); \
+ Zone zone(__temp_isolate__); \
+ HANDLESCOPE(__temp_isolate__);
class Api : AllStatic {
public:
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698