| OLD | NEW |
| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 int end_position, | 785 int end_position, |
| 786 Scope* scope, | 786 Scope* scope, |
| 787 AstNodeFactory* factory) { | 787 AstNodeFactory* factory) { |
| 788 if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); | 788 if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); |
| 789 | 789 |
| 790 // Arrow function parameters are parsed as an expression. When | 790 // Arrow function parameters are parsed as an expression. When |
| 791 // parsing lazily, it is enough to create a VariableProxy in order | 791 // parsing lazily, it is enough to create a VariableProxy in order |
| 792 // for Traits::DeclareArrowParametersFromExpression() to be able to | 792 // for Traits::DeclareArrowParametersFromExpression() to be able to |
| 793 // pick the names of the parameters. | 793 // pick the names of the parameters. |
| 794 return parser_->parsing_lazy_arrow_parameters_ | 794 return parser_->parsing_lazy_arrow_parameters_ |
| 795 ? factory->NewVariableProxy(name, false, start_position, | 795 ? factory->NewVariableProxy(name, Variable::NORMAL, start_position, |
| 796 end_position) | 796 end_position) |
| 797 : scope->NewUnresolved(factory, name, start_position, | 797 : scope->NewUnresolved(factory, name, start_position, |
| 798 end_position); | 798 end_position); |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| 802 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, | 802 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, |
| 803 AstNodeFactory* factory) { | 803 AstNodeFactory* factory) { |
| 804 const AstRawString* symbol = GetSymbol(scanner); | 804 const AstRawString* symbol = GetSymbol(scanner); |
| 805 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); | 805 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 // same variable if it is declared several times. This is not a | 1970 // same variable if it is declared several times. This is not a |
| 1971 // semantic issue as long as we keep the source order, but it may be | 1971 // semantic issue as long as we keep the source order, but it may be |
| 1972 // a performance issue since it may lead to repeated | 1972 // a performance issue since it may lead to repeated |
| 1973 // RuntimeHidden_DeclareLookupSlot calls. | 1973 // RuntimeHidden_DeclareLookupSlot calls. |
| 1974 declaration_scope->AddDeclaration(declaration); | 1974 declaration_scope->AddDeclaration(declaration); |
| 1975 | 1975 |
| 1976 if (mode == CONST_LEGACY && declaration_scope->is_script_scope()) { | 1976 if (mode == CONST_LEGACY && declaration_scope->is_script_scope()) { |
| 1977 // For global const variables we bind the proxy to a variable. | 1977 // For global const variables we bind the proxy to a variable. |
| 1978 DCHECK(resolve); // should be set by all callers | 1978 DCHECK(resolve); // should be set by all callers |
| 1979 Variable::Kind kind = Variable::NORMAL; | 1979 Variable::Kind kind = Variable::NORMAL; |
| 1980 var = new (zone()) Variable(declaration_scope, name, mode, true, kind, | 1980 var = new (zone()) Variable(declaration_scope, name, mode, kind, |
| 1981 kNeedsInitialization, kNotAssigned); | 1981 kNeedsInitialization, kNotAssigned); |
| 1982 } else if (declaration_scope->is_eval_scope() && | 1982 } else if (declaration_scope->is_eval_scope() && |
| 1983 is_sloppy(declaration_scope->language_mode())) { | 1983 is_sloppy(declaration_scope->language_mode())) { |
| 1984 // For variable declarations in a sloppy eval scope the proxy is bound | 1984 // For variable declarations in a sloppy eval scope the proxy is bound |
| 1985 // to a lookup variable to force a dynamic declaration using the | 1985 // to a lookup variable to force a dynamic declaration using the |
| 1986 // DeclareLookupSlot runtime function. | 1986 // DeclareLookupSlot runtime function. |
| 1987 Variable::Kind kind = Variable::NORMAL; | 1987 Variable::Kind kind = Variable::NORMAL; |
| 1988 // TODO(sigurds) figure out if kNotAssigned is OK here | 1988 // TODO(sigurds) figure out if kNotAssigned is OK here |
| 1989 var = new (zone()) Variable(declaration_scope, name, mode, true, kind, | 1989 var = new (zone()) Variable(declaration_scope, name, mode, kind, |
| 1990 declaration->initialization(), kNotAssigned); | 1990 declaration->initialization(), kNotAssigned); |
| 1991 var->AllocateTo(Variable::LOOKUP, -1); | 1991 var->AllocateTo(Variable::LOOKUP, -1); |
| 1992 resolve = true; | 1992 resolve = true; |
| 1993 } | 1993 } |
| 1994 | 1994 |
| 1995 // If requested and we have a local variable, bind the proxy to the variable | 1995 // If requested and we have a local variable, bind the proxy to the variable |
| 1996 // at parse-time. This is used for functions (and consts) declared inside | 1996 // at parse-time. This is used for functions (and consts) declared inside |
| 1997 // statements: the corresponding function (or const) variable must be in the | 1997 // statements: the corresponding function (or const) variable must be in the |
| 1998 // function scope and not a statement-local scope, e.g. as provided with a | 1998 // function scope and not a statement-local scope, e.g. as provided with a |
| 1999 // 'with' statement: | 1999 // 'with' statement: |
| (...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 Variable* fvar = NULL; | 3878 Variable* fvar = NULL; |
| 3879 Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; | 3879 Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; |
| 3880 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { | 3880 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { |
| 3881 if (is_strict(language_mode())) { | 3881 if (is_strict(language_mode())) { |
| 3882 fvar_init_op = Token::INIT_CONST; | 3882 fvar_init_op = Token::INIT_CONST; |
| 3883 } | 3883 } |
| 3884 VariableMode fvar_mode = | 3884 VariableMode fvar_mode = |
| 3885 is_strict(language_mode()) ? CONST : CONST_LEGACY; | 3885 is_strict(language_mode()) ? CONST : CONST_LEGACY; |
| 3886 DCHECK(function_name != NULL); | 3886 DCHECK(function_name != NULL); |
| 3887 fvar = new (zone()) | 3887 fvar = new (zone()) |
| 3888 Variable(scope_, function_name, fvar_mode, true /* is valid LHS */, | 3888 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, |
| 3889 Variable::NORMAL, kCreatedInitialized, kNotAssigned); | 3889 kCreatedInitialized, kNotAssigned); |
| 3890 VariableProxy* proxy = factory()->NewVariableProxy(fvar); | 3890 VariableProxy* proxy = factory()->NewVariableProxy(fvar); |
| 3891 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( | 3891 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( |
| 3892 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); | 3892 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); |
| 3893 scope_->DeclareFunctionVar(fvar_declaration); | 3893 scope_->DeclareFunctionVar(fvar_declaration); |
| 3894 } | 3894 } |
| 3895 | 3895 |
| 3896 // Determine if the function can be parsed lazily. Lazy parsing is different | 3896 // Determine if the function can be parsed lazily. Lazy parsing is different |
| 3897 // from lazy compilation; we need to parse more eagerly than we compile. | 3897 // from lazy compilation; we need to parse more eagerly than we compile. |
| 3898 | 3898 |
| 3899 // We can only parse lazily if we also compile lazily. The heuristics for | 3899 // We can only parse lazily if we also compile lazily. The heuristics for |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5558 } else { | 5558 } else { |
| 5559 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5559 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
| 5560 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5560 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
| 5561 raw_string->length()); | 5561 raw_string->length()); |
| 5562 } | 5562 } |
| 5563 } | 5563 } |
| 5564 | 5564 |
| 5565 return running_hash; | 5565 return running_hash; |
| 5566 } | 5566 } |
| 5567 } } // namespace v8::internal | 5567 } } // namespace v8::internal |
| OLD | NEW |