Chromium Code Reviews| Index: src/ast.h |
| diff --git a/src/ast.h b/src/ast.h |
| index aa23b4e237afa7602613a5b6a151adf0c5536608..c68c58c1789c05572109262d843209d80a6ffaad 100644 |
| --- a/src/ast.h |
| +++ b/src/ast.h |
| @@ -359,11 +359,16 @@ class Expression : public AstNode { |
| void set_bounds(Bounds bounds) { bounds_ = bounds; } |
| // Whether the expression is parenthesized |
| - bool is_parenthesized() const { return is_parenthesized_; } |
| - bool is_multi_parenthesized() const { return is_multi_parenthesized_; } |
| + bool is_parenthesized() const { |
| + return IsParenthesizedField::decode(bit_field_); |
| + } |
| + bool is_multi_parenthesized() const { |
| + return IsMultiParenthesizedField::decode(bit_field_); |
| + } |
| void increase_parenthesization_level() { |
| - is_multi_parenthesized_ = is_parenthesized_; |
| - is_parenthesized_ = true; |
| + bit_field_ = |
| + IsMultiParenthesizedField::update(bit_field_, is_parenthesized()); |
| + bit_field_ = IsParenthesizedField::update(bit_field_, true); |
| } |
| // Type feedback information for assignments and properties. |
| @@ -375,18 +380,20 @@ class Expression : public AstNode { |
| UNREACHABLE(); |
| return NULL; |
| } |
| - virtual KeyedAccessStoreMode GetStoreMode() { |
| + virtual KeyedAccessStoreMode GetStoreMode() const { |
| UNREACHABLE(); |
| return STANDARD_STORE; |
| } |
| - virtual IcCheckType GetKeyType() { |
| + virtual IcCheckType GetKeyType() const { |
| UNREACHABLE(); |
| return ELEMENT; |
| } |
| // TODO(rossberg): this should move to its own AST node eventually. |
| virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| - byte to_boolean_types() const { return to_boolean_types_; } |
| + byte to_boolean_types() const { |
| + return ToBooleanTypesField::decode(bit_field_); |
| + } |
| void set_base_id(int id) { base_id_ = id; } |
| static int num_ids() { return parent_num_ids() + 2; } |
| @@ -398,10 +405,11 @@ class Expression : public AstNode { |
| : AstNode(pos), |
| base_id_(BailoutId::None().ToInt()), |
| bounds_(Bounds::Unbounded(zone)), |
| - is_parenthesized_(false), |
| - is_multi_parenthesized_(false) {} |
| + bit_field_(0) {} |
| static int parent_num_ids() { return 0; } |
| - void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| + void set_to_boolean_types(byte types) { |
| + bit_field_ = ToBooleanTypesField::update(bit_field_, types); |
| + } |
| int base_id() const { |
| DCHECK(!BailoutId(base_id_).IsNone()); |
| @@ -413,9 +421,10 @@ class Expression : public AstNode { |
| int base_id_; |
| Bounds bounds_; |
| - byte to_boolean_types_; |
| - bool is_parenthesized_ : 1; |
| - bool is_multi_parenthesized_ : 1; |
| + class ToBooleanTypesField : public BitField<byte, 0, 8> {}; |
| + class IsParenthesizedField : public BitField<bool, 8, 1> {}; |
| + class IsMultiParenthesizedField : public BitField<bool, 9, 1> {}; |
| + uint32_t bit_field_; |
|
brucedawson
2014/11/05 01:33:17
Why use a bit field at all? byte/bool/bool take up
Sven Panne
2014/11/05 09:11:49
All the code in ast.h *must* stay as it is, for th
Jakob Kummerow
2014/11/05 12:13:46
Used a smaller field per offline discussion.
|
| }; |
| @@ -1697,13 +1706,17 @@ class VariableProxy FINAL : public Expression { |
| var_ = v; |
| } |
| - bool is_this() const { return is_this_; } |
| + bool is_this() const { return IsThisField::decode(bit_field_); } |
| - bool is_assigned() const { return is_assigned_; } |
| - void set_is_assigned() { is_assigned_ = true; } |
| + bool is_assigned() const { return IsAssignedField::decode(bit_field_); } |
| + void set_is_assigned() { |
| + bit_field_ = IsAssignedField::update(bit_field_, true); |
| + } |
| - bool is_resolved() const { return is_resolved_; } |
| - void set_is_resolved() { is_resolved_ = true; } |
| + bool is_resolved() const { return IsResolvedField::decode(bit_field_); } |
| + void set_is_resolved() { |
| + bit_field_ = IsResolvedField::update(bit_field_, true); |
| + } |
| Interface* interface() const { return interface_; } |
| @@ -1727,9 +1740,10 @@ class VariableProxy FINAL : public Expression { |
| VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| Interface* interface, int position); |
| - bool is_this_ : 1; |
| - bool is_assigned_ : 1; |
| - bool is_resolved_ : 1; |
| + class IsThisField : public BitField<bool, 0, 1> {}; |
| + class IsAssignedField : public BitField<bool, 1, 1> {}; |
| + class IsResolvedField : public BitField<bool, 2, 1> {}; |
| + uint32_t bit_field_; |
| FeedbackVectorICSlot variable_feedback_slot_; |
| union { |
| const AstRawString* raw_name_; // if !is_resolved_ |
| @@ -1752,7 +1766,9 @@ class Property FINAL : public Expression { |
| BailoutId LoadId() const { return BailoutId(local_id(0)); } |
| TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); } |
| - bool IsStringAccess() const { return is_string_access_; } |
| + bool IsStringAccess() const { |
| + return IsStringAccessField::decode(bit_field_); |
| + } |
| // Type feedback information. |
| virtual bool IsMonomorphic() OVERRIDE { |
| @@ -1761,21 +1777,29 @@ class Property FINAL : public Expression { |
| virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| return &receiver_types_; |
| } |
| - virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| + virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
| return STANDARD_STORE; |
| } |
| - virtual IcCheckType GetKeyType() OVERRIDE { |
| + virtual IcCheckType GetKeyType() const OVERRIDE { |
| // PROPERTY key types currently aren't implemented for KeyedLoadICs. |
| return ELEMENT; |
| } |
| - bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; } |
| - bool HasNoTypeInformation() { |
| - return is_uninitialized_; |
| + bool IsUninitialized() const { |
| + return !is_for_call() && HasNoTypeInformation(); |
| + } |
| + bool HasNoTypeInformation() const { |
| + return IsUninitializedField::decode(bit_field_); |
| + } |
| + void set_is_uninitialized(bool b) { |
| + bit_field_ = IsUninitializedField::update(bit_field_, b); |
| + } |
| + void set_is_string_access(bool b) { |
| + bit_field_ = IsStringAccessField::update(bit_field_, b); |
| } |
| - void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| - void set_is_string_access(bool b) { is_string_access_ = b; } |
| - void mark_for_call() { is_for_call_ = true; } |
| - bool IsForCall() { return is_for_call_; } |
| + void mark_for_call() { |
| + bit_field_ = IsForCallField::update(bit_field_, true); |
| + } |
| + bool is_for_call() const { return IsForCallField::decode(bit_field_); } |
| bool IsSuperAccess() { |
| return obj()->IsSuperReference(); |
| @@ -1795,9 +1819,9 @@ class Property FINAL : public Expression { |
| protected: |
| Property(Zone* zone, Expression* obj, Expression* key, int pos) |
| : Expression(zone, pos), |
| - is_for_call_(false), |
| - is_uninitialized_(false), |
| - is_string_access_(false), |
| + bit_field_(IsForCallField::encode(false) | |
| + IsUninitializedField::encode(false) | |
| + IsStringAccessField::encode(false)), |
| property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
| obj_(obj), |
| key_(key) {} |
| @@ -1806,9 +1830,10 @@ class Property FINAL : public Expression { |
| private: |
| int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| - bool is_for_call_ : 1; |
| - bool is_uninitialized_ : 1; |
| - bool is_string_access_ : 1; |
| + class IsForCallField : public BitField<bool, 0, 1> {}; |
| + class IsUninitializedField : public BitField<bool, 1, 1> {}; |
| + class IsStringAccessField : public BitField<bool, 2, 1> {}; |
| + uint32_t bit_field_; |
| FeedbackVectorICSlot property_feedback_slot_; |
| Expression* obj_; |
| Expression* key_; |
| @@ -2120,8 +2145,8 @@ class CountOperation FINAL : public Expression { |
| public: |
| DECLARE_NODE_TYPE(CountOperation) |
| - bool is_prefix() const { return is_prefix_; } |
| - bool is_postfix() const { return !is_prefix_; } |
| + bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
| + bool is_postfix() const { return !is_prefix(); } |
| Token::Value op() const { return op_; } |
| Token::Value binary_op() { |
| @@ -2136,13 +2161,19 @@ class CountOperation FINAL : public Expression { |
| virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| return &receiver_types_; |
| } |
| - virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } |
| - virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| - return store_mode_; |
| + virtual IcCheckType GetKeyType() const OVERRIDE { |
| + return KeyTypeField::decode(bit_field_); |
| + } |
| + virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
| + return StoreModeField::decode(bit_field_); |
| } |
| Type* type() const { return type_; } |
| - void set_key_type(IcCheckType type) { key_type_ = type; } |
| - void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| + void set_key_type(IcCheckType type) { |
| + bit_field_ = KeyTypeField::update(bit_field_, type); |
| + } |
| + void set_store_mode(KeyedAccessStoreMode mode) { |
| + bit_field_ = StoreModeField::update(bit_field_, mode); |
| + } |
| void set_type(Type* type) { type_ = type; } |
| static int num_ids() { return parent_num_ids() + 3; } |
| @@ -2159,20 +2190,22 @@ class CountOperation FINAL : public Expression { |
| int pos) |
| : Expression(zone, pos), |
| op_(op), |
| - is_prefix_(is_prefix), |
| - key_type_(ELEMENT), |
| - store_mode_(STANDARD_STORE), |
| + bit_field_(IsPrefixField::encode(is_prefix) | |
| + KeyTypeField::encode(ELEMENT) | |
| + StoreModeField::encode(STANDARD_STORE)), |
| + type_(NULL), |
| expression_(expr) {} |
| static int parent_num_ids() { return Expression::num_ids(); } |
| private: |
| int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| + class IsPrefixField : public BitField<bool, 0, 1> {}; |
| + class KeyTypeField : public BitField<IcCheckType, 1, 1> {}; |
| + class StoreModeField : public BitField<KeyedAccessStoreMode, 2, 4> {}; |
| + |
| Token::Value op_; |
| - bool is_prefix_ : 1; |
| - IcCheckType key_type_ : 1; |
| - KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| - // must have extra bit. |
| + uint32_t bit_field_; |
| Type* type_; |
| Expression* expression_; |
| SmallMapList receiver_types_; |
| @@ -2277,20 +2310,30 @@ class Assignment FINAL : public Expression { |
| virtual bool IsMonomorphic() OVERRIDE { |
| return receiver_types_.length() == 1; |
| } |
| - bool IsUninitialized() { return is_uninitialized_; } |
| + bool IsUninitialized() const { |
| + return IsUninitializedField::decode(bit_field_); |
| + } |
| bool HasNoTypeInformation() { |
| - return is_uninitialized_; |
| + return IsUninitializedField::decode(bit_field_); |
| } |
| virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| return &receiver_types_; |
| } |
| - virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } |
| - virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
| - return store_mode_; |
| + virtual IcCheckType GetKeyType() const OVERRIDE { |
| + return KeyTypeField::decode(bit_field_); |
| + } |
| + virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
| + return StoreModeField::decode(bit_field_); |
| + } |
| + void set_is_uninitialized(bool b) { |
| + bit_field_ = IsUninitializedField::update(bit_field_, b); |
| + } |
| + void set_key_type(IcCheckType key_type) { |
| + bit_field_ = KeyTypeField::update(bit_field_, key_type); |
| + } |
| + void set_store_mode(KeyedAccessStoreMode mode) { |
| + bit_field_ = StoreModeField::update(bit_field_, mode); |
| } |
| - void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| - void set_key_type(IcCheckType key_type) { key_type_ = key_type; } |
| - void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| protected: |
| Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
| @@ -2309,10 +2352,10 @@ class Assignment FINAL : public Expression { |
| private: |
| int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| - bool is_uninitialized_ : 1; |
| - IcCheckType key_type_ : 1; |
| - KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| - // must have extra bit. |
| + class IsUninitializedField : public BitField<bool, 0, 1> {}; |
| + class KeyTypeField : public BitField<IcCheckType, 1, 1> {}; |
| + class StoreModeField : public BitField<KeyedAccessStoreMode, 2, 4> {}; |
| + uint32_t bit_field_; |
| Token::Value op_; |
| Expression* target_; |
| Expression* value_; |