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

Side by Side Diff: src/ast.h

Issue 17468003: Use AST's type field and merge types for unary, binary & compare ICs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 6 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 | « src/arm/lithium-codegen-arm.cc ('k') | 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 // 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 // True iff the expression is a string literal. 350 // True iff the expression is a string literal.
351 bool IsStringLiteral(); 351 bool IsStringLiteral();
352 352
353 // True iff the expression is the null literal. 353 // True iff the expression is the null literal.
354 bool IsNullLiteral(); 354 bool IsNullLiteral();
355 355
356 // True iff the expression is the undefined literal. 356 // True iff the expression is the undefined literal.
357 bool IsUndefinedLiteral(); 357 bool IsUndefinedLiteral();
358 358
359 // Expression type 359 // Expression type bounds
360 Handle<Type> type() { return type_; } 360 Handle<Type> upper_type() { return upper_type_; }
361 void set_type(Handle<Type> type) { type_ = type; } 361 Handle<Type> lower_type() { return lower_type_; }
362 void set_upper_type(Handle<Type> type) { upper_type_ = type; }
363 void set_lower_type(Handle<Type> type) { lower_type_ = type; }
362 364
363 // Type feedback information for assignments and properties. 365 // Type feedback information for assignments and properties.
364 virtual bool IsMonomorphic() { 366 virtual bool IsMonomorphic() {
365 UNREACHABLE(); 367 UNREACHABLE();
366 return false; 368 return false;
367 } 369 }
368 virtual SmallMapList* GetReceiverTypes() { 370 virtual SmallMapList* GetReceiverTypes() {
369 UNREACHABLE(); 371 UNREACHABLE();
370 return NULL; 372 return NULL;
371 } 373 }
(...skipping 10 matching lines...) Expand all
382 384
383 // TODO(rossberg): this should move to its own AST node eventually. 385 // TODO(rossberg): this should move to its own AST node eventually.
384 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); 386 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
385 byte to_boolean_types() const { return to_boolean_types_; } 387 byte to_boolean_types() const { return to_boolean_types_; }
386 388
387 BailoutId id() const { return id_; } 389 BailoutId id() const { return id_; }
388 TypeFeedbackId test_id() const { return test_id_; } 390 TypeFeedbackId test_id() const { return test_id_; }
389 391
390 protected: 392 protected:
391 explicit Expression(Isolate* isolate) 393 explicit Expression(Isolate* isolate)
392 : type_(Type::None(), isolate), 394 : upper_type_(Type::Any(), isolate),
395 lower_type_(Type::None(), isolate),
393 id_(GetNextId(isolate)), 396 id_(GetNextId(isolate)),
394 test_id_(GetNextId(isolate)) {} 397 test_id_(GetNextId(isolate)) {}
395 398
396 private: 399 private:
397 Handle<Type> type_; 400 Handle<Type> upper_type_;
401 Handle<Type> lower_type_;
398 byte to_boolean_types_; 402 byte to_boolean_types_;
399 403
400 const BailoutId id_; 404 const BailoutId id_;
401 const TypeFeedbackId test_id_; 405 const TypeFeedbackId test_id_;
402 }; 406 };
403 407
404 408
405 class BreakableStatement: public Statement { 409 class BreakableStatement: public Statement {
406 public: 410 public:
407 enum BreakableType { 411 enum BreakableType {
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 virtual bool ResultOverwriteAllowed(); 1833 virtual bool ResultOverwriteAllowed();
1830 1834
1831 Token::Value op() const { return op_; } 1835 Token::Value op() const { return op_; }
1832 Expression* expression() const { return expression_; } 1836 Expression* expression() const { return expression_; }
1833 virtual int position() const { return pos_; } 1837 virtual int position() const { return pos_; }
1834 1838
1835 BailoutId MaterializeTrueId() { return materialize_true_id_; } 1839 BailoutId MaterializeTrueId() { return materialize_true_id_; }
1836 BailoutId MaterializeFalseId() { return materialize_false_id_; } 1840 BailoutId MaterializeFalseId() { return materialize_false_id_; }
1837 1841
1838 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); } 1842 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); }
1839 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1840 Handle<Type> type() const { return type_; }
1841 1843
1842 protected: 1844 protected:
1843 UnaryOperation(Isolate* isolate, 1845 UnaryOperation(Isolate* isolate,
1844 Token::Value op, 1846 Token::Value op,
1845 Expression* expression, 1847 Expression* expression,
1846 int pos) 1848 int pos)
1847 : Expression(isolate), 1849 : Expression(isolate),
1848 op_(op), 1850 op_(op),
1849 expression_(expression), 1851 expression_(expression),
1850 pos_(pos), 1852 pos_(pos),
1851 materialize_true_id_(GetNextId(isolate)), 1853 materialize_true_id_(GetNextId(isolate)),
1852 materialize_false_id_(GetNextId(isolate)) { 1854 materialize_false_id_(GetNextId(isolate)) {
1853 ASSERT(Token::IsUnaryOp(op)); 1855 ASSERT(Token::IsUnaryOp(op));
1854 } 1856 }
1855 1857
1856 private: 1858 private:
1857 Token::Value op_; 1859 Token::Value op_;
1858 Expression* expression_; 1860 Expression* expression_;
1859 int pos_; 1861 int pos_;
1860 1862
1861 Handle<Type> type_;
1862
1863 // For unary not (Token::NOT), the AST ids where true and false will 1863 // For unary not (Token::NOT), the AST ids where true and false will
1864 // actually be materialized, respectively. 1864 // actually be materialized, respectively.
1865 const BailoutId materialize_true_id_; 1865 const BailoutId materialize_true_id_;
1866 const BailoutId materialize_false_id_; 1866 const BailoutId materialize_false_id_;
1867 }; 1867 };
1868 1868
1869 1869
1870 class BinaryOperation: public Expression { 1870 class BinaryOperation: public Expression {
1871 public: 1871 public:
1872 DECLARE_NODE_TYPE(BinaryOperation) 1872 DECLARE_NODE_TYPE(BinaryOperation)
1873 1873
1874 virtual bool ResultOverwriteAllowed(); 1874 virtual bool ResultOverwriteAllowed();
1875 1875
1876 Token::Value op() const { return op_; } 1876 Token::Value op() const { return op_; }
1877 Expression* left() const { return left_; } 1877 Expression* left() const { return left_; }
1878 Expression* right() const { return right_; } 1878 Expression* right() const { return right_; }
1879 virtual int position() const { return pos_; } 1879 virtual int position() const { return pos_; }
1880 1880
1881 BailoutId RightId() const { return right_id_; } 1881 BailoutId RightId() const { return right_id_; }
1882 1882
1883 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } 1883 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
1884 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1884 // TODO(rossberg): result_type should be subsumed by lower_type.
1885 Handle<Type> left_type() const { return left_type_; }
1886 Handle<Type> right_type() const { return right_type_; }
1887 Handle<Type> result_type() const { return result_type_; } 1885 Handle<Type> result_type() const { return result_type_; }
1888 bool has_fixed_right_arg() const { return has_fixed_right_arg_; } 1886 void set_result_type(Handle<Type> type) { result_type_ = type; }
1889 int fixed_right_arg_value() const { return fixed_right_arg_value_; } 1887 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
1888 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
1890 1889
1891 protected: 1890 protected:
1892 BinaryOperation(Isolate* isolate, 1891 BinaryOperation(Isolate* isolate,
1893 Token::Value op, 1892 Token::Value op,
1894 Expression* left, 1893 Expression* left,
1895 Expression* right, 1894 Expression* right,
1896 int pos) 1895 int pos)
1897 : Expression(isolate), 1896 : Expression(isolate),
1898 op_(op), 1897 op_(op),
1899 left_(left), 1898 left_(left),
1900 right_(right), 1899 right_(right),
1901 pos_(pos), 1900 pos_(pos),
1902 right_id_(GetNextId(isolate)) { 1901 right_id_(GetNextId(isolate)) {
1903 ASSERT(Token::IsBinaryOp(op)); 1902 ASSERT(Token::IsBinaryOp(op));
1904 } 1903 }
1905 1904
1906 private: 1905 private:
1907 Token::Value op_; 1906 Token::Value op_;
1908 Expression* left_; 1907 Expression* left_;
1909 Expression* right_; 1908 Expression* right_;
1910 int pos_; 1909 int pos_;
1911 1910
1912 Handle<Type> left_type_;
1913 Handle<Type> right_type_;
1914 Handle<Type> result_type_; 1911 Handle<Type> result_type_;
1915 bool has_fixed_right_arg_; 1912 // TODO(rossberg): the fixed arg should probably be represented as a Constant
1916 int fixed_right_arg_value_; 1913 // type for the RHS.
1914 Maybe<int> fixed_right_arg_;
1917 1915
1918 // The short-circuit logical operations need an AST ID for their 1916 // The short-circuit logical operations need an AST ID for their
1919 // right-hand subexpression. 1917 // right-hand subexpression.
1920 const BailoutId right_id_; 1918 const BailoutId right_id_;
1921 }; 1919 };
1922 1920
1923 1921
1924 class CountOperation: public Expression { 1922 class CountOperation: public Expression {
1925 public: 1923 public:
1926 DECLARE_NODE_TYPE(CountOperation) 1924 DECLARE_NODE_TYPE(CountOperation)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 public: 1985 public:
1988 DECLARE_NODE_TYPE(CompareOperation) 1986 DECLARE_NODE_TYPE(CompareOperation)
1989 1987
1990 Token::Value op() const { return op_; } 1988 Token::Value op() const { return op_; }
1991 Expression* left() const { return left_; } 1989 Expression* left() const { return left_; }
1992 Expression* right() const { return right_; } 1990 Expression* right() const { return right_; }
1993 virtual int position() const { return pos_; } 1991 virtual int position() const { return pos_; }
1994 1992
1995 // Type feedback information. 1993 // Type feedback information.
1996 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } 1994 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); }
1997 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1995 Handle<Type> combined_type() const { return combined_type_; }
1998 Handle<Type> left_type() const { return left_type_; } 1996 void set_combined_type(Handle<Type> type) { combined_type_ = type; }
1999 Handle<Type> right_type() const { return right_type_; }
2000 Handle<Type> overall_type() const { return overall_type_; }
2001 Handle<Type> compare_nil_type() const { return compare_nil_type_; }
2002 1997
2003 // Match special cases. 1998 // Match special cases.
2004 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 1999 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2005 bool IsLiteralCompareUndefined(Expression** expr); 2000 bool IsLiteralCompareUndefined(Expression** expr);
2006 bool IsLiteralCompareNull(Expression** expr); 2001 bool IsLiteralCompareNull(Expression** expr);
2007 2002
2008 protected: 2003 protected:
2009 CompareOperation(Isolate* isolate, 2004 CompareOperation(Isolate* isolate,
2010 Token::Value op, 2005 Token::Value op,
2011 Expression* left, 2006 Expression* left,
2012 Expression* right, 2007 Expression* right,
2013 int pos) 2008 int pos)
2014 : Expression(isolate), 2009 : Expression(isolate),
2015 op_(op), 2010 op_(op),
2016 left_(left), 2011 left_(left),
2017 right_(right), 2012 right_(right),
2018 pos_(pos) { 2013 pos_(pos) {
2019 ASSERT(Token::IsCompareOp(op)); 2014 ASSERT(Token::IsCompareOp(op));
2020 } 2015 }
2021 2016
2022 private: 2017 private:
2023 Token::Value op_; 2018 Token::Value op_;
2024 Expression* left_; 2019 Expression* left_;
2025 Expression* right_; 2020 Expression* right_;
2026 int pos_; 2021 int pos_;
2027 2022
2028 Handle<Type> left_type_; 2023 Handle<Type> combined_type_;
2029 Handle<Type> right_type_;
2030 Handle<Type> overall_type_;
2031 Handle<Type> compare_nil_type_;
2032 }; 2024 };
2033 2025
2034 2026
2035 class Conditional: public Expression { 2027 class Conditional: public Expression {
2036 public: 2028 public:
2037 DECLARE_NODE_TYPE(Conditional) 2029 DECLARE_NODE_TYPE(Conditional)
2038 2030
2039 Expression* condition() const { return condition_; } 2031 Expression* condition() const { return condition_; }
2040 Expression* then_expression() const { return then_expression_; } 2032 Expression* then_expression() const { return then_expression_; }
2041 Expression* else_expression() const { return else_expression_; } 2033 Expression* else_expression() const { return else_expression_; }
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 private: 3210 private:
3219 Isolate* isolate_; 3211 Isolate* isolate_;
3220 Zone* zone_; 3212 Zone* zone_;
3221 Visitor visitor_; 3213 Visitor visitor_;
3222 }; 3214 };
3223 3215
3224 3216
3225 } } // namespace v8::internal 3217 } } // namespace v8::internal
3226 3218
3227 #endif // V8_AST_H_ 3219 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698