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

Side by Side Diff: src/wasm/function-body-decoder.cc

Issue 2771803005: Hide WasmModule.origin field behind readable accessors. (Closed)
Patch Set: Use boolean accessors instead of get_origin. Created 3 years, 9 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/compiler/wasm-compiler.cc ('k') | src/wasm/module-decoder.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/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/base/platform/elapsed-timer.h" 7 #include "src/base/platform/elapsed-timer.h"
8 #include "src/bit-vector.h" 8 #include "src/bit-vector.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 17 matching lines...) Expand all
28 28
29 #if DEBUG 29 #if DEBUG
30 #define TRACE(...) \ 30 #define TRACE(...) \
31 do { \ 31 do { \
32 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ 32 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \
33 } while (false) 33 } while (false)
34 #else 34 #else
35 #define TRACE(...) 35 #define TRACE(...)
36 #endif 36 #endif
37 37
38 #define CHECK_PROTOTYPE_OPCODE(flag) \ 38 #define CHECK_PROTOTYPE_OPCODE(flag) \
39 if (module_ != nullptr && module_->origin == kAsmJsOrigin) { \ 39 if (module_ != nullptr && module_->is_asm_js()) { \
40 error("Opcode not supported for asmjs modules"); \ 40 error("Opcode not supported for asmjs modules"); \
41 } \ 41 } \
42 if (!FLAG_##flag) { \ 42 if (!FLAG_##flag) { \
43 error("Invalid opcode (enable with --" #flag ")"); \ 43 error("Invalid opcode (enable with --" #flag ")"); \
44 break; \ 44 break; \
45 } 45 }
46 46
47 // An SsaEnv environment carries the current local variable renaming 47 // An SsaEnv environment carries the current local variable renaming
48 // as well as the current effect and control dependency in the TF graph. 48 // as well as the current effect and control dependency in the TF graph.
49 // It maintains a control state that tracks whether the environment 49 // It maintains a control state that tracks whether the environment
50 // is reachable, has reached a control end, or has been merged. 50 // is reachable, has reached a control end, or has been merged.
51 struct SsaEnv { 51 struct SsaEnv {
52 enum State { kControlEnd, kUnreachable, kReached, kMerged }; 52 enum State { kControlEnd, kUnreachable, kReached, kMerged };
53 53
54 State state; 54 State state;
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 case kExprF64StoreMem: 1187 case kExprF64StoreMem:
1188 len = DecodeStoreMem(kWasmF64, MachineType::Float64()); 1188 len = DecodeStoreMem(kWasmF64, MachineType::Float64());
1189 break; 1189 break;
1190 case kExprS128StoreMem: 1190 case kExprS128StoreMem:
1191 len = DecodeStoreMem(kWasmS128, MachineType::Simd128()); 1191 len = DecodeStoreMem(kWasmS128, MachineType::Simd128());
1192 break; 1192 break;
1193 case kExprGrowMemory: { 1193 case kExprGrowMemory: {
1194 if (!CheckHasMemory()) break; 1194 if (!CheckHasMemory()) break;
1195 MemoryIndexOperand operand(this, pc_); 1195 MemoryIndexOperand operand(this, pc_);
1196 DCHECK_NOT_NULL(module_); 1196 DCHECK_NOT_NULL(module_);
1197 if (module_->origin != kAsmJsOrigin) { 1197 if (module_->is_wasm()) {
1198 Value val = Pop(0, kWasmI32); 1198 Value val = Pop(0, kWasmI32);
1199 Push(kWasmI32, BUILD(GrowMemory, val.node)); 1199 Push(kWasmI32, BUILD(GrowMemory, val.node));
1200 } else { 1200 } else {
1201 error("grow_memory is not supported for asmjs modules"); 1201 error("grow_memory is not supported for asmjs modules");
1202 } 1202 }
1203 len = 1 + operand.length; 1203 len = 1 + operand.length;
1204 break; 1204 break;
1205 } 1205 }
1206 case kExprMemorySize: { 1206 case kExprMemorySize: {
1207 if (!CheckHasMemory()) break; 1207 if (!CheckHasMemory()) break;
(...skipping 30 matching lines...) Expand all
1238 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); 1238 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
1239 len++; 1239 len++;
1240 byte simd_index = checked_read_u8(pc_, 1, "simd index"); 1240 byte simd_index = checked_read_u8(pc_, 1, "simd index");
1241 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); 1241 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
1242 TRACE(" @%-4d #%-20s|", startrel(pc_), 1242 TRACE(" @%-4d #%-20s|", startrel(pc_),
1243 WasmOpcodes::OpcodeName(opcode)); 1243 WasmOpcodes::OpcodeName(opcode));
1244 len += DecodeSimdOpcode(opcode); 1244 len += DecodeSimdOpcode(opcode);
1245 break; 1245 break;
1246 } 1246 }
1247 case kAtomicPrefix: { 1247 case kAtomicPrefix: {
1248 if (module_ == nullptr || module_->origin != kAsmJsOrigin) { 1248 if (module_ == nullptr || !module_->is_asm_js()) {
1249 error("Atomics are allowed only in AsmJs modules"); 1249 error("Atomics are allowed only in AsmJs modules");
1250 break; 1250 break;
1251 } 1251 }
1252 if (!FLAG_wasm_atomics_prototype) { 1252 if (!FLAG_wasm_atomics_prototype) {
1253 error("Invalid opcode (enable with --wasm_atomics_prototype)"); 1253 error("Invalid opcode (enable with --wasm_atomics_prototype)");
1254 break; 1254 break;
1255 } 1255 }
1256 len = 2; 1256 len = 2;
1257 byte atomic_opcode = checked_read_u8(pc_, 1, "atomic index"); 1257 byte atomic_opcode = checked_read_u8(pc_, 1, "atomic index");
1258 opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_opcode); 1258 opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_opcode);
1259 sig = WasmOpcodes::AtomicSignature(opcode); 1259 sig = WasmOpcodes::AtomicSignature(opcode);
1260 if (sig) { 1260 if (sig) {
1261 BuildAtomicOperator(opcode); 1261 BuildAtomicOperator(opcode);
1262 } 1262 }
1263 break; 1263 break;
1264 } 1264 }
1265 default: { 1265 default: {
1266 // Deal with special asmjs opcodes. 1266 // Deal with special asmjs opcodes.
1267 if (module_ != nullptr && module_->origin == kAsmJsOrigin) { 1267 if (module_ != nullptr && module_->is_asm_js()) {
1268 sig = WasmOpcodes::AsmjsSignature(opcode); 1268 sig = WasmOpcodes::AsmjsSignature(opcode);
1269 if (sig) { 1269 if (sig) {
1270 BuildSimpleOperator(opcode, sig); 1270 BuildSimpleOperator(opcode, sig);
1271 } 1271 }
1272 } else { 1272 } else {
1273 error("Invalid opcode"); 1273 error("Invalid opcode");
1274 return; 1274 return;
1275 } 1275 }
1276 } 1276 }
1277 } 1277 }
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2167 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2168 const byte* start, const byte* end) { 2168 const byte* start, const byte* end) {
2169 Decoder decoder(start, end); 2169 Decoder decoder(start, end);
2170 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, 2170 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,
2171 static_cast<int>(num_locals), zone); 2171 static_cast<int>(num_locals), zone);
2172 } 2172 }
2173 2173
2174 } // namespace wasm 2174 } // namespace wasm
2175 } // namespace internal 2175 } // namespace internal
2176 } // namespace v8 2176 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/module-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698