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

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

Issue 9560001: Guard calls to ByteAddr when a ByteArray copy length is 0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | runtime/vm/object_test.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 7810 matching lines...) Expand 10 before | Expand all | Expand 10 after
7821 } 7821 }
7822 7822
7823 7823
7824 void ByteArray::Copy(uint8_t* dst, 7824 void ByteArray::Copy(uint8_t* dst,
7825 const ByteArray& src, 7825 const ByteArray& src,
7826 intptr_t src_offset, 7826 intptr_t src_offset,
7827 intptr_t length) { 7827 intptr_t length) {
7828 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); 7828 ASSERT(Utils::RangeCheck(src_offset, length, src.Length()));
7829 { 7829 {
7830 NoGCScope no_gc; 7830 NoGCScope no_gc;
7831 memmove(dst, src.ByteAddr(src_offset), length); 7831 if (length > 0) {
7832 memmove(dst, src.ByteAddr(src_offset), length);
7833 }
7832 } 7834 }
7833 } 7835 }
7834 7836
7835 7837
7836 void ByteArray::Copy(const ByteArray& dst, 7838 void ByteArray::Copy(const ByteArray& dst,
7837 intptr_t dst_offset, 7839 intptr_t dst_offset,
7838 const uint8_t* src, 7840 const uint8_t* src,
7839 intptr_t length) { 7841 intptr_t length) {
7840 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); 7842 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length()));
7841 { 7843 {
7842 NoGCScope no_gc; 7844 NoGCScope no_gc;
7843 memmove(dst.ByteAddr(dst_offset), src, length); 7845 if (length > 0) {
7846 memmove(dst.ByteAddr(dst_offset), src, length);
7847 }
7844 } 7848 }
7845 } 7849 }
7846 7850
7847 7851
7848 void ByteArray::Copy(const ByteArray& dst, 7852 void ByteArray::Copy(const ByteArray& dst,
7849 intptr_t dst_offset, 7853 intptr_t dst_offset,
7850 const ByteArray& src, 7854 const ByteArray& src,
7851 intptr_t src_offset, 7855 intptr_t src_offset,
7852 intptr_t length) { 7856 intptr_t length) {
7853 ASSERT(Utils::RangeCheck(src_offset, length, src.Length())); 7857 ASSERT(Utils::RangeCheck(src_offset, length, src.Length()));
7854 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length())); 7858 ASSERT(Utils::RangeCheck(dst_offset, length, dst.Length()));
7855 { 7859 {
7856 NoGCScope no_gc; 7860 NoGCScope no_gc;
7857 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length); 7861 if (length > 0) {
7862 memmove(dst.ByteAddr(dst_offset), src.ByteAddr(src_offset), length);
7863 }
7858 } 7864 }
7859 } 7865 }
7860 7866
7861 7867
7862 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const { 7868 uint8_t* ByteArray::ByteAddr(intptr_t byte_offset) const {
7863 // ByteArray is an abstract class. 7869 // ByteArray is an abstract class.
7864 UNREACHABLE(); 7870 UNREACHABLE();
7865 return NULL; 7871 return NULL;
7866 } 7872 }
7867 7873
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
8366 result.set_num_args_tested(num_args_tested); 8372 result.set_num_args_tested(num_args_tested);
8367 // Number of array elements in one test entry (num_args_tested + 1) 8373 // Number of array elements in one test entry (num_args_tested + 1)
8368 intptr_t len = num_args_tested + 1; 8374 intptr_t len = num_args_tested + 1;
8369 // IC data array must be null terminated (sentinel entry). 8375 // IC data array must be null terminated (sentinel entry).
8370 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 8376 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
8371 result.set_ic_data(ic_data); 8377 result.set_ic_data(ic_data);
8372 return result.raw(); 8378 return result.raw();
8373 } 8379 }
8374 8380
8375 } // namespace dart 8381 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698