OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 5831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5842 | 5842 |
5843 int separator_length = separator->length(); | 5843 int separator_length = separator->length(); |
5844 int max_nof_separators = | 5844 int max_nof_separators = |
5845 (String::kMaxLength + separator_length - 1) / separator_length; | 5845 (String::kMaxLength + separator_length - 1) / separator_length; |
5846 if (max_nof_separators < (array_length - 1)) { | 5846 if (max_nof_separators < (array_length - 1)) { |
5847 Top::context()->mark_out_of_memory(); | 5847 Top::context()->mark_out_of_memory(); |
5848 return Failure::OutOfMemoryException(); | 5848 return Failure::OutOfMemoryException(); |
5849 } | 5849 } |
5850 int length = (array_length - 1) * separator_length; | 5850 int length = (array_length - 1) * separator_length; |
5851 for (int i = 0; i < array_length; i++) { | 5851 for (int i = 0; i < array_length; i++) { |
5852 String* element = String::cast(fixed_array->get(i)); | 5852 Object* element_obj = fixed_array->get(i); |
| 5853 if (!element_obj->IsString()) { |
| 5854 // TODO(1161): handle this case. |
| 5855 return Top::Throw(Heap::illegal_argument_symbol()); |
| 5856 } |
| 5857 String* element = String::cast(element_obj); |
5853 int increment = element->length(); | 5858 int increment = element->length(); |
5854 if (increment > String::kMaxLength - length) { | 5859 if (increment > String::kMaxLength - length) { |
5855 Top::context()->mark_out_of_memory(); | 5860 Top::context()->mark_out_of_memory(); |
5856 return Failure::OutOfMemoryException(); | 5861 return Failure::OutOfMemoryException(); |
5857 } | 5862 } |
5858 length += increment; | 5863 length += increment; |
5859 } | 5864 } |
5860 | 5865 |
5861 Object* object; | 5866 Object* object; |
5862 { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length); | 5867 { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length); |
(...skipping 5333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11196 } else { | 11201 } else { |
11197 // Handle last resort GC and make sure to allow future allocations | 11202 // Handle last resort GC and make sure to allow future allocations |
11198 // to grow the heap without causing GCs (if possible). | 11203 // to grow the heap without causing GCs (if possible). |
11199 Counters::gc_last_resort_from_js.Increment(); | 11204 Counters::gc_last_resort_from_js.Increment(); |
11200 Heap::CollectAllGarbage(false); | 11205 Heap::CollectAllGarbage(false); |
11201 } | 11206 } |
11202 } | 11207 } |
11203 | 11208 |
11204 | 11209 |
11205 } } // namespace v8::internal | 11210 } } // namespace v8::internal |
OLD | NEW |