VM: New, faster default Map construction.
Replace the C++ implementation of the default Map constructor with a Dart version that uses the existing native setters to initialize members. This avoid the expensive runtime transition when doing "new Map()". BUG=#26046 R=asiva@google.com Review URL: https://codereview.chromium.org/2278273003 .
This commit is contained in:
@@ -123,7 +123,13 @@ class _InternalLinkedHashMap<K, V> extends _HashVMBase
|
||||
with MapMixin<K, V>, _LinkedHashMapMixin<K, V>, _HashBase,
|
||||
_OperatorEqualsAndHashCode
|
||||
implements LinkedHashMap<K, V> {
|
||||
factory _InternalLinkedHashMap() native "LinkedHashMap_allocate";
|
||||
_InternalLinkedHashMap() {
|
||||
_index = new Uint32List(_HashBase._INITIAL_INDEX_SIZE);
|
||||
_hashMask = _HashBase._indexSizeToHashMask(_HashBase._INITIAL_INDEX_SIZE);
|
||||
_data = new List(_HashBase._INITIAL_INDEX_SIZE);
|
||||
_usedData = 0;
|
||||
_deletedKeys = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class _LinkedHashMapMixin<K, V> {
|
||||
|
||||
@@ -13,16 +13,6 @@
|
||||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_NATIVE_ENTRY(LinkedHashMap_allocate, 1) {
|
||||
const TypeArguments& type_arguments =
|
||||
TypeArguments::CheckedHandle(arguments->NativeArgAt(0));
|
||||
const LinkedHashMap& map =
|
||||
LinkedHashMap::Handle(LinkedHashMap::NewDefault());
|
||||
map.SetTypeArguments(type_arguments);
|
||||
return map.raw();
|
||||
}
|
||||
|
||||
|
||||
DEFINE_NATIVE_ENTRY(LinkedHashMap_getIndex, 1) {
|
||||
const LinkedHashMap& map =
|
||||
LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
|
||||
|
||||
@@ -316,7 +316,6 @@ namespace dart {
|
||||
V(Internal_makeListFixedLength, 1) \
|
||||
V(Internal_makeFixedListUnmodifiable, 1) \
|
||||
V(Internal_inquireIs64Bit, 0) \
|
||||
V(LinkedHashMap_allocate, 1) \
|
||||
V(LinkedHashMap_getIndex, 1) \
|
||||
V(LinkedHashMap_setIndex, 2) \
|
||||
V(LinkedHashMap_getData, 1) \
|
||||
|
||||
Reference in New Issue
Block a user