Commit ad7caee4 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[asm.js] Tune initial buffer sizes and growing strategy.

This simplifies the growing strategy used in {ZoneBuffer} and also tunes
the initial sizes used for various instances of these buffers. Note that
such a {ZoneBuffer} is used for entire modules and individual function
bodies.

R=clemensh@chromium.org

Change-Id: I99a0898589984e1830c681845fabb0ed5f8317ab
Reviewed-on: https://chromium-review.googlesource.com/508711
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45419}
parent 0980d759
......@@ -47,7 +47,7 @@ WasmFunctionBuilder::WasmFunctionBuilder(WasmModuleBuilder* builder)
locals_(builder->zone()),
signature_index_(0),
func_index_(static_cast<uint32_t>(builder->functions_.size())),
body_(builder->zone()),
body_(builder->zone(), 256),
i32_temps_(builder->zone()),
i64_temps_(builder->zone()),
f32_temps_(builder->zone()),
......
......@@ -20,7 +20,7 @@ namespace wasm {
class ZoneBuffer : public ZoneObject {
public:
static const uint32_t kInitialSize = 4096;
static constexpr size_t kInitialSize = 1024;
explicit ZoneBuffer(Zone* zone, size_t initial = kInitialSize)
: zone_(zone), buffer_(reinterpret_cast<byte*>(zone->New(initial))) {
pos_ = buffer_;
......@@ -125,7 +125,7 @@ class ZoneBuffer : public ZoneObject {
void EnsureSpace(size_t size) {
if ((pos_ + size) > end_) {
size_t new_size = 4096 + size + (end_ - buffer_) * 3;
size_t new_size = size + (end_ - buffer_) * 2;
byte* new_buffer = reinterpret_cast<byte*>(zone_->New(new_size));
memcpy(new_buffer, buffer_, (pos_ - buffer_));
pos_ = new_buffer + (pos_ - buffer_);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment