Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: src/runtime.cc

Issue 8540009: Merging r9980 into 3.6 branch (Catch OOM when sparse array join results in too large array). (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.6
Patch Set: fixing copy-paste error Created 9 years, 1 month 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 | « no previous file | src/version.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 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 6823 matching lines...) Expand 10 before | Expand all | Expand 10 after
6834 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); 6834 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]);
6835 CONVERT_CHECKED(String, separator, args[2]); 6835 CONVERT_CHECKED(String, separator, args[2]);
6836 // elements_array is fast-mode JSarray of alternating positions 6836 // elements_array is fast-mode JSarray of alternating positions
6837 // (increasing order) and strings. 6837 // (increasing order) and strings.
6838 // array_length is length of original array (used to add separators); 6838 // array_length is length of original array (used to add separators);
6839 // separator is string to put between elements. Assumed to be non-empty. 6839 // separator is string to put between elements. Assumed to be non-empty.
6840 6840
6841 // Find total length of join result. 6841 // Find total length of join result.
6842 int string_length = 0; 6842 int string_length = 0;
6843 bool is_ascii = separator->IsAsciiRepresentation(); 6843 bool is_ascii = separator->IsAsciiRepresentation();
6844 int max_string_length = SeqAsciiString::kMaxLength; 6844 int max_string_length;
6845 if (is_ascii) {
6846 max_string_length = SeqAsciiString::kMaxLength;
6847 } else {
6848 max_string_length = SeqTwoByteString::kMaxLength;
6849 }
6845 bool overflow = false; 6850 bool overflow = false;
6846 CONVERT_NUMBER_CHECKED(int, elements_length, 6851 CONVERT_NUMBER_CHECKED(int, elements_length,
6847 Int32, elements_array->length()); 6852 Int32, elements_array->length());
6848 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length. 6853 RUNTIME_ASSERT((elements_length & 1) == 0); // Even length.
6849 FixedArray* elements = FixedArray::cast(elements_array->elements()); 6854 FixedArray* elements = FixedArray::cast(elements_array->elements());
6850 for (int i = 0; i < elements_length; i += 2) { 6855 for (int i = 0; i < elements_length; i += 2) {
6851 RUNTIME_ASSERT(elements->get(i)->IsNumber()); 6856 RUNTIME_ASSERT(elements->get(i)->IsNumber());
6852 CONVERT_CHECKED(String, string, elements->get(i + 1)); 6857 CONVERT_CHECKED(String, string, elements->get(i + 1));
6853 int length = string->length(); 6858 int length = string->length();
6854 if (is_ascii && !string->IsAsciiRepresentation()) { 6859 if (is_ascii && !string->IsAsciiRepresentation()) {
(...skipping 6373 matching lines...) Expand 10 before | Expand all | Expand 10 after
13228 } else { 13233 } else {
13229 // Handle last resort GC and make sure to allow future allocations 13234 // Handle last resort GC and make sure to allow future allocations
13230 // to grow the heap without causing GCs (if possible). 13235 // to grow the heap without causing GCs (if possible).
13231 isolate->counters()->gc_last_resort_from_js()->Increment(); 13236 isolate->counters()->gc_last_resort_from_js()->Increment();
13232 isolate->heap()->CollectAllGarbage(false); 13237 isolate->heap()->CollectAllGarbage(false);
13233 } 13238 }
13234 } 13239 }
13235 13240
13236 13241
13237 } } // namespace v8::internal 13242 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698