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

Unified Diff: src/ast/variables.h

Issue 2253513002: Better pack fields in Variable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | src/ast/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/variables.h
diff --git a/src/ast/variables.h b/src/ast/variables.h
index e1ac44616e85e01de42025a18e754fabda9f373a..bacecc3ec87d14068cddaa0797d687d0e4805367 100644
--- a/src/ast/variables.h
+++ b/src/ast/variables.h
@@ -17,7 +17,13 @@ namespace internal {
// after binding and variable allocation.
class Variable final : public ZoneObject {
public:
- enum Kind { NORMAL, FUNCTION, THIS, ARGUMENTS };
+ enum Kind : uint8_t {
+ NORMAL,
+ FUNCTION,
+ THIS,
+ ARGUMENTS,
+ kLastKind = ARGUMENTS
+ };
Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind,
InitializationFlag initialization_flag,
@@ -105,23 +111,27 @@ class Variable final : public ZoneObject {
private:
Scope* scope_;
const AstRawString* name_;
- VariableMode mode_;
- Kind kind_;
- VariableLocation location_;
- int index_;
- int initializer_position_;
-
// If this field is set, this variable references the stored locally bound
// variable, but it might be shadowed by variable bindings introduced by
// sloppy 'eval' calls between the reference scope (inclusive) and the
// binding scope (exclusive).
Variable* local_if_not_shadowed_;
+ int index_;
+ int initializer_position_;
+
+ STATIC_ASSERT(kLastVariableMode < (1 << 3));
+ VariableMode mode_ : 3;
+ STATIC_ASSERT(kLastKind < (1 << 2));
+ Kind kind_ : 2;
+ STATIC_ASSERT(static_cast<uint8_t>(VariableLocation::kLastVariableLocation) <
+ (1 << 3));
+ VariableLocation location_ : 3;
// Usage info.
- bool force_context_allocation_; // set by variable resolver
- bool is_used_;
- InitializationFlag initialization_flag_;
- MaybeAssignedFlag maybe_assigned_;
+ bool force_context_allocation_ : 1; // set by variable resolver
+ bool is_used_ : 1;
+ InitializationFlag initialization_flag_ : 2;
+ MaybeAssignedFlag maybe_assigned_ : 2;
};
} // namespace internal
} // namespace v8
« no previous file with comments | « no previous file | src/ast/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698