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

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

Issue 381483002: Allocate fewer empty arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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
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 <limits> 8 #include <limits>
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 6010 matching lines...) Expand 10 before | Expand all | Expand 10 after
6021 6021
6022 // Returns true if all elements are OK for canonicalization. 6022 // Returns true if all elements are OK for canonicalization.
6023 virtual bool CheckAndCanonicalizeFields(const char** error_str) const; 6023 virtual bool CheckAndCanonicalizeFields(const char** error_str) const;
6024 6024
6025 // Make the array immutable to Dart code by switching the class pointer 6025 // Make the array immutable to Dart code by switching the class pointer
6026 // to ImmutableArray. 6026 // to ImmutableArray.
6027 void MakeImmutable() const; 6027 void MakeImmutable() const;
6028 6028
6029 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew); 6029 static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew);
6030 6030
6031 // Empty array is read-only. Use only for arrays without type arguments.
6032 static RawArray* NewOrEmpty(intptr_t len, Heap::Space space = Heap::kNew) {
6033 return (len == 0) ? empty_array().raw() : New(len, space);
6034 }
siva 2014/07/09 20:08:03 may not need this if you do the explicit checks in
6035
6031 // Creates and returns a new array with 'new_length'. Copies all elements from 6036 // Creates and returns a new array with 'new_length'. Copies all elements from
6032 // 'source' to the new array. 'new_length' must be greater than or equal to 6037 // 'source' to the new array. 'new_length' must be greater than or equal to
6033 // 'source.Length()'. 'source' can be null. 6038 // 'source.Length()'. 'source' can be null.
6034 static RawArray* Grow(const Array& source, 6039 static RawArray* Grow(const Array& source,
6035 intptr_t new_length, 6040 intptr_t new_length,
6036 Heap::Space space = Heap::kNew); 6041 Heap::Space space = Heap::kNew);
6037 6042
6038 // Return an Array object that contains all the elements currently present 6043 // Return an Array object that contains all the elements currently present
6039 // in the specified Growable Object Array. This is done by first truncating 6044 // in the specified Growable Object Array. This is done by first truncating
6040 // the Growable Object Array's backing array to the currently used size and 6045 // the Growable Object Array's backing array to the currently used size and
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
7148 7153
7149 7154
7150 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7155 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7151 intptr_t index) { 7156 intptr_t index) {
7152 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7157 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7153 } 7158 }
7154 7159
7155 } // namespace dart 7160 } // namespace dart
7156 7161
7157 #endif // VM_OBJECT_H_ 7162 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698