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

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

Issue 1970543003: [formatting] Remove all double blank lines in WASM code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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-module.cc ('k') | src/wasm/wasm-result.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/messages.h" 6 #include "src/messages.h"
7 #include "src/signature.h" 7 #include "src/signature.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i)); 44 os << WasmOpcodes::ShortNameOf(sig.GetReturn(i));
45 } 45 }
46 os << "_"; 46 os << "_";
47 if (sig.parameter_count() == 0) os << "v"; 47 if (sig.parameter_count() == 0) os << "v";
48 for (size_t i = 0; i < sig.parameter_count(); i++) { 48 for (size_t i = 0; i < sig.parameter_count(); i++) {
49 os << WasmOpcodes::ShortNameOf(sig.GetParam(i)); 49 os << WasmOpcodes::ShortNameOf(sig.GetParam(i));
50 } 50 }
51 return os; 51 return os;
52 } 52 }
53 53
54
55 #define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name, 54 #define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name,
56 55
57
58 enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) }; 56 enum WasmOpcodeSig { FOREACH_SIGNATURE(DECLARE_SIG_ENUM) };
59 57
60
61 // TODO(titzer): not static-initializer safe. Wrap in LazyInstance. 58 // TODO(titzer): not static-initializer safe. Wrap in LazyInstance.
62 #define DECLARE_SIG(name, ...) \ 59 #define DECLARE_SIG(name, ...) \
63 static LocalType kTypes_##name[] = {__VA_ARGS__}; \ 60 static LocalType kTypes_##name[] = {__VA_ARGS__}; \
64 static const FunctionSig kSig_##name( \ 61 static const FunctionSig kSig_##name( \
65 1, static_cast<int>(arraysize(kTypes_##name)) - 1, kTypes_##name); 62 1, static_cast<int>(arraysize(kTypes_##name)) - 1, kTypes_##name);
66 63
67 FOREACH_SIGNATURE(DECLARE_SIG) 64 FOREACH_SIGNATURE(DECLARE_SIG)
68 65
69 #define DECLARE_SIG_ENTRY(name, ...) &kSig_##name, 66 #define DECLARE_SIG_ENTRY(name, ...) &kSig_##name,
70 67
71 static const FunctionSig* kSimpleExprSigs[] = { 68 static const FunctionSig* kSimpleExprSigs[] = {
72 nullptr, FOREACH_SIGNATURE(DECLARE_SIG_ENTRY)}; 69 nullptr, FOREACH_SIGNATURE(DECLARE_SIG_ENTRY)};
73 70
74 static byte kSimpleExprSigTable[256]; 71 static byte kSimpleExprSigTable[256];
75 72
76
77 // Initialize the signature table. 73 // Initialize the signature table.
78 static void InitSigTable() { 74 static void InitSigTable() {
79 #define SET_SIG_TABLE(name, opcode, sig) \ 75 #define SET_SIG_TABLE(name, opcode, sig) \
80 kSimpleExprSigTable[opcode] = static_cast<int>(kSigEnum_##sig) + 1; 76 kSimpleExprSigTable[opcode] = static_cast<int>(kSigEnum_##sig) + 1;
81 FOREACH_SIMPLE_OPCODE(SET_SIG_TABLE); 77 FOREACH_SIMPLE_OPCODE(SET_SIG_TABLE);
82 FOREACH_ASMJS_COMPAT_OPCODE(SET_SIG_TABLE); 78 FOREACH_ASMJS_COMPAT_OPCODE(SET_SIG_TABLE);
83 #undef SET_SIG_TABLE 79 #undef SET_SIG_TABLE
84 } 80 }
85 81
86
87 FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) { 82 FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
88 // TODO(titzer): use LazyInstance to make this thread safe. 83 // TODO(titzer): use LazyInstance to make this thread safe.
89 if (kSimpleExprSigTable[kExprI32Add] == 0) InitSigTable(); 84 if (kSimpleExprSigTable[kExprI32Add] == 0) InitSigTable();
90 return const_cast<FunctionSig*>( 85 return const_cast<FunctionSig*>(
91 kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]); 86 kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
92 } 87 }
93 88
94
95 // TODO(titzer): pull WASM_64 up to a common header. 89 // TODO(titzer): pull WASM_64 up to a common header.
96 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 90 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
97 #define WASM_64 1 91 #define WASM_64 1
98 #else 92 #else
99 #define WASM_64 0 93 #define WASM_64 0
100 #endif 94 #endif
101 95
102 int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) { 96 int WasmOpcodes::TrapReasonToMessageId(TrapReason reason) {
103 switch (reason) { 97 switch (reason) {
104 #define TRAPREASON_TO_MESSAGE(name) \ 98 #define TRAPREASON_TO_MESSAGE(name) \
105 case k##name: \ 99 case k##name: \
106 return MessageTemplate::kWasm##name; 100 return MessageTemplate::kWasm##name;
107 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE) 101 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
108 #undef TRAPREASON_TO_MESSAGE 102 #undef TRAPREASON_TO_MESSAGE
109 default: 103 default:
110 return MessageTemplate::kNone; 104 return MessageTemplate::kNone;
111 } 105 }
112 } 106 }
113 107
114 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) { 108 const char* WasmOpcodes::TrapReasonMessage(TrapReason reason) {
115 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason)); 109 return MessageTemplate::TemplateString(TrapReasonToMessageId(reason));
116 } 110 }
117 } // namespace wasm 111 } // namespace wasm
118 } // namespace internal 112 } // namespace internal
119 } // namespace v8 113 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | src/wasm/wasm-result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698