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

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

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: [wasm] Canonicalize function signature indices for matching in indirect calls. Created 4 years, 2 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
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/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 9
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 2042
2043 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index, 2043 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index,
2044 const WasmModule* module) { 2044 const WasmModule* module) {
2045 const WasmIndirectFunctionTable* table = &module->function_tables[index]; 2045 const WasmIndirectFunctionTable* table = &module->function_tables[index];
2046 DCHECK_EQ(table->size, table->values.size()); 2046 DCHECK_EQ(table->size, table->values.size());
2047 DCHECK_GE(table->max_size, table->size); 2047 DCHECK_GE(table->max_size, table->size);
2048 Handle<FixedArray> values = 2048 Handle<FixedArray> values =
2049 isolate->factory()->NewFixedArray(2 * table->max_size, TENURED); 2049 isolate->factory()->NewFixedArray(2 * table->max_size, TENURED);
2050 for (uint32_t i = 0; i < table->size; ++i) { 2050 for (uint32_t i = 0; i < table->size; ++i) {
2051 const WasmFunction* function = &module->functions[table->values[i]]; 2051 const WasmFunction* function = &module->functions[table->values[i]];
2052 values->set(i, Smi::FromInt(function->sig_index)); 2052 int32_t index = table->map_.Find(function->sig);
2053 DCHECK_GE(index, 0);
2054 values->set(i, Smi::FromInt(index));
2053 values->set(i + table->max_size, Smi::FromInt(table->values[i])); 2055 values->set(i + table->max_size, Smi::FromInt(table->values[i]));
2054 } 2056 }
2055 // Set the remaining elements to -1 (instead of "undefined"). These 2057 // Set the remaining elements to -1 (instead of "undefined"). These
2056 // elements are accessed directly as SMIs (without a check). On 64-bit 2058 // elements are accessed directly as SMIs (without a check). On 64-bit
2057 // platforms, it is possible to have the top bits of "undefined" take 2059 // platforms, it is possible to have the top bits of "undefined" take
2058 // small integer values (or zero), which are more likely to be equal to 2060 // small integer values (or zero), which are more likely to be equal to
2059 // the signature index we check against. 2061 // the signature index we check against.
2060 for (uint32_t i = table->size; i < table->max_size; ++i) { 2062 for (uint32_t i = table->size; i < table->max_size; ++i) {
2061 values->set(i, Smi::FromInt(-1)); 2063 values->set(i, Smi::FromInt(-1));
2062 } 2064 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 WasmCompiledModule* compiled_module = 2269 WasmCompiledModule* compiled_module =
2268 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule)); 2270 WasmCompiledModule::cast(instance->GetInternalField(kWasmCompiledModule));
2269 CHECK(compiled_module->has_weak_module_object()); 2271 CHECK(compiled_module->has_weak_module_object());
2270 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); 2272 CHECK(compiled_module->ptr_to_weak_module_object()->cleared());
2271 } 2273 }
2272 2274
2273 } // namespace testing 2275 } // namespace testing
2274 } // namespace wasm 2276 } // namespace wasm
2275 } // namespace internal 2277 } // namespace internal
2276 } // namespace v8 2278 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698