Commit b0f9b4df authored by Toon Verwaest's avatar Toon Verwaest Committed by V8 LUCI CQ

[maglev] Copy OpProperties into the bitfield for fast access

Bug: v8:7700
Change-Id: I11e2a5eaf607b7501b19b9cb04de086cd4ee0a4c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3553113Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79671}
parent 0be69835
...@@ -210,6 +210,9 @@ class OpProperties { ...@@ -210,6 +210,9 @@ class OpProperties {
return Reading() | Writing() | NonMemorySideEffects(); return Reading() | Writing() | NonMemorySideEffects();
} }
constexpr explicit OpProperties(uint32_t bitfield) : bitfield_(bitfield) {}
operator uint32_t() const { return bitfield_; }
private: private:
using kIsCallBit = base::BitField<bool, 0, 1>; using kIsCallBit = base::BitField<bool, 0, 1>;
using kCanDeoptBit = kIsCallBit::Next<bool, 1>; using kCanDeoptBit = kIsCallBit::Next<bool, 1>;
...@@ -223,9 +226,10 @@ class OpProperties { ...@@ -223,9 +226,10 @@ class OpProperties {
kCanWriteBit::encode(false) | kCanWriteBit::encode(false) |
kNonMemorySideEffectsBit::encode(false); kNonMemorySideEffectsBit::encode(false);
constexpr explicit OpProperties(uint32_t bitfield) : bitfield_(bitfield) {}
const uint32_t bitfield_; const uint32_t bitfield_;
public:
static const size_t kSize = kNonMemorySideEffectsBit::kLastUsedBit + 1;
}; };
class ValueLocation { class ValueLocation {
...@@ -321,7 +325,9 @@ class NodeBase : public ZoneObject { ...@@ -321,7 +325,9 @@ class NodeBase : public ZoneObject {
// Bitfield specification. // Bitfield specification.
using OpcodeField = base::BitField<Opcode, 0, 6>; using OpcodeField = base::BitField<Opcode, 0, 6>;
STATIC_ASSERT(OpcodeField::is_valid(kLastOpcode)); STATIC_ASSERT(OpcodeField::is_valid(kLastOpcode));
using InputCountField = OpcodeField::Next<uint16_t, 16>; using OpPropertiesField =
OpcodeField::Next<OpProperties, OpProperties::kSize>;
using InputCountField = OpPropertiesField::Next<uint16_t, 16>;
protected: protected:
// Subclasses may use the remaining bitfield bits. // Subclasses may use the remaining bitfield bits.
...@@ -357,9 +363,11 @@ class NodeBase : public ZoneObject { ...@@ -357,9 +363,11 @@ class NodeBase : public ZoneObject {
// Overwritten by subclasses. // Overwritten by subclasses.
static constexpr OpProperties kProperties = OpProperties::Pure(); static constexpr OpProperties kProperties = OpProperties::Pure();
inline const OpProperties& properties() const;
constexpr Opcode opcode() const { return OpcodeField::decode(bit_field_); } constexpr Opcode opcode() const { return OpcodeField::decode(bit_field_); }
OpProperties properties() const {
return OpPropertiesField::decode(bit_field_);
}
template <class T> template <class T>
constexpr bool Is() const; constexpr bool Is() const;
...@@ -468,6 +476,7 @@ class NodeBase : public ZoneObject { ...@@ -468,6 +476,7 @@ class NodeBase : public ZoneObject {
void* node_buffer = void* node_buffer =
reinterpret_cast<void*>(raw_buffer + input_count * sizeof(Input)); reinterpret_cast<void*>(raw_buffer + input_count * sizeof(Input));
uint32_t bitfield = OpcodeField::encode(opcode_of<Derived>) | uint32_t bitfield = OpcodeField::encode(opcode_of<Derived>) |
OpPropertiesField::encode(Derived::kProperties) |
InputCountField::encode(input_count); InputCountField::encode(input_count);
Derived* node = Derived* node =
new (node_buffer) Derived(bitfield, std::forward<Args>(args)...); new (node_buffer) Derived(bitfield, std::forward<Args>(args)...);
...@@ -1411,17 +1420,6 @@ class BranchIfCompare ...@@ -1411,17 +1420,6 @@ class BranchIfCompare
Operation operation_; Operation operation_;
}; };
const OpProperties& NodeBase::properties() const {
switch (opcode()) {
#define V(Name) \
case Opcode::k##Name: \
return Name::kProperties;
NODE_BASE_LIST(V)
#undef V
}
UNREACHABLE();
}
} // namespace maglev } // namespace maglev
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
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