Commit ff46fcb9 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Only use the table maximum in allocation if it is non-zero.

R=ahaas@chromium.org
BUG=chromium:654231

Review-Url: https://chromiumcodereview.appspot.com/2433313002
Cr-Commit-Position: refs/heads/master@{#40458}
parent 0a82f091
...@@ -31,6 +31,8 @@ namespace { ...@@ -31,6 +31,8 @@ namespace {
const char* kNameString = "name"; const char* kNameString = "name";
const size_t kNameStringLength = 4; const size_t kNameStringLength = 4;
static const uint32_t kMaxTableSize = 1 << 28;
LocalType TypeOf(const WasmModule* module, const WasmInitExpr& expr) { LocalType TypeOf(const WasmModule* module, const WasmInitExpr& expr) {
switch (expr.kind) { switch (expr.kind) {
case WasmInitExpr::kNone: case WasmInitExpr::kNone:
...@@ -313,7 +315,7 @@ class ModuleDecoder : public Decoder { ...@@ -313,7 +315,7 @@ class ModuleDecoder : public Decoder {
{0, 0, std::vector<int32_t>(), true, false, SignatureMap()}); {0, 0, std::vector<int32_t>(), true, false, SignatureMap()});
expect_u8("element type", 0x20); expect_u8("element type", 0x20);
WasmIndirectFunctionTable* table = &module->function_tables.back(); WasmIndirectFunctionTable* table = &module->function_tables.back();
consume_resizable_limits("element count", "elements", kMaxUInt32, consume_resizable_limits("element count", "elements", kMaxTableSize,
&table->size, &table->max_size); &table->size, &table->max_size);
break; break;
} }
......
...@@ -1042,7 +1042,7 @@ class WasmInstanceBuilder { ...@@ -1042,7 +1042,7 @@ class WasmInstanceBuilder {
factory->NewFixedArray(function_table_count); factory->NewFixedArray(function_table_count);
for (int index = 0; index < function_table_count; ++index) { for (int index = 0; index < function_table_count; ++index) {
WasmIndirectFunctionTable& table = module_->function_tables[index]; WasmIndirectFunctionTable& table = module_->function_tables[index];
uint32_t size = table.max_size; uint32_t size = table.max_size > 0 ? table.max_size : table.size;
Handle<FixedArray> new_table = factory->NewFixedArray(size * 2); Handle<FixedArray> new_table = factory->NewFixedArray(size * 2);
for (int i = 0; i < new_table->length(); ++i) { for (int i = 0; i < new_table->length(); ++i) {
static const int kInvalidSigIndex = -1; static const int kInvalidSigIndex = -1;
......
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