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

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

Issue 1182103003: Assert typed data is external iff actually not in heap. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Assert in ExternalTypedData::SetData and External*String::SetExternalData Created 5 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
« no previous file with comments | « no previous file | runtime/vm/object.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 "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 3613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 const TypedData& data_obj = TypedData::Cast(obj); 3624 const TypedData& data_obj = TypedData::Cast(obj);
3625 data_tmp = data_obj.DataAddr(offset_in_bytes); 3625 data_tmp = data_obj.DataAddr(offset_in_bytes);
3626 } else { 3626 } else {
3627 ASSERT(ExternalTypedData::IsExternalTypedData(obj)); 3627 ASSERT(ExternalTypedData::IsExternalTypedData(obj));
3628 const ExternalTypedData& data_obj = ExternalTypedData::Cast(obj); 3628 const ExternalTypedData& data_obj = ExternalTypedData::Cast(obj);
3629 data_tmp = data_obj.DataAddr(offset_in_bytes); 3629 data_tmp = data_obj.DataAddr(offset_in_bytes);
3630 external = true; 3630 external = true;
3631 } 3631 }
3632 } 3632 }
3633 if (FLAG_verify_acquired_data) { 3633 if (FLAG_verify_acquired_data) {
3634 if (external) {
3635 ASSERT(!isolate->heap()->Contains(reinterpret_cast<uword>(data_tmp)));
3636 } else {
3637 ASSERT(isolate->heap()->Contains(reinterpret_cast<uword>(data_tmp)));
3638 }
3634 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); 3639 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object));
3635 WeakTable* table = isolate->api_state()->acquired_table(); 3640 WeakTable* table = isolate->api_state()->acquired_table();
3636 intptr_t current = table->GetValue(obj.raw()); 3641 intptr_t current = table->GetValue(obj.raw());
3637 if (current != 0) { 3642 if (current != 0) {
3638 return Api::NewError("Data was already acquired for this object."); 3643 return Api::NewError("Data was already acquired for this object.");
3639 } 3644 }
3640 // Do not make a copy if the data is external. Some callers expect external 3645 // Do not make a copy if the data is external. Some callers expect external
3641 // data to remain in place, even though the API spec doesn't guarantee it. 3646 // data to remain in place, even though the API spec doesn't guarantee it.
3642 // TODO(koda/asiva): Make final decision and document it. 3647 // TODO(koda/asiva): Make final decision and document it.
3643 AcquiredData* ad = new AcquiredData(data_tmp, size_in_bytes, !external); 3648 AcquiredData* ad = new AcquiredData(data_tmp, size_in_bytes, !external);
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
5662 5667
5663 5668
5664 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 5669 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
5665 const char* name, 5670 const char* name,
5666 Dart_ServiceRequestCallback callback, 5671 Dart_ServiceRequestCallback callback,
5667 void* user_data) { 5672 void* user_data) {
5668 Service::RegisterRootEmbedderCallback(name, callback, user_data); 5673 Service::RegisterRootEmbedderCallback(name, callback, user_data);
5669 } 5674 }
5670 5675
5671 } // namespace dart 5676 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698