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/parser.cc

Issue 10442015: Rollback of r11638, r11636 on trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-printer.cc ('k') | src/profile-generator.cc » ('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 // 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 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 } 3760 }
3761 Expect(Token::RBRACK, CHECK_OK); 3761 Expect(Token::RBRACK, CHECK_OK);
3762 3762
3763 // Update the scope information before the pre-parsing bailout. 3763 // Update the scope information before the pre-parsing bailout.
3764 int literal_index = current_function_state_->NextMaterializedLiteralIndex(); 3764 int literal_index = current_function_state_->NextMaterializedLiteralIndex();
3765 3765
3766 // Allocate a fixed array to hold all the object literals. 3766 // Allocate a fixed array to hold all the object literals.
3767 Handle<FixedArray> object_literals = 3767 Handle<FixedArray> object_literals =
3768 isolate()->factory()->NewFixedArray(values->length(), TENURED); 3768 isolate()->factory()->NewFixedArray(values->length(), TENURED);
3769 Handle<FixedDoubleArray> double_literals; 3769 Handle<FixedDoubleArray> double_literals;
3770 ElementsKind elements_kind = FAST_SMI_ELEMENTS; 3770 ElementsKind elements_kind = FAST_SMI_ONLY_ELEMENTS;
3771 bool has_only_undefined_values = true; 3771 bool has_only_undefined_values = true;
3772 bool has_hole_values = false;
3773 3772
3774 // Fill in the literals. 3773 // Fill in the literals.
3775 Heap* heap = isolate()->heap();
3776 bool is_simple = true; 3774 bool is_simple = true;
3777 int depth = 1; 3775 int depth = 1;
3778 for (int i = 0, n = values->length(); i < n; i++) { 3776 for (int i = 0, n = values->length(); i < n; i++) {
3779 MaterializedLiteral* m_literal = values->at(i)->AsMaterializedLiteral(); 3777 MaterializedLiteral* m_literal = values->at(i)->AsMaterializedLiteral();
3780 if (m_literal != NULL && m_literal->depth() + 1 > depth) { 3778 if (m_literal != NULL && m_literal->depth() + 1 > depth) {
3781 depth = m_literal->depth() + 1; 3779 depth = m_literal->depth() + 1;
3782 } 3780 }
3783 Handle<Object> boilerplate_value = GetBoilerplateValue(values->at(i)); 3781 Handle<Object> boilerplate_value = GetBoilerplateValue(values->at(i));
3784 if (boilerplate_value->IsTheHole()) { 3782 if (boilerplate_value->IsUndefined()) {
3785 has_hole_values = true;
3786 object_literals->set_the_hole(i); 3783 object_literals->set_the_hole(i);
3787 if (elements_kind == FAST_DOUBLE_ELEMENTS) { 3784 if (elements_kind == FAST_DOUBLE_ELEMENTS) {
3788 double_literals->set_the_hole(i); 3785 double_literals->set_the_hole(i);
3789 } 3786 }
3790 } else if (boilerplate_value->IsUndefined()) {
3791 is_simple = false; 3787 is_simple = false;
3792 object_literals->set(i, Smi::FromInt(0));
3793 if (elements_kind == FAST_DOUBLE_ELEMENTS) {
3794 double_literals->set(i, 0);
3795 }
3796 } else { 3788 } else {
3797 // Examine each literal element, and adjust the ElementsKind if the 3789 // Examine each literal element, and adjust the ElementsKind if the
3798 // literal element is not of a type that can be stored in the current 3790 // literal element is not of a type that can be stored in the current
3799 // ElementsKind. Start with FAST_SMI_ONLY_ELEMENTS, and transition to 3791 // ElementsKind. Start with FAST_SMI_ONLY_ELEMENTS, and transition to
3800 // FAST_DOUBLE_ELEMENTS and FAST_ELEMENTS as necessary. Always remember 3792 // FAST_DOUBLE_ELEMENTS and FAST_ELEMENTS as necessary. Always remember
3801 // the tagged value, no matter what the ElementsKind is in case we 3793 // the tagged value, no matter what the ElementsKind is in case we
3802 // ultimately end up in FAST_ELEMENTS. 3794 // ultimately end up in FAST_ELEMENTS.
3803 has_only_undefined_values = false; 3795 has_only_undefined_values = false;
3804 object_literals->set(i, *boilerplate_value); 3796 object_literals->set(i, *boilerplate_value);
3805 if (elements_kind == FAST_SMI_ELEMENTS) { 3797 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) {
3806 // Smi only elements. Notice if a transition to FAST_DOUBLE_ELEMENTS or 3798 // Smi only elements. Notice if a transition to FAST_DOUBLE_ELEMENTS or
3807 // FAST_ELEMENTS is required. 3799 // FAST_ELEMENTS is required.
3808 if (!boilerplate_value->IsSmi()) { 3800 if (!boilerplate_value->IsSmi()) {
3809 if (boilerplate_value->IsNumber() && FLAG_smi_only_arrays) { 3801 if (boilerplate_value->IsNumber() && FLAG_smi_only_arrays) {
3810 // Allocate a double array on the FAST_DOUBLE_ELEMENTS transition to 3802 // Allocate a double array on the FAST_DOUBLE_ELEMENTS transition to
3811 // avoid over-allocating in TENURED space. 3803 // avoid over-allocating in TENURED space.
3812 double_literals = isolate()->factory()->NewFixedDoubleArray( 3804 double_literals = isolate()->factory()->NewFixedDoubleArray(
3813 values->length(), TENURED); 3805 values->length(), TENURED);
3814 // Copy the contents of the FAST_SMI_ONLY_ELEMENT array to the 3806 // Copy the contents of the FAST_SMI_ONLY_ELEMENT array to the
3815 // FAST_DOUBLE_ELEMENTS array so that they are in sync. 3807 // FAST_DOUBLE_ELEMENTS array so that they are in sync.
(...skipping 27 matching lines...) Expand all
3843 // from a constant value should default to the slow case to avoid lots of 3835 // from a constant value should default to the slow case to avoid lots of
3844 // elements transitions on really small objects. 3836 // elements transitions on really small objects.
3845 if (has_only_undefined_values && values->length() <= 2) { 3837 if (has_only_undefined_values && values->length() <= 2) {
3846 elements_kind = FAST_ELEMENTS; 3838 elements_kind = FAST_ELEMENTS;
3847 } 3839 }
3848 3840
3849 // Simple and shallow arrays can be lazily copied, we transform the 3841 // Simple and shallow arrays can be lazily copied, we transform the
3850 // elements array to a copy-on-write array. 3842 // elements array to a copy-on-write array.
3851 if (is_simple && depth == 1 && values->length() > 0 && 3843 if (is_simple && depth == 1 && values->length() > 0 &&
3852 elements_kind != FAST_DOUBLE_ELEMENTS) { 3844 elements_kind != FAST_DOUBLE_ELEMENTS) {
3853 object_literals->set_map(heap->fixed_cow_array_map()); 3845 object_literals->set_map(isolate()->heap()->fixed_cow_array_map());
3854 } 3846 }
3855 3847
3856 Handle<FixedArrayBase> element_values = elements_kind == FAST_DOUBLE_ELEMENTS 3848 Handle<FixedArrayBase> element_values = elements_kind == FAST_DOUBLE_ELEMENTS
3857 ? Handle<FixedArrayBase>(double_literals) 3849 ? Handle<FixedArrayBase>(double_literals)
3858 : Handle<FixedArrayBase>(object_literals); 3850 : Handle<FixedArrayBase>(object_literals);
3859 3851
3860 // Remember both the literal's constant values as well as the ElementsKind 3852 // Remember both the literal's constant values as well as the ElementsKind
3861 // in a 2-element FixedArray. 3853 // in a 2-element FixedArray.
3862 Handle<FixedArray> literals = 3854 Handle<FixedArray> literals =
3863 isolate()->factory()->NewFixedArray(2, TENURED); 3855 isolate()->factory()->NewFixedArray(2, TENURED);
3864 3856
3865 if (has_hole_values || !FLAG_packed_arrays) {
3866 elements_kind = GetHoleyElementsKind(elements_kind);
3867 }
3868
3869 literals->set(0, Smi::FromInt(elements_kind)); 3857 literals->set(0, Smi::FromInt(elements_kind));
3870 literals->set(1, *element_values); 3858 literals->set(1, *element_values);
3871 3859
3872 return factory()->NewArrayLiteral( 3860 return factory()->NewArrayLiteral(
3873 literals, values, literal_index, is_simple, depth); 3861 literals, values, literal_index, is_simple, depth);
3874 } 3862 }
3875 3863
3876 3864
3877 bool Parser::IsBoilerplateProperty(ObjectLiteral::Property* property) { 3865 bool Parser::IsBoilerplateProperty(ObjectLiteral::Property* property) {
3878 return property != NULL && 3866 return property != NULL &&
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 ASSERT(info->isolate()->has_pending_exception()); 6030 ASSERT(info->isolate()->has_pending_exception());
6043 } else { 6031 } else {
6044 result = parser.ParseProgram(info); 6032 result = parser.ParseProgram(info);
6045 } 6033 }
6046 } 6034 }
6047 info->SetFunction(result); 6035 info->SetFunction(result);
6048 return (result != NULL); 6036 return (result != NULL);
6049 } 6037 }
6050 6038
6051 } } // namespace v8::internal 6039 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698