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

Side by Side 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 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.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 #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/object.h" 9 #include "vm/object.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 class ApiState; 13 class ApiState;
14 class LocalHandle; 14 class LocalHandle;
15 class PersistentHandle; 15 class PersistentHandle;
16 16
17 const char* CanonicalFunction(const char* func);
18
19 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__)
20
21 // Checks that the current isolate is not NULL.
22 #define CHECK_ISOLATE(isolate) \
23 do { \
24 if ((isolate) == NULL) { \
25 FATAL1("%s expects there to be a current isolate. Did you " \
26 "forget to call Dart_CreateIsolate or Dart_EnterIsolate?", \
27 CURRENT_FUNC); \
28 } \
29 } while (0)
30
31 // Checks that the current isolate is NULL.
32 #define CHECK_NO_ISOLATE(isolate) \
33 do { \
34 if ((isolate) != NULL) { \
35 FATAL1("%s expects there to be no current isolate. Did you " \
36 "forget to call Dart_ExitIsolate?", CURRENT_FUNC); \
37 } \
38 } while (0)
39
40 // Checks that the current isolate is not NULL and that it has an API scope.
41 #define CHECK_ISOLATE_SCOPE(isolate) \
42 do { \
43 Isolate* tmp = (isolate); \
44 CHECK_ISOLATE(tmp); \
45 ApiState* state = tmp->api_state(); \
46 ASSERT(state); \
47 if (state->top_scope() == NULL) { \
48 FATAL1("%s expects to find a current scope. Did you forget to call " \
49 "Dart_EnterScope?", CURRENT_FUNC); \
50 } \
51 } while (0)
52
53 #define DARTSCOPE_NOCHECKS(isolate) \
54 Isolate* __temp_isolate__ = (isolate); \
55 ASSERT(__temp_isolate__ != NULL); \
56 Zone zone(__temp_isolate__); \
57 HANDLESCOPE(__temp_isolate__);
58
17 #define DARTSCOPE(isolate) \ 59 #define DARTSCOPE(isolate) \
18 ASSERT(isolate != NULL); \ 60 Isolate* __temp_isolate__ = (isolate); \
19 Zone zone(isolate); \ 61 CHECK_ISOLATE_SCOPE(__temp_isolate__); \
20 HANDLESCOPE(isolate); \ 62 Zone zone(__temp_isolate__); \
63 HANDLESCOPE(__temp_isolate__);
21 64
22 class Api : AllStatic { 65 class Api : AllStatic {
23 public: 66 public:
24 // Creates a new local handle. 67 // Creates a new local handle.
25 static Dart_Handle NewLocalHandle(const Object& object); 68 static Dart_Handle NewLocalHandle(const Object& object);
26 69
27 // Unwraps the raw object from the handle. 70 // Unwraps the raw object from the handle.
28 static RawObject* UnwrapHandle(Dart_Handle object); 71 static RawObject* UnwrapHandle(Dart_Handle object);
29 72
30 // Unwraps a raw Type from the handle. The handle will be null if 73 // Unwraps a raw Type from the handle. The handle will be null if
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Allocates space in the local zone. 112 // Allocates space in the local zone.
70 static uword Allocate(intptr_t size); 113 static uword Allocate(intptr_t size);
71 114
72 // Reallocates space in the local zone. 115 // Reallocates space in the local zone.
73 static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size); 116 static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size);
74 }; 117 };
75 118
76 } // namespace dart. 119 } // namespace dart.
77 120
78 #endif // VM_DART_API_IMPL_H_ 121 #endif // VM_DART_API_IMPL_H_
OLDNEW
« 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