Skip to content

Commit

Permalink
[asm.js] Tune initial buffer sizes and growing strategy.
Browse files Browse the repository at this point in the history
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.

[email protected]

Change-Id: I99a0898589984e1830c681845fabb0ed5f8317ab
Reviewed-on: https://chromium-review.googlesource.com/508711
Commit-Queue: Michael Starzinger <[email protected]>
Reviewed-by: Clemens Hammacher <[email protected]>
Cr-Commit-Position: refs/heads/master@{#45419}
  • Loading branch information
Michael Starzinger authored and Commit Bot committed May 19, 2017
1 parent 0980d75 commit ad7caee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/wasm/wasm-module-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-module-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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_);
Expand Down

0 comments on commit ad7caee

Please sign in to comment.