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

Side by Side Diff: src/ast.h

Issue 647018: Introduce 'trivial' expressions, use them for this property assignments. (Closed)
Patch Set: 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 | « no previous file | src/ia32/codegen-ia32.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 2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Symbols that cannot be parsed as array indices are considered property 192 // Symbols that cannot be parsed as array indices are considered property
193 // names. We do not treat symbols that can be array indexes as property 193 // names. We do not treat symbols that can be array indexes as property
194 // names because [] for string objects is handled only by keyed ICs. 194 // names because [] for string objects is handled only by keyed ICs.
195 virtual bool IsPropertyName() { return false; } 195 virtual bool IsPropertyName() { return false; }
196 196
197 // True if the expression does not have (evaluated) subexpressions. 197 // True if the expression does not have (evaluated) subexpressions.
198 // Function literals are leaves because their subexpressions are not 198 // Function literals are leaves because their subexpressions are not
199 // evaluated. 199 // evaluated.
200 virtual bool IsLeaf() { return false; } 200 virtual bool IsLeaf() { return false; }
201 201
202 // True if the expression has no side effects and is safe to
203 // evaluate out of order.
204 virtual bool IsTrivial() { return false; }
205
202 // Mark the expression as being compiled as an expression 206 // Mark the expression as being compiled as an expression
203 // statement. This is used to transform postfix increments to 207 // statement. This is used to transform postfix increments to
204 // (faster) prefix increments. 208 // (faster) prefix increments.
205 virtual void MarkAsStatement() { /* do nothing */ } 209 virtual void MarkAsStatement() { /* do nothing */ }
206 210
207 // Static type information for this expression. 211 // Static type information for this expression.
208 StaticType* type() { return &type_; } 212 StaticType* type() { return &type_; }
209 213
210 int num() { return num_; } 214 int num() { return num_; }
211 215
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 735
732 virtual bool IsPropertyName() { 736 virtual bool IsPropertyName() {
733 if (handle_->IsSymbol()) { 737 if (handle_->IsSymbol()) {
734 uint32_t ignored; 738 uint32_t ignored;
735 return !String::cast(*handle_)->AsArrayIndex(&ignored); 739 return !String::cast(*handle_)->AsArrayIndex(&ignored);
736 } 740 }
737 return false; 741 return false;
738 } 742 }
739 743
740 virtual bool IsLeaf() { return true; } 744 virtual bool IsLeaf() { return true; }
745 virtual bool IsTrivial() { return true; }
741 746
742 // Identity testers. 747 // Identity testers.
743 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } 748 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); }
744 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); } 749 bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); }
745 bool IsFalse() const { 750 bool IsFalse() const {
746 return handle_.is_identical_to(Factory::false_value()); 751 return handle_.is_identical_to(Factory::false_value());
747 } 752 }
748 753
749 Handle<Object> handle() const { return handle_; } 754 Handle<Object> handle() const { return handle_; }
750 755
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 924
920 virtual bool IsValidLeftHandSide() { 925 virtual bool IsValidLeftHandSide() {
921 return var_ == NULL ? true : var_->IsValidLeftHandSide(); 926 return var_ == NULL ? true : var_->IsValidLeftHandSide();
922 } 927 }
923 928
924 virtual bool IsLeaf() { 929 virtual bool IsLeaf() {
925 ASSERT(var_ != NULL); // Variable must be resolved. 930 ASSERT(var_ != NULL); // Variable must be resolved.
926 return var()->is_global() || var()->rewrite()->IsLeaf(); 931 return var()->is_global() || var()->rewrite()->IsLeaf();
927 } 932 }
928 933
934 // Reading from a mutable variable is a side effect, but 'this' is
935 // immutable.
936 virtual bool IsTrivial() { return is_this(); }
937
929 bool IsVariable(Handle<String> n) { 938 bool IsVariable(Handle<String> n) {
930 return !is_this() && name().is_identical_to(n); 939 return !is_this() && name().is_identical_to(n);
931 } 940 }
932 941
933 bool IsArguments() { 942 bool IsArguments() {
934 Variable* variable = AsVariable(); 943 Variable* variable = AsVariable();
935 return (variable == NULL) ? false : variable->is_arguments(); 944 return (variable == NULL) ? false : variable->is_arguments();
936 } 945 }
937 946
938 Handle<String> name() const { return name_; } 947 Handle<String> name() const { return name_; }
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 #undef DEF_VISIT 1849 #undef DEF_VISIT
1841 1850
1842 private: 1851 private:
1843 bool stack_overflow_; 1852 bool stack_overflow_;
1844 }; 1853 };
1845 1854
1846 1855
1847 } } // namespace v8::internal 1856 } } // namespace v8::internal
1848 1857
1849 #endif // V8_AST_H_ 1858 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698