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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2628203003: Reland of [wasm] Enforce that function bodies end with the \"end\" opcode. (Closed)
Patch Set: Created 3 years, 11 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 | « src/wasm/wasm-text.cc ('k') | test/cctest/wasm/test-run-wasm-interpreter.cc » ('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 <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 HandleScope scope(isolate); 1844 HandleScope scope(isolate);
1845 // Enable all optional operators. 1845 // Enable all optional operators.
1846 CommonOperatorBuilder common(&zone); 1846 CommonOperatorBuilder common(&zone);
1847 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), 1847 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(),
1848 MachineOperatorBuilder::kAllOptionalOps); 1848 MachineOperatorBuilder::kAllOptionalOps);
1849 Graph graph(&zone); 1849 Graph graph(&zone);
1850 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 1850 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
1851 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1851 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1852 1852
1853 if (sig->parameter_count() == 1) { 1853 if (sig->parameter_count() == 1) {
1854 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)}; 1854 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode),
1855 WASM_END};
1855 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1856 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1856 code + arraysize(code)); 1857 code + arraysize(code));
1857 } else { 1858 } else {
1858 CHECK_EQ(2, sig->parameter_count()); 1859 CHECK_EQ(2, sig->parameter_count());
1859 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1, 1860 byte code[] = {WASM_NO_LOCALS,
1860 static_cast<byte>(opcode)}; 1861 kExprGetLocal,
1862 0,
1863 kExprGetLocal,
1864 1,
1865 static_cast<byte>(opcode),
1866 WASM_END};
1861 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1867 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1862 code + arraysize(code)); 1868 code + arraysize(code));
1863 } 1869 }
1864 } 1870 }
1865 1871
1866 TEST(Build_Wasm_SimpleExprs) { 1872 TEST(Build_Wasm_SimpleExprs) {
1867 // Test that the decoder can build a graph for all supported simple expressions. 1873 // Test that the decoder can build a graph for all supported simple expressions.
1868 #define GRAPH_BUILD_TEST(name, opcode, sig) \ 1874 #define GRAPH_BUILD_TEST(name, opcode, sig) \
1869 TestBuildGraphForSimpleExpression(kExpr##name); 1875 TestBuildGraphForSimpleExpression(kExpr##name);
1870 1876
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, 2865 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP,
2860 WASM_ZERO); 2866 WASM_ZERO);
2861 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2867 const int32_t kMin = std::numeric_limits<int32_t>::min();
2862 CHECK_EQ(0, r.Call(133, 100)); 2868 CHECK_EQ(0, r.Call(133, 100));
2863 CHECK_EQ(0, r.Call(kMin, -1)); 2869 CHECK_EQ(0, r.Call(kMin, -1));
2864 CHECK_EQ(0, r.Call(0, 1)); 2870 CHECK_EQ(0, r.Call(0, 1));
2865 CHECK_TRAP(r.Call(100, 0)); 2871 CHECK_TRAP(r.Call(100, 0));
2866 CHECK_TRAP(r.Call(-1001, 0)); 2872 CHECK_TRAP(r.Call(-1001, 0));
2867 CHECK_TRAP(r.Call(kMin, 0)); 2873 CHECK_TRAP(r.Call(kMin, 0));
2868 } 2874 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-text.cc ('k') | test/cctest/wasm/test-run-wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698