Commit b7f4981c authored by bbudge's avatar bbudge Committed by Commit bot

Expand ToBoolean stub so it can handle more types.

SIMD values will require their own type code for conversion to boolean.

LOG=N
BUG=v8:4124

Review URL: https://codereview.chromium.org/1202973003

Cr-Commit-Position: refs/heads/master@{#29247}
parent 3e2c6a2e
......@@ -924,7 +924,7 @@ bool ToBooleanStub::UpdateStatus(Handle<Object> object) {
Types old_types = new_types;
bool to_boolean_value = new_types.UpdateStatus(object);
TraceTransition(old_types, new_types);
set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToByte()));
set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToIntegral()));
return to_boolean_value;
}
......
......@@ -2737,16 +2737,15 @@ class ToBooleanStub: public HydrogenCodeStub {
RESULT_AS_INVERSE_ODDBALL // For {false} on truthy value, {true} otherwise.
};
// At most 8 different types can be distinguished, because the Code object
// only has room for a single byte to hold a set of these types. :-P
STATIC_ASSERT(NUMBER_OF_TYPES <= 8);
// At most 16 different types can be distinguished, because the Code object
// only has room for two bytes to hold a set of these types. :-P
STATIC_ASSERT(NUMBER_OF_TYPES <= 16);
class Types : public EnumSet<Type, byte> {
class Types : public EnumSet<Type, uint16_t> {
public:
Types() : EnumSet<Type, byte>(0) {}
explicit Types(byte bits) : EnumSet<Type, byte>(bits) {}
Types() : EnumSet<Type, uint16_t>(0) {}
explicit Types(uint16_t bits) : EnumSet<Type, uint16_t>(bits) {}
byte ToByte() const { return ToIntegral(); }
bool UpdateStatus(Handle<Object> object);
bool NeedsMap() const;
bool CanBeUndetectable() const;
......@@ -2757,13 +2756,13 @@ class ToBooleanStub: public HydrogenCodeStub {
ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types())
: HydrogenCodeStub(isolate) {
set_sub_minor_key(TypesBits::encode(types.ToByte()) |
set_sub_minor_key(TypesBits::encode(types.ToIntegral()) |
ResultModeBits::encode(mode));
}
ToBooleanStub(Isolate* isolate, ExtraICState state)
: HydrogenCodeStub(isolate) {
set_sub_minor_key(TypesBits::encode(static_cast<byte>(state)) |
set_sub_minor_key(TypesBits::encode(static_cast<uint16_t>(state)) |
ResultModeBits::encode(RESULT_AS_SMI));
}
......@@ -2796,7 +2795,7 @@ class ToBooleanStub: public HydrogenCodeStub {
set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI));
}
class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {};
class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {};
class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean);
......
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