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

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

Issue 2049513003: [wasm] Support undefined indirect table entries, behind a flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] Patching in the change to have only one runtime check, instead of two. Created 4 years, 6 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 | src/flag-definitions.h » ('j') | src/wasm/wasm-module.cc » ('J')
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 "src/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include "src/isolate-inl.h" 7 #include "src/isolate-inl.h"
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 DCHECK(module_ && module_->instance); 1924 DCHECK(module_ && module_->instance);
1925 1925
1926 MachineOperatorBuilder* machine = jsgraph()->machine(); 1926 MachineOperatorBuilder* machine = jsgraph()->machine();
1927 1927
1928 // Compute the code object by loading it from the function table. 1928 // Compute the code object by loading it from the function table.
1929 Node* key = args[0]; 1929 Node* key = args[0];
1930 1930
1931 // Bounds check the index. 1931 // Bounds check the index.
1932 int table_size = static_cast<int>(module_->FunctionTableSize()); 1932 int table_size = static_cast<int>(module_->FunctionTableSize());
1933 if (table_size > 0) { 1933 if (table_size > 0) {
1934 // Bounds check against the table size. 1934 if (FLAG_wasm_jit_prototype) {
1935 Node* size = Int32Constant(static_cast<int>(table_size)); 1935 int indirect_table_size =
bradn 2016/06/16 08:00:20 Can we move the computation of the size to Functio
1936 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size); 1936 static_cast<int>(module_->instance->function_table->length());
1937 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position); 1937
1938 Node* lower_bound = Int32Constant(indirect_table_size / 2 -
1939 module_->instance->padded_entries);
1940 Node* more_than_lower_bound =
1941 graph()->NewNode(machine->Uint32LessThanOrEqual(), lower_bound, key);
1942 trap_->AddTrapIfTrue(wasm::kTrapFuncInvalid, more_than_lower_bound,
1943 position);
1944 } else {
1945 // Bounds check against the table size.
1946 Node* size = Int32Constant(static_cast<int>(table_size));
1947 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
1948 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position);
1949 }
1938 } else { 1950 } else {
1939 // No function table. Generate a trap and return a constant. 1951 // No function table. Generate a trap and return a constant.
1940 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position); 1952 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position);
1941 return trap_->GetTrapValue(module_->GetSignature(index)); 1953 return trap_->GetTrapValue(module_->GetSignature(index));
1942 } 1954 }
1943 Node* table = FunctionTable(); 1955 Node* table = FunctionTable();
1944 1956
1945 // Load signature from the table and check. 1957 // Load signature from the table and check.
1946 // The table is a FixedArray; signatures are encoded as SMIs. 1958 // The table is a FixedArray; signatures are encoded as SMIs.
1947 // [sig1, sig2, sig3, ...., code1, code2, code3 ...] 1959 // [sig1, sig2, sig3, ...., code1, code2, code3 ...]
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3297 function_->code_start_offset), 3309 function_->code_start_offset),
3298 compile_ms); 3310 compile_ms);
3299 } 3311 }
3300 3312
3301 return code; 3313 return code;
3302 } 3314 }
3303 3315
3304 } // namespace compiler 3316 } // namespace compiler
3305 } // namespace internal 3317 } // namespace internal
3306 } // namespace v8 3318 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/wasm/wasm-module.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698