Browse Source
Merge pull request #2278 from riscv-software-src/reduce-virtual-calls-chunk
refactor: remove excessive chunk_max_size calls
pull/2212/head
Andrew Waterman
4 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
5 additions and
4 deletions
-
fesvr/htif.cc
-
fesvr/memif.cc
|
|
@ -277,8 +277,8 @@ void htif_t::clear_chunk(addr_t taddr, size_t len) |
|
|
{ |
|
|
{ |
|
|
std::vector<uint8_t> zeros(chunk_max_size(), 0); |
|
|
std::vector<uint8_t> zeros(chunk_max_size(), 0); |
|
|
|
|
|
|
|
|
for (size_t pos = 0; pos < len; pos += chunk_max_size()) |
|
|
for (size_t pos = 0; pos < len; pos += zeros.size()) |
|
|
write_chunk(taddr + pos, std::min(len - pos, chunk_max_size()), &zeros[0]); |
|
|
write_chunk(taddr + pos, std::min(len - pos, zeros.size()), &zeros[0]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int htif_t::run() |
|
|
int htif_t::run() |
|
|
|
|
|
@ -35,8 +35,9 @@ void memif_t::read(addr_t addr, size_t len, void* bytes) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// now we're aligned
|
|
|
// now we're aligned
|
|
|
for (size_t pos = 0; pos < len; pos += cmemif->chunk_max_size()) |
|
|
size_t max_chunk = cmemif->chunk_max_size(); |
|
|
cmemif->read_chunk(addr + pos, std::min(cmemif->chunk_max_size(), len - pos), (char*)bytes + pos); |
|
|
for (size_t pos = 0; pos < len; pos += max_chunk) |
|
|
|
|
|
cmemif->read_chunk(addr + pos, std::min(max_chunk, len - pos), (char*)bytes + pos); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void memif_t::write(addr_t addr, size_t len, const void* bytes) |
|
|
void memif_t::write(addr_t addr, size_t len, const void* bytes) |
|
|
|