| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 set_allow_modules(!info->is_native() && FLAG_harmony_modules); | 558 set_allow_modules(!info->is_native() && FLAG_harmony_modules); |
| 559 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); | 559 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); |
| 560 set_allow_lazy(false); // Must be explicitly enabled. | 560 set_allow_lazy(false); // Must be explicitly enabled. |
| 561 set_allow_generators(FLAG_harmony_generators); | 561 set_allow_generators(FLAG_harmony_generators); |
| 562 set_allow_for_of(FLAG_harmony_iteration); | 562 set_allow_for_of(FLAG_harmony_iteration); |
| 563 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 563 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
| 564 } | 564 } |
| 565 | 565 |
| 566 | 566 |
| 567 FunctionLiteral* Parser::ParseProgram() { | 567 FunctionLiteral* Parser::ParseProgram() { |
| 568 HistogramTimerScope timer_scope(isolate()->counters()->parse()); | 568 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, |
| 569 // see comment for HistogramTimerScope class. |
| 570 HistogramTimerScope timer_scope(isolate()->counters()->parse(), true); |
| 569 Handle<String> source(String::cast(script_->source())); | 571 Handle<String> source(String::cast(script_->source())); |
| 570 isolate()->counters()->total_parse_size()->Increment(source->length()); | 572 isolate()->counters()->total_parse_size()->Increment(source->length()); |
| 571 ElapsedTimer timer; | 573 ElapsedTimer timer; |
| 572 if (FLAG_trace_parse) { | 574 if (FLAG_trace_parse) { |
| 573 timer.Start(); | 575 timer.Start(); |
| 574 } | 576 } |
| 575 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); | 577 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
| 576 | 578 |
| 577 // Initialize parser state. | 579 // Initialize parser state. |
| 578 source->TryFlatten(); | 580 source->TryFlatten(); |
| (...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 | 2616 |
| 2615 | 2617 |
| 2616 void Parser::InitializeForEachStatement(ForEachStatement* stmt, | 2618 void Parser::InitializeForEachStatement(ForEachStatement* stmt, |
| 2617 Expression* each, | 2619 Expression* each, |
| 2618 Expression* subject, | 2620 Expression* subject, |
| 2619 Statement* body) { | 2621 Statement* body) { |
| 2620 ForOfStatement* for_of = stmt->AsForOfStatement(); | 2622 ForOfStatement* for_of = stmt->AsForOfStatement(); |
| 2621 | 2623 |
| 2622 if (for_of != NULL) { | 2624 if (for_of != NULL) { |
| 2623 Factory* heap_factory = isolate()->factory(); | 2625 Factory* heap_factory = isolate()->factory(); |
| 2624 Handle<String> iterator_str = heap_factory->InternalizeOneByteString( | 2626 Variable* iterator = top_scope_->DeclarationScope()->NewTemporary( |
| 2625 STATIC_ASCII_VECTOR(".iterator")); | 2627 heap_factory->dot_iterator_string()); |
| 2626 Handle<String> result_str = heap_factory->InternalizeOneByteString( | 2628 Variable* result = top_scope_->DeclarationScope()->NewTemporary( |
| 2627 STATIC_ASCII_VECTOR(".result")); | 2629 heap_factory->dot_result_string()); |
| 2628 Variable* iterator = | |
| 2629 top_scope_->DeclarationScope()->NewTemporary(iterator_str); | |
| 2630 Variable* result = top_scope_->DeclarationScope()->NewTemporary(result_str); | |
| 2631 | 2630 |
| 2632 Expression* assign_iterator; | 2631 Expression* assign_iterator; |
| 2633 Expression* next_result; | 2632 Expression* next_result; |
| 2634 Expression* result_done; | 2633 Expression* result_done; |
| 2635 Expression* assign_each; | 2634 Expression* assign_each; |
| 2636 | 2635 |
| 2637 // var iterator = iterable; | 2636 // var iterator = iterable; |
| 2638 { | 2637 { |
| 2639 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); | 2638 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); |
| 2640 assign_iterator = factory()->NewAssignment( | 2639 assign_iterator = factory()->NewAssignment( |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 values->Add(elem, zone()); | 3653 values->Add(elem, zone()); |
| 3655 if (peek() != Token::RBRACK) { | 3654 if (peek() != Token::RBRACK) { |
| 3656 Expect(Token::COMMA, CHECK_OK); | 3655 Expect(Token::COMMA, CHECK_OK); |
| 3657 } | 3656 } |
| 3658 } | 3657 } |
| 3659 Expect(Token::RBRACK, CHECK_OK); | 3658 Expect(Token::RBRACK, CHECK_OK); |
| 3660 | 3659 |
| 3661 // Update the scope information before the pre-parsing bailout. | 3660 // Update the scope information before the pre-parsing bailout. |
| 3662 int literal_index = current_function_state_->NextMaterializedLiteralIndex(); | 3661 int literal_index = current_function_state_->NextMaterializedLiteralIndex(); |
| 3663 | 3662 |
| 3664 // Allocate a fixed array to hold all the object literals. | 3663 return factory()->NewArrayLiteral(values, literal_index, pos); |
| 3665 Handle<JSArray> array = | |
| 3666 isolate()->factory()->NewJSArray(0, FAST_HOLEY_SMI_ELEMENTS); | |
| 3667 isolate()->factory()->SetElementsCapacityAndLength( | |
| 3668 array, values->length(), values->length()); | |
| 3669 | |
| 3670 // Fill in the literals. | |
| 3671 Heap* heap = isolate()->heap(); | |
| 3672 bool is_simple = true; | |
| 3673 int depth = 1; | |
| 3674 bool is_holey = false; | |
| 3675 for (int i = 0, n = values->length(); i < n; i++) { | |
| 3676 MaterializedLiteral* m_literal = values->at(i)->AsMaterializedLiteral(); | |
| 3677 if (m_literal != NULL && m_literal->depth() + 1 > depth) { | |
| 3678 depth = m_literal->depth() + 1; | |
| 3679 } | |
| 3680 Handle<Object> boilerplate_value = GetBoilerplateValue(values->at(i)); | |
| 3681 if (boilerplate_value->IsTheHole()) { | |
| 3682 is_holey = true; | |
| 3683 } else if (boilerplate_value->IsUninitialized()) { | |
| 3684 is_simple = false; | |
| 3685 JSObject::SetOwnElement( | |
| 3686 array, i, handle(Smi::FromInt(0), isolate()), kNonStrictMode); | |
| 3687 } else { | |
| 3688 JSObject::SetOwnElement(array, i, boilerplate_value, kNonStrictMode); | |
| 3689 } | |
| 3690 } | |
| 3691 | |
| 3692 Handle<FixedArrayBase> element_values(array->elements()); | |
| 3693 | |
| 3694 // Simple and shallow arrays can be lazily copied, we transform the | |
| 3695 // elements array to a copy-on-write array. | |
| 3696 if (is_simple && depth == 1 && values->length() > 0 && | |
| 3697 array->HasFastSmiOrObjectElements()) { | |
| 3698 element_values->set_map(heap->fixed_cow_array_map()); | |
| 3699 } | |
| 3700 | |
| 3701 // Remember both the literal's constant values as well as the ElementsKind | |
| 3702 // in a 2-element FixedArray. | |
| 3703 Handle<FixedArray> literals = isolate()->factory()->NewFixedArray(2, TENURED); | |
| 3704 | |
| 3705 ElementsKind kind = array->GetElementsKind(); | |
| 3706 kind = is_holey ? GetHoleyElementsKind(kind) : GetPackedElementsKind(kind); | |
| 3707 | |
| 3708 literals->set(0, Smi::FromInt(kind)); | |
| 3709 literals->set(1, *element_values); | |
| 3710 | |
| 3711 return factory()->NewArrayLiteral( | |
| 3712 literals, values, literal_index, is_simple, depth, pos); | |
| 3713 } | 3664 } |
| 3714 | 3665 |
| 3715 | 3666 |
| 3716 bool Parser::IsBoilerplateProperty(ObjectLiteral::Property* property) { | |
| 3717 return property != NULL && | |
| 3718 property->kind() != ObjectLiteral::Property::PROTOTYPE; | |
| 3719 } | |
| 3720 | |
| 3721 | |
| 3722 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { | 3667 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
| 3723 if (expression->AsLiteral() != NULL) return true; | 3668 if (expression->AsLiteral() != NULL) return true; |
| 3724 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); | 3669 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); |
| 3725 return lit != NULL && lit->is_simple(); | 3670 return lit != NULL && lit->is_simple(); |
| 3726 } | 3671 } |
| 3727 | 3672 |
| 3728 | 3673 |
| 3729 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate, | 3674 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate, |
| 3730 Expression* expression) { | 3675 Expression* expression) { |
| 3731 Factory* factory = isolate->factory(); | 3676 Factory* factory = isolate->factory(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3755 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot)); | 3700 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot)); |
| 3756 return static_cast<LiteralType>(literal_type->value()); | 3701 return static_cast<LiteralType>(literal_type->value()); |
| 3757 } | 3702 } |
| 3758 | 3703 |
| 3759 | 3704 |
| 3760 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { | 3705 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { |
| 3761 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); | 3706 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); |
| 3762 } | 3707 } |
| 3763 | 3708 |
| 3764 | 3709 |
| 3765 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { | |
| 3766 if (expression->AsLiteral() != NULL) { | |
| 3767 return expression->AsLiteral()->value(); | |
| 3768 } | |
| 3769 if (CompileTimeValue::IsCompileTimeValue(expression)) { | |
| 3770 return CompileTimeValue::GetValue(isolate(), expression); | |
| 3771 } | |
| 3772 return isolate()->factory()->uninitialized_value(); | |
| 3773 } | |
| 3774 | |
| 3775 | |
| 3776 void Parser::BuildObjectLiteralConstantProperties( | |
| 3777 ZoneList<ObjectLiteral::Property*>* properties, | |
| 3778 Handle<FixedArray> constant_properties, | |
| 3779 bool* is_simple, | |
| 3780 bool* fast_elements, | |
| 3781 int* depth, | |
| 3782 bool* may_store_doubles) { | |
| 3783 int position = 0; | |
| 3784 // Accumulate the value in local variables and store it at the end. | |
| 3785 bool is_simple_acc = true; | |
| 3786 int depth_acc = 1; | |
| 3787 uint32_t max_element_index = 0; | |
| 3788 uint32_t elements = 0; | |
| 3789 for (int i = 0; i < properties->length(); i++) { | |
| 3790 ObjectLiteral::Property* property = properties->at(i); | |
| 3791 if (!IsBoilerplateProperty(property)) { | |
| 3792 is_simple_acc = false; | |
| 3793 continue; | |
| 3794 } | |
| 3795 MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); | |
| 3796 if (m_literal != NULL && m_literal->depth() >= depth_acc) { | |
| 3797 depth_acc = m_literal->depth() + 1; | |
| 3798 } | |
| 3799 | |
| 3800 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined | |
| 3801 // value for COMPUTED properties, the real value is filled in at | |
| 3802 // runtime. The enumeration order is maintained. | |
| 3803 Handle<Object> key = property->key()->value(); | |
| 3804 Handle<Object> value = GetBoilerplateValue(property->value()); | |
| 3805 | |
| 3806 // Ensure objects that may, at any point in time, contain fields with double | |
| 3807 // representation are always treated as nested objects. This is true for | |
| 3808 // computed fields (value is undefined), and smi and double literals | |
| 3809 // (value->IsNumber()). | |
| 3810 // TODO(verwaest): Remove once we can store them inline. | |
| 3811 if (FLAG_track_double_fields && | |
| 3812 (value->IsNumber() || value->IsUninitialized())) { | |
| 3813 *may_store_doubles = true; | |
| 3814 } | |
| 3815 | |
| 3816 is_simple_acc = is_simple_acc && !value->IsUninitialized(); | |
| 3817 | |
| 3818 // Keep track of the number of elements in the object literal and | |
| 3819 // the largest element index. If the largest element index is | |
| 3820 // much larger than the number of elements, creating an object | |
| 3821 // literal with fast elements will be a waste of space. | |
| 3822 uint32_t element_index = 0; | |
| 3823 if (key->IsString() | |
| 3824 && Handle<String>::cast(key)->AsArrayIndex(&element_index) | |
| 3825 && element_index > max_element_index) { | |
| 3826 max_element_index = element_index; | |
| 3827 elements++; | |
| 3828 } else if (key->IsSmi()) { | |
| 3829 int key_value = Smi::cast(*key)->value(); | |
| 3830 if (key_value > 0 | |
| 3831 && static_cast<uint32_t>(key_value) > max_element_index) { | |
| 3832 max_element_index = key_value; | |
| 3833 } | |
| 3834 elements++; | |
| 3835 } | |
| 3836 | |
| 3837 // Add name, value pair to the fixed array. | |
| 3838 constant_properties->set(position++, *key); | |
| 3839 constant_properties->set(position++, *value); | |
| 3840 } | |
| 3841 *fast_elements = | |
| 3842 (max_element_index <= 32) || ((2 * elements) >= max_element_index); | |
| 3843 *is_simple = is_simple_acc; | |
| 3844 *depth = depth_acc; | |
| 3845 } | |
| 3846 | |
| 3847 | |
| 3848 Expression* Parser::ParseObjectLiteral(bool* ok) { | 3710 Expression* Parser::ParseObjectLiteral(bool* ok) { |
| 3849 // ObjectLiteral :: | 3711 // ObjectLiteral :: |
| 3850 // '{' ( | 3712 // '{' ( |
| 3851 // ((IdentifierName | String | Number) ':' AssignmentExpression) | 3713 // ((IdentifierName | String | Number) ':' AssignmentExpression) |
| 3852 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) | 3714 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) |
| 3853 // )*[','] '}' | 3715 // )*[','] '}' |
| 3854 | 3716 |
| 3855 int pos = peek_position(); | 3717 int pos = peek_position(); |
| 3856 ZoneList<ObjectLiteral::Property*>* properties = | 3718 ZoneList<ObjectLiteral::Property*>* properties = |
| 3857 new(zone()) ZoneList<ObjectLiteral::Property*>(4, zone()); | 3719 new(zone()) ZoneList<ObjectLiteral::Property*>(4, zone()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 ParseFunctionLiteral(name, | 3768 ParseFunctionLiteral(name, |
| 3907 false, // reserved words are allowed here | 3769 false, // reserved words are allowed here |
| 3908 false, // not a generator | 3770 false, // not a generator |
| 3909 RelocInfo::kNoPosition, | 3771 RelocInfo::kNoPosition, |
| 3910 FunctionLiteral::ANONYMOUS_EXPRESSION, | 3772 FunctionLiteral::ANONYMOUS_EXPRESSION, |
| 3911 CHECK_OK); | 3773 CHECK_OK); |
| 3912 // Allow any number of parameters for compatibilty with JSC. | 3774 // Allow any number of parameters for compatibilty with JSC. |
| 3913 // Specification only allows zero parameters for get and one for set. | 3775 // Specification only allows zero parameters for get and one for set. |
| 3914 ObjectLiteral::Property* property = | 3776 ObjectLiteral::Property* property = |
| 3915 factory()->NewObjectLiteralProperty(is_getter, value, next_pos); | 3777 factory()->NewObjectLiteralProperty(is_getter, value, next_pos); |
| 3916 if (IsBoilerplateProperty(property)) { | 3778 if (ObjectLiteral::IsBoilerplateProperty(property)) { |
| 3917 number_of_boilerplate_properties++; | 3779 number_of_boilerplate_properties++; |
| 3918 } | 3780 } |
| 3919 properties->Add(property, zone()); | 3781 properties->Add(property, zone()); |
| 3920 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); | 3782 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
| 3921 | 3783 |
| 3922 if (fni_ != NULL) { | 3784 if (fni_ != NULL) { |
| 3923 fni_->Infer(); | 3785 fni_->Infer(); |
| 3924 fni_->Leave(); | 3786 fni_->Leave(); |
| 3925 } | 3787 } |
| 3926 continue; // restart the while | 3788 continue; // restart the while |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3978 // Mark top-level object literals that contain function literals and | 3840 // Mark top-level object literals that contain function literals and |
| 3979 // pretenure the literal so it can be added as a constant function | 3841 // pretenure the literal so it can be added as a constant function |
| 3980 // property. | 3842 // property. |
| 3981 if (top_scope_->DeclarationScope()->is_global_scope() && | 3843 if (top_scope_->DeclarationScope()->is_global_scope() && |
| 3982 value->AsFunctionLiteral() != NULL) { | 3844 value->AsFunctionLiteral() != NULL) { |
| 3983 has_function = true; | 3845 has_function = true; |
| 3984 value->AsFunctionLiteral()->set_pretenure(); | 3846 value->AsFunctionLiteral()->set_pretenure(); |
| 3985 } | 3847 } |
| 3986 | 3848 |
| 3987 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. | 3849 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. |
| 3988 if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++; | 3850 if (ObjectLiteral::IsBoilerplateProperty(property)) { |
| 3851 number_of_boilerplate_properties++; |
| 3852 } |
| 3989 properties->Add(property, zone()); | 3853 properties->Add(property, zone()); |
| 3990 | 3854 |
| 3991 // TODO(1240767): Consider allowing trailing comma. | 3855 // TODO(1240767): Consider allowing trailing comma. |
| 3992 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); | 3856 if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
| 3993 | 3857 |
| 3994 if (fni_ != NULL) { | 3858 if (fni_ != NULL) { |
| 3995 fni_->Infer(); | 3859 fni_->Infer(); |
| 3996 fni_->Leave(); | 3860 fni_->Leave(); |
| 3997 } | 3861 } |
| 3998 } | 3862 } |
| 3999 Expect(Token::RBRACE, CHECK_OK); | 3863 Expect(Token::RBRACE, CHECK_OK); |
| 4000 | 3864 |
| 4001 // Computation of literal_index must happen before pre parse bailout. | 3865 // Computation of literal_index must happen before pre parse bailout. |
| 4002 int literal_index = current_function_state_->NextMaterializedLiteralIndex(); | 3866 int literal_index = current_function_state_->NextMaterializedLiteralIndex(); |
| 4003 | 3867 |
| 4004 Handle<FixedArray> constant_properties = isolate()->factory()->NewFixedArray( | 3868 return factory()->NewObjectLiteral(properties, |
| 4005 number_of_boilerplate_properties * 2, TENURED); | |
| 4006 | |
| 4007 bool is_simple = true; | |
| 4008 bool fast_elements = true; | |
| 4009 int depth = 1; | |
| 4010 bool may_store_doubles = false; | |
| 4011 BuildObjectLiteralConstantProperties(properties, | |
| 4012 constant_properties, | |
| 4013 &is_simple, | |
| 4014 &fast_elements, | |
| 4015 &depth, | |
| 4016 &may_store_doubles); | |
| 4017 return factory()->NewObjectLiteral(constant_properties, | |
| 4018 properties, | |
| 4019 literal_index, | 3869 literal_index, |
| 4020 is_simple, | 3870 number_of_boilerplate_properties, |
| 4021 fast_elements, | |
| 4022 depth, | |
| 4023 may_store_doubles, | |
| 4024 has_function, | 3871 has_function, |
| 4025 pos); | 3872 pos); |
| 4026 } | 3873 } |
| 4027 | 3874 |
| 4028 | 3875 |
| 4029 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { | 3876 Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) { |
| 4030 int pos = peek_position(); | 3877 int pos = peek_position(); |
| 4031 if (!scanner().ScanRegExpPattern(seen_equal)) { | 3878 if (!scanner().ScanRegExpPattern(seen_equal)) { |
| 4032 Next(); | 3879 Next(); |
| 4033 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); | 3880 ReportMessage("unterminated_regexp", Vector<const char*>::empty()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4243 if (is_generator) { | 4090 if (is_generator) { |
| 4244 // For generators, allocating variables in contexts is currently a win | 4091 // For generators, allocating variables in contexts is currently a win |
| 4245 // because it minimizes the work needed to suspend and resume an | 4092 // because it minimizes the work needed to suspend and resume an |
| 4246 // activation. | 4093 // activation. |
| 4247 top_scope_->ForceContextAllocation(); | 4094 top_scope_->ForceContextAllocation(); |
| 4248 | 4095 |
| 4249 // Calling a generator returns a generator object. That object is stored | 4096 // Calling a generator returns a generator object. That object is stored |
| 4250 // in a temporary variable, a definition that is used by "yield" | 4097 // in a temporary variable, a definition that is used by "yield" |
| 4251 // expressions. Presence of a variable for the generator object in the | 4098 // expressions. Presence of a variable for the generator object in the |
| 4252 // FunctionState indicates that this function is a generator. | 4099 // FunctionState indicates that this function is a generator. |
| 4253 Handle<String> tempname = isolate()->factory()->InternalizeOneByteString( | 4100 Variable* temp = top_scope_->DeclarationScope()->NewTemporary( |
| 4254 STATIC_ASCII_VECTOR(".generator_object")); | 4101 isolate()->factory()->dot_generator_object_string()); |
| 4255 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(tempname); | |
| 4256 function_state.set_generator_object_variable(temp); | 4102 function_state.set_generator_object_variable(temp); |
| 4257 } | 4103 } |
| 4258 | 4104 |
| 4259 // FormalParameterList :: | 4105 // FormalParameterList :: |
| 4260 // '(' (Identifier)*[','] ')' | 4106 // '(' (Identifier)*[','] ')' |
| 4261 Expect(Token::LPAREN, CHECK_OK); | 4107 Expect(Token::LPAREN, CHECK_OK); |
| 4262 scope->set_start_position(scanner().location().beg_pos); | 4108 scope->set_start_position(scanner().location().beg_pos); |
| 4263 Scanner::Location name_loc = Scanner::Location::invalid(); | 4109 Scanner::Location name_loc = Scanner::Location::invalid(); |
| 4264 Scanner::Location dupe_loc = Scanner::Location::invalid(); | 4110 Scanner::Location dupe_loc = Scanner::Location::invalid(); |
| 4265 Scanner::Location reserved_loc = Scanner::Location::invalid(); | 4111 Scanner::Location reserved_loc = Scanner::Location::invalid(); |
| 4266 | 4112 |
| 4267 bool done = (peek() == Token::RPAREN); | 4113 bool done = (peek() == Token::RPAREN); |
| 4268 while (!done) { | 4114 while (!done) { |
| 4269 bool is_strict_reserved = false; | 4115 bool is_strict_reserved = false; |
| 4270 Handle<String> param_name = | 4116 Handle<String> param_name = |
| 4271 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, | 4117 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
| 4272 CHECK_OK); | |
| 4273 | 4118 |
| 4274 // Store locations for possible future error reports. | 4119 // Store locations for possible future error reports. |
| 4275 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { | 4120 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { |
| 4276 name_loc = scanner().location(); | 4121 name_loc = scanner().location(); |
| 4277 } | 4122 } |
| 4278 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 4123 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
| 4279 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; | 4124 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; |
| 4280 dupe_loc = scanner().location(); | 4125 dupe_loc = scanner().location(); |
| 4281 } | 4126 } |
| 4282 if (!reserved_loc.IsValid() && is_strict_reserved) { | 4127 if (!reserved_loc.IsValid() && is_strict_reserved) { |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5694 ranges->Add(CharacterRange::Everything(), zone()); | 5539 ranges->Add(CharacterRange::Everything(), zone()); |
| 5695 is_negated = !is_negated; | 5540 is_negated = !is_negated; |
| 5696 } | 5541 } |
| 5697 return new(zone()) RegExpCharacterClass(ranges, is_negated); | 5542 return new(zone()) RegExpCharacterClass(ranges, is_negated); |
| 5698 } | 5543 } |
| 5699 | 5544 |
| 5700 | 5545 |
| 5701 // ---------------------------------------------------------------------------- | 5546 // ---------------------------------------------------------------------------- |
| 5702 // The Parser interface. | 5547 // The Parser interface. |
| 5703 | 5548 |
| 5704 ParserMessage::~ParserMessage() { | |
| 5705 for (int i = 0; i < args().length(); i++) | |
| 5706 DeleteArray(args()[i]); | |
| 5707 DeleteArray(args().start()); | |
| 5708 } | |
| 5709 | |
| 5710 | |
| 5711 ScriptDataImpl::~ScriptDataImpl() { | 5549 ScriptDataImpl::~ScriptDataImpl() { |
| 5712 if (owns_store_) store_.Dispose(); | 5550 if (owns_store_) store_.Dispose(); |
| 5713 } | 5551 } |
| 5714 | 5552 |
| 5715 | 5553 |
| 5716 int ScriptDataImpl::Length() { | 5554 int ScriptDataImpl::Length() { |
| 5717 return store_.length() * sizeof(unsigned); | 5555 return store_.length() * sizeof(unsigned); |
| 5718 } | 5556 } |
| 5719 | 5557 |
| 5720 | 5558 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5848 ASSERT(info()->isolate()->has_pending_exception()); | 5686 ASSERT(info()->isolate()->has_pending_exception()); |
| 5849 } else { | 5687 } else { |
| 5850 result = ParseProgram(); | 5688 result = ParseProgram(); |
| 5851 } | 5689 } |
| 5852 } | 5690 } |
| 5853 info()->SetFunction(result); | 5691 info()->SetFunction(result); |
| 5854 return (result != NULL); | 5692 return (result != NULL); |
| 5855 } | 5693 } |
| 5856 | 5694 |
| 5857 } } // namespace v8::internal | 5695 } } // namespace v8::internal |
| OLD | NEW |