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

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

Issue 16816007: When unwraping handles, verify only if --verify_handles. Fixes issue 11265, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | no next file » | 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 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 16 matching lines...) Expand all
27 #include "vm/stack_frame.h" 27 #include "vm/stack_frame.h"
28 #include "vm/symbols.h" 28 #include "vm/symbols.h"
29 #include "vm/timer.h" 29 #include "vm/timer.h"
30 #include "vm/unicode.h" 30 #include "vm/unicode.h"
31 #include "vm/verifier.h" 31 #include "vm/verifier.h"
32 #include "vm/version.h" 32 #include "vm/version.h"
33 33
34 namespace dart { 34 namespace dart {
35 35
36 DECLARE_FLAG(bool, print_class_table); 36 DECLARE_FLAG(bool, print_class_table);
37 DECLARE_FLAG(bool, verify_handles);
37 38
38 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey; 39 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey;
39 Dart_Handle Api::true_handle_ = NULL; 40 Dart_Handle Api::true_handle_ = NULL;
40 Dart_Handle Api::false_handle_ = NULL; 41 Dart_Handle Api::false_handle_ = NULL;
41 Dart_Handle Api::null_handle_ = NULL; 42 Dart_Handle Api::null_handle_ = NULL;
42 43
43 44
44 const char* CanonicalFunction(const char* func) { 45 const char* CanonicalFunction(const char* func) {
45 if (strncmp(func, "dart::", 6) == 0) { 46 if (strncmp(func, "dart::", 6) == 0) {
46 return func + 6; 47 return func + 6;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ref->set_raw(raw); 91 ref->set_raw(raw);
91 return reinterpret_cast<Dart_Handle>(ref); 92 return reinterpret_cast<Dart_Handle>(ref);
92 } 93 }
93 94
94 RawObject* Api::UnwrapHandle(Dart_Handle object) { 95 RawObject* Api::UnwrapHandle(Dart_Handle object) {
95 #if defined(DEBUG) 96 #if defined(DEBUG)
96 Isolate* isolate = Isolate::Current(); 97 Isolate* isolate = Isolate::Current();
97 ASSERT(isolate != NULL); 98 ASSERT(isolate != NULL);
98 ApiState* state = isolate->api_state(); 99 ApiState* state = isolate->api_state();
99 ASSERT(state != NULL); 100 ASSERT(state != NULL);
100 ASSERT(state->IsValidLocalHandle(object) || 101 ASSERT(!FLAG_verify_handles ||
102 state->IsValidLocalHandle(object) ||
101 Dart::vm_isolate()->api_state()->IsValidLocalHandle(object)); 103 Dart::vm_isolate()->api_state()->IsValidLocalHandle(object));
102 ASSERT(FinalizablePersistentHandle::raw_offset() == 0 && 104 ASSERT(FinalizablePersistentHandle::raw_offset() == 0 &&
103 PersistentHandle::raw_offset() == 0 && 105 PersistentHandle::raw_offset() == 0 &&
104 LocalHandle::raw_offset() == 0); 106 LocalHandle::raw_offset() == 0);
105 #endif 107 #endif
106 return (reinterpret_cast<LocalHandle*>(object))->raw(); 108 return (reinterpret_cast<LocalHandle*>(object))->raw();
107 } 109 }
108 110
109 #define DEFINE_UNWRAP(type) \ 111 #define DEFINE_UNWRAP(type) \
110 const type& Api::Unwrap##type##Handle(Isolate* iso, \ 112 const type& Api::Unwrap##type##Handle(Isolate* iso, \
(...skipping 4748 matching lines...) Expand 10 before | Expand all | Expand 10 after
4859 } 4861 }
4860 { 4862 {
4861 NoGCScope no_gc; 4863 NoGCScope no_gc;
4862 RawObject* raw_obj = obj.raw(); 4864 RawObject* raw_obj = obj.raw();
4863 isolate->heap()->SetPeer(raw_obj, peer); 4865 isolate->heap()->SetPeer(raw_obj, peer);
4864 } 4866 }
4865 return Api::Success(); 4867 return Api::Success();
4866 } 4868 }
4867 4869
4868 } // namespace dart 4870 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698