| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 | 272 |
| 273 | 273 |
| 274 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, | 274 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, |
| 275 int pos, int end_pos) { | 275 int pos, int end_pos) { |
| 276 int materialized_literal_count = -1; | 276 int materialized_literal_count = -1; |
| 277 int expected_property_count = -1; | 277 int expected_property_count = -1; |
| 278 int handler_count = 0; | 278 int handler_count = 0; |
| 279 int parameter_count = 0; | 279 int parameter_count = 0; |
| 280 AstProperties ast_properties; | 280 AstProperties ast_properties; |
| 281 BailoutReason dont_optimize_reason = kNoReason; | |
| 282 const AstRawString* name = ast_value_factory()->empty_string(); | 281 const AstRawString* name = ast_value_factory()->empty_string(); |
| 283 FunctionKind kind = call_super ? FunctionKind::kDefaultConstructorCallSuper | 282 FunctionKind kind = call_super ? FunctionKind::kDefaultConstructorCallSuper |
| 284 : FunctionKind::kDefaultConstructor; | 283 : FunctionKind::kDefaultConstructor; |
| 285 | 284 |
| 286 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE); | 285 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE); |
| 287 function_scope->SetStrictMode(STRICT); | 286 function_scope->SetStrictMode(STRICT); |
| 288 // Set start and end position to the same value | 287 // Set start and end position to the same value |
| 289 function_scope->set_start_position(pos); | 288 function_scope->set_start_position(pos); |
| 290 function_scope->set_end_position(pos); | 289 function_scope->set_end_position(pos); |
| 291 ZoneList<Statement*>* body = NULL; | 290 ZoneList<Statement*>* body = NULL; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 305 Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args, | 304 Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args, |
| 306 pos); | 305 pos); |
| 307 body->Add(factory()->NewExpressionStatement(call, pos), zone()); | 306 body->Add(factory()->NewExpressionStatement(call, pos), zone()); |
| 308 } | 307 } |
| 309 | 308 |
| 310 materialized_literal_count = function_state.materialized_literal_count(); | 309 materialized_literal_count = function_state.materialized_literal_count(); |
| 311 expected_property_count = function_state.expected_property_count(); | 310 expected_property_count = function_state.expected_property_count(); |
| 312 handler_count = function_state.handler_count(); | 311 handler_count = function_state.handler_count(); |
| 313 | 312 |
| 314 ast_properties = *factory()->visitor()->ast_properties(); | 313 ast_properties = *factory()->visitor()->ast_properties(); |
| 315 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); | |
| 316 } | 314 } |
| 317 | 315 |
| 318 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 316 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
| 319 name, ast_value_factory(), function_scope, body, | 317 name, ast_value_factory(), function_scope, body, |
| 320 materialized_literal_count, expected_property_count, handler_count, | 318 materialized_literal_count, expected_property_count, handler_count, |
| 321 parameter_count, FunctionLiteral::kNoDuplicateParameters, | 319 parameter_count, FunctionLiteral::kNoDuplicateParameters, |
| 322 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 320 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 323 FunctionLiteral::kNotParenthesized, kind, pos); | 321 FunctionLiteral::kNotParenthesized, kind, pos); |
| 324 | 322 |
| 325 function_literal->set_ast_properties(&ast_properties); | 323 function_literal->set_ast_properties(&ast_properties); |
| 326 function_literal->set_dont_optimize_reason(dont_optimize_reason); | |
| 327 | 324 |
| 328 return function_literal; | 325 return function_literal; |
| 329 } | 326 } |
| 330 | 327 |
| 331 | 328 |
| 332 // ---------------------------------------------------------------------------- | 329 // ---------------------------------------------------------------------------- |
| 333 // Target is a support class to facilitate manipulation of the | 330 // Target is a support class to facilitate manipulation of the |
| 334 // Parser's target_stack_ (the stack of potential 'break' and | 331 // Parser's target_stack_ (the stack of potential 'break' and |
| 335 // 'continue' statement targets). Upon construction, a new target is | 332 // 'continue' statement targets). Upon construction, a new target is |
| 336 // added; it is removed upon destruction. | 333 // added; it is removed upon destruction. |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 if (ok) { | 962 if (ok) { |
| 966 result = factory()->NewFunctionLiteral( | 963 result = factory()->NewFunctionLiteral( |
| 967 ast_value_factory()->empty_string(), ast_value_factory(), scope_, | 964 ast_value_factory()->empty_string(), ast_value_factory(), scope_, |
| 968 body, function_state.materialized_literal_count(), | 965 body, function_state.materialized_literal_count(), |
| 969 function_state.expected_property_count(), | 966 function_state.expected_property_count(), |
| 970 function_state.handler_count(), 0, | 967 function_state.handler_count(), 0, |
| 971 FunctionLiteral::kNoDuplicateParameters, | 968 FunctionLiteral::kNoDuplicateParameters, |
| 972 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval, | 969 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval, |
| 973 FunctionLiteral::kNotParenthesized, FunctionKind::kNormalFunction, 0); | 970 FunctionLiteral::kNotParenthesized, FunctionKind::kNormalFunction, 0); |
| 974 result->set_ast_properties(factory()->visitor()->ast_properties()); | 971 result->set_ast_properties(factory()->visitor()->ast_properties()); |
| 975 result->set_dont_optimize_reason( | |
| 976 factory()->visitor()->dont_optimize_reason()); | |
| 977 } | 972 } |
| 978 } | 973 } |
| 979 | 974 |
| 980 // Make sure the target stack is empty. | 975 // Make sure the target stack is empty. |
| 981 DCHECK(target_stack_ == NULL); | 976 DCHECK(target_stack_ == NULL); |
| 982 | 977 |
| 983 return result; | 978 return result; |
| 984 } | 979 } |
| 985 | 980 |
| 986 | 981 |
| (...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3553 ZoneList<Statement*>* body = NULL; | 3548 ZoneList<Statement*>* body = NULL; |
| 3554 int materialized_literal_count = -1; | 3549 int materialized_literal_count = -1; |
| 3555 int expected_property_count = -1; | 3550 int expected_property_count = -1; |
| 3556 int handler_count = 0; | 3551 int handler_count = 0; |
| 3557 FunctionLiteral::ParameterFlag duplicate_parameters = | 3552 FunctionLiteral::ParameterFlag duplicate_parameters = |
| 3558 FunctionLiteral::kNoDuplicateParameters; | 3553 FunctionLiteral::kNoDuplicateParameters; |
| 3559 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ | 3554 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ |
| 3560 ? FunctionLiteral::kIsParenthesized | 3555 ? FunctionLiteral::kIsParenthesized |
| 3561 : FunctionLiteral::kNotParenthesized; | 3556 : FunctionLiteral::kNotParenthesized; |
| 3562 AstProperties ast_properties; | 3557 AstProperties ast_properties; |
| 3563 BailoutReason dont_optimize_reason = kNoReason; | |
| 3564 // Parse function body. | 3558 // Parse function body. |
| 3565 { | 3559 { |
| 3566 AstNodeFactory<AstConstructionVisitor> function_factory( | 3560 AstNodeFactory<AstConstructionVisitor> function_factory( |
| 3567 ast_value_factory()); | 3561 ast_value_factory()); |
| 3568 FunctionState function_state(&function_state_, &scope_, scope, | 3562 FunctionState function_state(&function_state_, &scope_, scope, |
| 3569 &function_factory); | 3563 &function_factory); |
| 3570 scope_->SetScopeName(function_name); | 3564 scope_->SetScopeName(function_name); |
| 3571 | 3565 |
| 3572 if (is_generator) { | 3566 if (is_generator) { |
| 3573 // For generators, allocating variables in contexts is currently a win | 3567 // For generators, allocating variables in contexts is currently a win |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3722 dupe_error_loc, | 3716 dupe_error_loc, |
| 3723 reserved_loc, | 3717 reserved_loc, |
| 3724 CHECK_OK); | 3718 CHECK_OK); |
| 3725 } | 3719 } |
| 3726 if (strict_mode() == STRICT) { | 3720 if (strict_mode() == STRICT) { |
| 3727 CheckOctalLiteral(scope->start_position(), | 3721 CheckOctalLiteral(scope->start_position(), |
| 3728 scope->end_position(), | 3722 scope->end_position(), |
| 3729 CHECK_OK); | 3723 CHECK_OK); |
| 3730 } | 3724 } |
| 3731 ast_properties = *factory()->visitor()->ast_properties(); | 3725 ast_properties = *factory()->visitor()->ast_properties(); |
| 3732 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); | |
| 3733 | 3726 |
| 3734 if (allow_harmony_scoping() && strict_mode() == STRICT) { | 3727 if (allow_harmony_scoping() && strict_mode() == STRICT) { |
| 3735 CheckConflictingVarDeclarations(scope, CHECK_OK); | 3728 CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 3736 } | 3729 } |
| 3737 } | 3730 } |
| 3738 | 3731 |
| 3739 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 3732 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
| 3740 function_name, ast_value_factory(), scope, body, | 3733 function_name, ast_value_factory(), scope, body, |
| 3741 materialized_literal_count, expected_property_count, handler_count, | 3734 materialized_literal_count, expected_property_count, handler_count, |
| 3742 num_parameters, duplicate_parameters, function_type, | 3735 num_parameters, duplicate_parameters, function_type, |
| 3743 FunctionLiteral::kIsFunction, parenthesized, kind, pos); | 3736 FunctionLiteral::kIsFunction, parenthesized, kind, pos); |
| 3744 function_literal->set_function_token_position(function_token_pos); | 3737 function_literal->set_function_token_position(function_token_pos); |
| 3745 function_literal->set_ast_properties(&ast_properties); | 3738 function_literal->set_ast_properties(&ast_properties); |
| 3746 function_literal->set_dont_optimize_reason(dont_optimize_reason); | |
| 3747 | 3739 |
| 3748 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); | 3740 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |
| 3749 return function_literal; | 3741 return function_literal; |
| 3750 } | 3742 } |
| 3751 | 3743 |
| 3752 | 3744 |
| 3753 void Parser::SkipLazyFunctionBody(const AstRawString* function_name, | 3745 void Parser::SkipLazyFunctionBody(const AstRawString* function_name, |
| 3754 int* materialized_literal_count, | 3746 int* materialized_literal_count, |
| 3755 int* expected_property_count, | 3747 int* expected_property_count, |
| 3756 bool* ok) { | 3748 bool* ok) { |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5019 | 5011 |
| 5020 // We cannot internalize on a background thread; a foreground task will take | 5012 // We cannot internalize on a background thread; a foreground task will take |
| 5021 // care of calling Parser::Internalize just before compilation. | 5013 // care of calling Parser::Internalize just before compilation. |
| 5022 | 5014 |
| 5023 if (compile_options() == ScriptCompiler::kProduceParserCache) { | 5015 if (compile_options() == ScriptCompiler::kProduceParserCache) { |
| 5024 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); | 5016 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); |
| 5025 log_ = NULL; | 5017 log_ = NULL; |
| 5026 } | 5018 } |
| 5027 } | 5019 } |
| 5028 } } // namespace v8::internal | 5020 } } // namespace v8::internal |
| OLD | NEW |