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

Side by Side Diff: runtime/vm/dart_api_impl.h

Issue 9956133: Remove many calls to Isolate::Current() in the dart embedding api by (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | 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
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 const char* CheckIsolateState(Isolate *isolate, 67 const char* CheckIsolateState(Isolate *isolate,
68 bool generating_snapshot = false); 68 bool generating_snapshot = false);
69 69
70 void SetupErrorResult(Dart_Handle* handle); 70 void SetupErrorResult(Dart_Handle* handle);
71 71
72 72
73 class Api : AllStatic { 73 class Api : AllStatic {
74 public: 74 public:
75 // Creates a new local handle. 75 // Creates a new local handle.
76 static Dart_Handle NewLocalHandle(const Object& object); 76 static Dart_Handle NewLocalHandle(Isolate* isolate, const Object& object);
77 77
78 // Unwraps the raw object from the handle. 78 // Unwraps the raw object from the handle.
79 static RawObject* UnwrapHandle(Dart_Handle object); 79 static RawObject* UnwrapHandle(Dart_Handle object);
80 80
81 // Unwraps a raw Type from the handle. The handle will be null if 81 // Unwraps a raw Type from the handle. The handle will be null if
82 // the object was not of the requested Type. 82 // the object was not of the requested Type.
83 #define DECLARE_UNWRAP(Type) \ 83 #define DECLARE_UNWRAP(Type) \
84 static const Type& Unwrap##Type##Handle(Dart_Handle object); 84 static const Type& Unwrap##Type##Handle(Isolate* isolate, \
85 Dart_Handle object);
85 CLASS_LIST_NO_OBJECT(DECLARE_UNWRAP) 86 CLASS_LIST_NO_OBJECT(DECLARE_UNWRAP)
86 #undef DECLARE_UNWRAP 87 #undef DECLARE_UNWRAP
87 88
88 // Validates and converts the passed in handle as a local handle. 89 // Validates and converts the passed in handle as a local handle.
89 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state, 90 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state,
90 Dart_Handle object); 91 Dart_Handle object);
91 92
92 // Validates and converts the passed in handle as a persistent handle. 93 // Validates and converts the passed in handle as a persistent handle.
93 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, 94 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state,
94 Dart_Handle object); 95 Dart_Handle object);
95 96
96 // Validates and converts the passed in handle as a weak persistent handle. 97 // Validates and converts the passed in handle as a weak persistent handle.
97 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( 98 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle(
98 const ApiState& state, 99 const ApiState& state,
99 Dart_Handle object); 100 Dart_Handle object);
100 101
101 // Validates and converts the passed in handle as a prologue weak 102 // Validates and converts the passed in handle as a prologue weak
102 // persistent handle. 103 // persistent handle.
103 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( 104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle(
104 const ApiState& state, 105 const ApiState& state,
105 Dart_Handle object); 106 Dart_Handle object);
106 107
107 // Casts the internal Isolate* type to the external Dart_Isolate type. 108 // Casts the internal Isolate* type to the external Dart_Isolate type.
108 static Dart_Isolate CastIsolate(Isolate* isolate); 109 static Dart_Isolate CastIsolate(Isolate* isolate);
109 110
110 // Gets the handle used to designate successful return. 111 // Gets the handle used to designate successful return.
111 static Dart_Handle Success(); 112 static Dart_Handle Success(Isolate* isolate);
112 113
113 // Generates a handle used to designate an error return. 114 // Generates a handle used to designate an error return.
114 static Dart_Handle NewError(const char* format, ...); 115 static Dart_Handle NewError(const char* format, ...);
115 116
116 // Gets a handle to Null. 117 // Gets a handle to Null.
117 static Dart_Handle Null(); 118 static Dart_Handle Null(Isolate* isolate);
118 119
119 // Gets a handle to True. 120 // Gets a handle to True.
120 static Dart_Handle True(); 121 static Dart_Handle True(Isolate* isolate);
121 122
122 // Gets a handle to False 123 // Gets a handle to False
123 static Dart_Handle False(); 124 static Dart_Handle False(Isolate* isolate);
124 125
125 // Allocates space in the local zone. 126 // Allocates space in the local zone.
126 static uword Allocate(intptr_t size); 127 static uword Allocate(Isolate* isolate, intptr_t size);
127 128
128 // Reallocates space in the local zone. 129 // Reallocates space in the local zone.
129 static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size); 130 static uword Reallocate(Isolate* isolate,
131 uword ptr,
132 intptr_t old_size,
133 intptr_t new_size);
130 134
131 // Performs one-time initialization needed by the API. 135 // Performs one-time initialization needed by the API.
132 static void InitOnce(); 136 static void InitOnce();
133 137
134 private: 138 private:
135 // Thread local key used by the API. Currently holds the current 139 // Thread local key used by the API. Currently holds the current
136 // ApiNativeScope if any. 140 // ApiNativeScope if any.
137 static ThreadLocalKey api_native_key_; 141 static ThreadLocalKey api_native_key_;
138 142
139 friend class ApiNativeScope; 143 friend class ApiNativeScope;
140 }; 144 };
141 145
142 class IsolateSaver { 146 class IsolateSaver {
143 public: 147 public:
144 explicit IsolateSaver(Isolate* current_isolate) 148 explicit IsolateSaver(Isolate* current_isolate)
145 : saved_isolate_(current_isolate) { 149 : saved_isolate_(current_isolate) {
146 } 150 }
147 ~IsolateSaver() { 151 ~IsolateSaver() {
148 Isolate::SetCurrent(saved_isolate_); 152 Isolate::SetCurrent(saved_isolate_);
149 } 153 }
150 private: 154 private:
151 Isolate* saved_isolate_; 155 Isolate* saved_isolate_;
152 156
153 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); 157 DISALLOW_COPY_AND_ASSIGN(IsolateSaver);
154 }; 158 };
155 159
156 } // namespace dart. 160 } // namespace dart.
157 161
158 #endif // VM_DART_API_IMPL_H_ 162 #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