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 6952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6963 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 6963 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
6964 CONVERT_CHECKED(String, separator, args[2]); | 6964 CONVERT_CHECKED(String, separator, args[2]); |
6965 // elements_array is fast-mode JSarray of alternating positions | 6965 // elements_array is fast-mode JSarray of alternating positions |
6966 // (increasing order) and strings. | 6966 // (increasing order) and strings. |
6967 // array_length is length of original array (used to add separators); | 6967 // array_length is length of original array (used to add separators); |
6968 // separator is string to put between elements. Assumed to be non-empty. | 6968 // separator is string to put between elements. Assumed to be non-empty. |
6969 | 6969 |
6970 // Find total length of join result. | 6970 // Find total length of join result. |
6971 int string_length = 0; | 6971 int string_length = 0; |
6972 bool is_ascii = separator->IsAsciiRepresentation(); | 6972 bool is_ascii = separator->IsAsciiRepresentation(); |
6973 int max_string_length = is_ascii ? SeqAsciiString::kMaxLength | 6973 int max_string_length; |
6974 : SeqTwoByteString::kMaxLength; | 6974 if (is_ascii) { |
6975 max_string_length = SeqAsciiString::kMaxLength; | |
6976 } else { | |
6977 max_string_length = SeqTwoByteString::kMaxLength; | |
6978 } | |
Sven Panne
2011/11/14 07:29:57
Contrary to popular belief, the "ternary aversion"
| |
6975 bool overflow = false; | 6979 bool overflow = false; |
6976 CONVERT_NUMBER_CHECKED(int, elements_length, | 6980 CONVERT_NUMBER_CHECKED(int, elements_length, |
6977 Int32, elements_array->length()); | 6981 Int32, elements_array->length()); |
6978 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. | 6982 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. |
6979 FixedArray* elements = FixedArray::cast(elements_array->elements()); | 6983 FixedArray* elements = FixedArray::cast(elements_array->elements()); |
6980 for (int i = 0; i < elements_length; i += 2) { | 6984 for (int i = 0; i < elements_length; i += 2) { |
6981 RUNTIME_ASSERT(elements->get(i)->IsNumber()); | 6985 RUNTIME_ASSERT(elements->get(i)->IsNumber()); |
6982 CONVERT_CHECKED(String, string, elements->get(i + 1)); | 6986 CONVERT_CHECKED(String, string, elements->get(i + 1)); |
6983 int length = string->length(); | 6987 int length = string->length(); |
6984 if (is_ascii && !string->IsAsciiRepresentation()) { | 6988 if (is_ascii && !string->IsAsciiRepresentation()) { |
(...skipping 6587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13572 } else { | 13576 } else { |
13573 // Handle last resort GC and make sure to allow future allocations | 13577 // Handle last resort GC and make sure to allow future allocations |
13574 // to grow the heap without causing GCs (if possible). | 13578 // to grow the heap without causing GCs (if possible). |
13575 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13579 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13576 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13580 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
13577 } | 13581 } |
13578 } | 13582 } |
13579 | 13583 |
13580 | 13584 |
13581 } } // namespace v8::internal | 13585 } } // namespace v8::internal |
OLD | NEW |