Commit 1539f125 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[CSA] Use IsSetWord32 and IsClearWord32 helpers

Change-Id: If9debcecd714494e24adf895eb077d5ba51528d2
Reviewed-on: https://chromium-review.googlesource.com/535619
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45979}
parent e48a2ef5
......@@ -78,9 +78,7 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
Node* native_context = LoadNativeContext(context);
Label map_done(this, vars);
Node* bit_field = LoadMapBitField(receiver_map);
int mask = static_cast<int>(1 << Map::kIsConstructor);
GotoIf(IsSetWord32(bit_field, mask), &with_constructor);
GotoIf(IsConstructorMap(receiver_map), &with_constructor);
bound_function_map.Bind(LoadContextElement(
native_context, Context::BOUND_FUNCTION_WITHOUT_CONSTRUCTOR_MAP_INDEX));
......
......@@ -210,10 +210,9 @@ TF_BUILTIN(NumberParseFloat, CodeStubAssembler) {
// a cached array index.
Label if_inputcached(this), if_inputnotcached(this);
Node* input_hash = LoadNameHashField(input);
Node* input_bit = Word32And(
input_hash, Int32Constant(String::kContainsCachedArrayIndexMask));
Branch(Word32Equal(input_bit, Int32Constant(0)), &if_inputcached,
&if_inputnotcached);
Branch(IsClearWord32(input_hash,
Name::kDoesNotContainCachedArrayIndexMask),
&if_inputcached, &if_inputnotcached);
BIND(&if_inputcached);
{
......@@ -323,9 +322,8 @@ TF_BUILTIN(NumberParseInt, CodeStubAssembler) {
{
// Check if the String {input} has a cached array index.
Node* input_hash = LoadNameHashField(input);
Node* input_bit = Word32And(
input_hash, Int32Constant(String::kContainsCachedArrayIndexMask));
GotoIf(Word32NotEqual(input_bit, Int32Constant(0)), &if_generic);
GotoIf(IsSetWord32(input_hash, Name::kDoesNotContainCachedArrayIndexMask),
&if_generic);
// Return the cached array index as result.
Node* input_index =
......
......@@ -325,11 +325,7 @@ Node* PromiseBuiltinsAssembler::SpeciesConstructor(Node* context, Node* object,
// 7. If IsConstructor(S) is true, return S.
Label throw_error(this);
GotoIf(TaggedIsSmi(species), &throw_error);
Node* species_bitfield = LoadMapBitField(LoadMap(species));
GotoIfNot(Word32Equal(Word32And(species_bitfield,
Int32Constant((1 << Map::kIsConstructor))),
Int32Constant(1 << Map::kIsConstructor)),
&throw_error);
GotoIfNot(IsConstructorMap(LoadMap(species)), &throw_error);
var_result.Bind(species);
Goto(&out);
......
This diff is collapsed.
......@@ -821,6 +821,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* IsSymbol(Node* object);
Node* IsUnseededNumberDictionary(Node* object);
Node* IsWeakCell(Node* object);
Node* IsUndetectableMap(Node* map);
// True iff |object| is a Smi or a HeapNumber.
Node* IsNumber(Node* object);
......
......@@ -2324,12 +2324,7 @@ IGNITION_HANDLER(TestUndetectable, InterpreterAssembler) {
GotoIf(TaggedIsSmi(object), &end);
// If it is a HeapObject, load the map and check for undetectable bit.
Node* map = LoadMap(object);
Node* map_bitfield = LoadMapBitField(map);
Node* map_undetectable =
Word32And(map_bitfield, Int32Constant(1 << Map::kIsUndetectable));
Node* result =
SelectBooleanConstant(Word32NotEqual(map_undetectable, Int32Constant(0)));
Node* result = SelectBooleanConstant(IsUndetectableMap(LoadMap(object)));
SetAccumulator(result);
Goto(&end);
......@@ -2419,12 +2414,8 @@ IGNITION_HANDLER(TestTypeOf, InterpreterAssembler) {
Comment("IfUndefined");
GotoIf(TaggedIsSmi(object), &if_false);
// Check it is not null and the map has the undetectable bit set.
GotoIf(WordEqual(object, NullConstant()), &if_false);
Node* map_bitfield = LoadMapBitField(LoadMap(object));
Node* undetectable_bit =
Word32And(map_bitfield, Int32Constant(1 << Map::kIsUndetectable));
Branch(Word32Equal(undetectable_bit, Int32Constant(0)), &if_false,
&if_true);
GotoIf(IsNull(object), &if_false);
Branch(IsUndetectableMap(LoadMap(object)), &if_true, &if_false);
}
BIND(&if_function);
{
......
......@@ -11798,7 +11798,7 @@ uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
DCHECK((value & String::kIsNotArrayIndexMask) == 0);
DCHECK_EQ(length <= String::kMaxCachedArrayIndexLength,
(value & String::kContainsCachedArrayIndexMask) == 0);
Name::ContainsCachedArrayIndex(value));
return value;
}
......@@ -17367,7 +17367,7 @@ Object* StringTable::LookupStringIfExists_NoAllocate(String* string) {
STATIC_ASSERT(
!String::ArrayIndexValueBits::is_valid(ResultSentinel::kNotFound));
if ((hash & Name::kContainsCachedArrayIndexMask) == 0) {
if (Name::ContainsCachedArrayIndex(hash)) {
return Smi::FromInt(String::ArrayIndexValueBits::decode(hash));
}
if ((hash & Name::kIsNotArrayIndexMask) == 0) {
......
......@@ -86,6 +86,11 @@ bool Name::AsArrayIndex(uint32_t* index) {
return IsString() && String::cast(this)->AsArrayIndex(index);
}
// static
bool Name::ContainsCachedArrayIndex(uint32_t hash) {
return (hash & Name::kDoesNotContainCachedArrayIndexMask) == 0;
}
} // namespace internal
} // namespace v8
......
......@@ -39,6 +39,8 @@ class Name : public HeapObject {
inline bool IsUniqueName() const;
static inline bool ContainsCachedArrayIndex(uint32_t hash);
// Return a string version of this name that is converted according to the
// rules described in ES6 section 9.2.11.
MUST_USE_RESULT static MaybeHandle<String> ToFunctionName(Handle<Name> name);
......@@ -107,7 +109,9 @@ class Name : public HeapObject {
// kMaxCachedArrayIndexLength.
STATIC_ASSERT(IS_POWER_OF_TWO(kMaxCachedArrayIndexLength + 1));
static const unsigned int kContainsCachedArrayIndexMask =
// When any of these bits is set then the hash field does not contain a cached
// array index.
static const unsigned int kDoesNotContainCachedArrayIndexMask =
(~static_cast<unsigned>(kMaxCachedArrayIndexLength)
<< ArrayIndexLengthBits::kShift) |
kIsNotArrayIndexMask;
......
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