Revision: 3977 Author: [email protected] Date: Fri Feb 26 07:19:13 2010 Log: Faster filling of arrays of holes.
Review URL: http://codereview.chromium.org/661105 http://code.google.com/p/v8/source/detail?r=3977 Modified: /branches/bleeding_edge/src/heap.cc /branches/bleeding_edge/src/utils.h ======================================= --- /branches/bleeding_edge/src/heap.cc Fri Feb 26 06:37:33 2010 +++ /branches/bleeding_edge/src/heap.cc Fri Feb 26 07:19:13 2010 @@ -2994,11 +2994,10 @@ FixedArray* array = FixedArray::cast(result); array->set_length(length); // Initialize body. - Object* value = the_hole_value(); - for (int index = 0; index < length; index++) { - ASSERT(!Heap::InNewSpace(value)); // value = the hole - array->set(index, value, SKIP_WRITE_BARRIER); - } + ASSERT(!Heap::InNewSpace(the_hole_value())); + MemsetPointer(HeapObject::RawField(array, FixedArray::kHeaderSize), + the_hole_value(), + length); } return result; } ======================================= --- /branches/bleeding_edge/src/utils.h Thu Feb 25 04:49:23 2010 +++ /branches/bleeding_edge/src/utils.h Fri Feb 26 07:19:13 2010 @@ -570,6 +570,30 @@ } return 0; } + + +template <typename T> +static inline void MemsetPointer(T** dest, T* value, int counter) { +#if defined(V8_HOST_ARCH_IA32) +#define STOS "stosl" +#elif defined(V8_HOST_ARCH_X64) +#define STOS "stosq" +#endif + +#if defined(__GNUC__) && defined(STOS) + asm("cld;" + "rep ; " STOS + : /* no output */ + : "c" (counter), "a" (value), "D" (dest) + : /* no clobbered list as all inputs are considered clobbered */); +#else + for (int i = 0; i < counter; i++) { + dest[i] = value; + } +#endif + +#undef STOS +} // Calculate 10^exponent. -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
