OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 function_state.expected_property_count(), | 989 function_state.expected_property_count(), |
990 function_state.handler_count(), | 990 function_state.handler_count(), |
991 0, | 991 0, |
992 FunctionLiteral::kNoDuplicateParameters, | 992 FunctionLiteral::kNoDuplicateParameters, |
993 FunctionLiteral::ANONYMOUS_EXPRESSION, | 993 FunctionLiteral::ANONYMOUS_EXPRESSION, |
994 FunctionLiteral::kGlobalOrEval, | 994 FunctionLiteral::kGlobalOrEval, |
995 FunctionLiteral::kNotParenthesized, | 995 FunctionLiteral::kNotParenthesized, |
996 FunctionLiteral::kNotGenerator, | 996 FunctionLiteral::kNotGenerator, |
997 0); | 997 0); |
998 result->set_ast_properties(factory()->visitor()->ast_properties()); | 998 result->set_ast_properties(factory()->visitor()->ast_properties()); |
999 result->set_slot_processor(factory()->visitor()->slot_processor()); | |
1000 result->set_dont_optimize_reason( | 999 result->set_dont_optimize_reason( |
1001 factory()->visitor()->dont_optimize_reason()); | 1000 factory()->visitor()->dont_optimize_reason()); |
1002 } else if (stack_overflow()) { | 1001 } else if (stack_overflow()) { |
1003 isolate()->StackOverflow(); | 1002 isolate()->StackOverflow(); |
1004 } | 1003 } |
1005 } | 1004 } |
1006 | 1005 |
1007 // Make sure the target stack is empty. | 1006 // Make sure the target stack is empty. |
1008 ASSERT(target_stack_ == NULL); | 1007 ASSERT(target_stack_ == NULL); |
1009 | 1008 |
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3251 : NewScope(scope_, FUNCTION_SCOPE); | 3250 : NewScope(scope_, FUNCTION_SCOPE); |
3252 ZoneList<Statement*>* body = NULL; | 3251 ZoneList<Statement*>* body = NULL; |
3253 int materialized_literal_count = -1; | 3252 int materialized_literal_count = -1; |
3254 int expected_property_count = -1; | 3253 int expected_property_count = -1; |
3255 int handler_count = 0; | 3254 int handler_count = 0; |
3256 FunctionLiteral::ParameterFlag duplicate_parameters = | 3255 FunctionLiteral::ParameterFlag duplicate_parameters = |
3257 FunctionLiteral::kNoDuplicateParameters; | 3256 FunctionLiteral::kNoDuplicateParameters; |
3258 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ | 3257 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ |
3259 ? FunctionLiteral::kIsParenthesized | 3258 ? FunctionLiteral::kIsParenthesized |
3260 : FunctionLiteral::kNotParenthesized; | 3259 : FunctionLiteral::kNotParenthesized; |
3261 DeferredFeedbackSlotProcessor* slot_processor; | |
3262 AstProperties ast_properties; | 3260 AstProperties ast_properties; |
3263 BailoutReason dont_optimize_reason = kNoReason; | 3261 BailoutReason dont_optimize_reason = kNoReason; |
3264 // Parse function body. | 3262 // Parse function body. |
3265 { FunctionState function_state(&function_state_, &scope_, scope, zone()); | 3263 { FunctionState function_state(&function_state_, &scope_, scope, zone()); |
3266 scope_->SetScopeName(function_name); | 3264 scope_->SetScopeName(function_name); |
3267 | 3265 |
3268 if (is_generator) { | 3266 if (is_generator) { |
3269 // For generators, allocating variables in contexts is currently a win | 3267 // For generators, allocating variables in contexts is currently a win |
3270 // because it minimizes the work needed to suspend and resume an | 3268 // because it minimizes the work needed to suspend and resume an |
3271 // activation. | 3269 // activation. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3422 if (reserved_loc.IsValid()) { | 3420 if (reserved_loc.IsValid()) { |
3423 ReportMessageAt(reserved_loc, "unexpected_strict_reserved"); | 3421 ReportMessageAt(reserved_loc, "unexpected_strict_reserved"); |
3424 *ok = false; | 3422 *ok = false; |
3425 return NULL; | 3423 return NULL; |
3426 } | 3424 } |
3427 CheckOctalLiteral(scope->start_position(), | 3425 CheckOctalLiteral(scope->start_position(), |
3428 scope->end_position(), | 3426 scope->end_position(), |
3429 CHECK_OK); | 3427 CHECK_OK); |
3430 } | 3428 } |
3431 ast_properties = *factory()->visitor()->ast_properties(); | 3429 ast_properties = *factory()->visitor()->ast_properties(); |
3432 slot_processor = factory()->visitor()->slot_processor(); | |
3433 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); | 3430 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); |
3434 } | 3431 } |
3435 | 3432 |
3436 if (allow_harmony_scoping() && strict_mode() == STRICT) { | 3433 if (allow_harmony_scoping() && strict_mode() == STRICT) { |
3437 CheckConflictingVarDeclarations(scope, CHECK_OK); | 3434 CheckConflictingVarDeclarations(scope, CHECK_OK); |
3438 } | 3435 } |
3439 | 3436 |
3440 FunctionLiteral::IsGeneratorFlag generator = is_generator | 3437 FunctionLiteral::IsGeneratorFlag generator = is_generator |
3441 ? FunctionLiteral::kIsGenerator | 3438 ? FunctionLiteral::kIsGenerator |
3442 : FunctionLiteral::kNotGenerator; | 3439 : FunctionLiteral::kNotGenerator; |
3443 FunctionLiteral* function_literal = | 3440 FunctionLiteral* function_literal = |
3444 factory()->NewFunctionLiteral(function_name, | 3441 factory()->NewFunctionLiteral(function_name, |
3445 scope, | 3442 scope, |
3446 body, | 3443 body, |
3447 materialized_literal_count, | 3444 materialized_literal_count, |
3448 expected_property_count, | 3445 expected_property_count, |
3449 handler_count, | 3446 handler_count, |
3450 num_parameters, | 3447 num_parameters, |
3451 duplicate_parameters, | 3448 duplicate_parameters, |
3452 function_type, | 3449 function_type, |
3453 FunctionLiteral::kIsFunction, | 3450 FunctionLiteral::kIsFunction, |
3454 parenthesized, | 3451 parenthesized, |
3455 generator, | 3452 generator, |
3456 pos); | 3453 pos); |
3457 function_literal->set_function_token_position(function_token_pos); | 3454 function_literal->set_function_token_position(function_token_pos); |
3458 function_literal->set_ast_properties(&ast_properties); | 3455 function_literal->set_ast_properties(&ast_properties); |
3459 function_literal->set_slot_processor(slot_processor); | |
3460 function_literal->set_dont_optimize_reason(dont_optimize_reason); | 3456 function_literal->set_dont_optimize_reason(dont_optimize_reason); |
3461 | 3457 |
3462 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); | 3458 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |
3463 return function_literal; | 3459 return function_literal; |
3464 } | 3460 } |
3465 | 3461 |
3466 | 3462 |
3467 void Parser::SkipLazyFunctionBody(Handle<String> function_name, | 3463 void Parser::SkipLazyFunctionBody(Handle<String> function_name, |
3468 int* materialized_literal_count, | 3464 int* materialized_literal_count, |
3469 int* expected_property_count, | 3465 int* expected_property_count, |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4692 ASSERT(info()->isolate()->has_pending_exception()); | 4688 ASSERT(info()->isolate()->has_pending_exception()); |
4693 } else { | 4689 } else { |
4694 result = ParseProgram(); | 4690 result = ParseProgram(); |
4695 } | 4691 } |
4696 } | 4692 } |
4697 info()->SetFunction(result); | 4693 info()->SetFunction(result); |
4698 return (result != NULL); | 4694 return (result != NULL); |
4699 } | 4695 } |
4700 | 4696 |
4701 } } // namespace v8::internal | 4697 } } // namespace v8::internal |
OLD | NEW |