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

Unified Diff: src/code-stub-assembler.cc

Issue 2436893003: [stubs] Cleanup CSA::BitFieldDecode() and friends. (Closed)
Patch Set: Addressing comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index f23b82829ecc3d8dbc81cf1a7622977a6a67bdca..6504c84287b0fb715c795760a180202c2697f1d5 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -658,8 +658,7 @@ void CodeStubAssembler::BranchIfFastJSArray(Node* object, Node* context,
GotoIf(WordNotEqual(LoadMapInstanceType(map), Int32Constant(JS_ARRAY_TYPE)),
if_false);
- Node* bit_field2 = LoadMapBitField2(map);
- Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2);
+ Node* elements_kind = LoadMapElementsKind(map);
// Bailout if receiver has slow elements.
GotoIf(
@@ -1025,7 +1024,7 @@ Node* CodeStubAssembler::LoadMapInstanceType(Node* map) {
Node* CodeStubAssembler::LoadMapElementsKind(Node* map) {
Node* bit_field2 = LoadMapBitField2(map);
- return BitFieldDecode<Map::ElementsKindBits>(bit_field2);
+ return DecodeWord32<Map::ElementsKindBits>(bit_field2);
}
Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
@@ -3319,7 +3318,8 @@ Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) {
Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask));
GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime);
- var_result.Bind(SmiTag(BitFieldDecode<String::ArrayIndexValueBits>(hash)));
+ var_result.Bind(
+ SmiTag(DecodeWordFromWord32<String::ArrayIndexValueBits>(hash)));
Goto(&end);
Bind(&runtime);
@@ -3711,12 +3711,16 @@ Node* CodeStubAssembler::ToInteger(Node* context, Node* input,
return var_arg.value();
}
-Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
- uint32_t mask) {
+Node* CodeStubAssembler::DecodeWord32(Node* word32, uint32_t shift,
+ uint32_t mask) {
return Word32Shr(Word32And(word32, Int32Constant(mask)),
static_cast<int>(shift));
}
+Node* CodeStubAssembler::DecodeWord(Node* word, uint32_t shift, uint32_t mask) {
+ return WordShr(WordAnd(word, IntPtrConstant(mask)), static_cast<int>(shift));
+}
+
void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) {
if (FLAG_native_code_counters && counter->Enabled()) {
Node* counter_address = ExternalConstant(ExternalReference(counter));
@@ -3786,7 +3790,7 @@ void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex,
Goto(if_keyisunique);
Bind(&if_hascachedindex);
- var_index->Bind(BitFieldDecodeWord<Name::ArrayIndexValueBits>(hash));
+ var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash));
Goto(if_keyisindex);
}
@@ -3999,13 +4003,14 @@ void CodeStubAssembler::TryLookupProperty(
CSA_ASSERT(Word32Equal(Word32And(bit_field, mask), Int32Constant(0)));
Node* bit_field3 = LoadMapBitField3(map);
- Node* bit = BitFieldDecode<Map::DictionaryMap>(bit_field3);
Label if_isfastmap(this), if_isslowmap(this);
- Branch(Word32Equal(bit, Int32Constant(0)), &if_isfastmap, &if_isslowmap);
+ Branch(IsSetWord32<Map::DictionaryMap>(bit_field3), &if_isslowmap,
+ &if_isfastmap);
Bind(&if_isfastmap);
{
Comment("DescriptorArrayLookup");
- Node* nof = BitFieldDecodeWord<Map::NumberOfOwnDescriptorsBits>(bit_field3);
+ Node* nof =
+ DecodeWordFromWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3);
// Bail out to the runtime for large numbers of own descriptors. The stub
// only does linear search, which becomes too expensive in that case.
{
@@ -4093,7 +4098,7 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
name_to_details_offset);
var_details->Bind(details);
- Node* location = BitFieldDecode<PropertyDetails::LocationField>(details);
+ Node* location = DecodeWord32<PropertyDetails::LocationField>(details);
Label if_in_field(this), if_in_descriptor(this), done(this);
Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field,
@@ -4101,9 +4106,9 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
Bind(&if_in_field);
{
Node* field_index =
- BitFieldDecodeWord<PropertyDetails::FieldIndexField>(details);
+ DecodeWordFromWord32<PropertyDetails::FieldIndexField>(details);
Node* representation =
- BitFieldDecode<PropertyDetails::RepresentationField>(details);
+ DecodeWord32<PropertyDetails::RepresentationField>(details);
Node* inobject_properties = LoadMapInobjectProperties(map);
@@ -4242,7 +4247,7 @@ Node* CodeStubAssembler::CallGetterIfAccessor(Node* value, Node* details,
var_value.Bind(value);
Label done(this);
- Node* kind = BitFieldDecode<PropertyDetails::KindField>(details);
+ Node* kind = DecodeWord32<PropertyDetails::KindField>(details);
GotoIf(Word32Equal(kind, Int32Constant(kData)), &done);
// Accessor case.
@@ -5139,7 +5144,7 @@ void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements,
var_entry.value(), SeededNumberDictionary::kEntryDetailsIndex);
Node* details = SmiToWord32(
LoadFixedArrayElement(elements, details_index, 0, INTPTR_PARAMETERS));
- Node* kind = BitFieldDecode<PropertyDetails::KindField>(details);
+ Node* kind = DecodeWord32<PropertyDetails::KindField>(details);
// TODO(jkummerow): Support accessors without missing?
GotoUnless(Word32Equal(kind, Int32Constant(kData)), miss);
// Finally, load the value.
@@ -5269,8 +5274,7 @@ void CodeStubAssembler::HandleLoadICHandlerCase(
Node* holder = var_holder.value();
Node* handler_word = SmiUntag(var_smi_handler.value());
- Node* handler_type =
- WordAnd(handler_word, IntPtrConstant(LoadHandlerTypeBits::kMask));
+ Node* handler_type = DecodeWord<LoadHandlerTypeBits>(handler_word);
if (support_elements == kSupportElements) {
Label property(this);
GotoUnless(
@@ -5280,10 +5284,8 @@ void CodeStubAssembler::HandleLoadICHandlerCase(
Comment("element_load");
Node* intptr_index = TryToIntptr(p->name, miss);
Node* elements = LoadElements(holder);
- Node* is_jsarray =
- WordAnd(handler_word, IntPtrConstant(KeyedLoadIsJsArray::kMask));
- Node* is_jsarray_condition = WordNotEqual(is_jsarray, IntPtrConstant(0));
- Node* elements_kind = BitFieldDecode<KeyedLoadElementsKind>(handler_word);
+ Node* is_jsarray_condition = IsSetWord<KeyedLoadIsJsArray>(handler_word);
+ Node* elements_kind = DecodeWord<KeyedLoadElementsKind>(handler_word);
Label if_hole(this), unimplemented_elements_kind(this);
Label* out_of_bounds = miss;
EmitElementLoad(holder, elements, elements_kind, intptr_index,
@@ -5302,9 +5304,7 @@ void CodeStubAssembler::HandleLoadICHandlerCase(
Bind(&if_hole);
{
Comment("convert hole");
- Node* convert_hole =
- WordAnd(handler_word, IntPtrConstant(KeyedLoadConvertHole::kMask));
- GotoIf(WordEqual(convert_hole, IntPtrConstant(0)), miss);
+ GotoUnless(IsSetWord<KeyedLoadConvertHole>(handler_word), miss);
Node* protector_cell = LoadRoot(Heap::kArrayProtectorRootIndex);
DCHECK(isolate()->heap()->array_protector()->IsPropertyCell());
GotoUnless(
@@ -5326,40 +5326,41 @@ void CodeStubAssembler::HandleLoadICHandlerCase(
Bind(&field);
{
Comment("field_load");
- Label inobject_double(this), out_of_object(this),
- out_of_object_double(this);
- Node* inobject_bit =
- WordAnd(handler_word, IntPtrConstant(FieldOffsetIsInobject::kMask));
- Node* double_bit =
- WordAnd(handler_word, IntPtrConstant(FieldOffsetIsDouble::kMask));
- Node* offset =
- WordSar(handler_word, IntPtrConstant(FieldOffsetOffset::kShift));
-
- GotoIf(WordEqual(inobject_bit, IntPtrConstant(0)), &out_of_object);
-
- GotoUnless(WordEqual(double_bit, IntPtrConstant(0)), &inobject_double);
- Return(LoadObjectField(holder, offset));
-
- Bind(&inobject_double);
- if (FLAG_unbox_double_fields) {
- var_double_value.Bind(
- LoadObjectField(holder, offset, MachineType::Float64()));
- } else {
- Node* mutable_heap_number = LoadObjectField(holder, offset);
- var_double_value.Bind(LoadHeapNumberValue(mutable_heap_number));
+ Node* offset = DecodeWord<FieldOffsetOffset>(handler_word);
+
+ Label inobject(this), out_of_object(this);
+ Branch(IsSetWord<FieldOffsetIsInobject>(handler_word), &inobject,
+ &out_of_object);
+
+ Bind(&inobject);
+ {
+ Label is_double(this);
+ GotoIf(IsSetWord<FieldOffsetIsDouble>(handler_word), &is_double);
+ Return(LoadObjectField(holder, offset));
+
+ Bind(&is_double);
+ if (FLAG_unbox_double_fields) {
+ var_double_value.Bind(
+ LoadObjectField(holder, offset, MachineType::Float64()));
+ } else {
+ Node* mutable_heap_number = LoadObjectField(holder, offset);
+ var_double_value.Bind(LoadHeapNumberValue(mutable_heap_number));
+ }
+ Goto(&rebox_double);
}
- Goto(&rebox_double);
Bind(&out_of_object);
- Node* properties = LoadProperties(holder);
- Node* value = LoadObjectField(properties, offset);
- GotoUnless(WordEqual(double_bit, IntPtrConstant(0)),
- &out_of_object_double);
- Return(value);
+ {
+ Label is_double(this);
+ Node* properties = LoadProperties(holder);
+ Node* value = LoadObjectField(properties, offset);
+ GotoIf(IsSetWord<FieldOffsetIsDouble>(handler_word), &is_double);
+ Return(value);
- Bind(&out_of_object_double);
- var_double_value.Bind(LoadHeapNumberValue(value));
- Goto(&rebox_double);
+ Bind(&is_double);
+ var_double_value.Bind(LoadHeapNumberValue(value));
+ Goto(&rebox_double);
+ }
Bind(&rebox_double);
Return(AllocateHeapNumberWithValue(var_double_value.value()));
@@ -5369,11 +5370,10 @@ void CodeStubAssembler::HandleLoadICHandlerCase(
{
Comment("constant_load");
Node* descriptors = LoadMapDescriptors(LoadMap(holder));
- Node* descriptor = WordSar(
- handler_word, IntPtrConstant(ValueIndexInDescriptorArray::kShift));
+ Node* descriptor = DecodeWord<ValueIndexInDescriptorArray>(handler_word);
#if defined(DEBUG)
- Assert(UintPtrLessThan(descriptor,
- LoadAndUntagFixedArrayBaseLength(descriptors)));
+ CSA_ASSERT(UintPtrLessThan(
+ descriptor, LoadAndUntagFixedArrayBaseLength(descriptors)));
#endif
Return(
LoadFixedArrayElement(descriptors, descriptor, 0, INTPTR_PARAMETERS));
@@ -5607,7 +5607,8 @@ void CodeStubAssembler::KeyedLoadICGeneric(const LoadICParameters* p) {
const int32_t kMaxLinear = 210;
Label stub_cache(this);
Node* bitfield3 = LoadMapBitField3(receiver_map);
- Node* nof = BitFieldDecodeWord<Map::NumberOfOwnDescriptorsBits>(bitfield3);
+ Node* nof =
+ DecodeWordFromWord32<Map::NumberOfOwnDescriptorsBits>(bitfield3);
GotoIf(UintPtrGreaterThan(nof, IntPtrConstant(kMaxLinear)), &stub_cache);
Node* descriptors = LoadMapDescriptors(receiver_map);
Variable var_name_index(this, MachineType::PointerRepresentation());
@@ -6414,7 +6415,7 @@ Node* CodeStubAssembler::PageFromAddress(Node* address) {
Node* CodeStubAssembler::EnumLength(Node* map) {
Node* bitfield_3 = LoadMapBitField3(map);
- Node* enum_length = BitFieldDecode<Map::EnumLengthBits>(bitfield_3);
+ Node* enum_length = DecodeWordFromWord32<Map::EnumLengthBits>(bitfield_3);
return SmiTag(enum_length);
}
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698