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

Side by Side Diff: src/ast.h

Issue 142813003: A64: Synchronize with r15358. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: 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 | « src/arraybuffer.js ('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 }
372 Handle<Map> GetMonomorphicReceiverType() { 374 Handle<Map> GetMonomorphicReceiverType() {
373 ASSERT(IsMonomorphic()); 375 ASSERT(IsMonomorphic());
374 SmallMapList* types = GetReceiverTypes(); 376 SmallMapList* types = GetReceiverTypes();
375 ASSERT(types != NULL && types->length() == 1); 377 ASSERT(types != NULL && types->length() == 1);
376 return types->at(0); 378 return types->at(0);
377 } 379 }
378 virtual KeyedAccessStoreMode GetStoreMode() { 380 virtual KeyedAccessStoreMode GetStoreMode() {
379 UNREACHABLE(); 381 UNREACHABLE();
380 return STANDARD_STORE; 382 return STANDARD_STORE;
381 } 383 }
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 virtual 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)) {}
398 void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
395 399
396 private: 400 private:
397 Handle<Type> type_; 401 Handle<Type> upper_type_;
402 Handle<Type> lower_type_;
398 byte to_boolean_types_; 403 byte to_boolean_types_;
399 404
400 const BailoutId id_; 405 const BailoutId id_;
401 const TypeFeedbackId test_id_; 406 const TypeFeedbackId test_id_;
402 }; 407 };
403 408
404 409
405 class BreakableStatement: public Statement { 410 class BreakableStatement: public Statement {
406 public: 411 public:
407 enum BreakableType { 412 enum BreakableType {
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 protected: 1306 protected:
1302 EmptyStatement() {} 1307 EmptyStatement() {}
1303 }; 1308 };
1304 1309
1305 1310
1306 class Literal: public Expression { 1311 class Literal: public Expression {
1307 public: 1312 public:
1308 DECLARE_NODE_TYPE(Literal) 1313 DECLARE_NODE_TYPE(Literal)
1309 1314
1310 virtual bool IsPropertyName() { 1315 virtual bool IsPropertyName() {
1311 if (handle_->IsInternalizedString()) { 1316 if (value_->IsInternalizedString()) {
1312 uint32_t ignored; 1317 uint32_t ignored;
1313 return !String::cast(*handle_)->AsArrayIndex(&ignored); 1318 return !String::cast(*value_)->AsArrayIndex(&ignored);
1314 } 1319 }
1315 return false; 1320 return false;
1316 } 1321 }
1317 1322
1318 Handle<String> AsPropertyName() { 1323 Handle<String> AsPropertyName() {
1319 ASSERT(IsPropertyName()); 1324 ASSERT(IsPropertyName());
1320 return Handle<String>::cast(handle_); 1325 return Handle<String>::cast(value_);
1321 } 1326 }
1322 1327
1323 virtual bool ToBooleanIsTrue() { return handle_->BooleanValue(); } 1328 virtual bool ToBooleanIsTrue() { return value_->BooleanValue(); }
1324 virtual bool ToBooleanIsFalse() { return !handle_->BooleanValue(); } 1329 virtual bool ToBooleanIsFalse() { return !value_->BooleanValue(); }
1325 1330
1326 // Identity testers. 1331 // Identity testers.
1327 bool IsNull() const { 1332 bool IsNull() const {
1328 ASSERT(!handle_.is_null()); 1333 ASSERT(!value_.is_null());
1329 return handle_->IsNull(); 1334 return value_->IsNull();
1330 } 1335 }
1331 bool IsTrue() const { 1336 bool IsTrue() const {
1332 ASSERT(!handle_.is_null()); 1337 ASSERT(!value_.is_null());
1333 return handle_->IsTrue(); 1338 return value_->IsTrue();
1334 } 1339 }
1335 bool IsFalse() const { 1340 bool IsFalse() const {
1336 ASSERT(!handle_.is_null()); 1341 ASSERT(!value_.is_null());
1337 return handle_->IsFalse(); 1342 return value_->IsFalse();
1338 } 1343 }
1339 1344
1340 Handle<Object> handle() const { return handle_; } 1345 Handle<Object> value() const { return value_; }
1341 1346
1342 // Support for using Literal as a HashMap key. NOTE: Currently, this works 1347 // Support for using Literal as a HashMap key. NOTE: Currently, this works
1343 // only for string and number literals! 1348 // only for string and number literals!
1344 uint32_t Hash() { return ToString()->Hash(); } 1349 uint32_t Hash() { return ToString()->Hash(); }
1345 1350
1346 static bool Match(void* literal1, void* literal2) { 1351 static bool Match(void* literal1, void* literal2) {
1347 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString(); 1352 Handle<String> s1 = static_cast<Literal*>(literal1)->ToString();
1348 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString(); 1353 Handle<String> s2 = static_cast<Literal*>(literal2)->ToString();
1349 return s1->Equals(*s2); 1354 return s1->Equals(*s2);
1350 } 1355 }
1351 1356
1352 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); } 1357 TypeFeedbackId LiteralFeedbackId() const { return reuse(id()); }
1353 1358
1354 protected: 1359 protected:
1355 Literal(Isolate* isolate, Handle<Object> handle) 1360 Literal(Isolate* isolate, Handle<Object> value)
1356 : Expression(isolate), 1361 : Expression(isolate),
1357 handle_(handle) { } 1362 value_(value) { }
1358 1363
1359 private: 1364 private:
1360 Handle<String> ToString(); 1365 Handle<String> ToString();
1361 1366
1362 Handle<Object> handle_; 1367 Handle<Object> value_;
1363 }; 1368 };
1364 1369
1365 1370
1366 // Base class for literals that needs space in the corresponding JSFunction. 1371 // Base class for literals that needs space in the corresponding JSFunction.
1367 class MaterializedLiteral: public Expression { 1372 class MaterializedLiteral: public Expression {
1368 public: 1373 public:
1369 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } 1374 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
1370 1375
1371 int literal_index() { return literal_index_; } 1376 int literal_index() { return literal_index_; }
1372 1377
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 virtual bool ResultOverwriteAllowed(); 1834 virtual bool ResultOverwriteAllowed();
1830 1835
1831 Token::Value op() const { return op_; } 1836 Token::Value op() const { return op_; }
1832 Expression* expression() const { return expression_; } 1837 Expression* expression() const { return expression_; }
1833 virtual int position() const { return pos_; } 1838 virtual int position() const { return pos_; }
1834 1839
1835 BailoutId MaterializeTrueId() { return materialize_true_id_; } 1840 BailoutId MaterializeTrueId() { return materialize_true_id_; }
1836 BailoutId MaterializeFalseId() { return materialize_false_id_; } 1841 BailoutId MaterializeFalseId() { return materialize_false_id_; }
1837 1842
1838 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); } 1843 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); }
1839 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1844
1840 Handle<Type> type() const { return type_; } 1845 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
1841 1846
1842 protected: 1847 protected:
1843 UnaryOperation(Isolate* isolate, 1848 UnaryOperation(Isolate* isolate,
1844 Token::Value op, 1849 Token::Value op,
1845 Expression* expression, 1850 Expression* expression,
1846 int pos) 1851 int pos)
1847 : Expression(isolate), 1852 : Expression(isolate),
1848 op_(op), 1853 op_(op),
1849 expression_(expression), 1854 expression_(expression),
1850 pos_(pos), 1855 pos_(pos),
1851 materialize_true_id_(GetNextId(isolate)), 1856 materialize_true_id_(GetNextId(isolate)),
1852 materialize_false_id_(GetNextId(isolate)) { 1857 materialize_false_id_(GetNextId(isolate)) {
1853 ASSERT(Token::IsUnaryOp(op)); 1858 ASSERT(Token::IsUnaryOp(op));
1854 } 1859 }
1855 1860
1856 private: 1861 private:
1857 Token::Value op_; 1862 Token::Value op_;
1858 Expression* expression_; 1863 Expression* expression_;
1859 int pos_; 1864 int pos_;
1860 1865
1861 Handle<Type> type_;
1862
1863 // For unary not (Token::NOT), the AST ids where true and false will 1866 // For unary not (Token::NOT), the AST ids where true and false will
1864 // actually be materialized, respectively. 1867 // actually be materialized, respectively.
1865 const BailoutId materialize_true_id_; 1868 const BailoutId materialize_true_id_;
1866 const BailoutId materialize_false_id_; 1869 const BailoutId materialize_false_id_;
1867 }; 1870 };
1868 1871
1869 1872
1870 class BinaryOperation: public Expression { 1873 class BinaryOperation: public Expression {
1871 public: 1874 public:
1872 DECLARE_NODE_TYPE(BinaryOperation) 1875 DECLARE_NODE_TYPE(BinaryOperation)
1873 1876
1874 virtual bool ResultOverwriteAllowed(); 1877 virtual bool ResultOverwriteAllowed();
1875 1878
1876 Token::Value op() const { return op_; } 1879 Token::Value op() const { return op_; }
1877 Expression* left() const { return left_; } 1880 Expression* left() const { return left_; }
1878 Expression* right() const { return right_; } 1881 Expression* right() const { return right_; }
1879 virtual int position() const { return pos_; } 1882 virtual int position() const { return pos_; }
1880 1883
1881 BailoutId RightId() const { return right_id_; } 1884 BailoutId RightId() const { return right_id_; }
1882 1885
1883 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } 1886 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); }
1884 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1887 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
1885 Handle<Type> left_type() const { return left_type_; } 1888 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
1886 Handle<Type> right_type() const { return right_type_; } 1889
1887 Handle<Type> result_type() const { return result_type_; } 1890 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle);
1888 bool has_fixed_right_arg() const { return has_fixed_right_arg_; }
1889 int fixed_right_arg_value() const { return fixed_right_arg_value_; }
1890 1891
1891 protected: 1892 protected:
1892 BinaryOperation(Isolate* isolate, 1893 BinaryOperation(Isolate* isolate,
1893 Token::Value op, 1894 Token::Value op,
1894 Expression* left, 1895 Expression* left,
1895 Expression* right, 1896 Expression* right,
1896 int pos) 1897 int pos)
1897 : Expression(isolate), 1898 : Expression(isolate),
1898 op_(op), 1899 op_(op),
1899 left_(left), 1900 left_(left),
1900 right_(right), 1901 right_(right),
1901 pos_(pos), 1902 pos_(pos),
1902 right_id_(GetNextId(isolate)) { 1903 right_id_(GetNextId(isolate)) {
1903 ASSERT(Token::IsBinaryOp(op)); 1904 ASSERT(Token::IsBinaryOp(op));
1904 } 1905 }
1905 1906
1906 private: 1907 private:
1907 Token::Value op_; 1908 Token::Value op_;
1908 Expression* left_; 1909 Expression* left_;
1909 Expression* right_; 1910 Expression* right_;
1910 int pos_; 1911 int pos_;
1911 1912
1912 Handle<Type> left_type_; 1913 // TODO(rossberg): the fixed arg should probably be represented as a Constant
1913 Handle<Type> right_type_; 1914 // type for the RHS.
1914 Handle<Type> result_type_; 1915 Maybe<int> fixed_right_arg_;
1915 bool has_fixed_right_arg_;
1916 int fixed_right_arg_value_;
1917 1916
1918 // The short-circuit logical operations need an AST ID for their 1917 // The short-circuit logical operations need an AST ID for their
1919 // right-hand subexpression. 1918 // right-hand subexpression.
1920 const BailoutId right_id_; 1919 const BailoutId right_id_;
1921 }; 1920 };
1922 1921
1923 1922
1924 class CountOperation: public Expression { 1923 class CountOperation: public Expression {
1925 public: 1924 public:
1926 DECLARE_NODE_TYPE(CountOperation) 1925 DECLARE_NODE_TYPE(CountOperation)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 public: 1986 public:
1988 DECLARE_NODE_TYPE(CompareOperation) 1987 DECLARE_NODE_TYPE(CompareOperation)
1989 1988
1990 Token::Value op() const { return op_; } 1989 Token::Value op() const { return op_; }
1991 Expression* left() const { return left_; } 1990 Expression* left() const { return left_; }
1992 Expression* right() const { return right_; } 1991 Expression* right() const { return right_; }
1993 virtual int position() const { return pos_; } 1992 virtual int position() const { return pos_; }
1994 1993
1995 // Type feedback information. 1994 // Type feedback information.
1996 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } 1995 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); }
1997 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1996 Handle<Type> combined_type() const { return combined_type_; }
1998 Handle<Type> left_type() const { return left_type_; } 1997 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 1998
2003 // Match special cases. 1999 // Match special cases.
2004 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2000 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
2005 bool IsLiteralCompareUndefined(Expression** expr); 2001 bool IsLiteralCompareUndefined(Expression** expr);
2006 bool IsLiteralCompareNull(Expression** expr); 2002 bool IsLiteralCompareNull(Expression** expr);
2007 2003
2008 protected: 2004 protected:
2009 CompareOperation(Isolate* isolate, 2005 CompareOperation(Isolate* isolate,
2010 Token::Value op, 2006 Token::Value op,
2011 Expression* left, 2007 Expression* left,
2012 Expression* right, 2008 Expression* right,
2013 int pos) 2009 int pos)
2014 : Expression(isolate), 2010 : Expression(isolate),
2015 op_(op), 2011 op_(op),
2016 left_(left), 2012 left_(left),
2017 right_(right), 2013 right_(right),
2018 pos_(pos) { 2014 pos_(pos) {
2019 ASSERT(Token::IsCompareOp(op)); 2015 ASSERT(Token::IsCompareOp(op));
2020 } 2016 }
2021 2017
2022 private: 2018 private:
2023 Token::Value op_; 2019 Token::Value op_;
2024 Expression* left_; 2020 Expression* left_;
2025 Expression* right_; 2021 Expression* right_;
2026 int pos_; 2022 int pos_;
2027 2023
2028 Handle<Type> left_type_; 2024 Handle<Type> combined_type_;
2029 Handle<Type> right_type_;
2030 Handle<Type> overall_type_;
2031 Handle<Type> compare_nil_type_;
2032 }; 2025 };
2033 2026
2034 2027
2035 class Conditional: public Expression { 2028 class Conditional: public Expression {
2036 public: 2029 public:
2037 DECLARE_NODE_TYPE(Conditional) 2030 DECLARE_NODE_TYPE(Conditional)
2038 2031
2039 Expression* condition() const { return condition_; } 2032 Expression* condition() const { return condition_; }
2040 Expression* then_expression() const { return then_expression_; } 2033 Expression* then_expression() const { return then_expression_; }
2041 Expression* else_expression() const { return else_expression_; } 2034 Expression* else_expression() const { return else_expression_; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 2082
2090 // This check relies on the definition order of token in token.h. 2083 // This check relies on the definition order of token in token.h.
2091 bool is_compound() const { return op() > Token::ASSIGN; } 2084 bool is_compound() const { return op() > Token::ASSIGN; }
2092 2085
2093 BailoutId AssignmentId() const { return assignment_id_; } 2086 BailoutId AssignmentId() const { return assignment_id_; }
2094 2087
2095 // Type feedback information. 2088 // Type feedback information.
2096 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } 2089 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
2097 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone); 2090 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
2098 virtual bool IsMonomorphic() { return is_monomorphic_; } 2091 virtual bool IsMonomorphic() { return is_monomorphic_; }
2092 bool IsUninitialized() { return is_uninitialized_; }
2099 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } 2093 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
2100 virtual KeyedAccessStoreMode GetStoreMode() { 2094 virtual KeyedAccessStoreMode GetStoreMode() {
2101 return store_mode_; 2095 return store_mode_;
2102 } 2096 }
2103 2097
2104 protected: 2098 protected:
2105 Assignment(Isolate* isolate, 2099 Assignment(Isolate* isolate,
2106 Token::Value op, 2100 Token::Value op,
2107 Expression* target, 2101 Expression* target,
2108 Expression* value, 2102 Expression* value,
(...skipping 10 matching lines...) Expand all
2119 2113
2120 private: 2114 private:
2121 Token::Value op_; 2115 Token::Value op_;
2122 Expression* target_; 2116 Expression* target_;
2123 Expression* value_; 2117 Expression* value_;
2124 int pos_; 2118 int pos_;
2125 BinaryOperation* binary_operation_; 2119 BinaryOperation* binary_operation_;
2126 const BailoutId assignment_id_; 2120 const BailoutId assignment_id_;
2127 2121
2128 bool is_monomorphic_ : 1; 2122 bool is_monomorphic_ : 1;
2123 bool is_uninitialized_ : 1;
2129 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, 2124 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
2130 // must have extra bit. 2125 // must have extra bit.
2131 SmallMapList receiver_types_; 2126 SmallMapList receiver_types_;
2132 }; 2127 };
2133 2128
2134 2129
2135 class Yield: public Expression { 2130 class Yield: public Expression {
2136 public: 2131 public:
2137 DECLARE_NODE_TYPE(Yield) 2132 DECLARE_NODE_TYPE(Yield)
2138 2133
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 private: 3213 private:
3219 Isolate* isolate_; 3214 Isolate* isolate_;
3220 Zone* zone_; 3215 Zone* zone_;
3221 Visitor visitor_; 3216 Visitor visitor_;
3222 }; 3217 };
3223 3218
3224 3219
3225 } } // namespace v8::internal 3220 } } // namespace v8::internal
3226 3221
3227 #endif // V8_AST_H_ 3222 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arraybuffer.js ('k') | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698