Commit 323cf26d authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[Collections] Change ::HasKey to return bool

Mask the lower byte before doing the compare.

Bug: v8:5717, v8:6455
Change-Id: I0c7e8b79adc36fb5ee643eae2e42fd892cd560fd
Reviewed-on: https://chromium-review.googlesource.com/527885
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46070}
parent 8744ef81
......@@ -360,14 +360,16 @@ Node* CollectionsBuiltinsAssembler::CallHasRaw(Node* const table,
Node* const isolate_ptr =
ExternalConstant(ExternalReference::isolate_address(isolate()));
MachineType type_uint8 = MachineType::Uint8();
MachineType type_ptr = MachineType::Pointer();
MachineType type_tagged = MachineType::AnyTagged();
Node* const result =
CallCFunction3(type_tagged, type_ptr, type_tagged, type_tagged,
CallCFunction3(type_uint8, type_ptr, type_tagged, type_tagged,
function_addr, isolate_ptr, table, key);
return result;
return SelectBooleanConstant(
Word32NotEqual(Word32And(result, Int32Constant(0xFF)), Int32Constant(0)));
}
TF_BUILTIN(MapGet, CollectionsBuiltinsAssembler) {
......
......@@ -18153,14 +18153,12 @@ Handle<Derived> OrderedHashTable<Derived, entrysize>::Clear(
}
template <class Derived, int entrysize>
Object* OrderedHashTable<Derived, entrysize>::HasKey(Isolate* isolate,
Derived* table,
Object* key) {
bool OrderedHashTable<Derived, entrysize>::HasKey(Isolate* isolate,
Derived* table, Object* key) {
DCHECK(table->IsOrderedHashTable());
DisallowHeapAllocation no_gc;
int entry = table->FindEntry(isolate, key);
return entry == kNotFound ? isolate->heap()->false_value()
: isolate->heap()->true_value();
return entry != kNotFound;
}
Handle<OrderedHashSet> OrderedHashSet::Add(Handle<OrderedHashSet> table,
......@@ -18339,8 +18337,9 @@ template Handle<OrderedHashSet> OrderedHashTable<OrderedHashSet, 1>::Shrink(
template Handle<OrderedHashSet> OrderedHashTable<OrderedHashSet, 1>::Clear(
Handle<OrderedHashSet> table);
template Object* OrderedHashTable<OrderedHashSet, 1>::HasKey(
Isolate* isolate, OrderedHashSet* table, Object* key);
template bool OrderedHashTable<OrderedHashSet, 1>::HasKey(Isolate* isolate,
OrderedHashSet* table,
Object* key);
template bool OrderedHashTable<OrderedHashSet, 1>::Delete(Isolate* isolate,
OrderedHashSet* table,
......@@ -18358,8 +18357,9 @@ template Handle<OrderedHashMap> OrderedHashTable<OrderedHashMap, 2>::Shrink(
template Handle<OrderedHashMap> OrderedHashTable<OrderedHashMap, 2>::Clear(
Handle<OrderedHashMap> table);
template Object* OrderedHashTable<OrderedHashMap, 2>::HasKey(
Isolate* isolate, OrderedHashMap* table, Object* key);
template bool OrderedHashTable<OrderedHashMap, 2>::HasKey(Isolate* isolate,
OrderedHashMap* table,
Object* key);
template bool OrderedHashTable<OrderedHashMap, 2>::Delete(Isolate* isolate,
OrderedHashMap* table,
......
......@@ -398,13 +398,13 @@ class OrderedHashTable : public FixedArray {
// existing iterators can be updated.
static Handle<Derived> Clear(Handle<Derived> table);
// Returns true if the OrderedHashTable contains the key
static bool HasKey(Isolate* isolate, Derived* table, Object* key);
// Returns a true value if the OrderedHashTable contains the key and
// the key has been deleted. This does not shrink the table.
static bool Delete(Isolate* isolate, Derived* table, Object* key);
// Returns a true value if the OrderedHashTable contains the key
static Object* HasKey(Isolate* isolate, Derived* table, Object* key);
int NumberOfElements() {
return Smi::cast(get(kNumberOfElementsIndex))->value();
}
......
This diff is collapsed.
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