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

Side by Side Diff: src/runtime.cc

Issue 519061: Improve performance of Array.prototype.join and String.prototype.substring... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 int element_length = string->length(); 3907 int element_length = string->length();
3908 String::WriteToFlat(string, sink + position, 0, element_length); 3908 String::WriteToFlat(string, sink + position, 0, element_length);
3909 position += element_length; 3909 position += element_length;
3910 } 3910 }
3911 } 3911 }
3912 } 3912 }
3913 3913
3914 3914
3915 static Object* Runtime_StringBuilderConcat(Arguments args) { 3915 static Object* Runtime_StringBuilderConcat(Arguments args) {
3916 NoHandleAllocation ha; 3916 NoHandleAllocation ha;
3917 ASSERT(args.length() == 2); 3917 ASSERT(args.length() == 3);
3918 CONVERT_CHECKED(JSArray, array, args[0]); 3918 CONVERT_CHECKED(JSArray, array, args[0]);
3919 CONVERT_CHECKED(String, special, args[1]); 3919 if (!args[1]->IsSmi()) {
3920 Top::context()->mark_out_of_memory();
3921 return Failure::OutOfMemoryException();
3922 }
3923 int array_length = Smi::cast(args[1])->value();
3924 CONVERT_CHECKED(String, special, args[2]);
3920 3925
3921 // This assumption is used by the slice encoding in one or two smis. 3926 // This assumption is used by the slice encoding in one or two smis.
3922 ASSERT(Smi::kMaxValue >= String::kMaxLength); 3927 ASSERT(Smi::kMaxValue >= String::kMaxLength);
3923 3928
3924 int special_length = special->length(); 3929 int special_length = special->length();
3925 Object* smi_array_length = array->length();
3926 if (!smi_array_length->IsSmi()) {
3927 Top::context()->mark_out_of_memory();
3928 return Failure::OutOfMemoryException();
3929 }
3930 int array_length = Smi::cast(smi_array_length)->value();
3931 if (!array->HasFastElements()) { 3930 if (!array->HasFastElements()) {
3932 return Top::Throw(Heap::illegal_argument_symbol()); 3931 return Top::Throw(Heap::illegal_argument_symbol());
3933 } 3932 }
3934 FixedArray* fixed_array = FixedArray::cast(array->elements()); 3933 FixedArray* fixed_array = FixedArray::cast(array->elements());
3935 if (fixed_array->length() < array_length) { 3934 if (fixed_array->length() < array_length) {
3936 array_length = fixed_array->length(); 3935 array_length = fixed_array->length();
3937 } 3936 }
3938 3937
3939 if (array_length == 0) { 3938 if (array_length == 0) {
3940 return Heap::empty_string(); 3939 return Heap::empty_string();
(...skipping 4086 matching lines...) Expand 10 before | Expand all | Expand 10 after
8027 } else { 8026 } else {
8028 // Handle last resort GC and make sure to allow future allocations 8027 // Handle last resort GC and make sure to allow future allocations
8029 // to grow the heap without causing GCs (if possible). 8028 // to grow the heap without causing GCs (if possible).
8030 Counters::gc_last_resort_from_js.Increment(); 8029 Counters::gc_last_resort_from_js.Increment();
8031 Heap::CollectAllGarbage(false); 8030 Heap::CollectAllGarbage(false);
8032 } 8031 }
8033 } 8032 }
8034 8033
8035 8034
8036 } } // namespace v8::internal 8035 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698