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

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

Issue 536043002: Merge array allocation and List._copyFromObjectArray to provide fast path for large arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/object.h ('k') | tests/language/list_test.dart » ('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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 18079 matching lines...) Expand 10 before | Expand all | Expand 10 after
18090 Object::Allocate(class_id, 18090 Object::Allocate(class_id,
18091 Array::InstanceSize(len), 18091 Array::InstanceSize(len),
18092 space)); 18092 space));
18093 NoGCScope no_gc; 18093 NoGCScope no_gc;
18094 raw->ptr()->length_ = Smi::New(len); 18094 raw->ptr()->length_ = Smi::New(len);
18095 return raw; 18095 return raw;
18096 } 18096 }
18097 } 18097 }
18098 18098
18099 18099
18100 RawArray* Array::Slice(intptr_t start,
18101 intptr_t count,
18102 bool with_type_argument) const {
18103 // TODO(vegorov) introduce an array allocation method that fills newly
18104 // allocated array with values from the given source array instead of
18105 // null-initializing all elements.
18106 Array& dest = Array::Handle(Array::New(count));
18107 if (dest.raw()->IsNewObject()) {
18108 NoGCScope no_gc_scope;
18109 memmove(dest.ObjectAddr(0), ObjectAddr(start), count * kWordSize);
18110 } else {
18111 PassiveObject& obj = PassiveObject::Handle();
18112 for (intptr_t i = 0; i < count; i++) {
18113 obj = At(start + i);
18114 dest.SetAt(i, obj);
18115 }
18116 }
18117
18118 if (with_type_argument) {
18119 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments()));
18120 }
18121
18122 return dest.raw();
18123 }
18124
18125
18100 void Array::MakeImmutable() const { 18126 void Array::MakeImmutable() const {
18101 NoGCScope no_gc; 18127 NoGCScope no_gc;
18102 uword tags = raw_ptr()->tags_; 18128 uword tags = raw_ptr()->tags_;
18103 uword old_tags; 18129 uword old_tags;
18104 do { 18130 do {
18105 old_tags = tags; 18131 old_tags = tags;
18106 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, 18132 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid,
18107 old_tags); 18133 old_tags);
18108 tags = AtomicOperations::CompareAndSwapWord( 18134 tags = AtomicOperations::CompareAndSwapWord(
18109 &raw_ptr()->tags_, old_tags, new_tags); 18135 &raw_ptr()->tags_, old_tags, new_tags);
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
19620 return tag_label.ToCString(); 19646 return tag_label.ToCString();
19621 } 19647 }
19622 19648
19623 19649
19624 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19650 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19625 Instance::PrintJSONImpl(stream, ref); 19651 Instance::PrintJSONImpl(stream, ref);
19626 } 19652 }
19627 19653
19628 19654
19629 } // namespace dart 19655 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | tests/language/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698