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_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 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 ? FeedbackVectorSlotKind::LOAD_IC | 1731 ? FeedbackVectorSlotKind::LOAD_IC |
1732 : FeedbackVectorSlotKind::KEYED_LOAD_IC; | 1732 : FeedbackVectorSlotKind::KEYED_LOAD_IC; |
1733 property_feedback_slot_ = spec->AddSlot(kind); | 1733 property_feedback_slot_ = spec->AddSlot(kind); |
1734 } | 1734 } |
1735 | 1735 |
1736 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1736 FeedbackVectorSlot PropertyFeedbackSlot() const { |
1737 return property_feedback_slot_; | 1737 return property_feedback_slot_; |
1738 } | 1738 } |
1739 | 1739 |
1740 // Returns the properties assign type. | 1740 // Returns the properties assign type. |
1741 static LhsKind GetAssignType( | 1741 static LhsKind GetAssignType(Property* property) { |
1742 Property* property, | |
1743 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) { | |
1744 if (property == NULL) return VARIABLE; | 1742 if (property == NULL) return VARIABLE; |
1745 bool super_access = property->IsSuperAccess(); | 1743 bool super_access = property->IsSuperAccess(); |
1746 return (property->key()->IsPropertyName()) | 1744 return (property->key()->IsPropertyName()) |
1747 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | 1745 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
1748 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | 1746 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); |
1749 } | 1747 } |
1750 | 1748 |
1751 private: | 1749 private: |
1752 friend class AstNodeFactory; | 1750 friend class AstNodeFactory; |
1753 | 1751 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1832 BailoutId LookupId() const { return BailoutId(local_id(2)); } | 1830 BailoutId LookupId() const { return BailoutId(local_id(2)); } |
1833 BailoutId CallId() const { return BailoutId(local_id(3)); } | 1831 BailoutId CallId() const { return BailoutId(local_id(3)); } |
1834 | 1832 |
1835 bool is_uninitialized() const { | 1833 bool is_uninitialized() const { |
1836 return IsUninitializedField::decode(bit_field_); | 1834 return IsUninitializedField::decode(bit_field_); |
1837 } | 1835 } |
1838 void set_is_uninitialized(bool b) { | 1836 void set_is_uninitialized(bool b) { |
1839 bit_field_ = IsUninitializedField::update(bit_field_, b); | 1837 bit_field_ = IsUninitializedField::update(bit_field_, b); |
1840 } | 1838 } |
1841 | 1839 |
| 1840 bool is_possibly_eval() const { |
| 1841 return IsPossiblyEvalField::decode(bit_field_); |
| 1842 } |
| 1843 |
1842 TailCallMode tail_call_mode() const { | 1844 TailCallMode tail_call_mode() const { |
1843 return IsTailField::decode(bit_field_) ? TailCallMode::kAllow | 1845 return IsTailField::decode(bit_field_) ? TailCallMode::kAllow |
1844 : TailCallMode::kDisallow; | 1846 : TailCallMode::kDisallow; |
1845 } | 1847 } |
1846 void MarkTail() { bit_field_ = IsTailField::update(bit_field_, true); } | 1848 void MarkTail() { bit_field_ = IsTailField::update(bit_field_, true); } |
1847 | 1849 |
1848 enum CallType { | 1850 enum CallType { |
1849 POSSIBLY_EVAL_CALL, | 1851 POSSIBLY_EVAL_CALL, |
1850 GLOBAL_CALL, | 1852 GLOBAL_CALL, |
1851 LOOKUP_SLOT_CALL, | 1853 LOOKUP_SLOT_CALL, |
1852 NAMED_PROPERTY_CALL, | 1854 NAMED_PROPERTY_CALL, |
1853 KEYED_PROPERTY_CALL, | 1855 KEYED_PROPERTY_CALL, |
1854 NAMED_SUPER_PROPERTY_CALL, | 1856 NAMED_SUPER_PROPERTY_CALL, |
1855 KEYED_SUPER_PROPERTY_CALL, | 1857 KEYED_SUPER_PROPERTY_CALL, |
1856 SUPER_CALL, | 1858 SUPER_CALL, |
1857 OTHER_CALL | 1859 OTHER_CALL |
1858 }; | 1860 }; |
1859 | 1861 |
| 1862 enum PossiblyEval { |
| 1863 IS_POSSIBLY_EVAL, |
| 1864 NOT_EVAL, |
| 1865 }; |
| 1866 |
1860 // Helpers to determine how to handle the call. | 1867 // Helpers to determine how to handle the call. |
1861 // If called with |deref_mode| of kDisallowed, then the AST nodes must have | 1868 CallType GetCallType() const; |
1862 // been internalized within a CanonicalHandleScope. | 1869 bool IsUsingCallFeedbackSlot() const; |
1863 CallType GetCallType( | 1870 bool IsUsingCallFeedbackICSlot() const; |
1864 Isolate* isolate, | |
1865 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const; | |
1866 bool IsUsingCallFeedbackSlot( | |
1867 Isolate* isolate, | |
1868 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const; | |
1869 bool IsUsingCallFeedbackICSlot( | |
1870 Isolate* isolate, | |
1871 HandleDereferenceMode deref_mode = HandleDereferenceMode::kAllowed) const; | |
1872 | 1871 |
1873 #ifdef DEBUG | 1872 #ifdef DEBUG |
1874 // Used to assert that the FullCodeGenerator records the return site. | 1873 // Used to assert that the FullCodeGenerator records the return site. |
1875 bool return_is_recorded_; | 1874 bool return_is_recorded_; |
1876 #endif | 1875 #endif |
1877 | 1876 |
1878 private: | 1877 private: |
1879 friend class AstNodeFactory; | 1878 friend class AstNodeFactory; |
1880 | 1879 |
1881 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1880 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1882 int pos) | 1881 int pos, PossiblyEval possibly_eval) |
1883 : Expression(zone, pos, kCall), | 1882 : Expression(zone, pos, kCall), |
1884 bit_field_(IsUninitializedField::encode(false)), | 1883 bit_field_( |
| 1884 IsUninitializedField::encode(false) | |
| 1885 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL)), |
1885 expression_(expression), | 1886 expression_(expression), |
1886 arguments_(arguments) { | 1887 arguments_(arguments) { |
1887 if (expression->IsProperty()) { | 1888 if (expression->IsProperty()) { |
1888 expression->AsProperty()->mark_for_call(); | 1889 expression->AsProperty()->mark_for_call(); |
1889 } | 1890 } |
1890 } | 1891 } |
1891 | 1892 |
1892 static int parent_num_ids() { return Expression::num_ids(); } | 1893 static int parent_num_ids() { return Expression::num_ids(); } |
1893 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1894 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1894 | 1895 |
1895 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | 1896 class IsUninitializedField : public BitField8<bool, 0, 1> {}; |
1896 class IsTailField : public BitField8<bool, 1, 1> {}; | 1897 class IsTailField : public BitField8<bool, 1, 1> {}; |
| 1898 class IsPossiblyEvalField : public BitField8<bool, 2, 1> {}; |
1897 | 1899 |
1898 uint8_t bit_field_; | 1900 uint8_t bit_field_; |
1899 FeedbackVectorSlot ic_slot_; | 1901 FeedbackVectorSlot ic_slot_; |
1900 FeedbackVectorSlot stub_slot_; | 1902 FeedbackVectorSlot stub_slot_; |
1901 Expression* expression_; | 1903 Expression* expression_; |
1902 ZoneList<Expression*>* arguments_; | 1904 ZoneList<Expression*>* arguments_; |
1903 Handle<JSFunction> target_; | 1905 Handle<JSFunction> target_; |
1904 Handle<AllocationSite> allocation_site_; | 1906 Handle<AllocationSite> allocation_site_; |
1905 }; | 1907 }; |
1906 | 1908 |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 | 3236 |
3235 // Recreates the VariableProxy in this Zone. | 3237 // Recreates the VariableProxy in this Zone. |
3236 VariableProxy* CopyVariableProxy(VariableProxy* proxy) { | 3238 VariableProxy* CopyVariableProxy(VariableProxy* proxy) { |
3237 return new (zone_) VariableProxy(zone_, proxy); | 3239 return new (zone_) VariableProxy(zone_, proxy); |
3238 } | 3240 } |
3239 | 3241 |
3240 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3242 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
3241 return new (zone_) Property(zone_, obj, key, pos); | 3243 return new (zone_) Property(zone_, obj, key, pos); |
3242 } | 3244 } |
3243 | 3245 |
3244 Call* NewCall(Expression* expression, | 3246 Call* NewCall(Expression* expression, ZoneList<Expression*>* arguments, |
3245 ZoneList<Expression*>* arguments, | 3247 int pos, Call::PossiblyEval possibly_eval = Call::NOT_EVAL) { |
3246 int pos) { | 3248 return new (zone_) Call(zone_, expression, arguments, pos, possibly_eval); |
3247 return new (zone_) Call(zone_, expression, arguments, pos); | |
3248 } | 3249 } |
3249 | 3250 |
3250 CallNew* NewCallNew(Expression* expression, | 3251 CallNew* NewCallNew(Expression* expression, |
3251 ZoneList<Expression*>* arguments, | 3252 ZoneList<Expression*>* arguments, |
3252 int pos) { | 3253 int pos) { |
3253 return new (zone_) CallNew(zone_, expression, arguments, pos); | 3254 return new (zone_) CallNew(zone_, expression, arguments, pos); |
3254 } | 3255 } |
3255 | 3256 |
3256 CallRuntime* NewCallRuntime(Runtime::FunctionId id, | 3257 CallRuntime* NewCallRuntime(Runtime::FunctionId id, |
3257 ZoneList<Expression*>* arguments, int pos) { | 3258 ZoneList<Expression*>* arguments, int pos) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 : NULL; \ | 3478 : NULL; \ |
3478 } | 3479 } |
3479 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3480 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3480 #undef DECLARE_NODE_FUNCTIONS | 3481 #undef DECLARE_NODE_FUNCTIONS |
3481 | 3482 |
3482 | 3483 |
3483 } // namespace internal | 3484 } // namespace internal |
3484 } // namespace v8 | 3485 } // namespace v8 |
3485 | 3486 |
3486 #endif // V8_AST_AST_H_ | 3487 #endif // V8_AST_AST_H_ |
OLD | NEW |