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

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

Issue 2225423002: Make the AstValueFactory more efficient and less memory hungry (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove HandleDereferenceMode from IsPropertyName 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/ast/ast.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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // True iff the expression is a valid reference expression. 307 // True iff the expression is a valid reference expression.
308 bool IsValidReferenceExpression() const; 308 bool IsValidReferenceExpression() const;
309 309
310 // Helpers for ToBoolean conversion. 310 // Helpers for ToBoolean conversion.
311 bool ToBooleanIsTrue() const; 311 bool ToBooleanIsTrue() const;
312 bool ToBooleanIsFalse() const; 312 bool ToBooleanIsFalse() const;
313 313
314 // Symbols that cannot be parsed as array indices are considered property 314 // Symbols that cannot be parsed as array indices are considered property
315 // names. We do not treat symbols that can be array indexes as property 315 // names. We do not treat symbols that can be array indexes as property
316 // names because [] for string objects is handled only by keyed ICs. 316 // names because [] for string objects is handled only by keyed ICs.
317 // Produces the same result whether |deref_mode| is kAllowed or kDisallowed, 317 bool IsPropertyName() const;
318 // although may be faster with kAllowed.
319 bool IsPropertyName(
320 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const;
321 318
322 // True iff the expression is a class or function expression without 319 // True iff the expression is a class or function expression without
323 // a syntactic name. 320 // a syntactic name.
324 bool IsAnonymousFunctionDefinition() const; 321 bool IsAnonymousFunctionDefinition() const;
325 322
326 // True iff the expression is a literal represented as a smi. 323 // True iff the expression is a literal represented as a smi.
327 bool IsSmiLiteral() const; 324 bool IsSmiLiteral() const;
328 325
329 // True iff the expression is a string literal. 326 // True iff the expression is a string literal.
330 bool IsStringLiteral() const; 327 bool IsStringLiteral() const;
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 Statement* statement_; 1187 Statement* statement_;
1191 Scope* const scope_; 1188 Scope* const scope_;
1192 SloppyBlockFunctionStatement* next_; 1189 SloppyBlockFunctionStatement* next_;
1193 }; 1190 };
1194 1191
1195 1192
1196 class Literal final : public Expression { 1193 class Literal final : public Expression {
1197 public: 1194 public:
1198 // Returns true if literal represents a property name (i.e. cannot be parsed 1195 // Returns true if literal represents a property name (i.e. cannot be parsed
1199 // as array indices). Produces the same result whether |deref_mode| is 1196 // as array indices). Produces the same result whether |deref_mode| is
1200 // kAllowed or kDisallowed, although may be faster with kAllowed. 1197 // kAllowed or kDisallowed, although may be faster with kAllowed.
rmcilroy 2016/08/10 11:12:57 Could you update the comment here please.
1201 bool IsPropertyName(HandleDereferenceMode deref_mode = 1198 bool IsPropertyName() const { return value_->IsPropertyName(); }
1202 HandleDereferenceMode::kAllowed) const {
1203 return value_->IsPropertyName(deref_mode);
1204 }
1205 1199
1206 Handle<String> AsPropertyName() { 1200 Handle<String> AsPropertyName() {
1207 DCHECK(IsPropertyName(HandleDereferenceMode::kDisallowed)); 1201 DCHECK(IsPropertyName());
1208 return Handle<String>::cast(value()); 1202 return Handle<String>::cast(value());
1209 } 1203 }
1210 1204
1211 const AstRawString* AsRawPropertyName() { 1205 const AstRawString* AsRawPropertyName() {
1212 DCHECK(IsPropertyName()); 1206 DCHECK(IsPropertyName());
1213 return value_->AsString(); 1207 return value_->AsString();
1214 } 1208 }
1215 1209
1216 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); } 1210 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); }
1217 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); } 1211 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 : FeedbackVectorSlotKind::KEYED_LOAD_IC; 1733 : FeedbackVectorSlotKind::KEYED_LOAD_IC;
1740 property_feedback_slot_ = spec->AddSlot(kind); 1734 property_feedback_slot_ = spec->AddSlot(kind);
1741 } 1735 }
1742 1736
1743 FeedbackVectorSlot PropertyFeedbackSlot() const { 1737 FeedbackVectorSlot PropertyFeedbackSlot() const {
1744 return property_feedback_slot_; 1738 return property_feedback_slot_;
1745 } 1739 }
1746 1740
1747 // Returns the properties assign type. Produces the same result whether 1741 // Returns the properties assign type. Produces the same result whether
1748 // |deref_mode| is kAllowed or kDisallowed, although may be faster with 1742 // |deref_mode| is kAllowed or kDisallowed, although may be faster with
1749 // kAllowed. 1743 // kAllowed.
rmcilroy 2016/08/10 11:12:57 Could you update the comment here please.
1750 static LhsKind GetAssignType( 1744 static LhsKind GetAssignType(
1751 Property* property, 1745 Property* property,
1752 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) { 1746 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) {
1753 if (property == NULL) return VARIABLE; 1747 if (property == NULL) return VARIABLE;
1754 bool super_access = property->IsSuperAccess(); 1748 bool super_access = property->IsSuperAccess();
1755 return (property->key()->IsPropertyName(deref_mode)) 1749 return (property->key()->IsPropertyName())
1756 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) 1750 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
1757 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); 1751 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY);
1758 } 1752 }
1759 1753
1760 private: 1754 private:
1761 friend class AstNodeFactory; 1755 friend class AstNodeFactory;
1762 1756
1763 Property(Zone* zone, Expression* obj, Expression* key, int pos) 1757 Property(Zone* zone, Expression* obj, Expression* key, int pos)
1764 : Expression(zone, pos, kProperty), 1758 : Expression(zone, pos, kProperty),
1765 bit_field_(IsForCallField::encode(false) | 1759 bit_field_(IsForCallField::encode(false) |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3486 : NULL; \ 3480 : NULL; \
3487 } 3481 }
3488 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3482 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3489 #undef DECLARE_NODE_FUNCTIONS 3483 #undef DECLARE_NODE_FUNCTIONS
3490 3484
3491 3485
3492 } // namespace internal 3486 } // namespace internal
3493 } // namespace v8 3487 } // namespace v8
3494 3488
3495 #endif // V8_AST_AST_H_ 3489 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698