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 len++; | |
1001 byte simd_index = *(pc_ + 1); | |
1002 opcode = static_cast<WasmOpcode>(opcode << 8 | simd_index); | |
1003 DecodeSimdOpcode(opcode); | |
bradnelson
2016/07/13 18:10:42
Add an --enable-wasm-simd flag, and error if this
gdeepti
2016/07/13 18:58:35
Added --enable-wasm-simd flag, falls through to in
| |
1004 break; | |
1005 } | |
999 default: | 1006 default: |
1000 error("Invalid opcode"); | 1007 error("Invalid opcode"); |
1001 return; | 1008 return; |
1002 } | 1009 } |
1003 } // end complex bytecode | 1010 } // end complex bytecode |
1004 | 1011 |
1005 #if DEBUG | 1012 #if DEBUG |
1006 if (FLAG_trace_wasm_decoder) { | 1013 if (FLAG_trace_wasm_decoder) { |
1007 for (size_t i = 0; i < stack_.size(); ++i) { | 1014 for (size_t i = 0; i < stack_.size(); ++i) { |
1008 Value& val = stack_[i]; | 1015 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) { | 1101 int DecodeStoreMem(LocalType type, MachineType mem_type) { |
1095 MemoryAccessOperand operand(this, pc_); | 1102 MemoryAccessOperand operand(this, pc_); |
1096 Value val = Pop(1, type); | 1103 Value val = Pop(1, type); |
1097 Value index = Pop(0, kAstI32); | 1104 Value index = Pop(0, kAstI32); |
1098 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, | 1105 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, |
1099 val.node, position()); | 1106 val.node, position()); |
1100 Push(type, val.node); | 1107 Push(type, val.node); |
1101 return 1 + operand.length; | 1108 return 1 + operand.length; |
1102 } | 1109 } |
1103 | 1110 |
1111 void DecodeSimdOpcode(WasmOpcode opcode) { | |
1112 FunctionSig* sig = WasmOpcodes::Signature(opcode); | |
1113 compiler::NodeVector inputs(sig->parameter_count(), zone_); | |
1114 for (int i = static_cast<int>(sig->parameter_count()); i > 0; i--) { | |
bradnelson
2016/07/13 18:10:42
size_t drop cast?
gdeepti
2016/07/13 18:58:35
Done.
| |
1115 Value val = Pop(i - 1, sig->GetParam(i - 1)); | |
1116 inputs[i - 1] = val.node; | |
1117 } | |
1118 TFNode* node = BUILD(SimdOp, opcode, inputs); | |
1119 Push(GetReturnType(sig), node); | |
1120 } | |
1121 | |
1104 void DoReturn() { | 1122 void DoReturn() { |
1105 int count = static_cast<int>(sig_->return_count()); | 1123 int count = static_cast<int>(sig_->return_count()); |
1106 TFNode** buffer = nullptr; | 1124 TFNode** buffer = nullptr; |
1107 if (build()) buffer = builder_->Buffer(count); | 1125 if (build()) buffer = builder_->Buffer(count); |
1108 | 1126 |
1109 // Pop return values off the stack in reverse order. | 1127 // Pop return values off the stack in reverse order. |
1110 for (int i = count - 1; i >= 0; i--) { | 1128 for (int i = count - 1; i >= 0; i--) { |
1111 Value val = Pop(i, sig_->GetReturn(i)); | 1129 Value val = Pop(i, sig_->GetReturn(i)); |
1112 if (buffer) buffer[i] = val.node; | 1130 if (buffer) buffer[i] = val.node; |
1113 } | 1131 } |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1638 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1656 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
1639 const byte* start, const byte* end) { | 1657 const byte* start, const byte* end) { |
1640 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1658 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
1641 WasmFullDecoder decoder(zone, nullptr, body); | 1659 WasmFullDecoder decoder(zone, nullptr, body); |
1642 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1660 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
1643 } | 1661 } |
1644 | 1662 |
1645 } // namespace wasm | 1663 } // namespace wasm |
1646 } // namespace internal | 1664 } // namespace internal |
1647 } // namespace v8 | 1665 } // namespace v8 |
OLD | NEW |