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

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

Issue 2223523002: [Interpreter] Avoid dereferencing handles on BytecodeGenerator for AST operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_const_array
Patch Set: Rebase 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 | « src/api.cc ('k') | 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 bool IsPropertyName() const; 317 // Produces the same result whether |deref_mode| is kAllowed or kDisallowed,
318 // although may be faster with kAllowed.
319 bool IsPropertyName(
320 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const;
318 321
319 // True iff the expression is a class or function expression without 322 // True iff the expression is a class or function expression without
320 // a syntactic name. 323 // a syntactic name.
321 bool IsAnonymousFunctionDefinition() const; 324 bool IsAnonymousFunctionDefinition() const;
322 325
323 // True iff the expression is a literal represented as a smi. 326 // True iff the expression is a literal represented as a smi.
324 bool IsSmiLiteral() const; 327 bool IsSmiLiteral() const;
325 328
326 // True iff the expression is a string literal. 329 // True iff the expression is a string literal.
327 bool IsStringLiteral() const; 330 bool IsStringLiteral() const;
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 statement_(statement), 1199 statement_(statement),
1197 scope_(scope) {} 1200 scope_(scope) {}
1198 1201
1199 Statement* statement_; 1202 Statement* statement_;
1200 Scope* const scope_; 1203 Scope* const scope_;
1201 }; 1204 };
1202 1205
1203 1206
1204 class Literal final : public Expression { 1207 class Literal final : public Expression {
1205 public: 1208 public:
1206 bool IsPropertyName() const { return value_->IsPropertyName(); } 1209 // Returns true if literal represents a property name (i.e. cannot be parsed
1210 // as array indices). Produces the same result whether |deref_mode| is
1211 // kAllowed or kDisallowed, although may be faster with kAllowed.
1212 bool IsPropertyName(HandleDereferenceMode deref_mode =
1213 HandleDereferenceMode::kAllowed) const {
1214 return value_->IsPropertyName(deref_mode);
1215 }
1207 1216
1208 Handle<String> AsPropertyName() { 1217 Handle<String> AsPropertyName() {
1209 DCHECK(IsPropertyName()); 1218 DCHECK(IsPropertyName(HandleDereferenceMode::kDisallowed));
1210 return Handle<String>::cast(value()); 1219 return Handle<String>::cast(value());
1211 } 1220 }
1212 1221
1213 const AstRawString* AsRawPropertyName() { 1222 const AstRawString* AsRawPropertyName() {
1214 DCHECK(IsPropertyName()); 1223 DCHECK(IsPropertyName());
1215 return value_->AsString(); 1224 return value_->AsString();
1216 } 1225 }
1217 1226
1218 bool ToBooleanIsTrue() const { return value()->BooleanValue(); } 1227 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); }
1219 bool ToBooleanIsFalse() const { return !value()->BooleanValue(); } 1228 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); }
1220 1229
1221 Handle<Object> value() const { return value_->value(); } 1230 Handle<Object> value() const { return value_->value(); }
1222 const AstValue* raw_value() const { return value_; } 1231 const AstValue* raw_value() const { return value_; }
1223 1232
1224 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1233 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1225 // only for string and number literals! 1234 // only for string and number literals!
1226 uint32_t Hash(); 1235 uint32_t Hash();
1227 static bool Match(void* literal1, void* literal2); 1236 static bool Match(void* literal1, void* literal2);
1228 1237
1229 static int num_ids() { return parent_num_ids() + 1; } 1238 static int num_ids() { return parent_num_ids() + 1; }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1373
1365 // An object literal has a boilerplate object that is used 1374 // An object literal has a boilerplate object that is used
1366 // for minimizing the work when constructing it at runtime. 1375 // for minimizing the work when constructing it at runtime.
1367 class ObjectLiteral final : public MaterializedLiteral { 1376 class ObjectLiteral final : public MaterializedLiteral {
1368 public: 1377 public:
1369 typedef ObjectLiteralProperty Property; 1378 typedef ObjectLiteralProperty Property;
1370 1379
1371 Handle<FixedArray> constant_properties() const { 1380 Handle<FixedArray> constant_properties() const {
1372 return constant_properties_; 1381 return constant_properties_;
1373 } 1382 }
1374 int properties_count() const { return constant_properties_->length() / 2; } 1383 int properties_count() const { return boilerplate_properties_; }
1375 ZoneList<Property*>* properties() const { return properties_; } 1384 ZoneList<Property*>* properties() const { return properties_; }
1376 bool fast_elements() const { return fast_elements_; } 1385 bool fast_elements() const { return fast_elements_; }
1377 bool may_store_doubles() const { return may_store_doubles_; } 1386 bool may_store_doubles() const { return may_store_doubles_; }
1378 bool has_elements() const { return has_elements_; } 1387 bool has_elements() const { return has_elements_; }
1379 bool has_shallow_properties() const { 1388 bool has_shallow_properties() const {
1380 return depth() == 1 && !has_elements() && !may_store_doubles(); 1389 return depth() == 1 && !has_elements() && !may_store_doubles();
1381 } 1390 }
1382 1391
1383 // Decide if a property should be in the object boilerplate. 1392 // Decide if a property should be in the object boilerplate.
1384 static bool IsBoilerplateProperty(Property* property); 1393 static bool IsBoilerplateProperty(Property* property);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 FeedbackVectorSlotKind kind = key()->IsPropertyName() 1748 FeedbackVectorSlotKind kind = key()->IsPropertyName()
1740 ? FeedbackVectorSlotKind::LOAD_IC 1749 ? FeedbackVectorSlotKind::LOAD_IC
1741 : FeedbackVectorSlotKind::KEYED_LOAD_IC; 1750 : FeedbackVectorSlotKind::KEYED_LOAD_IC;
1742 property_feedback_slot_ = spec->AddSlot(kind); 1751 property_feedback_slot_ = spec->AddSlot(kind);
1743 } 1752 }
1744 1753
1745 FeedbackVectorSlot PropertyFeedbackSlot() const { 1754 FeedbackVectorSlot PropertyFeedbackSlot() const {
1746 return property_feedback_slot_; 1755 return property_feedback_slot_;
1747 } 1756 }
1748 1757
1749 static LhsKind GetAssignType(Property* property) { 1758 // Returns the properties assign type. Produces the same result whether
1759 // |deref_mode| is kAllowed or kDisallowed, although may be faster with
1760 // kAllowed.
1761 static LhsKind GetAssignType(
1762 Property* property,
1763 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) {
1750 if (property == NULL) return VARIABLE; 1764 if (property == NULL) return VARIABLE;
1751 bool super_access = property->IsSuperAccess(); 1765 bool super_access = property->IsSuperAccess();
1752 return (property->key()->IsPropertyName()) 1766 return (property->key()->IsPropertyName(deref_mode))
1753 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) 1767 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
1754 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); 1768 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY);
1755 } 1769 }
1756 1770
1757 private: 1771 private:
1758 friend class AstNodeFactory; 1772 friend class AstNodeFactory;
1759 1773
1760 Property(Zone* zone, Expression* obj, Expression* key, int pos) 1774 Property(Zone* zone, Expression* obj, Expression* key, int pos)
1761 : Expression(zone, pos, kProperty), 1775 : Expression(zone, pos, kProperty),
1762 bit_field_(IsForCallField::encode(false) | 1776 bit_field_(IsForCallField::encode(false) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 LOOKUP_SLOT_CALL, 1871 LOOKUP_SLOT_CALL,
1858 NAMED_PROPERTY_CALL, 1872 NAMED_PROPERTY_CALL,
1859 KEYED_PROPERTY_CALL, 1873 KEYED_PROPERTY_CALL,
1860 NAMED_SUPER_PROPERTY_CALL, 1874 NAMED_SUPER_PROPERTY_CALL,
1861 KEYED_SUPER_PROPERTY_CALL, 1875 KEYED_SUPER_PROPERTY_CALL,
1862 SUPER_CALL, 1876 SUPER_CALL,
1863 OTHER_CALL 1877 OTHER_CALL
1864 }; 1878 };
1865 1879
1866 // Helpers to determine how to handle the call. 1880 // Helpers to determine how to handle the call.
1867 CallType GetCallType(Isolate* isolate) const; 1881 // If called with |deref_mode| of kDisallowed, then the AST nodes must have
1868 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; 1882 // been internalized within a CanonicalHandleScope.
1869 bool IsUsingCallFeedbackICSlot(Isolate* isolate) const; 1883 CallType GetCallType(
1884 Isolate* isolate,
1885 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const;
1886 bool IsUsingCallFeedbackSlot(
1887 Isolate* isolate,
1888 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const;
1889 bool IsUsingCallFeedbackICSlot(
1890 Isolate* isolate,
1891 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const;
1870 1892
1871 #ifdef DEBUG 1893 #ifdef DEBUG
1872 // Used to assert that the FullCodeGenerator records the return site. 1894 // Used to assert that the FullCodeGenerator records the return site.
1873 bool return_is_recorded_; 1895 bool return_is_recorded_;
1874 #endif 1896 #endif
1875 1897
1876 private: 1898 private:
1877 friend class AstNodeFactory; 1899 friend class AstNodeFactory;
1878 1900
1879 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, 1901 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
3487 : NULL; \ 3509 : NULL; \
3488 } 3510 }
3489 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3511 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3490 #undef DECLARE_NODE_FUNCTIONS 3512 #undef DECLARE_NODE_FUNCTIONS
3491 3513
3492 3514
3493 } // namespace internal 3515 } // namespace internal
3494 } // namespace v8 3516 } // namespace v8
3495 3517
3496 #endif // V8_AST_AST_H_ 3518 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698