Commit 416fae86 authored by Frank Emrich's avatar Frank Emrich Committed by Commit Bot

[dict-proto] SwissNameDictionary rollout in runtime code, pt. 3

This CL is part of a series that makes SwissNameDictionary available
as a new property backing store. Previously, the flag
v8_dict_mode_prototypes allows selecting between NameDictionary and
OrderedNameDictionary as the backing store used for all dictionary
mode objects. This series of CLs changes this such that enabling the
flag causes SwissNameDictionary being used instead of
OrderedNameDictionary. The behavior for when the flag is not set
remains unchanged (= use NameDictionary).

This particular CL just collects many small changes, including some
CSA changes where runtime calls are necessary.

Bug: v8:11388
Change-Id: I38fd18098fc641a5d92a986da251a6b3ac09411a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739642
Commit-Queue: Frank Emrich <emrich@google.com>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73257}
parent d0abf522
...@@ -454,8 +454,8 @@ extern enum PrimitiveType { kString, kBoolean, kSymbol, kNumber } ...@@ -454,8 +454,8 @@ extern enum PrimitiveType { kString, kBoolean, kSymbol, kNumber }
const kNameDictionaryInitialCapacity: const kNameDictionaryInitialCapacity:
constexpr int32 generates 'NameDictionary::kInitialCapacity'; constexpr int32 generates 'NameDictionary::kInitialCapacity';
const kOrderedNameDictionaryInitialCapacity: const kSwissNameDictionaryInitialCapacity:
constexpr int32 generates 'OrderedNameDictionary::kInitialCapacity'; constexpr int32 generates 'SwissNameDictionary::kInitialCapacity';
const kSwissNameDictionaryGroupWidth: const kSwissNameDictionaryGroupWidth:
constexpr int32 generates 'SwissNameDictionary::kGroupWidth'; constexpr int32 generates 'SwissNameDictionary::kGroupWidth';
...@@ -686,6 +686,8 @@ extern macro CodeStubAssembler::AllocateNameDictionary(constexpr int32): ...@@ -686,6 +686,8 @@ extern macro CodeStubAssembler::AllocateNameDictionary(constexpr int32):
NameDictionary; NameDictionary;
extern macro CodeStubAssembler::AllocateOrderedNameDictionary(constexpr int32): extern macro CodeStubAssembler::AllocateOrderedNameDictionary(constexpr int32):
OrderedNameDictionary; OrderedNameDictionary;
extern macro CodeStubAssembler::AllocateSwissNameDictionary(constexpr int32):
SwissNameDictionary;
extern builtin ToObject(Context, JSAny): JSReceiver; extern builtin ToObject(Context, JSAny): JSReceiver;
extern macro ToObject_Inline(Context, JSAny): JSReceiver; extern macro ToObject_Inline(Context, JSAny): JSReceiver;
......
...@@ -328,8 +328,8 @@ TNode<JSObject> ConstructorBuiltinsAssembler::FastNewObject( ...@@ -328,8 +328,8 @@ TNode<JSObject> ConstructorBuiltinsAssembler::FastNewObject(
BIND(&allocate_properties); BIND(&allocate_properties);
{ {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
properties = AllocateOrderedNameDictionary( properties =
OrderedNameDictionary::kInitialCapacity); AllocateSwissNameDictionary(SwissNameDictionary::kInitialCapacity);
} else { } else {
properties = AllocateNameDictionary(NameDictionary::kInitialCapacity); properties = AllocateNameDictionary(NameDictionary::kInitialCapacity);
} }
...@@ -548,7 +548,7 @@ TNode<HeapObject> ConstructorBuiltinsAssembler::CreateShallowObjectLiteral( ...@@ -548,7 +548,7 @@ TNode<HeapObject> ConstructorBuiltinsAssembler::CreateShallowObjectLiteral(
BIND(&if_dictionary); BIND(&if_dictionary);
{ {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), call_runtime); GotoIf(Int32TrueConstant(), call_runtime);
} }
......
...@@ -492,7 +492,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { ...@@ -492,7 +492,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
if_notfound(this), slow(this), if_proxy(this); if_notfound(this), slow(this), if_proxy(this);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &slow); GotoIf(Int32TrueConstant(), &slow);
} }
...@@ -961,7 +961,7 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) { ...@@ -961,7 +961,7 @@ TF_BUILTIN(GetProperty, CodeStubAssembler) {
if_slow(this, Label::kDeferred); if_slow(this, Label::kDeferred);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &if_slow); GotoIf(Int32TrueConstant(), &if_slow);
} }
...@@ -1021,7 +1021,7 @@ TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) { ...@@ -1021,7 +1021,7 @@ TF_BUILTIN(GetPropertyWithReceiver, CodeStubAssembler) {
if_slow(this, Label::kDeferred); if_slow(this, Label::kDeferred);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &if_slow); GotoIf(Int32TrueConstant(), &if_slow);
} }
......
...@@ -1034,7 +1034,7 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { ...@@ -1034,7 +1034,7 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
no_properties(this); no_properties(this);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &call_runtime); GotoIf(Int32TrueConstant(), &call_runtime);
} }
...@@ -1078,8 +1078,8 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) { ...@@ -1078,8 +1078,8 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
{ {
map = LoadSlowObjectWithNullPrototypeMap(native_context); map = LoadSlowObjectWithNullPrototypeMap(native_context);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
properties = AllocateOrderedNameDictionary( properties =
OrderedNameDictionary::kInitialCapacity); AllocateSwissNameDictionary(SwissNameDictionary::kInitialCapacity);
} else { } else {
properties = AllocateNameDictionary(NameDictionary::kInitialCapacity); properties = AllocateNameDictionary(NameDictionary::kInitialCapacity);
} }
...@@ -1284,9 +1284,8 @@ TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) { ...@@ -1284,9 +1284,8 @@ TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) {
Label if_keyisindex(this), if_iskeyunique(this), Label if_keyisindex(this), if_iskeyunique(this),
call_runtime(this, Label::kDeferred), call_runtime(this, Label::kDeferred),
return_undefined(this, Label::kDeferred), if_notunique_name(this); return_undefined(this, Label::kDeferred), if_notunique_name(this);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &call_runtime); GotoIf(Int32TrueConstant(), &call_runtime);
} }
...@@ -1373,7 +1372,7 @@ void ObjectBuiltinsAssembler::AddToDictionaryIf( ...@@ -1373,7 +1372,7 @@ void ObjectBuiltinsAssembler::AddToDictionaryIf(
GotoIfNot(condition, &done); GotoIfNot(condition, &done);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
CallRuntime(Runtime::kAddDictionaryProperty, context, object, CallRuntime(Runtime::kAddDictionaryProperty, context, object,
HeapConstant(name), value); HeapConstant(name), value);
} else { } else {
...@@ -1437,7 +1436,7 @@ TNode<JSObject> ObjectBuiltinsAssembler::FromPropertyDescriptor( ...@@ -1437,7 +1436,7 @@ TNode<JSObject> ObjectBuiltinsAssembler::FromPropertyDescriptor(
// enumerable and configurable - a total of 6 // enumerable and configurable - a total of 6
TNode<HeapObject> properties = TNode<HeapObject> properties =
V8_DICT_MODE_PROTOTYPES_BOOL V8_DICT_MODE_PROTOTYPES_BOOL
? TNode<HeapObject>(AllocateOrderedNameDictionary(6)) ? TNode<HeapObject>(AllocateSwissNameDictionary(6))
: AllocateNameDictionary(6); : AllocateNameDictionary(6);
TNode<JSObject> js_desc = AllocateJSObjectFromMap(map, properties); TNode<JSObject> js_desc = AllocateJSObjectFromMap(map, properties);
...@@ -1481,7 +1480,7 @@ TNode<JSObject> ObjectBuiltinsAssembler::FromPropertyDescriptor( ...@@ -1481,7 +1480,7 @@ TNode<JSObject> ObjectBuiltinsAssembler::FromPropertyDescriptor(
Goto(&return_desc); Goto(&return_desc);
if (!V8_DICT_MODE_PROTOTYPES_BOOL) { if (!V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) make unconditional once OrderedNameDictionary supported. // TODO(v8:11167) make unconditional once SwissNameDictionary supported.
BIND(&bailout); BIND(&bailout);
CSA_ASSERT(this, Int32Constant(0)); CSA_ASSERT(this, Int32Constant(0));
Unreachable(); Unreachable();
......
...@@ -53,7 +53,7 @@ TNode<JSProxy> ProxiesCodeStubAssembler::AllocateProxy( ...@@ -53,7 +53,7 @@ TNode<JSProxy> ProxiesCodeStubAssembler::AllocateProxy(
TNode<HeapObject> proxy = Allocate(JSProxy::kSize); TNode<HeapObject> proxy = Allocate(JSProxy::kSize);
StoreMapNoWriteBarrier(proxy, map.value()); StoreMapNoWriteBarrier(proxy, map.value());
RootIndex empty_dict = V8_DICT_MODE_PROTOTYPES_BOOL RootIndex empty_dict = V8_DICT_MODE_PROTOTYPES_BOOL
? RootIndex::kEmptyOrderedPropertyDictionary ? RootIndex::kEmptySwissPropertyDictionary
: RootIndex::kEmptyPropertyDictionary; : RootIndex::kEmptyPropertyDictionary;
StoreObjectFieldRoot(proxy, JSProxy::kPropertiesOrHashOffset, empty_dict); StoreObjectFieldRoot(proxy, JSProxy::kPropertiesOrHashOffset, empty_dict);
StoreObjectFieldNoWriteBarrier(proxy, JSProxy::kTargetOffset, target); StoreObjectFieldNoWriteBarrier(proxy, JSProxy::kTargetOffset, target);
......
...@@ -324,8 +324,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo( ...@@ -324,8 +324,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
TNode<Map> map = LoadSlowObjectWithNullPrototypeMap(native_context); TNode<Map> map = LoadSlowObjectWithNullPrototypeMap(native_context);
TNode<HeapObject> properties; TNode<HeapObject> properties;
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// AllocateOrderedNameDictionary always uses kAllowLargeObjectAllocation. properties = AllocateSwissNameDictionary(num_properties);
properties = AllocateOrderedNameDictionary(num_properties);
} else { } else {
properties = properties =
AllocateNameDictionary(num_properties, kAllowLargeObjectAllocation); AllocateNameDictionary(num_properties, kAllowLargeObjectAllocation);
...@@ -365,7 +364,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo( ...@@ -365,7 +364,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
// - Receiver has no interceptors // - Receiver has no interceptors
Label add_dictionary_property_slow(this, Label::kDeferred); Label add_dictionary_property_slow(this, Label::kDeferred);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
CallRuntime(Runtime::kAddDictionaryProperty, context, group_object, CallRuntime(Runtime::kAddDictionaryProperty, context, group_object,
name, capture); name, capture);
} else { } else {
...@@ -378,7 +377,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo( ...@@ -378,7 +377,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
&maybe_build_indices, &loop); &maybe_build_indices, &loop);
if (!V8_DICT_MODE_PROTOTYPES_BOOL) { if (!V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) make unconditional once OrderedNameDictionary // TODO(v8:11167) make unconditional once SwissNameDictionary
// supported. // supported.
BIND(&add_dictionary_property_slow); BIND(&add_dictionary_property_slow);
// If the dictionary needs resizing, the above Add call will jump here // If the dictionary needs resizing, the above Add call will jump here
......
...@@ -94,14 +94,14 @@ transitioning builtin CreateObjectWithoutProperties(implicit context: Context)( ...@@ -94,14 +94,14 @@ transitioning builtin CreateObjectWithoutProperties(implicit context: Context)(
prototype: JSAny): JSAny { prototype: JSAny): JSAny {
try { try {
let map: Map; let map: Map;
let properties: NameDictionary|OrderedNameDictionary|EmptyFixedArray; let properties: NameDictionary|SwissNameDictionary|EmptyFixedArray;
typeswitch (prototype) { typeswitch (prototype) {
case (Null): { case (Null): {
map = *NativeContextSlot( map = *NativeContextSlot(
ContextSlot::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP); ContextSlot::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP);
if (kDictModePrototypes) { if (kDictModePrototypes) {
properties = AllocateOrderedNameDictionary( properties =
kOrderedNameDictionaryInitialCapacity); AllocateSwissNameDictionary(kSwissNameDictionaryInitialCapacity);
} else { } else {
properties = AllocateNameDictionary(kNameDictionaryInitialCapacity); properties = AllocateNameDictionary(kNameDictionaryInitialCapacity);
} }
......
...@@ -1592,7 +1592,7 @@ TNode<HeapObject> CodeStubAssembler::LoadSlowProperties( ...@@ -1592,7 +1592,7 @@ TNode<HeapObject> CodeStubAssembler::LoadSlowProperties(
TNode<Object> properties = LoadJSReceiverPropertiesOrHash(object); TNode<Object> properties = LoadJSReceiverPropertiesOrHash(object);
NodeGenerator<HeapObject> make_empty = [=]() -> TNode<HeapObject> { NodeGenerator<HeapObject> make_empty = [=]() -> TNode<HeapObject> {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
return EmptyOrderedPropertyDictionaryConstant(); return EmptySwissPropertyDictionaryConstant();
} else { } else {
return EmptyPropertyDictionaryConstant(); return EmptyPropertyDictionaryConstant();
} }
...@@ -1600,7 +1600,7 @@ TNode<HeapObject> CodeStubAssembler::LoadSlowProperties( ...@@ -1600,7 +1600,7 @@ TNode<HeapObject> CodeStubAssembler::LoadSlowProperties(
NodeGenerator<HeapObject> cast_properties = [=] { NodeGenerator<HeapObject> cast_properties = [=] {
TNode<HeapObject> dict = CAST(properties); TNode<HeapObject> dict = CAST(properties);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
CSA_ASSERT(this, Word32Or(IsOrderedNameDictionary(dict), CSA_ASSERT(this, Word32Or(IsSwissNameDictionary(dict),
IsGlobalDictionary(dict))); IsGlobalDictionary(dict)));
} else { } else {
CSA_ASSERT(this, CSA_ASSERT(this,
...@@ -1779,7 +1779,7 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash( ...@@ -1779,7 +1779,7 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
TNode<JSReceiver> receiver, Label* if_no_hash) { TNode<JSReceiver> receiver, Label* if_no_hash) {
TVARIABLE(IntPtrT, var_hash); TVARIABLE(IntPtrT, var_hash);
Label done(this), if_smi(this), if_property_array(this), Label done(this), if_smi(this), if_property_array(this),
if_ordered_property_dictionary(this), if_property_dictionary(this), if_swiss_property_dictionary(this), if_property_dictionary(this),
if_fixed_array(this); if_fixed_array(this);
TNode<Object> properties_or_hash = TNode<Object> properties_or_hash =
...@@ -1792,9 +1792,9 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash( ...@@ -1792,9 +1792,9 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
GotoIf(InstanceTypeEqual(properties_instance_type, PROPERTY_ARRAY_TYPE), GotoIf(InstanceTypeEqual(properties_instance_type, PROPERTY_ARRAY_TYPE),
&if_property_array); &if_property_array);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
GotoIf(InstanceTypeEqual(properties_instance_type, GotoIf(
ORDERED_NAME_DICTIONARY_TYPE), InstanceTypeEqual(properties_instance_type, SWISS_NAME_DICTIONARY_TYPE),
&if_ordered_property_dictionary); &if_swiss_property_dictionary);
} }
Branch(InstanceTypeEqual(properties_instance_type, NAME_DICTIONARY_TYPE), Branch(InstanceTypeEqual(properties_instance_type, NAME_DICTIONARY_TYPE),
&if_property_dictionary, &if_fixed_array); &if_property_dictionary, &if_fixed_array);
...@@ -1819,10 +1819,10 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash( ...@@ -1819,10 +1819,10 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
Goto(&done); Goto(&done);
} }
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
BIND(&if_ordered_property_dictionary); BIND(&if_swiss_property_dictionary);
{ {
var_hash = SmiUntag(CAST(LoadFixedArrayElement( var_hash = Signed(
CAST(properties), OrderedNameDictionary::HashIndex()))); ChangeUint32ToWord(LoadSwissNameDictionaryHash(CAST(properties))));
Goto(&done); Goto(&done);
} }
} }
...@@ -3581,7 +3581,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap( ...@@ -3581,7 +3581,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap(
} else { } else {
CSA_ASSERT(this, Word32Or(Word32Or(Word32Or(IsPropertyArray(*properties), CSA_ASSERT(this, Word32Or(Word32Or(Word32Or(IsPropertyArray(*properties),
IsNameDictionary(*properties)), IsNameDictionary(*properties)),
IsOrderedNameDictionary(*properties)), IsSwissNameDictionary(*properties)),
IsEmptyFixedArray(*properties))); IsEmptyFixedArray(*properties)));
StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOrHashOffset, StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOrHashOffset,
*properties); *properties);
...@@ -6397,6 +6397,11 @@ TNode<BoolT> CodeStubAssembler::IsOrderedNameDictionary( ...@@ -6397,6 +6397,11 @@ TNode<BoolT> CodeStubAssembler::IsOrderedNameDictionary(
return HasInstanceType(object, ORDERED_NAME_DICTIONARY_TYPE); return HasInstanceType(object, ORDERED_NAME_DICTIONARY_TYPE);
} }
TNode<BoolT> CodeStubAssembler::IsSwissNameDictionary(
TNode<HeapObject> object) {
return HasInstanceType(object, SWISS_NAME_DICTIONARY_TYPE);
}
TNode<BoolT> CodeStubAssembler::IsGlobalDictionary(TNode<HeapObject> object) { TNode<BoolT> CodeStubAssembler::IsGlobalDictionary(TNode<HeapObject> object) {
return HasInstanceType(object, GLOBAL_DICTIONARY_TYPE); return HasInstanceType(object, GLOBAL_DICTIONARY_TYPE);
} }
...@@ -8005,6 +8010,25 @@ TNode<Word32T> CodeStubAssembler::ComputeSeededHash(TNode<IntPtrT> key) { ...@@ -8005,6 +8010,25 @@ TNode<Word32T> CodeStubAssembler::ComputeSeededHash(TNode<IntPtrT> key) {
std::make_pair(type_int32, TruncateIntPtrToInt32(key)))); std::make_pair(type_int32, TruncateIntPtrToInt32(key))));
} }
template <>
void CodeStubAssembler::NameDictionaryLookup(
TNode<SwissNameDictionary> dictionary, TNode<Name> unique_name,
Label* if_found, TVariable<IntPtrT>* var_name_index, Label* if_not_found,
LookupMode mode) {
Label store_found_index(this);
// TOOD(v8:11330) Dummy implementation until real version exists.
TNode<Smi> index =
CallRuntime<Smi>(Runtime::kSwissTableFindEntry, NoContextConstant(),
dictionary, unique_name);
BranchIfSmiEqual(index, SmiConstant(SwissNameDictionary::kNotFoundSentinel),
if_not_found, &store_found_index);
BIND(&store_found_index);
*var_name_index = SmiToIntPtr(index);
Goto(if_found);
}
void CodeStubAssembler::NumberDictionaryLookup( void CodeStubAssembler::NumberDictionaryLookup(
TNode<NumberDictionary> dictionary, TNode<IntPtrT> intptr_index, TNode<NumberDictionary> dictionary, TNode<IntPtrT> intptr_index,
Label* if_found, TVariable<IntPtrT>* var_entry, Label* if_not_found) { Label* if_found, TVariable<IntPtrT>* var_entry, Label* if_not_found) {
...@@ -8204,9 +8228,10 @@ TNode<Smi> CodeStubAssembler::GetNumberOfElements( ...@@ -8204,9 +8228,10 @@ TNode<Smi> CodeStubAssembler::GetNumberOfElements(
template <> template <>
TNode<Smi> CodeStubAssembler::GetNumberOfElements( TNode<Smi> CodeStubAssembler::GetNumberOfElements(
TNode<OrderedNameDictionary> dictionary) { TNode<SwissNameDictionary> dictionary) {
return CAST(LoadFixedArrayElement( // TOOD(v8:11330) Dummy implementation until real version exists.
dictionary, OrderedNameDictionary::NumberOfElementsIndex())); return CallRuntime<Smi>(Runtime::kSwissTableElementsCount,
NoContextConstant(), dictionary);
} }
template TNode<Smi> CodeStubAssembler::GetNumberOfElements( template TNode<Smi> CodeStubAssembler::GetNumberOfElements(
...@@ -8729,15 +8754,18 @@ void CodeStubAssembler::TryLookupPropertyInSimpleObject( ...@@ -8729,15 +8754,18 @@ void CodeStubAssembler::TryLookupPropertyInSimpleObject(
BIND(&if_isslowmap); BIND(&if_isslowmap);
{ {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167, v8:11177) Only here due to SetDataProperties workaround. TNode<SwissNameDictionary> dictionary = CAST(LoadSlowProperties(object));
GotoIf(Int32TrueConstant(), bailout); *var_meta_storage = dictionary;
}
TNode<NameDictionary> dictionary = CAST(LoadSlowProperties(object)); NameDictionaryLookup<SwissNameDictionary>(
*var_meta_storage = dictionary; dictionary, unique_name, if_found_dict, var_name_index, if_not_found);
} else {
TNode<NameDictionary> dictionary = CAST(LoadSlowProperties(object));
*var_meta_storage = dictionary;
NameDictionaryLookup<NameDictionary>(dictionary, unique_name, if_found_dict, NameDictionaryLookup<NameDictionary>(
var_name_index, if_not_found); dictionary, unique_name, if_found_dict, var_name_index, if_not_found);
}
} }
} }
...@@ -8971,6 +8999,23 @@ void CodeStubAssembler::LoadPropertyFromNameDictionary( ...@@ -8971,6 +8999,23 @@ void CodeStubAssembler::LoadPropertyFromNameDictionary(
Comment("] LoadPropertyFromNameDictionary"); Comment("] LoadPropertyFromNameDictionary");
} }
void CodeStubAssembler::LoadPropertyFromSwissNameDictionary(
TNode<SwissNameDictionary> dictionary, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Object>* var_value) {
Comment("[ LoadPropertyFromSwissNameDictionary");
// TOOD(v8:11330) Dummy implementation until real version exists.
TNode<Smi> details =
CallRuntime<Smi>(Runtime::kSwissTableDetailsAt, NoContextConstant(),
dictionary, SmiFromIntPtr(name_index));
*var_details = Unsigned(SmiToInt32(details));
*var_value =
CallRuntime<Object>(Runtime::kSwissTableValueAt, NoContextConstant(),
dictionary, SmiFromIntPtr(name_index));
Comment("] LoadPropertyFromSwissNameDictionary");
}
void CodeStubAssembler::LoadPropertyFromGlobalDictionary( void CodeStubAssembler::LoadPropertyFromGlobalDictionary(
TNode<GlobalDictionary> dictionary, TNode<IntPtrT> name_index, TNode<GlobalDictionary> dictionary, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Object>* var_value, TVariable<Uint32T>* var_details, TVariable<Object>* var_value,
...@@ -9154,9 +9199,17 @@ void CodeStubAssembler::TryGetOwnProperty( ...@@ -9154,9 +9199,17 @@ void CodeStubAssembler::TryGetOwnProperty(
} }
BIND(&if_found_dict); BIND(&if_found_dict);
{ {
TNode<NameDictionary> dictionary = CAST(var_meta_storage.value()); if (V8_DICT_MODE_PROTOTYPES_BOOL) {
TNode<IntPtrT> entry = var_entry.value(); TNode<SwissNameDictionary> dictionary = CAST(var_meta_storage.value());
LoadPropertyFromNameDictionary(dictionary, entry, var_details, var_value); TNode<IntPtrT> entry = var_entry.value();
LoadPropertyFromSwissNameDictionary(dictionary, entry, var_details,
var_value);
} else {
TNode<NameDictionary> dictionary = CAST(var_meta_storage.value());
TNode<IntPtrT> entry = var_entry.value();
LoadPropertyFromNameDictionary(dictionary, entry, var_details, var_value);
}
Goto(&if_found); Goto(&if_found);
} }
BIND(&if_found_global); BIND(&if_found_global);
...@@ -12646,7 +12699,7 @@ TNode<Oddball> CodeStubAssembler::HasProperty(TNode<Context> context, ...@@ -12646,7 +12699,7 @@ TNode<Oddball> CodeStubAssembler::HasProperty(TNode<Context> context,
return_false(this), end(this), if_proxy(this, Label::kDeferred); return_false(this), end(this), if_proxy(this, Label::kDeferred);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), &call_runtime); GotoIf(Int32TrueConstant(), &call_runtime);
} }
...@@ -13742,14 +13795,14 @@ TNode<Map> CodeStubAssembler::CheckEnumCache(TNode<JSReceiver> receiver, ...@@ -13742,14 +13795,14 @@ TNode<Map> CodeStubAssembler::CheckEnumCache(TNode<JSReceiver> receiver,
TNode<HeapObject> properties = LoadSlowProperties(receiver); TNode<HeapObject> properties = LoadSlowProperties(receiver);
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
CSA_ASSERT(this, Word32Or(IsOrderedNameDictionary(properties), CSA_ASSERT(this, Word32Or(IsSwissNameDictionary(properties),
IsGlobalDictionary(properties))); IsGlobalDictionary(properties)));
length = Select<Smi>( length = Select<Smi>(
IsOrderedNameDictionary(properties), IsSwissNameDictionary(properties),
[=] { [=] {
return GetNumberOfElements( return GetNumberOfElements(
UncheckedCast<OrderedNameDictionary>(properties)); UncheckedCast<SwissNameDictionary>(properties));
}, },
[=] { [=] {
return GetNumberOfElements( return GetNumberOfElements(
...@@ -14119,5 +14172,18 @@ void PrototypeCheckAssembler::CheckAndBranch(TNode<HeapObject> prototype, ...@@ -14119,5 +14172,18 @@ void PrototypeCheckAssembler::CheckAndBranch(TNode<HeapObject> prototype,
} }
} }
TNode<SwissNameDictionary> CodeStubAssembler::AllocateSwissNameDictionary(
TNode<IntPtrT> at_least_space_for) {
// TOOD(v8:11330) Dummy implementation until real version exists.
return CallRuntime<SwissNameDictionary>(Runtime::kSwissTableAllocate,
NoContextConstant(),
SmiFromIntPtr(at_least_space_for));
}
TNode<SwissNameDictionary> CodeStubAssembler::AllocateSwissNameDictionary(
int at_least_space_for) {
return AllocateSwissNameDictionary(IntPtrConstant(at_least_space_for));
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -135,6 +135,8 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; ...@@ -135,6 +135,8 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
EmptyPropertyDictionary) \ EmptyPropertyDictionary) \
V(EmptyOrderedPropertyDictionary, empty_ordered_property_dictionary, \ V(EmptyOrderedPropertyDictionary, empty_ordered_property_dictionary, \
EmptyOrderedPropertyDictionary) \ EmptyOrderedPropertyDictionary) \
V(EmptySwissPropertyDictionary, empty_swiss_property_dictionary, \
EmptySwissPropertyDictionary) \
V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ V(EmptySlowElementDictionary, empty_slow_element_dictionary, \
EmptySlowElementDictionary) \ EmptySlowElementDictionary) \
V(empty_string, empty_string, EmptyString) \ V(empty_string, empty_string, EmptyString) \
...@@ -2425,6 +2427,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -2425,6 +2427,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> IsStringInstanceType(TNode<Int32T> instance_type); TNode<BoolT> IsStringInstanceType(TNode<Int32T> instance_type);
TNode<BoolT> IsString(TNode<HeapObject> object); TNode<BoolT> IsString(TNode<HeapObject> object);
TNode<BoolT> IsSeqOneByteString(TNode<HeapObject> object); TNode<BoolT> IsSeqOneByteString(TNode<HeapObject> object);
TNode<BoolT> IsSwissNameDictionary(TNode<HeapObject> object);
TNode<BoolT> IsSymbolInstanceType(TNode<Int32T> instance_type); TNode<BoolT> IsSymbolInstanceType(TNode<Int32T> instance_type);
TNode<BoolT> IsInternalizedStringInstanceType(TNode<Int32T> instance_type); TNode<BoolT> IsInternalizedStringInstanceType(TNode<Int32T> instance_type);
...@@ -3039,6 +3042,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3039,6 +3042,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<IntPtrT> name_index, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Uint32T>* var_details,
TVariable<Object>* var_value); TVariable<Object>* var_value);
void LoadPropertyFromSwissNameDictionary(
TNode<SwissNameDictionary> dictionary, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Object>* var_value);
void LoadPropertyFromGlobalDictionary(TNode<GlobalDictionary> dictionary, void LoadPropertyFromGlobalDictionary(TNode<GlobalDictionary> dictionary,
TNode<IntPtrT> name_index, TNode<IntPtrT> name_index,
TVariable<Uint32T>* var_details, TVariable<Uint32T>* var_details,
...@@ -3697,6 +3703,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3697,6 +3703,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return IntPtrConstant(FeedbackIterator::kHandlerOffset); return IntPtrConstant(FeedbackIterator::kHandlerOffset);
} }
TNode<SwissNameDictionary> AllocateSwissNameDictionary(
TNode<IntPtrT> at_least_space_for);
TNode<SwissNameDictionary> AllocateSwissNameDictionary(
int at_least_space_for);
private: private:
friend class CodeStubArguments; friend class CodeStubArguments;
......
...@@ -860,7 +860,7 @@ TNode<Object> AccessorAssembler::HandleProtoHandler( ...@@ -860,7 +860,7 @@ TNode<Object> AccessorAssembler::HandleProtoHandler(
BIND(&if_lookup_on_lookup_start_object); BIND(&if_lookup_on_lookup_start_object);
{ {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), miss); GotoIf(Int32TrueConstant(), miss);
} }
...@@ -2440,7 +2440,7 @@ void AccessorAssembler::GenericPropertyLoad( ...@@ -2440,7 +2440,7 @@ void AccessorAssembler::GenericPropertyLoad(
BIND(&if_property_dictionary); BIND(&if_property_dictionary);
{ {
if (V8_DICT_MODE_PROTOTYPES_BOOL) { if (V8_DICT_MODE_PROTOTYPES_BOOL) {
// TODO(v8:11167) remove once OrderedNameDictionary supported. // TODO(v8:11167) remove once SwissNameDictionary supported.
GotoIf(Int32TrueConstant(), slow); GotoIf(Int32TrueConstant(), slow);
} }
......
...@@ -639,20 +639,6 @@ DEF_GETTER(JSReceiver, property_dictionary, NameDictionary) { ...@@ -639,20 +639,6 @@ DEF_GETTER(JSReceiver, property_dictionary, NameDictionary) {
return NameDictionary::cast(prop); return NameDictionary::cast(prop);
} }
DEF_GETTER(JSReceiver, property_dictionary_ordered, OrderedNameDictionary) {
DCHECK(!IsJSGlobalObject(isolate));
DCHECK(!HasFastProperties(isolate));
DCHECK(V8_DICT_MODE_PROTOTYPES_BOOL);
// Can't use ReadOnlyRoots(isolate) as this isolate could be produced by
// i::GetIsolateForPtrCompr(HeapObject).
Object prop = raw_properties_or_hash(isolate);
if (prop.IsSmi()) {
return GetReadOnlyRoots(isolate).empty_ordered_property_dictionary();
}
return OrderedNameDictionary::cast(prop);
}
DEF_GETTER(JSReceiver, property_dictionary_swiss, SwissNameDictionary) { DEF_GETTER(JSReceiver, property_dictionary_swiss, SwissNameDictionary) {
DCHECK(!IsJSGlobalObject(isolate)); DCHECK(!IsJSGlobalObject(isolate));
DCHECK(!HasFastProperties(isolate)); DCHECK(!HasFastProperties(isolate));
......
...@@ -50,10 +50,6 @@ class JSReceiver : public HeapObject { ...@@ -50,10 +50,6 @@ class JSReceiver : public HeapObject {
// Gets slow properties for non-global objects (if v8_dict_mode_prototypes is // Gets slow properties for non-global objects (if v8_dict_mode_prototypes is
// set). // set).
// TODO(v8:11388) Keeping both versions around while transition to
// SwissNameDictionary is in progress, will then delete
// property_dictionary_ordered.
DECL_GETTER(property_dictionary_ordered, OrderedNameDictionary)
DECL_GETTER(property_dictionary_swiss, SwissNameDictionary) DECL_GETTER(property_dictionary_swiss, SwissNameDictionary)
// Sets the properties backing store and makes sure any existing hash is moved // Sets the properties backing store and makes sure any existing hash is moved
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
@abstract @abstract
@highestInstanceTypeWithinParentClassRange @highestInstanceTypeWithinParentClassRange
extern class JSReceiver extends HeapObject { extern class JSReceiver extends HeapObject {
properties_or_hash: FixedArrayBase|PropertyArray|Smi; properties_or_hash: SwissNameDictionary|FixedArrayBase|PropertyArray|Smi;
} }
type Constructor extends JSReceiver; type Constructor extends JSReceiver;
...@@ -73,12 +73,12 @@ macro GetDerivedMap(implicit context: Context)( ...@@ -73,12 +73,12 @@ macro GetDerivedMap(implicit context: Context)(
macro AllocateFastOrSlowJSObjectFromMap(implicit context: Context)(map: Map): macro AllocateFastOrSlowJSObjectFromMap(implicit context: Context)(map: Map):
JSObject { JSObject {
let properties: EmptyFixedArray|NameDictionary|OrderedNameDictionary = let properties: EmptyFixedArray|NameDictionary|SwissNameDictionary =
kEmptyFixedArray; kEmptyFixedArray;
if (IsDictionaryMap(map)) { if (IsDictionaryMap(map)) {
if (kDictModePrototypes) { if (kDictModePrototypes) {
properties = properties =
AllocateOrderedNameDictionary(kOrderedNameDictionaryInitialCapacity); AllocateSwissNameDictionary(kSwissNameDictionaryInitialCapacity);
} else { } else {
properties = AllocateNameDictionary(kNameDictionaryInitialCapacity); properties = AllocateNameDictionary(kNameDictionaryInitialCapacity);
} }
...@@ -161,10 +161,9 @@ extern class JSStringIterator extends JSObject { ...@@ -161,10 +161,9 @@ extern class JSStringIterator extends JSObject {
extern macro AllocateJSObjectFromMap(Map): JSObject; extern macro AllocateJSObjectFromMap(Map): JSObject;
extern macro AllocateJSObjectFromMap( extern macro AllocateJSObjectFromMap(
Map, Map,
NameDictionary | OrderedNameDictionary | EmptyFixedArray | NameDictionary | SwissNameDictionary | EmptyFixedArray |
PropertyArray): JSObject; PropertyArray): JSObject;
extern macro AllocateJSObjectFromMap( extern macro AllocateJSObjectFromMap(
Map, Map, NameDictionary | SwissNameDictionary | EmptyFixedArray | PropertyArray,
NameDictionary | OrderedNameDictionary | EmptyFixedArray | PropertyArray,
FixedArray, constexpr AllocationFlag, FixedArray, constexpr AllocationFlag,
constexpr SlackTrackingMode): JSObject; constexpr SlackTrackingMode): JSObject;
...@@ -328,7 +328,7 @@ PrimitiveHeapObject InferMethodName(Isolate* isolate, JSReceiver receiver, ...@@ -328,7 +328,7 @@ PrimitiveHeapObject InferMethodName(Isolate* isolate, JSReceiver receiver,
fun, name); fun, name);
} else if (V8_DICT_MODE_PROTOTYPES_BOOL) { } else if (V8_DICT_MODE_PROTOTYPES_BOOL) {
name = InferMethodNameFromDictionary( name = InferMethodNameFromDictionary(
isolate, object.property_dictionary_ordered(), fun, name); isolate, object.property_dictionary_swiss(), fun, name);
} else { } else {
name = InferMethodNameFromDictionary( name = InferMethodNameFromDictionary(
isolate, object.property_dictionary(), fun, name); isolate, object.property_dictionary(), fun, name);
......
...@@ -1890,13 +1890,21 @@ TEST(AllocateJSObjectFromMap) { ...@@ -1890,13 +1890,21 @@ TEST(AllocateJSObjectFromMap) {
"object"))); "object")));
JSObject::NormalizeProperties(isolate, object, KEEP_INOBJECT_PROPERTIES, 0, JSObject::NormalizeProperties(isolate, object, KEEP_INOBJECT_PROPERTIES, 0,
"Normalize"); "Normalize");
Handle<HeapObject> properties =
V8_DICT_MODE_PROTOTYPES_BOOL
? Handle<HeapObject>(object->property_dictionary_swiss(), isolate)
: handle(object->property_dictionary(), isolate);
Handle<JSObject> result = Handle<JSObject>::cast( Handle<JSObject> result = Handle<JSObject>::cast(
ft.Call(handle(object->map(), isolate), ft.Call(handle(object->map(), isolate), properties,
handle(object->property_dictionary(), isolate),
handle(object->elements(), isolate)) handle(object->elements(), isolate))
.ToHandleChecked()); .ToHandleChecked());
CHECK_EQ(result->map(), object->map()); CHECK_EQ(result->map(), object->map());
CHECK_EQ(result->property_dictionary(), object->property_dictionary()); if (V8_DICT_MODE_PROTOTYPES_BOOL) {
CHECK_EQ(result->property_dictionary_swiss(),
object->property_dictionary_swiss());
} else {
CHECK_EQ(result->property_dictionary(), object->property_dictionary());
}
CHECK(!result->HasFastProperties()); CHECK(!result->HasFastProperties());
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
isolate->heap()->Verify(); isolate->heap()->Verify();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment