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

Side by Side Diff: src/ast.h

Issue 594008: Initial implementation of fast path operation for bitwise OR. (Closed)
Patch Set: Fixed bug, added test. Created 10 years, 10 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 | « src/arm/fast-codegen-arm.cc ('k') | src/data-flow.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 virtual Expression* AsExpression() { return this; } 187 virtual Expression* AsExpression() { return this; }
188 188
189 virtual bool IsValidLeftHandSide() { return false; } 189 virtual bool IsValidLeftHandSide() { return false; }
190 190
191 // Symbols that cannot be parsed as array indices are considered property 191 // Symbols that cannot be parsed as array indices are considered property
192 // names. We do not treat symbols that can be array indexes as property 192 // names. We do not treat symbols that can be array indexes as property
193 // names because [] for string objects is handled only by keyed ICs. 193 // names because [] for string objects is handled only by keyed ICs.
194 virtual bool IsPropertyName() { return false; } 194 virtual bool IsPropertyName() { return false; }
195 195
196 // True if the expression does not have (evaluated) subexpressions.
197 // Function literals are leaves because their subexpressions are not
198 // evaluated.
199 virtual bool IsLeaf() { return false; }
200
196 // Mark the expression as being compiled as an expression 201 // Mark the expression as being compiled as an expression
197 // statement. This is used to transform postfix increments to 202 // statement. This is used to transform postfix increments to
198 // (faster) prefix increments. 203 // (faster) prefix increments.
199 virtual void MarkAsStatement() { /* do nothing */ } 204 virtual void MarkAsStatement() { /* do nothing */ }
200 205
201 // Static type information for this expression. 206 // Static type information for this expression.
202 StaticType* type() { return &type_; } 207 StaticType* type() { return &type_; }
203 208
204 int num() { return num_; } 209 int num() { return num_; }
205 210
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 718 }
714 719
715 virtual bool IsPropertyName() { 720 virtual bool IsPropertyName() {
716 if (handle_->IsSymbol()) { 721 if (handle_->IsSymbol()) {
717 uint32_t ignored; 722 uint32_t ignored;
718 return !String::cast(*handle_)->AsArrayIndex(&ignored); 723 return !String::cast(*handle_)->AsArrayIndex(&ignored);
719 } 724 }
720 return false; 725 return false;
721 } 726 }
722 727
728 virtual bool IsLeaf() { return true; }
729
723 // Identity testers. 730 // Identity testers.
724 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } 731 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); }
725 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); } 732 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); }
726 bool IsFalse() const { 733 bool IsFalse() const {
727 return handle_.is_identical_to(Factory::false_value()); 734 return handle_.is_identical_to(Factory::false_value());
728 } 735 }
729 736
730 Handle<Object> handle() const { return handle_; } 737 Handle<Object> handle() const { return handle_; }
731 738
732 private: 739 private:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 int literal_index, 802 int literal_index,
796 bool is_simple, 803 bool is_simple,
797 int depth) 804 int depth)
798 : MaterializedLiteral(literal_index, is_simple, depth), 805 : MaterializedLiteral(literal_index, is_simple, depth),
799 constant_properties_(constant_properties), 806 constant_properties_(constant_properties),
800 properties_(properties) {} 807 properties_(properties) {}
801 808
802 virtual ObjectLiteral* AsObjectLiteral() { return this; } 809 virtual ObjectLiteral* AsObjectLiteral() { return this; }
803 virtual void Accept(AstVisitor* v); 810 virtual void Accept(AstVisitor* v);
804 811
812 virtual bool IsLeaf() { return properties()->is_empty(); }
813
805 Handle<FixedArray> constant_properties() const { 814 Handle<FixedArray> constant_properties() const {
806 return constant_properties_; 815 return constant_properties_;
807 } 816 }
808 ZoneList<Property*>* properties() const { return properties_; } 817 ZoneList<Property*>* properties() const { return properties_; }
809 818
810 private: 819 private:
811 Handle<FixedArray> constant_properties_; 820 Handle<FixedArray> constant_properties_;
812 ZoneList<Property*>* properties_; 821 ZoneList<Property*>* properties_;
813 }; 822 };
814 823
815 824
816 // Node for capturing a regexp literal. 825 // Node for capturing a regexp literal.
817 class RegExpLiteral: public MaterializedLiteral { 826 class RegExpLiteral: public MaterializedLiteral {
818 public: 827 public:
819 RegExpLiteral(Handle<String> pattern, 828 RegExpLiteral(Handle<String> pattern,
820 Handle<String> flags, 829 Handle<String> flags,
821 int literal_index) 830 int literal_index)
822 : MaterializedLiteral(literal_index, false, 1), 831 : MaterializedLiteral(literal_index, false, 1),
823 pattern_(pattern), 832 pattern_(pattern),
824 flags_(flags) {} 833 flags_(flags) {}
825 834
826 virtual void Accept(AstVisitor* v); 835 virtual void Accept(AstVisitor* v);
827 836
837 virtual bool IsLeaf() { return true; }
838
828 Handle<String> pattern() const { return pattern_; } 839 Handle<String> pattern() const { return pattern_; }
829 Handle<String> flags() const { return flags_; } 840 Handle<String> flags() const { return flags_; }
830 841
831 private: 842 private:
832 Handle<String> pattern_; 843 Handle<String> pattern_;
833 Handle<String> flags_; 844 Handle<String> flags_;
834 }; 845 };
835 846
836 // An array literal has a literals object that is used 847 // An array literal has a literals object that is used
837 // for minimizing the work when constructing it at runtime. 848 // for minimizing the work when constructing it at runtime.
838 class ArrayLiteral: public MaterializedLiteral { 849 class ArrayLiteral: public MaterializedLiteral {
839 public: 850 public:
840 ArrayLiteral(Handle<FixedArray> constant_elements, 851 ArrayLiteral(Handle<FixedArray> constant_elements,
841 ZoneList<Expression*>* values, 852 ZoneList<Expression*>* values,
842 int literal_index, 853 int literal_index,
843 bool is_simple, 854 bool is_simple,
844 int depth) 855 int depth)
845 : MaterializedLiteral(literal_index, is_simple, depth), 856 : MaterializedLiteral(literal_index, is_simple, depth),
846 constant_elements_(constant_elements), 857 constant_elements_(constant_elements),
847 values_(values) {} 858 values_(values) {}
848 859
849 virtual void Accept(AstVisitor* v); 860 virtual void Accept(AstVisitor* v);
850 virtual ArrayLiteral* AsArrayLiteral() { return this; } 861 virtual ArrayLiteral* AsArrayLiteral() { return this; }
851 862
863 virtual bool IsLeaf() { return values()->is_empty(); }
864
852 Handle<FixedArray> constant_elements() const { return constant_elements_; } 865 Handle<FixedArray> constant_elements() const { return constant_elements_; }
853 ZoneList<Expression*>* values() const { return values_; } 866 ZoneList<Expression*>* values() const { return values_; }
854 867
855 private: 868 private:
856 Handle<FixedArray> constant_elements_; 869 Handle<FixedArray> constant_elements_;
857 ZoneList<Expression*>* values_; 870 ZoneList<Expression*>* values_;
858 }; 871 };
859 872
860 873
861 // Node for constructing a context extension object for a catch block. 874 // Node for constructing a context extension object for a catch block.
(...skipping 27 matching lines...) Expand all
889 virtual VariableProxy* AsVariableProxy() { return this; } 902 virtual VariableProxy* AsVariableProxy() { return this; }
890 903
891 Variable* AsVariable() { 904 Variable* AsVariable() {
892 return this == NULL || var_ == NULL ? NULL : var_->AsVariable(); 905 return this == NULL || var_ == NULL ? NULL : var_->AsVariable();
893 } 906 }
894 907
895 virtual bool IsValidLeftHandSide() { 908 virtual bool IsValidLeftHandSide() {
896 return var_ == NULL ? true : var_->IsValidLeftHandSide(); 909 return var_ == NULL ? true : var_->IsValidLeftHandSide();
897 } 910 }
898 911
912 virtual bool IsLeaf() {
913 ASSERT(var_ != NULL); // Variable must be resolved.
914 return var()->is_global() || var()->rewrite()->IsLeaf();
915 }
916
899 bool IsVariable(Handle<String> n) { 917 bool IsVariable(Handle<String> n) {
900 return !is_this() && name().is_identical_to(n); 918 return !is_this() && name().is_identical_to(n);
901 } 919 }
902 920
903 bool IsArguments() { 921 bool IsArguments() {
904 Variable* variable = AsVariable(); 922 Variable* variable = AsVariable();
905 return (variable == NULL) ? false : variable->is_arguments(); 923 return (variable == NULL) ? false : variable->is_arguments();
906 } 924 }
907 925
908 Handle<String> name() const { return name_; } 926 Handle<String> name() const { return name_; }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 Slot(Variable* var, Type type, int index) 992 Slot(Variable* var, Type type, int index)
975 : var_(var), type_(type), index_(index) { 993 : var_(var), type_(type), index_(index) {
976 ASSERT(var != NULL); 994 ASSERT(var != NULL);
977 } 995 }
978 996
979 virtual void Accept(AstVisitor* v); 997 virtual void Accept(AstVisitor* v);
980 998
981 // Type testing & conversion 999 // Type testing & conversion
982 virtual Slot* AsSlot() { return this; } 1000 virtual Slot* AsSlot() { return this; }
983 1001
1002 virtual bool IsLeaf() { return true; }
1003
984 // Accessors 1004 // Accessors
985 Variable* var() const { return var_; } 1005 Variable* var() const { return var_; }
986 Type type() const { return type_; } 1006 Type type() const { return type_; }
987 int index() const { return index_; } 1007 int index() const { return index_; }
988 bool is_arguments() const { return var_->is_arguments(); } 1008 bool is_arguments() const { return var_->is_arguments(); }
989 1009
990 private: 1010 private:
991 Variable* var_; 1011 Variable* var_;
992 Type type_; 1012 Type type_;
993 int index_; 1013 int index_;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 #ifdef DEBUG 1350 #ifdef DEBUG
1331 already_compiled_ = false; 1351 already_compiled_ = false;
1332 #endif 1352 #endif
1333 } 1353 }
1334 1354
1335 virtual void Accept(AstVisitor* v); 1355 virtual void Accept(AstVisitor* v);
1336 1356
1337 // Type testing & conversion 1357 // Type testing & conversion
1338 virtual FunctionLiteral* AsFunctionLiteral() { return this; } 1358 virtual FunctionLiteral* AsFunctionLiteral() { return this; }
1339 1359
1360 virtual bool IsLeaf() { return true; }
1361
1340 Handle<String> name() const { return name_; } 1362 Handle<String> name() const { return name_; }
1341 Scope* scope() const { return scope_; } 1363 Scope* scope() const { return scope_; }
1342 ZoneList<Statement*>* body() const { return body_; } 1364 ZoneList<Statement*>* body() const { return body_; }
1343 void set_function_token_position(int pos) { function_token_position_ = pos; } 1365 void set_function_token_position(int pos) { function_token_position_ = pos; }
1344 int function_token_position() const { return function_token_position_; } 1366 int function_token_position() const { return function_token_position_; }
1345 int start_position() const { return start_position_; } 1367 int start_position() const { return start_position_; }
1346 int end_position() const { return end_position_; } 1368 int end_position() const { return end_position_; }
1347 bool is_expression() const { return is_expression_; } 1369 bool is_expression() const { return is_expression_; }
1348 1370
1349 int materialized_literal_count() { return materialized_literal_count_; } 1371 int materialized_literal_count() { return materialized_literal_count_; }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 1418
1397 class FunctionBoilerplateLiteral: public Expression { 1419 class FunctionBoilerplateLiteral: public Expression {
1398 public: 1420 public:
1399 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate) 1421 explicit FunctionBoilerplateLiteral(Handle<JSFunction> boilerplate)
1400 : boilerplate_(boilerplate) { 1422 : boilerplate_(boilerplate) {
1401 ASSERT(boilerplate->IsBoilerplate()); 1423 ASSERT(boilerplate->IsBoilerplate());
1402 } 1424 }
1403 1425
1404 Handle<JSFunction> boilerplate() const { return boilerplate_; } 1426 Handle<JSFunction> boilerplate() const { return boilerplate_; }
1405 1427
1428 virtual bool IsLeaf() { return true; }
1429
1406 virtual void Accept(AstVisitor* v); 1430 virtual void Accept(AstVisitor* v);
1407 1431
1408 private: 1432 private:
1409 Handle<JSFunction> boilerplate_; 1433 Handle<JSFunction> boilerplate_;
1410 }; 1434 };
1411 1435
1412 1436
1413 class ThisFunction: public Expression { 1437 class ThisFunction: public Expression {
1414 public: 1438 public:
1415 virtual void Accept(AstVisitor* v); 1439 virtual void Accept(AstVisitor* v);
1440 virtual bool IsLeaf() { return true; }
1416 }; 1441 };
1417 1442
1418 1443
1419 // ---------------------------------------------------------------------------- 1444 // ----------------------------------------------------------------------------
1420 // Regular expressions 1445 // Regular expressions
1421 1446
1422 1447
1423 class RegExpVisitor BASE_EMBEDDED { 1448 class RegExpVisitor BASE_EMBEDDED {
1424 public: 1449 public:
1425 virtual ~RegExpVisitor() { } 1450 virtual ~RegExpVisitor() { }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 #undef DEF_VISIT 1828 #undef DEF_VISIT
1804 1829
1805 private: 1830 private:
1806 bool stack_overflow_; 1831 bool stack_overflow_;
1807 }; 1832 };
1808 1833
1809 1834
1810 } } // namespace v8::internal 1835 } } // namespace v8::internal
1811 1836
1812 #endif // V8_AST_H_ 1837 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/arm/fast-codegen-arm.cc ('k') | src/data-flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698