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.h

Issue 137403009: Adding a type vector to replace type cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Seperate file for feedback slot allocation. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/ast.cc » ('J')
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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return zone->New(static_cast<int>(size)); 206 return zone->New(static_cast<int>(size));
207 } 207 }
208 208
209 explicit AstNode(int position): position_(position) {} 209 explicit AstNode(int position): position_(position) {}
210 virtual ~AstNode() {} 210 virtual ~AstNode() {}
211 211
212 virtual void Accept(AstVisitor* v) = 0; 212 virtual void Accept(AstVisitor* v) = 0;
213 virtual NodeType node_type() const = 0; 213 virtual NodeType node_type() const = 0;
214 int position() const { return position_; } 214 int position() const { return position_; }
215 215
216 static const int kInvalidFeedbackSlot = -1;
217 virtual int ConsumeFeedbackSlots(Isolate* isolate, int current_slot) {
danno 2014/01/28 08:27:17 Is it really consuming? Isn't it more like earmark
mvstanton 2014/01/30 15:13:41 Changed the approach quite a bit.
218 return current_slot;
219 }
220
216 // Type testing & conversion functions overridden by concrete subclasses. 221 // Type testing & conversion functions overridden by concrete subclasses.
217 #define DECLARE_NODE_FUNCTIONS(type) \ 222 #define DECLARE_NODE_FUNCTIONS(type) \
218 bool Is##type() { return node_type() == AstNode::k##type; } \ 223 bool Is##type() { return node_type() == AstNode::k##type; } \
219 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; } 224 type* As##type() { return Is##type() ? reinterpret_cast<type*>(this) : NULL; }
220 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 225 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
221 #undef DECLARE_NODE_FUNCTIONS 226 #undef DECLARE_NODE_FUNCTIONS
222 227
223 virtual TargetCollector* AsTargetCollector() { return NULL; } 228 virtual TargetCollector* AsTargetCollector() { return NULL; }
224 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 229 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
225 virtual IterationStatement* AsIterationStatement() { return NULL; } 230 virtual IterationStatement* AsIterationStatement() { return NULL; }
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 920
916 921
917 class ForInStatement V8_FINAL : public ForEachStatement { 922 class ForInStatement V8_FINAL : public ForEachStatement {
918 public: 923 public:
919 DECLARE_NODE_TYPE(ForInStatement) 924 DECLARE_NODE_TYPE(ForInStatement)
920 925
921 Expression* enumerable() const { 926 Expression* enumerable() const {
922 return subject(); 927 return subject();
923 } 928 }
924 929
925 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } 930 // Type feedback information.
931 virtual int ConsumeFeedbackSlots(Isolate* isolate, int current_slot) {
932 for_in_feedback_slot_ = current_slot;
933 return current_slot + 1;
934 }
935 int ForInFeedbackSlot() {
936 ASSERT(for_in_feedback_slot_ != kInvalidFeedbackSlot);
937 return for_in_feedback_slot_;
938 }
939
926 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; 940 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
927 ForInType for_in_type() const { return for_in_type_; } 941 ForInType for_in_type() const { return for_in_type_; }
928 void set_for_in_type(ForInType type) { for_in_type_ = type; } 942 void set_for_in_type(ForInType type) { for_in_type_ = type; }
929 943
930 BailoutId BodyId() const { return body_id_; } 944 BailoutId BodyId() const { return body_id_; }
931 BailoutId PrepareId() const { return prepare_id_; } 945 BailoutId PrepareId() const { return prepare_id_; }
932 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); } 946 virtual BailoutId ContinueId() const V8_OVERRIDE { return EntryId(); }
933 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; } 947 virtual BailoutId StackCheckId() const V8_OVERRIDE { return body_id_; }
934 948
935 protected: 949 protected:
936 ForInStatement(Zone* zone, ZoneStringList* labels, int pos) 950 ForInStatement(Zone* zone, ZoneStringList* labels, int pos)
937 : ForEachStatement(zone, labels, pos), 951 : ForEachStatement(zone, labels, pos),
938 for_in_type_(SLOW_FOR_IN), 952 for_in_type_(SLOW_FOR_IN),
953 for_in_feedback_slot_(kInvalidFeedbackSlot),
939 body_id_(GetNextId(zone)), 954 body_id_(GetNextId(zone)),
940 prepare_id_(GetNextId(zone)) { 955 prepare_id_(GetNextId(zone)) {
941 } 956 }
942 957
943 ForInType for_in_type_; 958 ForInType for_in_type_;
959 int for_in_feedback_slot_;
944 const BailoutId body_id_; 960 const BailoutId body_id_;
945 const BailoutId prepare_id_; 961 const BailoutId prepare_id_;
946 }; 962 };
947 963
948 964
949 class ForOfStatement V8_FINAL : public ForEachStatement { 965 class ForOfStatement V8_FINAL : public ForEachStatement {
950 public: 966 public:
951 DECLARE_NODE_TYPE(ForOfStatement) 967 DECLARE_NODE_TYPE(ForOfStatement)
952 968
953 void Initialize(Expression* each, 969 void Initialize(Expression* each,
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 }; 1749 };
1734 1750
1735 1751
1736 class Call V8_FINAL : public Expression { 1752 class Call V8_FINAL : public Expression {
1737 public: 1753 public:
1738 DECLARE_NODE_TYPE(Call) 1754 DECLARE_NODE_TYPE(Call)
1739 1755
1740 Expression* expression() const { return expression_; } 1756 Expression* expression() const { return expression_; }
1741 ZoneList<Expression*>* arguments() const { return arguments_; } 1757 ZoneList<Expression*>* arguments() const { return arguments_; }
1742 1758
1759 virtual int ConsumeFeedbackSlots(Isolate* isolate, int current_slot);
1760 bool HasCallFeedbackSlot() const {
1761 return call_feedback_slot_ != kInvalidFeedbackSlot;
1762 }
1763 int CallFeedbackSlot() const { return call_feedback_slot_; }
1764
1743 // Type feedback information. 1765 // Type feedback information.
1744 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } 1766 TypeFeedbackId CallFeedbackId() const { return reuse(id()); }
1745 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1767 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1746 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { 1768 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
1747 return &receiver_types_; 1769 return &receiver_types_;
1748 } 1770 }
1749 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1771 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1750 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; } 1772 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; }
1751 CheckType check_type() const { return check_type_; } 1773 CheckType check_type() const { return check_type_; }
1752 1774
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 Call(Zone* zone, 1826 Call(Zone* zone,
1805 Expression* expression, 1827 Expression* expression,
1806 ZoneList<Expression*>* arguments, 1828 ZoneList<Expression*>* arguments,
1807 int pos) 1829 int pos)
1808 : Expression(zone, pos), 1830 : Expression(zone, pos),
1809 expression_(expression), 1831 expression_(expression),
1810 arguments_(arguments), 1832 arguments_(arguments),
1811 is_monomorphic_(false), 1833 is_monomorphic_(false),
1812 keyed_array_call_is_holey_(true), 1834 keyed_array_call_is_holey_(true),
1813 check_type_(RECEIVER_MAP_CHECK), 1835 check_type_(RECEIVER_MAP_CHECK),
1836 call_feedback_slot_(kInvalidFeedbackSlot),
1814 return_id_(GetNextId(zone)) { } 1837 return_id_(GetNextId(zone)) { }
1815 1838
1816 private: 1839 private:
1817 Expression* expression_; 1840 Expression* expression_;
1818 ZoneList<Expression*>* arguments_; 1841 ZoneList<Expression*>* arguments_;
1819 1842
1820 bool is_monomorphic_; 1843 bool is_monomorphic_;
1821 bool keyed_array_call_is_holey_; 1844 bool keyed_array_call_is_holey_;
1822 CheckType check_type_; 1845 CheckType check_type_;
1823 SmallMapList receiver_types_; 1846 SmallMapList receiver_types_;
1824 Handle<JSFunction> target_; 1847 Handle<JSFunction> target_;
1825 Handle<JSObject> holder_; 1848 Handle<JSObject> holder_;
1826 Handle<Cell> cell_; 1849 Handle<Cell> cell_;
1850 int call_feedback_slot_;
1827 1851
1828 const BailoutId return_id_; 1852 const BailoutId return_id_;
1829 }; 1853 };
1830 1854
1831 1855
1832 class CallNew V8_FINAL : public Expression { 1856 class CallNew V8_FINAL : public Expression {
1833 public: 1857 public:
1834 DECLARE_NODE_TYPE(CallNew) 1858 DECLARE_NODE_TYPE(CallNew)
1835 1859
1836 Expression* expression() const { return expression_; } 1860 Expression* expression() const { return expression_; }
1837 ZoneList<Expression*>* arguments() const { return arguments_; } 1861 ZoneList<Expression*>* arguments() const { return arguments_; }
1838 1862
1839 // Type feedback information. 1863 // Type feedback information.
1864 virtual int ConsumeFeedbackSlots(Isolate* isolate, int current_slot) {
danno 2014/01/28 08:27:17 Somehow, this seems a little clunky. It seems like
1865 callnew_feedback_slot_ = current_slot;
1866 return current_slot + 1;
1867 }
1868 int CallNewFeedbackSlot() {
1869 ASSERT(callnew_feedback_slot_ != kInvalidFeedbackSlot);
1870 return callnew_feedback_slot_;
1871 }
1872
1840 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } 1873 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); }
1841 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1874 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1842 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } 1875 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
1843 Handle<JSFunction> target() const { return target_; } 1876 Handle<JSFunction> target() const { return target_; }
1844 ElementsKind elements_kind() const { return elements_kind_; } 1877 ElementsKind elements_kind() const { return elements_kind_; }
1845 Handle<AllocationSite> allocation_site() const { 1878 Handle<AllocationSite> allocation_site() const {
1846 return allocation_site_; 1879 return allocation_site_;
1847 } 1880 }
1848 1881
1882 static int feedback_slots() { return 1; }
1883
1849 BailoutId ReturnId() const { return return_id_; } 1884 BailoutId ReturnId() const { return return_id_; }
1850 1885
1851 protected: 1886 protected:
1852 CallNew(Zone* zone, 1887 CallNew(Zone* zone,
1853 Expression* expression, 1888 Expression* expression,
1854 ZoneList<Expression*>* arguments, 1889 ZoneList<Expression*>* arguments,
1855 int pos) 1890 int pos)
1856 : Expression(zone, pos), 1891 : Expression(zone, pos),
1857 expression_(expression), 1892 expression_(expression),
1858 arguments_(arguments), 1893 arguments_(arguments),
1859 is_monomorphic_(false), 1894 is_monomorphic_(false),
1860 elements_kind_(GetInitialFastElementsKind()), 1895 elements_kind_(GetInitialFastElementsKind()),
1896 callnew_feedback_slot_(kInvalidFeedbackSlot),
1861 return_id_(GetNextId(zone)) { } 1897 return_id_(GetNextId(zone)) { }
1862 1898
1863 private: 1899 private:
1864 Expression* expression_; 1900 Expression* expression_;
1865 ZoneList<Expression*>* arguments_; 1901 ZoneList<Expression*>* arguments_;
1866 1902
1867 bool is_monomorphic_; 1903 bool is_monomorphic_;
1868 Handle<JSFunction> target_; 1904 Handle<JSFunction> target_;
1869 ElementsKind elements_kind_; 1905 ElementsKind elements_kind_;
1870 Handle<AllocationSite> allocation_site_; 1906 Handle<AllocationSite> allocation_site_;
1907 Handle<Cell> allocation_info_cell_;
1908 int callnew_feedback_slot_;
1871 1909
1872 const BailoutId return_id_; 1910 const BailoutId return_id_;
1873 }; 1911 };
1874 1912
1875 1913
1876 // The CallRuntime class does not represent any official JavaScript 1914 // The CallRuntime class does not represent any official JavaScript
1877 // language construct. Instead it is used to call a C or JS function 1915 // language construct. Instead it is used to call a C or JS function
1878 // with a set of arguments. This is used from the builtins that are 1916 // with a set of arguments. This is used from the builtins that are
1879 // implemented in JavaScript (see "v8natives.js"). 1917 // implemented in JavaScript (see "v8natives.js").
1880 class CallRuntime V8_FINAL : public Expression { 1918 class CallRuntime V8_FINAL : public Expression {
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 3359
3322 private: 3360 private:
3323 Zone* zone_; 3361 Zone* zone_;
3324 Visitor visitor_; 3362 Visitor visitor_;
3325 }; 3363 };
3326 3364
3327 3365
3328 } } // namespace v8::internal 3366 } } // namespace v8::internal
3329 3367
3330 #endif // V8_AST_H_ 3368 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698