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

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

Issue 2381573002: Fix off-by-one issue in clustered snapshot implementation and api impl (Closed)
Patch Set: same in dart_api_impl Created 4 years, 2 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/clustered_snapshot.cc ('k') | 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 #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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 609 }
610 return false; 610 return false;
611 } 611 }
612 612
613 613
614 bool Api::GetNativeReceiver(NativeArguments* arguments, intptr_t* value) { 614 bool Api::GetNativeReceiver(NativeArguments* arguments, intptr_t* value) {
615 NoSafepointScope no_safepoint_scope; 615 NoSafepointScope no_safepoint_scope;
616 RawObject* raw_obj = arguments->NativeArg0(); 616 RawObject* raw_obj = arguments->NativeArg0();
617 if (raw_obj->IsHeapObject()) { 617 if (raw_obj->IsHeapObject()) {
618 intptr_t cid = raw_obj->GetClassId(); 618 intptr_t cid = raw_obj->GetClassId();
619 if (cid > kNumPredefinedCids) { 619 if (cid >= kNumPredefinedCids) {
620 ASSERT(Instance::Cast(Object::Handle(raw_obj)).IsValidNativeIndex(0)); 620 ASSERT(Instance::Cast(Object::Handle(raw_obj)).IsValidNativeIndex(0));
621 RawTypedData* native_fields = *reinterpret_cast<RawTypedData**>( 621 RawTypedData* native_fields = *reinterpret_cast<RawTypedData**>(
622 RawObject::ToAddr(raw_obj) + sizeof(RawObject)); 622 RawObject::ToAddr(raw_obj) + sizeof(RawObject));
623 if (native_fields == TypedData::null()) { 623 if (native_fields == TypedData::null()) {
624 *value = 0; 624 *value = 0;
625 } else { 625 } else {
626 *value = *bit_cast<intptr_t*, uint8_t*>(native_fields->ptr()->data()); 626 *value = *bit_cast<intptr_t*, uint8_t*>(native_fields->ptr()->data());
627 } 627 }
628 return true; 628 return true;
629 } 629 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 694
695 695
696 bool Api::GetNativeFieldsOfArgument(NativeArguments* arguments, 696 bool Api::GetNativeFieldsOfArgument(NativeArguments* arguments,
697 int arg_index, 697 int arg_index,
698 int num_fields, 698 int num_fields,
699 intptr_t* field_values) { 699 intptr_t* field_values) {
700 NoSafepointScope no_safepoint_scope; 700 NoSafepointScope no_safepoint_scope;
701 RawObject* raw_obj = arguments->NativeArgAt(arg_index); 701 RawObject* raw_obj = arguments->NativeArgAt(arg_index);
702 if (raw_obj->IsHeapObject()) { 702 if (raw_obj->IsHeapObject()) {
703 intptr_t cid = raw_obj->GetClassId(); 703 intptr_t cid = raw_obj->GetClassId();
704 if (cid > kNumPredefinedCids) { 704 if (cid >= kNumPredefinedCids) {
705 RawTypedData* native_fields = *reinterpret_cast<RawTypedData**>( 705 RawTypedData* native_fields = *reinterpret_cast<RawTypedData**>(
706 RawObject::ToAddr(raw_obj) + sizeof(RawObject)); 706 RawObject::ToAddr(raw_obj) + sizeof(RawObject));
707 if (native_fields == TypedData::null()) { 707 if (native_fields == TypedData::null()) {
708 memset(field_values, 0, (num_fields * sizeof(field_values[0]))); 708 memset(field_values, 0, (num_fields * sizeof(field_values[0])));
709 } else if (num_fields == Smi::Value(native_fields->ptr()->length_)) { 709 } else if (num_fields == Smi::Value(native_fields->ptr()->length_)) {
710 intptr_t* native_values = 710 intptr_t* native_values =
711 bit_cast<intptr_t*, uint8_t*>(native_fields->ptr()->data()); 711 bit_cast<intptr_t*, uint8_t*>(native_fields->ptr()->data());
712 memmove(field_values, 712 memmove(field_values,
713 native_values, 713 native_values,
714 (num_fields * sizeof(field_values[0]))); 714 (num_fields * sizeof(field_values[0])));
(...skipping 5906 matching lines...) Expand 10 before | Expand all | Expand 10 after
6621 6621
6622 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6622 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6623 #if defined(DART_PRECOMPILED_RUNTIME) 6623 #if defined(DART_PRECOMPILED_RUNTIME)
6624 return true; 6624 return true;
6625 #else 6625 #else
6626 return false; 6626 return false;
6627 #endif 6627 #endif
6628 } 6628 }
6629 6629
6630 } // namespace dart 6630 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698