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

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

Issue 2655853010: [TypeFeedbackVector] Combine the literals array and the feedback vector. (Closed)
Patch Set: gyp file Created 3 years, 10 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
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-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 1233
1234 Literal(const AstValue* value, int position) 1234 Literal(const AstValue* value, int position)
1235 : Expression(position, kLiteral), value_(value) {} 1235 : Expression(position, kLiteral), value_(value) {}
1236 1236
1237 static int parent_num_ids() { return Expression::num_ids(); } 1237 static int parent_num_ids() { return Expression::num_ids(); }
1238 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1238 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1239 1239
1240 const AstValue* value_; 1240 const AstValue* value_;
1241 }; 1241 };
1242 1242
1243
1244 class AstLiteralReindexer;
1245
1246 // Base class for literals that needs space in the corresponding JSFunction. 1243 // Base class for literals that needs space in the corresponding JSFunction.
Michael Starzinger 2017/01/30 11:16:44 nit: s/in the corresponding JSFunction/in the type
mvstanton 2017/01/30 11:57:04 Done.
1247 class MaterializedLiteral : public Expression { 1244 class MaterializedLiteral : public Expression {
1248 public: 1245 public:
1249 int literal_index() { return literal_index_; }
1250
1251 int depth() const { 1246 int depth() const {
1252 // only callable after initialization. 1247 // only callable after initialization.
1253 DCHECK(depth_ >= 1); 1248 DCHECK(depth_ >= 1);
1254 return depth_; 1249 return depth_;
1255 } 1250 }
1256 1251
1252 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
1253 FeedbackVectorSlotCache* cache) {
1254 literal_slot_ = spec->AddLiteralSlot();
1255 }
1256
1257 FeedbackVectorSlot literal_slot() const { return literal_slot_; }
1258
1257 private: 1259 private:
1258 int depth_ : 31; 1260 int depth_ : 31;
1259 int literal_index_; 1261 FeedbackVectorSlot literal_slot_;
1260
1261 friend class AstLiteralReindexer;
1262 1262
1263 class IsSimpleField 1263 class IsSimpleField
1264 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; 1264 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
1265 1265
1266 protected: 1266 protected:
1267 MaterializedLiteral(int literal_index, int pos, NodeType type) 1267 MaterializedLiteral(int pos, NodeType type)
1268 : Expression(pos, type), depth_(0), literal_index_(literal_index) { 1268 : Expression(pos, type), depth_(0) {
1269 bit_field_ |= IsSimpleField::encode(false); 1269 bit_field_ |= IsSimpleField::encode(false);
1270 } 1270 }
1271 1271
1272 // A materialized literal is simple if the values consist of only 1272 // A materialized literal is simple if the values consist of only
1273 // constants and simple object and array literals. 1273 // constants and simple object and array literals.
1274 bool is_simple() const { return IsSimpleField::decode(bit_field_); } 1274 bool is_simple() const { return IsSimpleField::decode(bit_field_); }
1275 void set_is_simple(bool is_simple) { 1275 void set_is_simple(bool is_simple) {
1276 bit_field_ = IsSimpleField::update(bit_field_, is_simple); 1276 bit_field_ = IsSimpleField::update(bit_field_, is_simple);
1277 } 1277 }
1278 friend class CompileTimeValue; 1278 friend class CompileTimeValue;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } 1464 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); }
1465 1465
1466 // Object literals need one feedback slot for each non-trivial value, as well 1466 // Object literals need one feedback slot for each non-trivial value, as well
1467 // as some slots for home objects. 1467 // as some slots for home objects.
1468 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, 1468 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
1469 FeedbackVectorSlotCache* cache); 1469 FeedbackVectorSlotCache* cache);
1470 1470
1471 private: 1471 private:
1472 friend class AstNodeFactory; 1472 friend class AstNodeFactory;
1473 1473
1474 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, 1474 ObjectLiteral(ZoneList<Property*>* properties,
1475 uint32_t boilerplate_properties, int pos, 1475 uint32_t boilerplate_properties, int pos,
1476 bool has_rest_property) 1476 bool has_rest_property)
1477 : MaterializedLiteral(literal_index, pos, kObjectLiteral), 1477 : MaterializedLiteral(pos, kObjectLiteral),
1478 boilerplate_properties_(boilerplate_properties), 1478 boilerplate_properties_(boilerplate_properties),
1479 properties_(properties) { 1479 properties_(properties) {
1480 bit_field_ |= FastElementsField::encode(false) | 1480 bit_field_ |= FastElementsField::encode(false) |
1481 HasElementsField::encode(false) | 1481 HasElementsField::encode(false) |
1482 MayStoreDoublesField::encode(false) | 1482 MayStoreDoublesField::encode(false) |
1483 HasRestPropertyField::encode(has_rest_property); 1483 HasRestPropertyField::encode(has_rest_property);
1484 } 1484 }
1485 1485
1486 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1486 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1487 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1487 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 Zone* zone_; 1523 Zone* zone_;
1524 }; 1524 };
1525 1525
1526 1526
1527 // Node for capturing a regexp literal. 1527 // Node for capturing a regexp literal.
1528 class RegExpLiteral final : public MaterializedLiteral { 1528 class RegExpLiteral final : public MaterializedLiteral {
1529 public: 1529 public:
1530 Handle<String> pattern() const { return pattern_->string(); } 1530 Handle<String> pattern() const { return pattern_->string(); }
1531 int flags() const { return flags_; } 1531 int flags() const { return flags_; }
1532 1532
1533 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
Michael Starzinger 2017/01/30 11:16:44 nit: Shouldn't this be the same as just using the
mvstanton 2017/01/30 11:57:04 Yep, thanks!
1534 FeedbackVectorSlotCache* cache) {
1535 MaterializedLiteral::AssignFeedbackVectorSlots(spec, cache);
1536 }
1537
1533 private: 1538 private:
1534 friend class AstNodeFactory; 1539 friend class AstNodeFactory;
1535 1540
1536 RegExpLiteral(const AstRawString* pattern, int flags, int literal_index, 1541 RegExpLiteral(const AstRawString* pattern, int flags, int pos)
1537 int pos) 1542 : MaterializedLiteral(pos, kRegExpLiteral),
1538 : MaterializedLiteral(literal_index, pos, kRegExpLiteral),
1539 flags_(flags), 1543 flags_(flags),
1540 pattern_(pattern) { 1544 pattern_(pattern) {
1541 set_depth(1); 1545 set_depth(1);
1542 } 1546 }
1543 1547
1544 int const flags_; 1548 int const flags_;
1545 const AstRawString* const pattern_; 1549 const AstRawString* const pattern_;
1546 }; 1550 };
1547 1551
1548 1552
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 kDisableMementos = 1 << 1 1617 kDisableMementos = 1 << 1
1614 }; 1618 };
1615 1619
1616 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, 1620 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec,
1617 FeedbackVectorSlotCache* cache); 1621 FeedbackVectorSlotCache* cache);
1618 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } 1622 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; }
1619 1623
1620 private: 1624 private:
1621 friend class AstNodeFactory; 1625 friend class AstNodeFactory;
1622 1626
1623 ArrayLiteral(ZoneList<Expression*>* values, int first_spread_index, 1627 ArrayLiteral(ZoneList<Expression*>* values, int first_spread_index, int pos)
1624 int literal_index, int pos) 1628 : MaterializedLiteral(pos, kArrayLiteral),
1625 : MaterializedLiteral(literal_index, pos, kArrayLiteral),
1626 first_spread_index_(first_spread_index), 1629 first_spread_index_(first_spread_index),
1627 values_(values) {} 1630 values_(values) {}
1628 1631
1629 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1632 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1630 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1633 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1631 1634
1632 int first_spread_index_; 1635 int first_spread_index_;
1633 FeedbackVectorSlot literal_slot_; 1636 FeedbackVectorSlot literal_slot_;
1634 Handle<ConstantElementsPair> constant_elements_; 1637 Handle<ConstantElementsPair> constant_elements_;
1635 ZoneList<Expression*>* values_; 1638 ZoneList<Expression*>* values_;
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 3330
3328 Literal* NewUndefinedLiteral(int pos) { 3331 Literal* NewUndefinedLiteral(int pos) {
3329 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos); 3332 return new (zone_) Literal(ast_value_factory_->NewUndefined(), pos);
3330 } 3333 }
3331 3334
3332 Literal* NewTheHoleLiteral(int pos) { 3335 Literal* NewTheHoleLiteral(int pos) {
3333 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos); 3336 return new (zone_) Literal(ast_value_factory_->NewTheHole(), pos);
3334 } 3337 }
3335 3338
3336 ObjectLiteral* NewObjectLiteral( 3339 ObjectLiteral* NewObjectLiteral(
3337 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, 3340 ZoneList<ObjectLiteral::Property*>* properties,
3338 uint32_t boilerplate_properties, int pos, bool has_rest_property) { 3341 uint32_t boilerplate_properties, int pos, bool has_rest_property) {
3339 return new (zone_) 3342 return new (zone_) ObjectLiteral(properties, boilerplate_properties, pos,
3340 ObjectLiteral(properties, literal_index, boilerplate_properties, pos, 3343 has_rest_property);
3341 has_rest_property);
3342 } 3344 }
3343 3345
3344 ObjectLiteral::Property* NewObjectLiteralProperty( 3346 ObjectLiteral::Property* NewObjectLiteralProperty(
3345 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, 3347 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
3346 bool is_computed_name) { 3348 bool is_computed_name) {
3347 return new (zone_) 3349 return new (zone_)
3348 ObjectLiteral::Property(key, value, kind, is_computed_name); 3350 ObjectLiteral::Property(key, value, kind, is_computed_name);
3349 } 3351 }
3350 3352
3351 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, 3353 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
3352 Expression* value, 3354 Expression* value,
3353 bool is_computed_name) { 3355 bool is_computed_name) {
3354 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value, 3356 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value,
3355 is_computed_name); 3357 is_computed_name);
3356 } 3358 }
3357 3359
3358 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags, 3360 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
3359 int literal_index, int pos) { 3361 int pos) {
3360 return new (zone_) RegExpLiteral(pattern, flags, literal_index, pos); 3362 return new (zone_) RegExpLiteral(pattern, flags, pos);
3361 } 3363 }
3362 3364
3363 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3365 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3364 int literal_index,
3365 int pos) { 3366 int pos) {
3366 return new (zone_) ArrayLiteral(values, -1, literal_index, pos); 3367 return new (zone_) ArrayLiteral(values, -1, pos);
3367 } 3368 }
3368 3369
3369 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, 3370 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
3370 int first_spread_index, int literal_index, 3371 int first_spread_index, int pos) {
3371 int pos) { 3372 return new (zone_) ArrayLiteral(values, first_spread_index, pos);
3372 return new (zone_)
3373 ArrayLiteral(values, first_spread_index, literal_index, pos);
3374 } 3373 }
3375 3374
3376 VariableProxy* NewVariableProxy(Variable* var, 3375 VariableProxy* NewVariableProxy(Variable* var,
3377 int start_position = kNoSourcePosition) { 3376 int start_position = kNoSourcePosition) {
3378 return new (zone_) VariableProxy(var, start_position); 3377 return new (zone_) VariableProxy(var, start_position);
3379 } 3378 }
3380 3379
3381 VariableProxy* NewVariableProxy(const AstRawString* name, 3380 VariableProxy* NewVariableProxy(const AstRawString* name,
3382 VariableKind variable_kind, 3381 VariableKind variable_kind,
3383 int start_position = kNoSourcePosition) { 3382 int start_position = kNoSourcePosition) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 : NULL; \ 3645 : NULL; \
3647 } 3646 }
3648 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3647 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3649 #undef DECLARE_NODE_FUNCTIONS 3648 #undef DECLARE_NODE_FUNCTIONS
3650 3649
3651 3650
3652 } // namespace internal 3651 } // namespace internal
3653 } // namespace v8 3652 } // namespace v8
3654 3653
3655 #endif // V8_AST_AST_H_ 3654 #endif // V8_AST_AST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698