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

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

Issue 189443004: Fix performance of setRange by avoiding going to Lists.copy (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | « runtime/vm/intrinsifier.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) 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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 6058 matching lines...) Expand 10 before | Expand all | Expand 10 after
6069 } 6069 }
6070 6070
6071 static RawTypedData* New(intptr_t class_id, 6071 static RawTypedData* New(intptr_t class_id,
6072 intptr_t len, 6072 intptr_t len,
6073 Heap::Space space = Heap::kNew); 6073 Heap::Space space = Heap::kNew);
6074 6074
6075 template <typename DstType, typename SrcType> 6075 template <typename DstType, typename SrcType>
6076 static void Copy(const DstType& dst, intptr_t dst_offset_in_bytes, 6076 static void Copy(const DstType& dst, intptr_t dst_offset_in_bytes,
6077 const SrcType& src, intptr_t src_offset_in_bytes, 6077 const SrcType& src, intptr_t src_offset_in_bytes,
6078 intptr_t length_in_bytes) { 6078 intptr_t length_in_bytes) {
6079 ASSERT(dst.ElementType() == src.ElementType());
6080 ASSERT(Utils::RangeCheck(src_offset_in_bytes, 6079 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
6081 length_in_bytes, 6080 length_in_bytes,
6082 src.LengthInBytes())); 6081 src.LengthInBytes()));
6083 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, 6082 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
6084 length_in_bytes, 6083 length_in_bytes,
6085 dst.LengthInBytes())); 6084 dst.LengthInBytes()));
6086 { 6085 {
6087 NoGCScope no_gc; 6086 NoGCScope no_gc;
6088 if (length_in_bytes > 0) { 6087 if (length_in_bytes > 0) {
6089 memmove(dst.DataAddr(dst_offset_in_bytes), 6088 memmove(dst.DataAddr(dst_offset_in_bytes),
6090 src.DataAddr(src_offset_in_bytes), 6089 src.DataAddr(src_offset_in_bytes),
6091 length_in_bytes); 6090 length_in_bytes);
6092 } 6091 }
6093 } 6092 }
6094 } 6093 }
6095 6094
6095
6096 template <typename DstType, typename SrcType>
6097 static void ClampedCopy(const DstType& dst, intptr_t dst_offset_in_bytes,
6098 const SrcType& src, intptr_t src_offset_in_bytes,
6099 intptr_t length_in_bytes) {
6100 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
6101 length_in_bytes,
6102 src.LengthInBytes()));
6103 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
6104 length_in_bytes,
6105 dst.LengthInBytes()));
6106 {
6107 NoGCScope no_gc;
6108 if (length_in_bytes > 0) {
6109 uint8_t* dst_data =
6110 reinterpret_cast<uint8_t*>(dst.DataAddr(dst_offset_in_bytes));
6111 int8_t* src_data =
6112 reinterpret_cast<int8_t*>(src.DataAddr(src_offset_in_bytes));
6113 for (intptr_t ix = 0; ix < length_in_bytes; ix++) {
6114 int8_t v = *src_data;
6115 if (v < 0) v = 0;
6116 *dst_data = v;
6117 src_data++;
6118 dst_data++;
6119 }
6120 }
6121 }
6122 }
6123
6096 static bool IsTypedData(const Instance& obj) { 6124 static bool IsTypedData(const Instance& obj) {
6097 ASSERT(!obj.IsNull()); 6125 ASSERT(!obj.IsNull());
6098 intptr_t cid = obj.raw()->GetClassId(); 6126 intptr_t cid = obj.raw()->GetClassId();
6099 return RawObject::IsTypedDataClassId(cid); 6127 return RawObject::IsTypedDataClassId(cid);
6100 } 6128 }
6101 6129
6102 protected: 6130 protected:
6103 void SetLength(intptr_t value) const { 6131 void SetLength(intptr_t value) const {
6104 raw_ptr()->length_ = Smi::New(value); 6132 raw_ptr()->length_ = Smi::New(value);
6105 } 6133 }
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
6692 6720
6693 6721
6694 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6722 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6695 intptr_t index) { 6723 intptr_t index) {
6696 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6724 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6697 } 6725 }
6698 6726
6699 } // namespace dart 6727 } // namespace dart
6700 6728
6701 #endif // VM_OBJECT_H_ 6729 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698