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

Side by Side Diff: src/ast.h

Issue 1321993004: Vector ICs: ObjectLiteral refactoring for Oracle feedback (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE, turned off flag. Created 5 years, 3 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.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_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
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 if (ic_slot_or_count_ == FeedbackVectorICSlot::Invalid().ToInt()) {
1404 return FeedbackVectorICSlot::Invalid();
1405 }
1406 return FeedbackVectorICSlot(ic_slot_or_count_ + offset);
1407 }
1408
1409 int ic_slot_count() const {
1410 if (ic_slot_or_count_ == FeedbackVectorICSlot::Invalid().ToInt()) {
1411 return 0;
1412 }
1413 return ic_slot_or_count_;
1414 }
1415
1402 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } 1416 void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
1417 void set_ic_slot_count(int count) {
1418 // Should only be called once.
1419 if (count == 0) {
1420 ic_slot_or_count_ = FeedbackVectorICSlot::Invalid().ToInt();
1421 } else {
1422 ic_slot_or_count_ = count;
1423 }
1424 }
1425
1426 int set_base_slot(int slot) {
1427 if (ic_slot_count() > 0) {
1428 int count = ic_slot_count();
1429 ic_slot_or_count_ = slot;
1430 return count;
1431 }
1432 return 0;
1433 }
1403 1434
1404 protected: 1435 protected:
1405 friend class AstNodeFactory; 1436 friend class AstNodeFactory;
1406 1437
1407 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind, 1438 ObjectLiteralProperty(Expression* key, Expression* value, Kind kind,
1408 bool is_static, bool is_computed_name); 1439 bool is_static, bool is_computed_name);
1409 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key, 1440 ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key,
1410 Expression* value, bool is_static, 1441 Expression* value, bool is_static,
1411 bool is_computed_name); 1442 bool is_computed_name);
1412 1443
1413 private: 1444 private:
1414 Expression* key_; 1445 Expression* key_;
1415 Expression* value_; 1446 Expression* value_;
1447 int ic_slot_or_count_;
1416 Kind kind_; 1448 Kind kind_;
1417 bool emit_store_; 1449 bool emit_store_;
1418 bool is_static_; 1450 bool is_static_;
1419 bool is_computed_name_; 1451 bool is_computed_name_;
1420 Handle<Map> receiver_type_; 1452 Handle<Map> receiver_type_;
1421 }; 1453 };
1422 1454
1423 1455
1424 // An object literal has a boilerplate object that is used 1456 // An object literal has a boilerplate object that is used
1425 // for minimizing the work when constructing it at runtime. 1457 // for minimizing the work when constructing it at runtime.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 kNoFlags = 0, 1502 kNoFlags = 0,
1471 kFastElements = 1, 1503 kFastElements = 1,
1472 kHasFunction = 1 << 1, 1504 kHasFunction = 1 << 1,
1473 kShallowProperties = 1 << 2, 1505 kShallowProperties = 1 << 2,
1474 kDisableMementos = 1 << 3, 1506 kDisableMementos = 1 << 3,
1475 kIsStrong = 1 << 4 1507 kIsStrong = 1 << 4
1476 }; 1508 };
1477 1509
1478 struct Accessors: public ZoneObject { 1510 struct Accessors: public ZoneObject {
1479 Accessors() : getter(NULL), setter(NULL) {} 1511 Accessors() : getter(NULL), setter(NULL) {}
1480 Expression* getter; 1512 ObjectLiteralProperty* getter;
1481 Expression* setter; 1513 ObjectLiteralProperty* setter;
1482 }; 1514 };
1483 1515
1484 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } 1516 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
1485 1517
1486 // Return an AST id for a property that is used in simulate instructions. 1518 // Return an AST id for a property that is used in simulate instructions.
1487 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } 1519 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); }
1488 1520
1489 // Unlike other AST nodes, this number of bailout IDs allocated for an 1521 // Unlike other AST nodes, this number of bailout IDs allocated for an
1490 // ObjectLiteral can vary, so num_ids() is not a static method. 1522 // ObjectLiteral can vary, so num_ids() is not a static method.
1491 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } 1523 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); }
1492 1524
1493 // Object literals need one feedback slot for each non-trivial value, as well 1525 // Object literals need one feedback slot for each non-trivial value, as well
1494 // as some slots for home objects. 1526 // as some slots for home objects.
1495 FeedbackVectorRequirements ComputeFeedbackRequirements( 1527 FeedbackVectorRequirements ComputeFeedbackRequirements(
1496 Isolate* isolate, const ICSlotCache* cache) override; 1528 Isolate* isolate, const ICSlotCache* cache) override;
1497 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 1529 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
1498 ICSlotCache* cache) override { 1530 ICSlotCache* cache) override {
1499 slot_ = slot; 1531 slot_ = slot;
1500 } 1532 }
1501 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } 1533 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; }
1502 FeedbackVectorICSlot GetNthSlot(int n) const {
1503 return FeedbackVectorICSlot(slot_.ToInt() + n);
1504 }
1505 1534
1506 // If value needs a home object, returns a valid feedback vector ic slot 1535 // After feedback slots were assigned, propagate information to the properties
1507 // given by slot_index, and increments slot_index. 1536 // which need it.
1508 FeedbackVectorICSlot SlotForHomeObject(Expression* value, 1537 void LayoutFeedbackSlots();
1509 int* slot_index) const;
1510
1511 #ifdef DEBUG
1512 int slot_count() const { return slot_count_; }
1513 #endif
1514 1538
1515 protected: 1539 protected:
1516 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, 1540 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
1517 int boilerplate_properties, bool has_function, bool is_strong, 1541 int boilerplate_properties, bool has_function, bool is_strong,
1518 int pos) 1542 int pos)
1519 : MaterializedLiteral(zone, literal_index, is_strong, pos), 1543 : MaterializedLiteral(zone, literal_index, is_strong, pos),
1520 properties_(properties), 1544 properties_(properties),
1521 boilerplate_properties_(boilerplate_properties), 1545 boilerplate_properties_(boilerplate_properties),
1522 fast_elements_(false), 1546 fast_elements_(false),
1523 has_elements_(false), 1547 has_elements_(false),
1524 may_store_doubles_(false), 1548 may_store_doubles_(false),
1525 has_function_(has_function), 1549 has_function_(has_function),
1526 #ifdef DEBUG
1527 slot_count_(0),
1528 #endif
1529 slot_(FeedbackVectorICSlot::Invalid()) { 1550 slot_(FeedbackVectorICSlot::Invalid()) {
1530 } 1551 }
1531 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } 1552 static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
1532 1553
1533 private: 1554 private:
1534 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 1555 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
1535 Handle<FixedArray> constant_properties_; 1556 Handle<FixedArray> constant_properties_;
1536 ZoneList<Property*>* properties_; 1557 ZoneList<Property*>* properties_;
1537 int boilerplate_properties_; 1558 int boilerplate_properties_;
1538 bool fast_elements_; 1559 bool fast_elements_;
1539 bool has_elements_; 1560 bool has_elements_;
1540 bool may_store_doubles_; 1561 bool may_store_doubles_;
1541 bool has_function_; 1562 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_; 1563 FeedbackVectorICSlot slot_;
1548 }; 1564 };
1549 1565
1550 1566
1551 // Node for capturing a regexp literal. 1567 // Node for capturing a regexp literal.
1552 class RegExpLiteral final : public MaterializedLiteral { 1568 class RegExpLiteral final : public MaterializedLiteral {
1553 public: 1569 public:
1554 DECLARE_NODE_TYPE(RegExpLiteral) 1570 DECLARE_NODE_TYPE(RegExpLiteral)
1555 1571
1556 Handle<String> pattern() const { return pattern_->string(); } 1572 Handle<String> pattern() const { return pattern_->string(); }
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 2723
2708 // Object literals need one feedback slot for each non-trivial value, as well 2724 // Object literals need one feedback slot for each non-trivial value, as well
2709 // as some slots for home objects. 2725 // as some slots for home objects.
2710 FeedbackVectorRequirements ComputeFeedbackRequirements( 2726 FeedbackVectorRequirements ComputeFeedbackRequirements(
2711 Isolate* isolate, const ICSlotCache* cache) override; 2727 Isolate* isolate, const ICSlotCache* cache) override;
2712 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, 2728 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2713 ICSlotCache* cache) override { 2729 ICSlotCache* cache) override {
2714 slot_ = slot; 2730 slot_ = slot;
2715 } 2731 }
2716 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; } 2732 Code::Kind FeedbackICSlotKind(int index) override { return Code::STORE_IC; }
2717 FeedbackVectorICSlot GetNthSlot(int n) const { 2733
2718 return FeedbackVectorICSlot(slot_.ToInt() + n); 2734 bool NeedsProxySlot() const {
2735 return FLAG_vector_stores && scope() != NULL &&
2736 class_variable_proxy()->var()->IsUnallocated();
2719 } 2737 }
2720 2738
2721 // If value needs a home object, returns a valid feedback vector ic slot 2739 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 2740
2726 #ifdef DEBUG 2741 // After feedback slots were assigned, propagate information to the properties
2727 int slot_count() const { return slot_count_; } 2742 // which need it.
2728 #endif 2743 void LayoutFeedbackSlots();
2729 2744
2730 protected: 2745 protected:
2731 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, 2746 ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope,
2732 VariableProxy* class_variable_proxy, Expression* extends, 2747 VariableProxy* class_variable_proxy, Expression* extends,
2733 FunctionLiteral* constructor, ZoneList<Property*>* properties, 2748 FunctionLiteral* constructor, ZoneList<Property*>* properties,
2734 int start_position, int end_position) 2749 int start_position, int end_position)
2735 : Expression(zone, start_position), 2750 : Expression(zone, start_position),
2736 raw_name_(name), 2751 raw_name_(name),
2737 scope_(scope), 2752 scope_(scope),
2738 class_variable_proxy_(class_variable_proxy), 2753 class_variable_proxy_(class_variable_proxy),
2739 extends_(extends), 2754 extends_(extends),
2740 constructor_(constructor), 2755 constructor_(constructor),
2741 properties_(properties), 2756 properties_(properties),
2742 end_position_(end_position), 2757 end_position_(end_position),
2743 #ifdef DEBUG
2744 slot_count_(0),
2745 #endif
2746 slot_(FeedbackVectorICSlot::Invalid()) { 2758 slot_(FeedbackVectorICSlot::Invalid()) {
2747 } 2759 }
2748 2760
2749 static int parent_num_ids() { return Expression::num_ids(); } 2761 static int parent_num_ids() { return Expression::num_ids(); }
2750 2762
2751 private: 2763 private:
2752 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2764 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2753 2765
2754 const AstRawString* raw_name_; 2766 const AstRawString* raw_name_;
2755 Scope* scope_; 2767 Scope* scope_;
2756 VariableProxy* class_variable_proxy_; 2768 VariableProxy* class_variable_proxy_;
2757 Expression* extends_; 2769 Expression* extends_;
2758 FunctionLiteral* constructor_; 2770 FunctionLiteral* constructor_;
2759 ZoneList<Property*>* properties_; 2771 ZoneList<Property*>* properties_;
2760 int end_position_; 2772 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_; 2773 FeedbackVectorICSlot slot_;
2767 }; 2774 };
2768 2775
2769 2776
2770 class NativeFunctionLiteral final : public Expression { 2777 class NativeFunctionLiteral final : public Expression {
2771 public: 2778 public:
2772 DECLARE_NODE_TYPE(NativeFunctionLiteral) 2779 DECLARE_NODE_TYPE(NativeFunctionLiteral)
2773 2780
2774 Handle<String> name() const { return name_->string(); } 2781 Handle<String> name() const { return name_->string(); }
2775 v8::Extension* extension() const { return extension_; } 2782 v8::Extension* extension() const { return extension_; }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 3661
3655 private: 3662 private:
3656 Zone* zone_; 3663 Zone* zone_;
3657 AstValueFactory* ast_value_factory_; 3664 AstValueFactory* ast_value_factory_;
3658 }; 3665 };
3659 3666
3660 3667
3661 } } // namespace v8::internal 3668 } } // namespace v8::internal
3662 3669
3663 #endif // V8_AST_H_ 3670 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698