OLD | NEW |
---|---|
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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 Handle<Map> GetReceiverType() { return receiver_type_; } | 1392 Handle<Map> GetReceiverType() { return receiver_type_; } |
1393 | 1393 |
1394 bool IsCompileTimeValue(); | 1394 bool IsCompileTimeValue(); |
1395 | 1395 |
1396 void set_emit_store(bool emit_store); | 1396 void set_emit_store(bool emit_store); |
1397 bool emit_store(); | 1397 bool emit_store(); |
1398 | 1398 |
1399 bool is_static() const { return is_static_; } | 1399 bool is_static() const { return is_static_; } |
1400 bool is_computed_name() const { return is_computed_name_; } | 1400 bool is_computed_name() const { return is_computed_name_; } |
1401 | 1401 |
1402 FeedbackVectorICSlot GetSlot(int offset = 0) const { | |
1403 DCHECK(!FLAG_vector_stores || (offset < ic_slot_count_)); | |
1404 if (ic_slot_.IsInvalid()) return ic_slot_; | |
1405 return FeedbackVectorICSlot(ic_slot_.ToInt() + offset); | |
1406 } | |
1407 | |
1408 int ic_slot_count() const { return ic_slot_count_; } | |
1409 | |
1402 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } | 1410 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } |
1411 void set_ic_slot_count(int count) { ic_slot_count_ = count; } | |
1412 | |
1413 void set_base_slot(int slot) { ic_slot_ = FeedbackVectorICSlot(slot); } | |
1403 | 1414 |
1404 protected: | 1415 protected: |
1405 friend class AstNodeFactory; | 1416 friend class AstNodeFactory; |
1406 | 1417 |
1407 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, | 1418 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, |
1408 bool is_static, bool is_computed_name); | 1419 bool is_static, bool is_computed_name); |
1409 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, | 1420 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, |
1410 Expression* value, bool is_static, | 1421 Expression* value, bool is_static, |
1411 bool is_computed_name); | 1422 bool is_computed_name); |
1412 | 1423 |
1413 private: | 1424 private: |
1414 Expression* key_; | 1425 Expression* key_; |
1415 Expression* value_; | 1426 Expression* value_; |
1416 Kind kind_; | 1427 Kind kind_; |
1428 FeedbackVectorICSlot ic_slot_; | |
1429 int ic_slot_count_; | |
Michael Starzinger
2015/09/07 08:31:13
As discussed offline, please move these fields eit
mvstanton
2015/09/07 13:36:09
Excellent. I've reduced the two new words to one,
| |
1417 bool emit_store_; | 1430 bool emit_store_; |
1418 bool is_static_; | 1431 bool is_static_; |
1419 bool is_computed_name_; | 1432 bool is_computed_name_; |
1420 Handle<Map> receiver_type_; | 1433 Handle<Map> receiver_type_; |
1421 }; | 1434 }; |
1422 | 1435 |
1423 | 1436 |
1424 // An object literal has a boilerplate object that is used | 1437 // An object literal has a boilerplate object that is used |
1425 // for minimizing the work when constructing it at runtime. | 1438 // for minimizing the work when constructing it at runtime. |
1426 class ObjectLiteral final : public MaterializedLiteral { | 1439 class ObjectLiteral final : public MaterializedLiteral { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1470 kNoFlags = 0, | 1483 kNoFlags = 0, |
1471 kFastElements = 1, | 1484 kFastElements = 1, |
1472 kHasFunction = 1 << 1, | 1485 kHasFunction = 1 << 1, |
1473 kShallowProperties = 1 << 2, | 1486 kShallowProperties = 1 << 2, |
1474 kDisableMementos = 1 << 3, | 1487 kDisableMementos = 1 << 3, |
1475 kIsStrong = 1 << 4 | 1488 kIsStrong = 1 << 4 |
1476 }; | 1489 }; |
1477 | 1490 |
1478 struct Accessors: public ZoneObject { | 1491 struct Accessors: public ZoneObject { |
1479 Accessors() : getter(NULL), setter(NULL) {} | 1492 Accessors() : getter(NULL), setter(NULL) {} |
1480 Expression* getter; | 1493 // Expression* getter; |
Michael Starzinger
2015/09/07 08:31:13
nit: Looks like a left-over.
| |
1481 Expression* setter; | 1494 // Expression* setter; |
1495 ObjectLiteralProperty* getter; | |
1496 ObjectLiteralProperty* setter; | |
1482 }; | 1497 }; |
1483 | 1498 |
1484 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } | 1499 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } |
1485 | 1500 |
1486 // Return an AST id for a property that is used in simulate instructions. | 1501 // Return an AST id for a property that is used in simulate instructions. |
1487 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } | 1502 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } |
1488 | 1503 |
1489 // Unlike other AST nodes, this number of bailout IDs allocated for an | 1504 // Unlike other AST nodes, this number of bailout IDs allocated for an |
1490 // ObjectLiteral can vary, so num_ids() is not a static method. | 1505 // ObjectLiteral can vary, so num_ids() is not a static method. |
1491 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } | 1506 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } |
1492 | 1507 |
1493 // Object literals need one feedback slot for each non-trivial value, as well | 1508 // Object literals need one feedback slot for each non-trivial value, as well |
1494 // as some slots for home objects. | 1509 // as some slots for home objects. |
1495 FeedbackVectorRequirements ComputeFeedbackRequirements( | 1510 FeedbackVectorRequirements ComputeFeedbackRequirements( |
1496 Isolate* isolate, const ICSlotCache* cache) override; | 1511 Isolate* isolate, const ICSlotCache* cache) override; |
1497 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | 1512 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
1498 ICSlotCache* cache) override { | 1513 ICSlotCache* cache) override { |
1499 slot_ = slot; | 1514 slot_ = slot; |
1500 } | 1515 } |
1501 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } | 1516 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } |
1502 FeedbackVectorICSlot GetNthSlot(int n) const { | |
1503 return FeedbackVectorICSlot(slot_.ToInt() + n); | |
1504 } | |
1505 | 1517 |
1506 // If value needs a home object, returns a valid feedback vector ic slot | 1518 // After feedback slots were assigned, propagate information to the properties |
1507 // given by slot_index, and increments slot_index. | 1519 // which need it. |
1508 FeedbackVectorICSlot SlotForHomeObject(Expression* value, | 1520 void LayoutFeedbackSlots(); |
1509 int* slot_index) const; | |
1510 | |
1511 #ifdef DEBUG | |
1512 int slot_count() const { return slot_count_; } | |
1513 #endif | |
1514 | 1521 |
1515 protected: | 1522 protected: |
1516 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1523 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
1517 int boilerplate_properties, bool has_function, bool is_strong, | 1524 int boilerplate_properties, bool has_function, bool is_strong, |
1518 int pos) | 1525 int pos) |
1519 : MaterializedLiteral(zone, literal_index, is_strong, pos), | 1526 : MaterializedLiteral(zone, literal_index, is_strong, pos), |
1520 properties_(properties), | 1527 properties_(properties), |
1521 boilerplate_properties_(boilerplate_properties), | 1528 boilerplate_properties_(boilerplate_properties), |
1522 fast_elements_(false), | 1529 fast_elements_(false), |
1523 has_elements_(false), | 1530 has_elements_(false), |
1524 may_store_doubles_(false), | 1531 may_store_doubles_(false), |
1525 has_function_(has_function), | 1532 has_function_(has_function), |
1526 #ifdef DEBUG | |
1527 slot_count_(0), | |
1528 #endif | |
1529 slot_(FeedbackVectorICSlot::Invalid()) { | 1533 slot_(FeedbackVectorICSlot::Invalid()) { |
1530 } | 1534 } |
1531 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1535 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1532 | 1536 |
1533 private: | 1537 private: |
1534 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1538 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1535 Handle<FixedArray> constant_properties_; | 1539 Handle<FixedArray> constant_properties_; |
1536 ZoneList<Property*>* properties_; | 1540 ZoneList<Property*>* properties_; |
1537 int boilerplate_properties_; | 1541 int boilerplate_properties_; |
1538 bool fast_elements_; | 1542 bool fast_elements_; |
1539 bool has_elements_; | 1543 bool has_elements_; |
1540 bool may_store_doubles_; | 1544 bool may_store_doubles_; |
1541 bool has_function_; | 1545 bool has_function_; |
1542 #ifdef DEBUG | |
1543 // slot_count_ helps validate that the logic to allocate ic slots and the | |
1544 // logic to use them are in sync. | |
1545 int slot_count_; | |
1546 #endif | |
1547 FeedbackVectorICSlot slot_; | 1546 FeedbackVectorICSlot slot_; |
1548 }; | 1547 }; |
1549 | 1548 |
1550 | 1549 |
1551 // Node for capturing a regexp literal. | 1550 // Node for capturing a regexp literal. |
1552 class RegExpLiteral final : public MaterializedLiteral { | 1551 class RegExpLiteral final : public MaterializedLiteral { |
1553 public: | 1552 public: |
1554 DECLARE_NODE_TYPE(RegExpLiteral) | 1553 DECLARE_NODE_TYPE(RegExpLiteral) |
1555 | 1554 |
1556 Handle<String> pattern() const { return pattern_->string(); } | 1555 Handle<String> pattern() const { return pattern_->string(); } |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2707 | 2706 |
2708 // Object literals need one feedback slot for each non-trivial value, as well | 2707 // Object literals need one feedback slot for each non-trivial value, as well |
2709 // as some slots for home objects. | 2708 // as some slots for home objects. |
2710 FeedbackVectorRequirements ComputeFeedbackRequirements( | 2709 FeedbackVectorRequirements ComputeFeedbackRequirements( |
2711 Isolate* isolate, const ICSlotCache* cache) override; | 2710 Isolate* isolate, const ICSlotCache* cache) override; |
2712 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | 2711 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
2713 ICSlotCache* cache) override { | 2712 ICSlotCache* cache) override { |
2714 slot_ = slot; | 2713 slot_ = slot; |
2715 } | 2714 } |
2716 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } | 2715 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } |
2717 FeedbackVectorICSlot GetNthSlot(int n) const { | 2716 |
2718 return FeedbackVectorICSlot(slot_.ToInt() + n); | 2717 bool NeedsProxySlot() const { |
2718 return FLAG_vector_stores && scope() != NULL && | |
2719 class_variable_proxy()->var()->IsUnallocated(); | |
2719 } | 2720 } |
2720 | 2721 |
2721 // If value needs a home object, returns a valid feedback vector ic slot | 2722 FeedbackVectorICSlot ProxySlot() const { return slot_; } |
2722 // given by slot_index, and increments slot_index. | |
2723 FeedbackVectorICSlot SlotForHomeObject(Expression* value, | |
2724 int* slot_index) const; | |
2725 | 2723 |
2726 #ifdef DEBUG | 2724 // After feedback slots were assigned, propagate information to the properties |
2727 int slot_count() const { return slot_count_; } | 2725 // which need it. |
2728 #endif | 2726 void LayoutFeedbackSlots(); |
2729 | 2727 |
2730 protected: | 2728 protected: |
2731 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, | 2729 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, |
2732 VariableProxy* class_variable_proxy, Expression* extends, | 2730 VariableProxy* class_variable_proxy, Expression* extends, |
2733 FunctionLiteral* constructor, ZoneList<Property*>* properties, | 2731 FunctionLiteral* constructor, ZoneList<Property*>* properties, |
2734 int start_position, int end_position) | 2732 int start_position, int end_position) |
2735 : Expression(zone, start_position), | 2733 : Expression(zone, start_position), |
2736 raw_name_(name), | 2734 raw_name_(name), |
2737 scope_(scope), | 2735 scope_(scope), |
2738 class_variable_proxy_(class_variable_proxy), | 2736 class_variable_proxy_(class_variable_proxy), |
2739 extends_(extends), | 2737 extends_(extends), |
2740 constructor_(constructor), | 2738 constructor_(constructor), |
2741 properties_(properties), | 2739 properties_(properties), |
2742 end_position_(end_position), | 2740 end_position_(end_position), |
2743 #ifdef DEBUG | |
2744 slot_count_(0), | |
2745 #endif | |
2746 slot_(FeedbackVectorICSlot::Invalid()) { | 2741 slot_(FeedbackVectorICSlot::Invalid()) { |
2747 } | 2742 } |
2748 | 2743 |
2749 static int parent_num_ids() { return Expression::num_ids(); } | 2744 static int parent_num_ids() { return Expression::num_ids(); } |
2750 | 2745 |
2751 private: | 2746 private: |
2752 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2747 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2753 | 2748 |
2754 const AstRawString* raw_name_; | 2749 const AstRawString* raw_name_; |
2755 Scope* scope_; | 2750 Scope* scope_; |
2756 VariableProxy* class_variable_proxy_; | 2751 VariableProxy* class_variable_proxy_; |
2757 Expression* extends_; | 2752 Expression* extends_; |
2758 FunctionLiteral* constructor_; | 2753 FunctionLiteral* constructor_; |
2759 ZoneList<Property*>* properties_; | 2754 ZoneList<Property*>* properties_; |
2760 int end_position_; | 2755 int end_position_; |
2761 #ifdef DEBUG | |
2762 // slot_count_ helps validate that the logic to allocate ic slots and the | |
2763 // logic to use them are in sync. | |
2764 int slot_count_; | |
2765 #endif | |
2766 FeedbackVectorICSlot slot_; | 2756 FeedbackVectorICSlot slot_; |
2767 }; | 2757 }; |
2768 | 2758 |
2769 | 2759 |
2770 class NativeFunctionLiteral final : public Expression { | 2760 class NativeFunctionLiteral final : public Expression { |
2771 public: | 2761 public: |
2772 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2762 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
2773 | 2763 |
2774 Handle<String> name() const { return name_->string(); } | 2764 Handle<String> name() const { return name_->string(); } |
2775 v8::Extension* extension() const { return extension_; } | 2765 v8::Extension* extension() const { return extension_; } |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3654 | 3644 |
3655 private: | 3645 private: |
3656 Zone* zone_; | 3646 Zone* zone_; |
3657 AstValueFactory* ast_value_factory_; | 3647 AstValueFactory* ast_value_factory_; |
3658 }; | 3648 }; |
3659 | 3649 |
3660 | 3650 |
3661 } } // namespace v8::internal | 3651 } } // namespace v8::internal |
3662 | 3652 |
3663 #endif // V8_AST_H_ | 3653 #endif // V8_AST_H_ |
OLD | NEW |