OLD | NEW |
---|---|
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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 case kSimdPrefix: { | 1139 case kSimdPrefix: { |
1140 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); | 1140 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); |
1141 len++; | 1141 len++; |
1142 byte simd_index = *(pc_ + 1); | 1142 byte simd_index = *(pc_ + 1); |
1143 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); | 1143 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); |
1144 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, | 1144 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, |
1145 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); | 1145 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); |
1146 len += DecodeSimdOpcode(opcode); | 1146 len += DecodeSimdOpcode(opcode); |
1147 break; | 1147 break; |
1148 } | 1148 } |
1149 case kAtomicPrefix: { | |
1150 if (!module_ || module_->origin != kAsmJsOrigin) { | |
1151 error("Atomics are allowed only in AsmJs modules"); | |
1152 break; | |
1153 } | |
1154 if (!FLAG_wasm_atomics_prototype) { | |
titzer
2016/10/26 08:07:17
You can use the macro for this check.
aseemgarg
2016/10/26 19:53:57
The CHECK_PROTOTYPE_OPCODE checks that module orig
| |
1155 error("Invalid opcode (enable with --wasm_atomics_prototype)"); | |
1156 break; | |
1157 } | |
1158 len++; | |
titzer
2016/10/26 08:07:17
Please don't do len++, but set len = 2.
aseemgarg
2016/10/26 19:53:57
Done. Can you explain why?
| |
1159 byte atomic_index = checked_read_u8(pc_, 1, "atomic index"); | |
titzer
2016/10/26 08:07:17
"atomic opcode" instead of "atomic index"
aseemgarg
2016/10/26 19:53:57
Done.
| |
1160 opcode = static_cast<WasmOpcode>(opcode << 8 | atomic_index); | |
1161 sig = WasmOpcodes::AtomicSignature(opcode); | |
1162 if (sig) { | |
1163 BuildAtomicOperator(opcode); | |
1164 } | |
1165 break; | |
1166 } | |
1149 default: { | 1167 default: { |
1150 // Deal with special asmjs opcodes. | 1168 // Deal with special asmjs opcodes. |
1151 if (module_ && module_->origin == kAsmJsOrigin) { | 1169 if (module_ && module_->origin == kAsmJsOrigin) { |
1152 sig = WasmOpcodes::AsmjsSignature(opcode); | 1170 sig = WasmOpcodes::AsmjsSignature(opcode); |
1153 if (sig) { | 1171 if (sig) { |
1154 BuildSimpleOperator(opcode, sig); | 1172 BuildSimpleOperator(opcode, sig); |
1155 } | 1173 } |
1156 } else { | 1174 } else { |
1157 error("Invalid opcode"); | 1175 error("Invalid opcode"); |
1158 return; | 1176 return; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 TFNode* node = BUILD(SimdOp, opcode, inputs); | 1339 TFNode* node = BUILD(SimdOp, opcode, inputs); |
1322 Push(GetReturnType(sig), node); | 1340 Push(GetReturnType(sig), node); |
1323 } else { | 1341 } else { |
1324 error("invalid simd opcode"); | 1342 error("invalid simd opcode"); |
1325 } | 1343 } |
1326 } | 1344 } |
1327 } | 1345 } |
1328 return len; | 1346 return len; |
1329 } | 1347 } |
1330 | 1348 |
1349 void BuildAtomicOperator(WasmOpcode opcode) { UNIMPLEMENTED(); } | |
1350 | |
1331 void DoReturn() { | 1351 void DoReturn() { |
1332 int count = static_cast<int>(sig_->return_count()); | 1352 int count = static_cast<int>(sig_->return_count()); |
1333 TFNode** buffer = nullptr; | 1353 TFNode** buffer = nullptr; |
1334 if (build()) buffer = builder_->Buffer(count); | 1354 if (build()) buffer = builder_->Buffer(count); |
1335 | 1355 |
1336 // Pop return values off the stack in reverse order. | 1356 // Pop return values off the stack in reverse order. |
1337 for (int i = count - 1; i >= 0; i--) { | 1357 for (int i = count - 1; i >= 0; i--) { |
1338 Value val = Pop(i, sig_->GetReturn(i)); | 1358 Value val = Pop(i, sig_->GetReturn(i)); |
1339 if (buffer) buffer[i] = val.node; | 1359 if (buffer) buffer[i] = val.node; |
1340 } | 1360 } |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1998 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 2018 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1999 const byte* start, const byte* end) { | 2019 const byte* start, const byte* end) { |
2000 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 2020 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
2001 WasmFullDecoder decoder(zone, nullptr, body); | 2021 WasmFullDecoder decoder(zone, nullptr, body); |
2002 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 2022 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
2003 } | 2023 } |
2004 | 2024 |
2005 } // namespace wasm | 2025 } // namespace wasm |
2006 } // namespace internal | 2026 } // namespace internal |
2007 } // namespace v8 | 2027 } // namespace v8 |
OLD | NEW |