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

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

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. Created 3 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')
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 RUNTIME_VM_DART_API_IMPL_H_ 5 #ifndef RUNTIME_VM_DART_API_IMPL_H_
6 #define RUNTIME_VM_DART_API_IMPL_H_ 6 #define RUNTIME_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"
11 #include "vm/safepoint.h" 11 #include "vm/safepoint.h"
12 #include "vm/thread_registry.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 class ApiLocalScope; 16 class ApiLocalScope;
16 class ApiState; 17 class ApiState;
17 class FinalizablePersistentHandle; 18 class FinalizablePersistentHandle;
18 class LocalHandle; 19 class LocalHandle;
19 class PersistentHandle; 20 class PersistentHandle;
20 class ReusableObjectHandleScope; 21 class ReusableObjectHandleScope;
22 class ThreadRegistry;
21 23
22 const char* CanonicalFunction(const char* func); 24 const char* CanonicalFunction(const char* func);
23 25
24 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) 26 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__)
25 27
26 // Checks that the current isolate is not NULL. 28 // Checks that the current isolate is not NULL.
27 #define CHECK_ISOLATE(isolate) \ 29 #define CHECK_ISOLATE(isolate) \
28 do { \ 30 do { \
29 if ((isolate) == NULL) { \ 31 if ((isolate) == NULL) { \
30 FATAL1( \ 32 FATAL1( \
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. 161 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix.
160 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); 162 RawObject* raw = *(reinterpret_cast<RawObject**>(handle));
161 return !raw->IsHeapObject(); 163 return !raw->IsHeapObject();
162 } 164 }
163 165
164 // Returns true if the handle holds a Dart Instance. 166 // Returns true if the handle holds a Dart Instance.
165 static bool IsInstance(Dart_Handle handle) { 167 static bool IsInstance(Dart_Handle handle) {
166 return (ClassId(handle) >= kInstanceCid); 168 return (ClassId(handle) >= kInstanceCid);
167 } 169 }
168 170
171 // Returns true if the handle is non-dangling.
172 static bool IsValid(Dart_Handle handle);
173
169 // Returns true if the handle holds an Error. 174 // Returns true if the handle holds an Error.
170 static bool IsError(Dart_Handle handle) { 175 static bool IsError(Dart_Handle handle) {
171 return RawObject::IsErrorClassId(ClassId(handle)); 176 return RawObject::IsErrorClassId(ClassId(handle));
172 } 177 }
173 178
174 // Returns the value of a Smi. 179 // Returns the value of a Smi.
175 static intptr_t SmiValue(Dart_Handle handle) { 180 static intptr_t SmiValue(Dart_Handle handle) {
176 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. 181 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix.
177 uword value = *(reinterpret_cast<uword*>(handle)); 182 uword value = *(reinterpret_cast<uword*>(handle));
178 return Smi::ValueFromRaw(value); 183 return Smi::ValueFromRaw(value);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return Api::NewError("%s: Cannot load after Dart_Precompile", \ 296 return Api::NewError("%s: Cannot load after Dart_Precompile", \
292 CURRENT_FUNC); \ 297 CURRENT_FUNC); \
293 } 298 }
294 299
295 #define ASSERT_CALLBACK_STATE(thread) \ 300 #define ASSERT_CALLBACK_STATE(thread) \
296 ASSERT(thread->no_callback_scope_depth() == 0) 301 ASSERT(thread->no_callback_scope_depth() == 0)
297 302
298 } // namespace dart. 303 } // namespace dart.
299 304
300 #endif // RUNTIME_VM_DART_API_IMPL_H_ 305 #endif // RUNTIME_VM_DART_API_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698