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

Side by Side Diff: src/parsing/parser-base.h

Issue 1772423002: Don't do any special normalization if a boilerplate contains function literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mark osr-one/osr-two as skip on ignition/arm Created 4 years, 9 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/parsing/parser.h ('k') | src/parsing/preparser.h » ('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 // 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_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 template <class Traits> 1813 template <class Traits>
1814 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( 1814 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral(
1815 ExpressionClassifier* classifier, bool* ok) { 1815 ExpressionClassifier* classifier, bool* ok) {
1816 // ObjectLiteral :: 1816 // ObjectLiteral ::
1817 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' 1817 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
1818 1818
1819 int pos = peek_position(); 1819 int pos = peek_position();
1820 typename Traits::Type::PropertyList properties = 1820 typename Traits::Type::PropertyList properties =
1821 this->NewPropertyList(4, zone_); 1821 this->NewPropertyList(4, zone_);
1822 int number_of_boilerplate_properties = 0; 1822 int number_of_boilerplate_properties = 0;
1823 bool has_function = false;
1824 bool has_computed_names = false; 1823 bool has_computed_names = false;
1825 ObjectLiteralChecker checker(this); 1824 ObjectLiteralChecker checker(this);
1826 1825
1827 Expect(Token::LBRACE, CHECK_OK); 1826 Expect(Token::LBRACE, CHECK_OK);
1828 1827
1829 while (peek() != Token::RBRACE) { 1828 while (peek() != Token::RBRACE) {
1830 FuncNameInferrer::State fni_state(fni_); 1829 FuncNameInferrer::State fni_state(fni_);
1831 1830
1832 const bool in_class = false; 1831 const bool in_class = false;
1833 const bool is_static = false; 1832 const bool is_static = false;
1834 const bool has_extends = false; 1833 const bool has_extends = false;
1835 bool is_computed_name = false; 1834 bool is_computed_name = false;
1836 IdentifierT name = this->EmptyIdentifier(); 1835 IdentifierT name = this->EmptyIdentifier();
1837 ObjectLiteralPropertyT property = this->ParsePropertyDefinition( 1836 ObjectLiteralPropertyT property = this->ParsePropertyDefinition(
1838 &checker, in_class, has_extends, is_static, &is_computed_name, NULL, 1837 &checker, in_class, has_extends, is_static, &is_computed_name, NULL,
1839 classifier, &name, CHECK_OK); 1838 classifier, &name, CHECK_OK);
1840 1839
1841 if (is_computed_name) { 1840 if (is_computed_name) {
1842 has_computed_names = true; 1841 has_computed_names = true;
1843 } 1842 }
1844 1843
1845 // Mark top-level object literals that contain function literals and
1846 // pretenure the literal so it can be added as a constant function
1847 // property. (Parser only.)
1848 this->CheckFunctionLiteralInsideTopLevelObjectLiteral(scope_, property,
1849 &has_function);
1850
1851 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. 1844 // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
1852 if (!has_computed_names && this->IsBoilerplateProperty(property)) { 1845 if (!has_computed_names && this->IsBoilerplateProperty(property)) {
1853 number_of_boilerplate_properties++; 1846 number_of_boilerplate_properties++;
1854 } 1847 }
1855 properties->Add(property, zone()); 1848 properties->Add(property, zone());
1856 1849
1857 if (peek() != Token::RBRACE) { 1850 if (peek() != Token::RBRACE) {
1858 // Need {} because of the CHECK_OK macro. 1851 // Need {} because of the CHECK_OK macro.
1859 Expect(Token::COMMA, CHECK_OK); 1852 Expect(Token::COMMA, CHECK_OK);
1860 } 1853 }
1861 1854
1862 if (fni_ != nullptr) fni_->Infer(); 1855 if (fni_ != nullptr) fni_->Infer();
1863 1856
1864 if (allow_harmony_function_name()) { 1857 if (allow_harmony_function_name()) {
1865 Traits::SetFunctionNameFromPropertyName(property, name); 1858 Traits::SetFunctionNameFromPropertyName(property, name);
1866 } 1859 }
1867 } 1860 }
1868 Expect(Token::RBRACE, CHECK_OK); 1861 Expect(Token::RBRACE, CHECK_OK);
1869 1862
1870 // Computation of literal_index must happen before pre parse bailout. 1863 // Computation of literal_index must happen before pre parse bailout.
1871 int literal_index = function_state_->NextMaterializedLiteralIndex(); 1864 int literal_index = function_state_->NextMaterializedLiteralIndex();
1872 1865
1873 return factory()->NewObjectLiteral(properties, 1866 return factory()->NewObjectLiteral(properties,
1874 literal_index, 1867 literal_index,
1875 number_of_boilerplate_properties, 1868 number_of_boilerplate_properties,
1876 has_function,
1877 pos); 1869 pos);
1878 } 1870 }
1879 1871
1880 1872
1881 template <class Traits> 1873 template <class Traits>
1882 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( 1874 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments(
1883 Scanner::Location* first_spread_arg_loc, ExpressionClassifier* classifier, 1875 Scanner::Location* first_spread_arg_loc, ExpressionClassifier* classifier,
1884 bool* ok) { 1876 bool* ok) {
1885 // Arguments :: 1877 // Arguments ::
1886 // '(' (AssignmentExpression)*[','] ')' 1878 // '(' (AssignmentExpression)*[','] ')'
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 has_seen_constructor_ = true; 3361 has_seen_constructor_ = true;
3370 return; 3362 return;
3371 } 3363 }
3372 } 3364 }
3373 3365
3374 3366
3375 } // namespace internal 3367 } // namespace internal
3376 } // namespace v8 3368 } // namespace v8
3377 3369
3378 #endif // V8_PARSING_PARSER_BASE_H 3370 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698