OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 } | 2897 } |
2898 | 2898 |
2899 | 2899 |
2900 void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { | 2900 void HGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
2901 HContext* context = new HContext; | 2901 HContext* context = new HContext; |
2902 AddInstruction(context); | 2902 AddInstruction(context); |
2903 HObjectLiteral* literal = (new HObjectLiteral(context, | 2903 HObjectLiteral* literal = (new HObjectLiteral(context, |
2904 expr->constant_properties(), | 2904 expr->constant_properties(), |
2905 expr->fast_elements(), | 2905 expr->fast_elements(), |
2906 expr->literal_index(), | 2906 expr->literal_index(), |
2907 expr->depth())); | 2907 expr->depth(), |
| 2908 expr->has_function())); |
2908 // The object is expected in the bailout environment during computation | 2909 // The object is expected in the bailout environment during computation |
2909 // of the property values and is the value of the entire expression. | 2910 // of the property values and is the value of the entire expression. |
2910 PushAndAdd(literal); | 2911 PushAndAdd(literal); |
2911 | 2912 |
2912 expr->CalculateEmitStore(); | 2913 expr->CalculateEmitStore(); |
2913 | 2914 |
2914 for (int i = 0; i < expr->properties()->length(); i++) { | 2915 for (int i = 0; i < expr->properties()->length(); i++) { |
2915 ObjectLiteral::Property* property = expr->properties()->at(i); | 2916 ObjectLiteral::Property* property = expr->properties()->at(i); |
2916 if (property->IsCompileTimeValue()) continue; | 2917 if (property->IsCompileTimeValue()) continue; |
2917 | 2918 |
(...skipping 20 matching lines...) Expand all Loading... |
2938 break; | 2939 break; |
2939 } | 2940 } |
2940 // Fall through. | 2941 // Fall through. |
2941 case ObjectLiteral::Property::PROTOTYPE: | 2942 case ObjectLiteral::Property::PROTOTYPE: |
2942 case ObjectLiteral::Property::SETTER: | 2943 case ObjectLiteral::Property::SETTER: |
2943 case ObjectLiteral::Property::GETTER: | 2944 case ObjectLiteral::Property::GETTER: |
2944 BAILOUT("Object literal with complex property"); | 2945 BAILOUT("Object literal with complex property"); |
2945 default: UNREACHABLE(); | 2946 default: UNREACHABLE(); |
2946 } | 2947 } |
2947 } | 2948 } |
2948 ast_context()->ReturnValue(Pop()); | 2949 |
| 2950 if (expr->has_function()) { |
| 2951 // Return the result of the transformation to fast properties |
| 2952 // instead of the original since this operation changes the map |
| 2953 // of the object. This makes sure that the original object won't |
| 2954 // be used by other optimized code before it is transformed |
| 2955 // (e.g. because of code motion). |
| 2956 HToFastProperties* result = new HToFastProperties(Pop()); |
| 2957 AddInstruction(result); |
| 2958 ast_context()->ReturnValue(result); |
| 2959 } else { |
| 2960 ast_context()->ReturnValue(Pop()); |
| 2961 } |
2949 } | 2962 } |
2950 | 2963 |
2951 | 2964 |
2952 void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 2965 void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
2953 ZoneList<Expression*>* subexprs = expr->values(); | 2966 ZoneList<Expression*>* subexprs = expr->values(); |
2954 int length = subexprs->length(); | 2967 int length = subexprs->length(); |
2955 | 2968 |
2956 HArrayLiteral* literal = new HArrayLiteral(expr->constant_elements(), | 2969 HArrayLiteral* literal = new HArrayLiteral(expr->constant_elements(), |
2957 length, | 2970 length, |
2958 expr->literal_index(), | 2971 expr->literal_index(), |
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5927 } | 5940 } |
5928 } | 5941 } |
5929 | 5942 |
5930 #ifdef DEBUG | 5943 #ifdef DEBUG |
5931 if (graph_ != NULL) graph_->Verify(); | 5944 if (graph_ != NULL) graph_->Verify(); |
5932 if (allocator_ != NULL) allocator_->Verify(); | 5945 if (allocator_ != NULL) allocator_->Verify(); |
5933 #endif | 5946 #endif |
5934 } | 5947 } |
5935 | 5948 |
5936 } } // namespace v8::internal | 5949 } } // namespace v8::internal |
OLD | NEW |