Chromium Code Reviews| 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-containers.h" | 10 #include "src/zone-containers.h" |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 break; | 1222 break; |
| 1223 case kExprI64StoreMem: | 1223 case kExprI64StoreMem: |
| 1224 len = DecodeStoreMem(kAstI64, MachineType::Int64()); | 1224 len = DecodeStoreMem(kAstI64, MachineType::Int64()); |
| 1225 break; | 1225 break; |
| 1226 case kExprF32StoreMem: | 1226 case kExprF32StoreMem: |
| 1227 len = DecodeStoreMem(kAstF32, MachineType::Float32()); | 1227 len = DecodeStoreMem(kAstF32, MachineType::Float32()); |
| 1228 break; | 1228 break; |
| 1229 case kExprF64StoreMem: | 1229 case kExprF64StoreMem: |
| 1230 len = DecodeStoreMem(kAstF64, MachineType::Float64()); | 1230 len = DecodeStoreMem(kAstF64, MachineType::Float64()); |
| 1231 break; | 1231 break; |
| 1232 | 1232 case kExprGrowMemory: |
| 1233 if (module_->origin != kAsmJsOrigin) { | |
| 1234 Push(kAstI32, BUILD(GrowMemory, Pop(0, kAstI32).node)); | |
| 1235 break; | |
| 1236 } else { | |
| 1237 error("grow_memory is not supported for asmjs modules"); | |
| 1238 return; | |
|
titzer
2016/09/08 08:16:29
No need to return here; the error will cause the m
ahaas
2016/09/09 10:52:28
Done.
| |
| 1239 } | |
| 1233 case kExprMemorySize: | 1240 case kExprMemorySize: |
| 1234 Push(kAstI32, BUILD(MemSize, 0)); | 1241 Push(kAstI32, BUILD(MemSize, 0)); |
| 1235 break; | 1242 break; |
| 1236 case kExprCallFunction: { | 1243 case kExprCallFunction: { |
| 1237 CallFunctionOperand operand(this, pc_); | 1244 CallFunctionOperand operand(this, pc_); |
| 1238 if (Validate(pc_, operand)) { | 1245 if (Validate(pc_, operand)) { |
| 1239 TFNode** buffer = PopArgs(operand.sig); | 1246 TFNode** buffer = PopArgs(operand.sig); |
| 1240 TFNode* call = | 1247 TFNode* call = |
| 1241 BUILD(CallDirect, operand.index, buffer, position()); | 1248 BUILD(CallDirect, operand.index, buffer, position()); |
| 1242 Push(GetReturnType(operand.sig), call); | 1249 Push(GetReturnType(operand.sig), call); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1272 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); | 1279 CHECK_PROTOTYPE_OPCODE(wasm_simd_prototype); |
| 1273 len++; | 1280 len++; |
| 1274 byte simd_index = *(pc_ + 1); | 1281 byte simd_index = *(pc_ + 1); |
| 1275 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); | 1282 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); |
| 1276 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, | 1283 TRACE(" @%-4d #%02x #%02x:%-20s|", startrel(pc_), kSimdPrefix, |
| 1277 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); | 1284 simd_index, WasmOpcodes::ShortOpcodeName(opcode)); |
| 1278 DecodeSimdOpcode(opcode); | 1285 DecodeSimdOpcode(opcode); |
| 1279 break; | 1286 break; |
| 1280 } | 1287 } |
| 1281 default: | 1288 default: |
| 1282 error("Invalid opcode"); | 1289 // Deal with special asmjs opcodes. |
| 1283 return; | 1290 if (module_->origin == kAsmJsOrigin) { |
| 1291 sig = WasmOpcodes::AsmjsSignature(opcode); | |
| 1292 if (sig) { | |
| 1293 // Fast case of a simple operator. | |
| 1294 TFNode* node; | |
|
titzer
2016/09/08 08:16:29
Factor this switch out to an inline method?
ahaas
2016/09/09 10:52:28
Done.
| |
| 1295 switch (sig->parameter_count()) { | |
| 1296 case 1: { | |
| 1297 Value val = Pop(0, sig->GetParam(0)); | |
| 1298 node = BUILD(Unop, opcode, val.node, position()); | |
| 1299 break; | |
| 1300 } | |
| 1301 case 2: { | |
| 1302 Value rval = Pop(1, sig->GetParam(1)); | |
| 1303 Value lval = Pop(0, sig->GetParam(0)); | |
| 1304 node = | |
| 1305 BUILD(Binop, opcode, lval.node, rval.node, position()); | |
| 1306 break; | |
| 1307 } | |
| 1308 default: | |
| 1309 UNREACHABLE(); | |
| 1310 node = nullptr; | |
| 1311 break; | |
| 1312 } | |
| 1313 Push(GetReturnType(sig), node); | |
| 1314 } | |
| 1315 } else { | |
| 1316 error("Invalid opcode"); | |
| 1317 return; | |
| 1318 } | |
| 1284 } | 1319 } |
| 1285 } // end complex bytecode | 1320 } // end complex bytecode |
| 1286 | 1321 |
| 1287 #if DEBUG | 1322 #if DEBUG |
| 1288 if (FLAG_trace_wasm_decoder) { | 1323 if (FLAG_trace_wasm_decoder) { |
| 1289 for (size_t i = 0; i < stack_.size(); ++i) { | 1324 for (size_t i = 0; i < stack_.size(); ++i) { |
| 1290 Value& val = stack_[i]; | 1325 Value& val = stack_[i]; |
| 1291 WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc); | 1326 WasmOpcode opcode = static_cast<WasmOpcode>(*val.pc); |
| 1292 if (WasmOpcodes::IsPrefixOpcode(opcode)) { | 1327 if (WasmOpcodes::IsPrefixOpcode(opcode)) { |
| 1293 opcode = static_cast<WasmOpcode>(opcode << 8 | *(val.pc + 1)); | 1328 opcode = static_cast<WasmOpcode>(opcode << 8 | *(val.pc + 1)); |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2074 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 2109 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 2075 const byte* start, const byte* end) { | 2110 const byte* start, const byte* end) { |
| 2076 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 2111 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 2077 WasmFullDecoder decoder(zone, nullptr, body); | 2112 WasmFullDecoder decoder(zone, nullptr, body); |
| 2078 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 2113 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
| 2079 } | 2114 } |
| 2080 | 2115 |
| 2081 } // namespace wasm | 2116 } // namespace wasm |
| 2082 } // namespace internal | 2117 } // namespace internal |
| 2083 } // namespace v8 | 2118 } // namespace v8 |
| OLD | NEW |