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

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

Issue 1608743006: [wasm] Verify boundaries of data segments when decoding modules. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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-opcodes.h ('k') | test/unittests/wasm/module-decoder-unittest.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 "src/wasm/wasm-opcodes.h" 5 #include "src/wasm/wasm-opcodes.h"
6 #include "src/signature.h" 6 #include "src/signature.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace wasm { 10 namespace wasm {
11 11
12 typedef Signature<LocalType> FunctionSig; 12 typedef Signature<LocalType> FunctionSig;
13 13
14 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) { 14 const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
15 switch (opcode) { 15 switch (opcode) {
16 #define DECLARE_NAME_CASE(name, opcode, sig) \ 16 #define DECLARE_NAME_CASE(name, opcode, sig) \
17 case kExpr##name: \ 17 case kExpr##name: \
18 return "Expr" #name; 18 return "Expr" #name;
19 FOREACH_OPCODE(DECLARE_NAME_CASE) 19 FOREACH_OPCODE(DECLARE_NAME_CASE)
20 #undef DECLARE_NAME_CASE 20 #undef DECLARE_NAME_CASE
21 default: 21 default:
22 break; 22 break;
23 } 23 }
24 return "Unknown"; 24 return "Unknown";
25 } 25 }
26 26
27 27
28 std::ostream& operator<<(std::ostream& os, const FunctionSig& sig) {
29 if (sig.return_count() == 0) os << "v";
30 for (size_t i = 0; i < sig.return_count(); i++) {
31 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i));
32 }
33 os << "_";
34 if (sig.parameter_count() == 0) os << "v";
35 for (size_t i = 0; i < sig.parameter_count(); i++) {
36 os << WasmOpcodes::ShortNameOf(sig.GetParam(i));
37 }
38 return os;
39 }
40
41
28 #define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name, 42 #define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name,
29 43
30 44
31 enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) }; 45 enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) };
32 46
33 47
34 // TODO(titzer): not static-initializer safe. Wrap in LazyInstance. 48 // TODO(titzer): not static-initializer safe. Wrap in LazyInstance.
35 #define DECLARE_SIG(name, ...) \ 49 #define DECLARE_SIG(name, ...) \
36 static LocalType kTypes_##name[] = {__VA_ARGS__}; \ 50 static LocalType kTypes_##name[] = {__VA_ARGS__}; \
37 static const FunctionSig kSig_##name( \ 51 static const FunctionSig kSig_##name( \
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 default: 138 default:
125 return true; 139 return true;
126 } 140 }
127 #else 141 #else
128 return true; 142 return true;
129 #endif 143 #endif
130 } 144 }
131 } // namespace wasm 145 } // namespace wasm
132 } // namespace internal 146 } // namespace internal
133 } // namespace v8 147 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | test/unittests/wasm/module-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698