Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1335)

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2661773002: [wasm] Update table bounds when module is instantiated with a table import (Closed)
Patch Set: [wasm] Fix bounds check for imported size > declared initial size of table Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/wasm/indirect-tables.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "src/assembler-inl.h" 7 #include "src/assembler-inl.h"
8 #include "src/base/adapters.h" 8 #include "src/base/adapters.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 table_instance.function_table = 2094 table_instance.function_table =
2095 isolate_->factory()->NewFixedArray(table_size); 2095 isolate_->factory()->NewFixedArray(table_size);
2096 table_instance.signature_table = 2096 table_instance.signature_table =
2097 isolate_->factory()->NewFixedArray(table_size); 2097 isolate_->factory()->NewFixedArray(table_size);
2098 for (int i = 0; i < table_size; ++i) { 2098 for (int i = 0; i < table_size; ++i) {
2099 // Fill the table with invalid signature indexes so that 2099 // Fill the table with invalid signature indexes so that
2100 // uninitialized entries will always fail the signature check. 2100 // uninitialized entries will always fail the signature check.
2101 table_instance.signature_table->set(i, 2101 table_instance.signature_table->set(i,
2102 Smi::FromInt(kInvalidSigIndex)); 2102 Smi::FromInt(kInvalidSigIndex));
2103 } 2103 }
2104 } else {
2105 // Table is imported, patch table bounds check
2106 DCHECK(table_size <= table_instance.function_table->length());
2107 if (table_size < table_instance.function_table->length()) {
2108 RelocateTableSizeReferences(code_table, table_size,
2109 table_instance.function_table->length());
2110 }
2104 } 2111 }
2105 2112
2106 new_function_tables->set(static_cast<int>(index), 2113 new_function_tables->set(static_cast<int>(index),
2107 *table_instance.function_table); 2114 *table_instance.function_table);
2108 new_signature_tables->set(static_cast<int>(index), 2115 new_signature_tables->set(static_cast<int>(index),
2109 *table_instance.signature_table); 2116 *table_instance.signature_table);
2110 } 2117 }
2111 2118
2112 // Patch all code that has references to the old indirect tables. 2119 // Patch all code that has references to the old indirect tables.
2113 Handle<FixedArray> old_function_tables = 2120 Handle<FixedArray> old_function_tables =
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 Handle<FixedArray> storage = factory->NewFixedArray(num_custom_sections); 2800 Handle<FixedArray> storage = factory->NewFixedArray(num_custom_sections);
2794 JSArray::SetContent(array_object, storage); 2801 JSArray::SetContent(array_object, storage);
2795 array_object->set_length(Smi::FromInt(num_custom_sections)); 2802 array_object->set_length(Smi::FromInt(num_custom_sections));
2796 2803
2797 for (int i = 0; i < num_custom_sections; i++) { 2804 for (int i = 0; i < num_custom_sections; i++) {
2798 storage->set(i, *matching_sections[i]); 2805 storage->set(i, *matching_sections[i]);
2799 } 2806 }
2800 2807
2801 return array_object; 2808 return array_object;
2802 } 2809 }
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/indirect-tables.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698