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

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

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Removed Dart API entry for IsValid. 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 | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_state.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 Dart_Handle Api::AcquiredError(Isolate* isolate) { 528 Dart_Handle Api::AcquiredError(Isolate* isolate) {
529 ASSERT(isolate != NULL); 529 ASSERT(isolate != NULL);
530 ApiState* state = isolate->api_state(); 530 ApiState* state = isolate->api_state();
531 ASSERT(state != NULL); 531 ASSERT(state != NULL);
532 PersistentHandle* acquired_error_handle = state->AcquiredError(); 532 PersistentHandle* acquired_error_handle = state->AcquiredError();
533 return reinterpret_cast<Dart_Handle>(acquired_error_handle); 533 return reinterpret_cast<Dart_Handle>(acquired_error_handle);
534 } 534 }
535 535
536 536
537 bool Api::IsValid(Dart_Handle handle) {
538 Isolate* isolate = Isolate::Current();
539 CHECK_ISOLATE(isolate);
540
541 // Check against all of the handles in the current isolate as well as the
542 // read-only handles.
543 return isolate->thread_registry()->IsValidHandle(handle) ||
544 isolate->api_state()->IsActivePersistentHandle(
bkonyi 2017/01/20 23:07:11 I added IsActive(Weak)PersistentHandle to check if
545 reinterpret_cast<Dart_PersistentHandle>(handle)) ||
546 isolate->api_state()->IsActiveWeakPersistentHandle(
547 reinterpret_cast<Dart_WeakPersistentHandle>(handle)) ||
548 Dart::IsReadOnlyApiHandle(handle) ||
549 Dart::IsReadOnlyHandle(reinterpret_cast<uword>(handle));
550 }
551
552
537 ApiLocalScope* Api::TopScope(Thread* thread) { 553 ApiLocalScope* Api::TopScope(Thread* thread) {
538 ASSERT(thread != NULL); 554 ASSERT(thread != NULL);
539 ApiLocalScope* scope = thread->api_top_scope(); 555 ApiLocalScope* scope = thread->api_top_scope();
540 ASSERT(scope != NULL); 556 ASSERT(scope != NULL);
541 return scope; 557 return scope;
542 } 558 }
543 559
544 560
545 void Api::InitOnce() { 561 void Api::InitOnce() {
546 ASSERT(api_native_key_ == kUnsetThreadLocalKey); 562 ASSERT(api_native_key_ == kUnsetThreadLocalKey);
(...skipping 6250 matching lines...) Expand 10 before | Expand all | Expand 10 after
6797 } 6813 }
6798 6814
6799 6815
6800 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { 6816 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) {
6801 #ifndef PRODUCT 6817 #ifndef PRODUCT
6802 Profiler::DumpStackTrace(context); 6818 Profiler::DumpStackTrace(context);
6803 #endif 6819 #endif
6804 } 6820 }
6805 6821
6806 } // namespace dart 6822 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698