OLD | NEW |
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 5222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5233 | 5233 |
5234 CONVERT_CHECKED(String, string, args[0]); | 5234 CONVERT_CHECKED(String, string, args[0]); |
5235 StringInputBuffer buffer(string); | 5235 StringInputBuffer buffer(string); |
5236 while (buffer.has_more()) { | 5236 while (buffer.has_more()) { |
5237 uint16_t character = buffer.GetNext(); | 5237 uint16_t character = buffer.GetNext(); |
5238 PrintF("%c", character); | 5238 PrintF("%c", character); |
5239 } | 5239 } |
5240 return string; | 5240 return string; |
5241 } | 5241 } |
5242 | 5242 |
5243 | 5243 // Moves all own elements of an object, that are below a limit, to positions |
| 5244 // starting at zero. All undefined values are placed after non-undefined values, |
| 5245 // and are followed by non-existing element. Does not change the length |
| 5246 // property. |
| 5247 // Returns the number of non-undefined elements collected. |
5244 static Object* Runtime_RemoveArrayHoles(Arguments args) { | 5248 static Object* Runtime_RemoveArrayHoles(Arguments args) { |
5245 ASSERT(args.length() == 1); | 5249 ASSERT(args.length() == 2); |
5246 // Ignore the case if this is not a JSArray. | 5250 CONVERT_CHECKED(JSObject, object, args[0]); |
5247 if (!args[0]->IsJSArray()) return args[0]; | 5251 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
5248 return JSArray::cast(args[0])->RemoveHoles(); | 5252 return object->PrepareElementsForSort(limit); |
5249 } | 5253 } |
5250 | 5254 |
5251 | 5255 |
5252 // Move contents of argument 0 (an array) to argument 1 (an array) | 5256 // Move contents of argument 0 (an array) to argument 1 (an array) |
5253 static Object* Runtime_MoveArrayContents(Arguments args) { | 5257 static Object* Runtime_MoveArrayContents(Arguments args) { |
5254 ASSERT(args.length() == 2); | 5258 ASSERT(args.length() == 2); |
5255 CONVERT_CHECKED(JSArray, from, args[0]); | 5259 CONVERT_CHECKED(JSArray, from, args[0]); |
5256 CONVERT_CHECKED(JSArray, to, args[1]); | 5260 CONVERT_CHECKED(JSArray, to, args[1]); |
5257 to->SetContent(FixedArray::cast(from->elements())); | 5261 to->SetContent(FixedArray::cast(from->elements())); |
5258 to->set_length(from->length()); | 5262 to->set_length(from->length()); |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6990 } else { | 6994 } else { |
6991 // Handle last resort GC and make sure to allow future allocations | 6995 // Handle last resort GC and make sure to allow future allocations |
6992 // to grow the heap without causing GCs (if possible). | 6996 // to grow the heap without causing GCs (if possible). |
6993 Counters::gc_last_resort_from_js.Increment(); | 6997 Counters::gc_last_resort_from_js.Increment(); |
6994 Heap::CollectAllGarbage(); | 6998 Heap::CollectAllGarbage(); |
6995 } | 6999 } |
6996 } | 7000 } |
6997 | 7001 |
6998 | 7002 |
6999 } } // namespace v8::internal | 7003 } } // namespace v8::internal |
OLD | NEW |