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

Side by Side Diff: src/ast/ast.h

Issue 2248813002: [ast] Clean up a few unnecessary bits in AST (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 unified diff | Download patch
« no previous file with comments | « no previous file | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/ast/modules.h" 9 #include "src/ast/modules.h"
10 #include "src/ast/variables.h" 10 #include "src/ast/variables.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 protected: 214 protected:
215 AstNode(int position, NodeType type) 215 AstNode(int position, NodeType type)
216 : position_(position), node_type_(type) {} 216 : position_(position), node_type_(type) {}
217 217
218 private: 218 private:
219 // Hidden to prevent accidental usage. It would have to load the 219 // Hidden to prevent accidental usage. It would have to load the
220 // current zone from the TLS. 220 // current zone from the TLS.
221 void* operator new(size_t size); 221 void* operator new(size_t size);
222 222
223 friend class CaseClause; // Generates AST IDs.
224
225 int position_; 223 int position_;
226 NodeType node_type_; 224 NodeType node_type_;
227 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin 225 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin
228 // sub-int32_t-sized fields for optimum packing efficiency. 226 // sub-int32_t-sized fields for optimum packing efficiency.
229 }; 227 };
230 228
231 229
232 class Statement : public AstNode { 230 class Statement : public AstNode {
233 public: 231 public:
234 bool IsEmpty() { return AsEmptyStatement() != NULL; } 232 bool IsEmpty() { return AsEmptyStatement() != NULL; }
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 ZoneList<Expression*>* values_; 1571 ZoneList<Expression*>* values_;
1574 }; 1572 };
1575 1573
1576 1574
1577 class VariableProxy final : public Expression { 1575 class VariableProxy final : public Expression {
1578 public: 1576 public:
1579 bool IsValidReferenceExpression() const { 1577 bool IsValidReferenceExpression() const {
1580 return !is_this() && !is_new_target(); 1578 return !is_this() && !is_new_target();
1581 } 1579 }
1582 1580
1583 bool IsArguments() const { return is_resolved() && var()->is_arguments(); }
1584
1585 Handle<String> name() const { return raw_name()->string(); } 1581 Handle<String> name() const { return raw_name()->string(); }
1586 const AstRawString* raw_name() const { 1582 const AstRawString* raw_name() const {
1587 return is_resolved() ? var_->raw_name() : raw_name_; 1583 return is_resolved() ? var_->raw_name() : raw_name_;
1588 } 1584 }
1589 1585
1590 Variable* var() const { 1586 Variable* var() const {
1591 DCHECK(is_resolved()); 1587 DCHECK(is_resolved());
1592 return var_; 1588 return var_;
1593 } 1589 }
1594 void set_var(Variable* v) { 1590 void set_var(Variable* v) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 VariableProxy(Zone* zone, const VariableProxy* copy_from); 1640 VariableProxy(Zone* zone, const VariableProxy* copy_from);
1645 1641
1646 static int parent_num_ids() { return Expression::num_ids(); } 1642 static int parent_num_ids() { return Expression::num_ids(); }
1647 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1643 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1648 1644
1649 class IsThisField : public BitField8<bool, 0, 1> {}; 1645 class IsThisField : public BitField8<bool, 0, 1> {};
1650 class IsAssignedField : public BitField8<bool, 1, 1> {}; 1646 class IsAssignedField : public BitField8<bool, 1, 1> {};
1651 class IsResolvedField : public BitField8<bool, 2, 1> {}; 1647 class IsResolvedField : public BitField8<bool, 2, 1> {};
1652 class IsNewTargetField : public BitField8<bool, 3, 1> {}; 1648 class IsNewTargetField : public BitField8<bool, 3, 1> {};
1653 1649
1654 // Start with 16-bit (or smaller) field, which should get packed together
1655 // with Expression's trailing 16-bit field.
1656 uint8_t bit_field_; 1650 uint8_t bit_field_;
1657 // Position is stored in the AstNode superclass, but VariableProxy needs to 1651 // Position is stored in the AstNode superclass, but VariableProxy needs to
1658 // know its end position too (for error messages). It cannot be inferred from 1652 // know its end position too (for error messages). It cannot be inferred from
1659 // the variable name length because it can contain escapes. 1653 // the variable name length because it can contain escapes.
1660 int end_position_; 1654 int end_position_;
1661 FeedbackVectorSlot variable_feedback_slot_; 1655 FeedbackVectorSlot variable_feedback_slot_;
1662 union { 1656 union {
1663 const AstRawString* raw_name_; // if !is_resolved_ 1657 const AstRawString* raw_name_; // if !is_resolved_
1664 Variable* var_; // if is_resolved_ 1658 Variable* var_; // if is_resolved_
1665 }; 1659 };
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after
3478 : NULL; \ 3472 : NULL; \
3479 } 3473 }
3480 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3474 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3481 #undef DECLARE_NODE_FUNCTIONS 3475 #undef DECLARE_NODE_FUNCTIONS
3482 3476
3483 3477
3484 } // namespace internal 3478 } // namespace internal
3485 } // namespace v8 3479 } // namespace v8
3486 3480
3487 #endif // V8_AST_AST_H_ 3481 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698