Changeset 222009 in webkit for trunk/Source/JavaScriptCore/assembler/ProbeStack.h
- Timestamp:
- Sep 13, 2017, 9:21:05 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/assembler/ProbeStack.h
r221832 r222009 57 57 T get(void* logicalAddress) 58 58 { 59 void* from = physicalAddressFor(logicalAddress); 60 typename std::remove_const<T>::type to { }; 61 std::memcpy(&to, from, sizeof(to)); // Use std::memcpy to avoid strict aliasing issues. 62 return to; 63 } 64 template<typename T> 65 T get(void* logicalBaseAddress, ptrdiff_t offset) 66 { 67 return get<T>(reinterpret_cast<uint8_t*>(logicalBaseAddress) + offset); 59 return *physicalAddressFor<T*>(logicalAddress); 68 60 } 69 61 … … 72 64 { 73 65 m_dirtyBits |= dirtyBitFor(logicalAddress); 74 void* to = physicalAddressFor(logicalAddress); 75 std::memcpy(to, &value, sizeof(T)); // Use std::memcpy to avoid strict aliasing issues. 76 } 77 template<typename T> 78 void set(void* logicalBaseAddress, ptrdiff_t offset, T value) 79 { 80 set<T>(reinterpret_cast<uint8_t*>(logicalBaseAddress) + offset, value); 66 *physicalAddressFor<T*>(logicalAddress) = value; 81 67 } 82 68 … … 95 81 } 96 82 97 void* physicalAddressFor(void* logicalAddress) 83 template<typename T, typename = typename std::enable_if<std::is_pointer<T>::value>::type> 84 T physicalAddressFor(void* logicalAddress) 98 85 { 99 return reinterpret_cast<uint8_t*>(logicalAddress) + m_physicalAddressOffset; 86 uintptr_t offset = reinterpret_cast<uintptr_t>(logicalAddress) & s_pageMask; 87 void* physicalAddress = reinterpret_cast<uint8_t*>(&m_buffer) + offset; 88 return reinterpret_cast<T>(physicalAddress); 100 89 } 101 90 … … 104 93 void* m_baseLogicalAddress { nullptr }; 105 94 uintptr_t m_dirtyBits { 0 }; 106 ptrdiff_t m_physicalAddressOffset;107 95 108 96 static constexpr size_t s_pageSize = 1024; … … 133 121 Stack(Stack&& other); 134 122 135 void* lowWatermark() 136 { 137 // We use the chunkAddress for the low watermark because we'll be doing write backs 138 // to the stack in increments of chunks. Hence, we'll treat the lowest address of 139 // the chunk as the low watermark of any given set address. 140 return Page::chunkAddressFor(m_lowWatermark); 141 } 123 void* lowWatermark() { return m_lowWatermark; } 142 124 143 125 template<typename T> 144 Tget(void* address)126 typename std::enable_if<!std::is_same<double, typename std::remove_cv<T>::type>::value, T>::type get(void* address) 145 127 { 146 128 Page* page = pageFor(address); 147 129 return page->get<T>(address); 148 130 } 149 template<typename T>150 T get(void* logicalBaseAddress, ptrdiff_t offset)151 {152 return get<T>(reinterpret_cast<uint8_t*>(logicalBaseAddress) + offset);153 }154 131 155 template<typename T >132 template<typename T, typename = typename std::enable_if<!std::is_same<double, typename std::remove_cv<T>::type>::value>::type> 156 133 void set(void* address, T value) 157 134 { … … 159 136 page->set<T>(address, value); 160 137 161 if (address < m_lowWatermark) 162 m_lowWatermark = address; 138 // We use the chunkAddress for the low watermark because we'll be doing write backs 139 // to the stack in increments of chunks. Hence, we'll treat the lowest address of 140 // the chunk as the low watermark of any given set address. 141 void* chunkAddress = Page::chunkAddressFor(address); 142 if (chunkAddress < m_lowWatermark) 143 m_lowWatermark = chunkAddress; 163 144 } 145 164 146 template<typename T> 165 void set(void* logicalBaseAddress, ptrdiff_t offset, T value)147 typename std::enable_if<std::is_same<double, typename std::remove_cv<T>::type>::value, T>::type get(void* address) 166 148 { 167 set<T>(reinterpret_cast<uint8_t*>(logicalBaseAddress) + offset, value); 149 Page* page = pageFor(address); 150 return bitwise_cast<double>(page->get<uint64_t>(address)); 151 } 152 153 template<typename T, typename = typename std::enable_if<std::is_same<double, typename std::remove_cv<T>::type>::value>::type> 154 void set(void* address, double value) 155 { 156 set<uint64_t>(address, bitwise_cast<uint64_t>(value)); 168 157 } 169 158
Note:
See TracChangeset
for help on using the changeset viewer.