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

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: 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/flag-definitions.h » ('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 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 DCHECK(module_ && module_->instance); 1919 DCHECK(module_ && module_->instance);
1920 1920
1921 MachineOperatorBuilder* machine = jsgraph()->machine(); 1921 MachineOperatorBuilder* machine = jsgraph()->machine();
1922 1922
1923 // Compute the code object by loading it from the function table. 1923 // Compute the code object by loading it from the function table.
1924 Node* key = args[0]; 1924 Node* key = args[0];
1925 1925
1926 // Bounds check the index. 1926 // Bounds check the index.
1927 int table_size = static_cast<int>(module_->FunctionTableSize()); 1927 int table_size = static_cast<int>(module_->FunctionTableSize());
1928 if (table_size > 0) { 1928 if (table_size > 0) {
1929 // Bounds check against the table size. 1929 if (FLAG_wasm_jit_prototype) {
1930 Node* size = Int32Constant(static_cast<int>(table_size)); 1930 int indirect_table_size =
1931 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size); 1931 static_cast<int>(module_->instance->function_table->length());
1932 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position); 1932
1933 Node* upper_bound = Int32Constant(indirect_table_size / 2);
1934 Node* less_than_upper_bound =
1935 graph()->NewNode(machine->Uint32LessThan(), key, upper_bound);
1936 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, less_than_upper_bound,
1937 position);
1938
1939 Node* lower_bound = Int32Constant(indirect_table_size / 2 -
1940 module_->instance->padded_entries);
bradn 2016/06/14 02:02:46 Hey Ritesh. Actually this isn't quite right. We do
titzer 2016/06/14 20:58:05 Agree.
bradn 2016/06/14 21:00:25 Actually since it can't run (since we don't know t
1941 Node* more_than_lower_bound =
1942 graph()->NewNode(machine->Uint32LessThanOrEqual(), lower_bound, key);
1943 trap_->AddTrapIfTrue(wasm::kTrapDefaultFuncCall, more_than_lower_bound,
1944 position);
1945 } else {
1946 // Bounds check against the table size.
1947 Node* size = Int32Constant(static_cast<int>(table_size));
1948 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
1949 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position);
1950 }
1933 } else { 1951 } else {
1934 // No function table. Generate a trap and return a constant. 1952 // No function table. Generate a trap and return a constant.
1935 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position); 1953 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position);
1936 return trap_->GetTrapValue(module_->GetSignature(index)); 1954 return trap_->GetTrapValue(module_->GetSignature(index));
1937 } 1955 }
1938 Node* table = FunctionTable(); 1956 Node* table = FunctionTable();
1939 1957
1940 // Load signature from the table and check. 1958 // Load signature from the table and check.
1941 // The table is a FixedArray; signatures are encoded as SMIs. 1959 // The table is a FixedArray; signatures are encoded as SMIs.
1942 // [sig1, sig2, sig3, ...., code1, code2, code3 ...] 1960 // [sig1, sig2, sig3, ...., code1, code2, code3 ...]
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 const wasm::WasmFunction* function) { 3129 const wasm::WasmFunction* function) {
3112 WasmCompilationUnit* unit = 3130 WasmCompilationUnit* unit =
3113 CreateWasmCompilationUnit(thrower, isolate, module_env, function, 0); 3131 CreateWasmCompilationUnit(thrower, isolate, module_env, function, 0);
3114 ExecuteCompilation(unit); 3132 ExecuteCompilation(unit);
3115 return FinishCompilation(unit); 3133 return FinishCompilation(unit);
3116 } 3134 }
3117 3135
3118 } // namespace compiler 3136 } // namespace compiler
3119 } // namespace internal 3137 } // namespace internal
3120 } // namespace v8 3138 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/flag-definitions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698