| 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 CallImportOperand operand(this, pc_); | 989 CallImportOperand operand(this, pc_); |
| 990 if (Validate(pc_, operand)) { | 990 if (Validate(pc_, operand)) { |
| 991 TFNode** buffer = PopArgs(operand.sig); | 991 TFNode** buffer = PopArgs(operand.sig); |
| 992 TFNode* call = | 992 TFNode* call = |
| 993 BUILD(CallImport, operand.index, buffer, position()); | 993 BUILD(CallImport, operand.index, buffer, position()); |
| 994 Push(GetReturnType(operand.sig), call); | 994 Push(GetReturnType(operand.sig), call); |
| 995 } | 995 } |
| 996 len = 1 + operand.length; | 996 len = 1 + operand.length; |
| 997 break; | 997 break; |
| 998 } | 998 } |
| 999 case kSimdPrefix: { |
| 1000 if (FLAG_enable_wasm_simd) { |
| 1001 len++; |
| 1002 byte simd_index = *(pc_ + 1); |
| 1003 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); |
| 1004 DecodeSimdOpcode(opcode); |
| 1005 break; |
| 1006 } |
| 1007 } |
| 999 default: | 1008 default: |
| 1000 error("Invalid opcode"); | 1009 error("Invalid opcode"); |
| 1001 return; | 1010 return; |
| 1002 } | 1011 } |
| 1003 } // end complex bytecode | 1012 } // end complex bytecode |
| 1004 | 1013 |
| 1005 #if DEBUG | 1014 #if DEBUG |
| 1006 if (FLAG_trace_wasm_decoder) { | 1015 if (FLAG_trace_wasm_decoder) { |
| 1007 for (size_t i = 0; i < stack_.size(); ++i) { | 1016 for (size_t i = 0; i < stack_.size(); ++i) { |
| 1008 Value& val = stack_[i]; | 1017 Value& val = stack_[i]; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 int DecodeStoreMem(LocalType type, MachineType mem_type) { | 1103 int DecodeStoreMem(LocalType type, MachineType mem_type) { |
| 1095 MemoryAccessOperand operand(this, pc_); | 1104 MemoryAccessOperand operand(this, pc_); |
| 1096 Value val = Pop(1, type); | 1105 Value val = Pop(1, type); |
| 1097 Value index = Pop(0, kAstI32); | 1106 Value index = Pop(0, kAstI32); |
| 1098 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, | 1107 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, |
| 1099 val.node, position()); | 1108 val.node, position()); |
| 1100 Push(type, val.node); | 1109 Push(type, val.node); |
| 1101 return 1 + operand.length; | 1110 return 1 + operand.length; |
| 1102 } | 1111 } |
| 1103 | 1112 |
| 1113 void DecodeSimdOpcode(WasmOpcode opcode) { |
| 1114 FunctionSig* sig = WasmOpcodes::Signature(opcode); |
| 1115 compiler::NodeVector inputs(sig->parameter_count(), zone_); |
| 1116 for (size_t i = sig->parameter_count(); i > 0; i--) { |
| 1117 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); |
| 1118 inputs[i - 1] = val.node; |
| 1119 } |
| 1120 TFNode* node = BUILD(SimdOp, opcode, inputs); |
| 1121 Push(GetReturnType(sig), node); |
| 1122 } |
| 1123 |
| 1104 void DoReturn() { | 1124 void DoReturn() { |
| 1105 int count = static_cast<int>(sig_->return_count()); | 1125 int count = static_cast<int>(sig_->return_count()); |
| 1106 TFNode** buffer = nullptr; | 1126 TFNode** buffer = nullptr; |
| 1107 if (build()) buffer = builder_->Buffer(count); | 1127 if (build()) buffer = builder_->Buffer(count); |
| 1108 | 1128 |
| 1109 // Pop return values off the stack in reverse order. | 1129 // Pop return values off the stack in reverse order. |
| 1110 for (int i = count - 1; i >= 0; i--) { | 1130 for (int i = count - 1; i >= 0; i--) { |
| 1111 Value val = Pop(i, sig_->GetReturn(i)); | 1131 Value val = Pop(i, sig_->GetReturn(i)); |
| 1112 if (buffer) buffer[i] = val.node; | 1132 if (buffer) buffer[i] = val.node; |
| 1113 } | 1133 } |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1658 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 1639 const byte* start, const byte* end) { | 1659 const byte* start, const byte* end) { |
| 1640 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1660 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 1641 WasmFullDecoder decoder(zone, nullptr, body); | 1661 WasmFullDecoder decoder(zone, nullptr, body); |
| 1642 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1662 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
| 1643 } | 1663 } |
| 1644 | 1664 |
| 1645 } // namespace wasm | 1665 } // namespace wasm |
| 1646 } // namespace internal | 1666 } // namespace internal |
| 1647 } // namespace v8 | 1667 } // namespace v8 |
| OLD | NEW |