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 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 HValue* context, | 3916 HValue* context, |
3917 HValue* left, | 3917 HValue* left, |
3918 HValue* right, | 3918 HValue* right, |
3919 PretenureFlag pretenure_flag, | 3919 PretenureFlag pretenure_flag, |
3920 StringAddFlags flags, | 3920 StringAddFlags flags, |
3921 Handle<AllocationSite> allocation_site) { | 3921 Handle<AllocationSite> allocation_site) { |
3922 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { | 3922 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
3923 HConstant* c_right = HConstant::cast(right); | 3923 HConstant* c_right = HConstant::cast(right); |
3924 HConstant* c_left = HConstant::cast(left); | 3924 HConstant* c_left = HConstant::cast(left); |
3925 if (c_left->HasStringValue() && c_right->HasStringValue()) { | 3925 if (c_left->HasStringValue() && c_right->HasStringValue()) { |
3926 Handle<String> left_string = c_left->StringValue(); | 3926 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( |
3927 Handle<String> right_string = c_right->StringValue(); | 3927 c_left->StringValue(), c_right->StringValue()); |
3928 // Prevent possible exception by invalid string length. | 3928 return HConstant::New(zone, context, concat); |
3929 if (left_string->length() + right_string->length() < String::kMaxLength) { | |
3930 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( | |
3931 c_left->StringValue(), c_right->StringValue()); | |
3932 ASSERT(!concat.is_null()); | |
3933 return HConstant::New(zone, context, concat); | |
3934 } | |
3935 } | 3929 } |
3936 } | 3930 } |
3937 return new(zone) HStringAdd( | 3931 return new(zone) HStringAdd( |
3938 context, left, right, pretenure_flag, flags, allocation_site); | 3932 context, left, right, pretenure_flag, flags, allocation_site); |
3939 } | 3933 } |
3940 | 3934 |
3941 | 3935 |
3942 void HStringAdd::PrintDataTo(StringStream* stream) { | 3936 void HStringAdd::PrintDataTo(StringStream* stream) { |
3943 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { | 3937 if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { |
3944 stream->Add("_CheckBoth"); | 3938 stream->Add("_CheckBoth"); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4593 break; | 4587 break; |
4594 case kExternalMemory: | 4588 case kExternalMemory: |
4595 stream->Add("[external-memory]"); | 4589 stream->Add("[external-memory]"); |
4596 break; | 4590 break; |
4597 } | 4591 } |
4598 | 4592 |
4599 stream->Add("@%d", offset()); | 4593 stream->Add("@%d", offset()); |
4600 } | 4594 } |
4601 | 4595 |
4602 } } // namespace v8::internal | 4596 } } // namespace v8::internal |
OLD | NEW |