Rev | Line | |
---|
[176] | 1 | /* -*- C++ -*- */ |
---|
| 2 | |
---|
| 3 | #ifndef _PREFETCHHEAP_H_ |
---|
| 4 | #define _PREFETCHHEAP_H_ |
---|
| 5 | |
---|
| 6 | #define prefetcht0 __asm _emit 0x0f __asm _emit 0x18 __asm _emit 0x08 |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | template <class Super> |
---|
| 10 | class PrefetchHeap : public Super { |
---|
| 11 | public: |
---|
| 12 | |
---|
| 13 | inline void * malloc (size_t sz) { |
---|
| 14 | void * Address = Super::malloc (sz); |
---|
| 15 | #ifdef _M_IX86 |
---|
| 16 | // Prefetch this ptr before we return. |
---|
| 17 | __asm |
---|
| 18 | { |
---|
| 19 | mov eax,Address // Load Address. |
---|
| 20 | prefetcht0 // Prefetch into the L1. |
---|
| 21 | } |
---|
| 22 | #endif |
---|
| 23 | return Address; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | inline void free (void * ptr) { |
---|
| 27 | Super::free (ptr); |
---|
| 28 | } |
---|
| 29 | }; |
---|
| 30 | |
---|
| 31 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.