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

Side by Side Diff: src/wasm/ast-decoder.cc

Issue 2540133002: [wasm] Remove raw byte pointers from WasmModule (Closed)
Patch Set: Address comments Created 4 years 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/vector.h ('k') | src/wasm/module-decoder.h » ('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/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 13 matching lines...) Expand all
24 24
25 #if DEBUG 25 #if DEBUG
26 #define TRACE(...) \ 26 #define TRACE(...) \
27 do { \ 27 do { \
28 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ 28 if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \
29 } while (false) 29 } while (false)
30 #else 30 #else
31 #define TRACE(...) 31 #define TRACE(...)
32 #endif 32 #endif
33 33
34 #define CHECK_PROTOTYPE_OPCODE(flag) \ 34 #define CHECK_PROTOTYPE_OPCODE(flag) \
35 if (module_ && module_->origin == kAsmJsOrigin) { \ 35 if (module_ && module_->module->origin == kAsmJsOrigin) { \
36 error("Opcode not supported for asmjs modules"); \ 36 error("Opcode not supported for asmjs modules"); \
37 } \ 37 } \
38 if (!FLAG_##flag) { \ 38 if (!FLAG_##flag) { \
39 error("Invalid opcode (enable with --" #flag ")"); \ 39 error("Invalid opcode (enable with --" #flag ")"); \
40 break; \ 40 break; \
41 } 41 }
42 // TODO(titzer): this is only for intermediate migration. 42 // TODO(titzer): this is only for intermediate migration.
43 #define IMPLICIT_FUNCTION_END 1 43 #define IMPLICIT_FUNCTION_END 1
44 44
45 // An SsaEnv environment carries the current local variable renaming 45 // An SsaEnv environment carries the current local variable renaming
46 // as well as the current effect and control dependency in the TF graph. 46 // as well as the current effect and control dependency in the TF graph.
47 // It maintains a control state that tracks whether the environment 47 // It maintains a control state that tracks whether the environment
48 // is reachable, has reached a control end, or has been merged. 48 // is reachable, has reached a control end, or has been merged.
49 struct SsaEnv { 49 struct SsaEnv {
50 enum State { kControlEnd, kUnreachable, kReached, kMerged }; 50 enum State { kControlEnd, kUnreachable, kReached, kMerged };
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 len = DecodeStoreMem(kAstI64, MachineType::Int64()); 1111 len = DecodeStoreMem(kAstI64, MachineType::Int64());
1112 break; 1112 break;
1113 case kExprF32StoreMem: 1113 case kExprF32StoreMem:
1114 len = DecodeStoreMem(kAstF32, MachineType::Float32()); 1114 len = DecodeStoreMem(kAstF32, MachineType::Float32());
1115 break; 1115 break;
1116 case kExprF64StoreMem: 1116 case kExprF64StoreMem:
1117 len = DecodeStoreMem(kAstF64, MachineType::Float64()); 1117 len = DecodeStoreMem(kAstF64, MachineType::Float64());
1118 break; 1118 break;
1119 case kExprGrowMemory: { 1119 case kExprGrowMemory: {
1120 MemoryIndexOperand operand(this, pc_); 1120 MemoryIndexOperand operand(this, pc_);
1121 if (module_->origin != kAsmJsOrigin) { 1121 if (module_->module->origin != kAsmJsOrigin) {
1122 Value val = Pop(0, kAstI32); 1122 Value val = Pop(0, kAstI32);
1123 Push(kAstI32, BUILD(GrowMemory, val.node)); 1123 Push(kAstI32, BUILD(GrowMemory, val.node));
1124 } else { 1124 } else {
1125 error("grow_memory is not supported for asmjs modules"); 1125 error("grow_memory is not supported for asmjs modules");
1126 } 1126 }
1127 len = 1 + operand.length; 1127 len = 1 + operand.length;
1128 break; 1128 break;
1129 } 1129 }
1130 case kExprMemorySize: { 1130 case kExprMemorySize: {
1131 MemoryIndexOperand operand(this, pc_); 1131 MemoryIndexOperand operand(this, pc_);
(...skipping 29 matching lines...) Expand all
1161 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); 1161 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype);
1162 len++; 1162 len++;
1163 byte simd_index = checked_read_u8(pc_, 1, "simd index"); 1163 byte simd_index = checked_read_u8(pc_, 1, "simd index");
1164 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); 1164 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index);
1165 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, 1165 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix,
1166 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); 1166 simd_index, WasmOpcodes::ShortOpcodeName(opcode));
1167 len += DecodeSimdOpcode(opcode); 1167 len += DecodeSimdOpcode(opcode);
1168 break; 1168 break;
1169 } 1169 }
1170 case kAtomicPrefix: { 1170 case kAtomicPrefix: {
1171 if (!module_ || module_->origin != kAsmJsOrigin) { 1171 if (!module_ || module_->module->origin != kAsmJsOrigin) {
1172 error("Atomics are allowed only in AsmJs modules"); 1172 error("Atomics are allowed only in AsmJs modules");
1173 break; 1173 break;
1174 } 1174 }
1175 if (!FLAG_wasm_atomics_prototype) { 1175 if (!FLAG_wasm_atomics_prototype) {
1176 error("Invalid opcode (enable with --wasm_atomics_prototype)"); 1176 error("Invalid opcode (enable with --wasm_atomics_prototype)");
1177 break; 1177 break;
1178 } 1178 }
1179 len = 2; 1179 len = 2;
1180 byte atomic_opcode = checked_read_u8(pc_, 1, "atomic index"); 1180 byte atomic_opcode = checked_read_u8(pc_, 1, "atomic index");
1181 opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_opcode); 1181 opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_opcode);
1182 sig = WasmOpcodes::AtomicSignature(opcode); 1182 sig = WasmOpcodes::AtomicSignature(opcode);
1183 if (sig) { 1183 if (sig) {
1184 BuildAtomicOperator(opcode); 1184 BuildAtomicOperator(opcode);
1185 } 1185 }
1186 break; 1186 break;
1187 } 1187 }
1188 default: { 1188 default: {
1189 // Deal with special asmjs opcodes. 1189 // Deal with special asmjs opcodes.
1190 if (module_ && module_->origin == kAsmJsOrigin) { 1190 if (module_ && module_->module->origin == kAsmJsOrigin) {
1191 sig = WasmOpcodes::AsmjsSignature(opcode); 1191 sig = WasmOpcodes::AsmjsSignature(opcode);
1192 if (sig) { 1192 if (sig) {
1193 BuildSimpleOperator(opcode, sig); 1193 BuildSimpleOperator(opcode, sig);
1194 } 1194 }
1195 } else { 1195 } else {
1196 error("Invalid opcode"); 1196 error("Invalid opcode");
1197 return; 1197 return;
1198 } 1198 }
1199 } 1199 }
1200 } 1200 }
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2038 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2039 const byte* start, const byte* end) { 2039 const byte* start, const byte* end) {
2040 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 2040 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
2041 WasmFullDecoder decoder(zone, nullptr, body); 2041 WasmFullDecoder decoder(zone, nullptr, body);
2042 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); 2042 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
2043 } 2043 }
2044 2044
2045 } // namespace wasm 2045 } // namespace wasm
2046 } // namespace internal 2046 } // namespace internal
2047 } // namespace v8 2047 } // namespace v8
OLDNEW
« no previous file with comments | « src/vector.h ('k') | src/wasm/module-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698