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/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 jsgraph()->Int64Constant(kMask64)); | 1059 jsgraph()->Int64Constant(kMask64)); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 return node; | 1062 return node; |
1063 } | 1063 } |
1064 | 1064 |
1065 static bool ReverseBytesSupported(MachineOperatorBuilder* m, | 1065 static bool ReverseBytesSupported(MachineOperatorBuilder* m, |
1066 size_t size_in_bytes) { | 1066 size_t size_in_bytes) { |
1067 switch (size_in_bytes) { | 1067 switch (size_in_bytes) { |
1068 case 4: | 1068 case 4: |
| 1069 case 16: |
1069 return m->Word32ReverseBytes().IsSupported(); | 1070 return m->Word32ReverseBytes().IsSupported(); |
1070 case 8: | 1071 case 8: |
1071 return m->Word64ReverseBytes().IsSupported(); | 1072 return m->Word64ReverseBytes().IsSupported(); |
1072 default: | 1073 default: |
1073 break; | 1074 break; |
1074 } | 1075 } |
1075 return false; | 1076 return false; |
1076 } | 1077 } |
1077 | 1078 |
1078 Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype, | 1079 Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype, |
(...skipping 16 matching lines...) Expand all Loading... |
1095 value = graph()->NewNode(m->BitcastFloat32ToInt32(), node); | 1096 value = graph()->NewNode(m->BitcastFloat32ToInt32(), node); |
1096 isFloat = true; | 1097 isFloat = true; |
1097 case MachineRepresentation::kWord32: | 1098 case MachineRepresentation::kWord32: |
1098 case MachineRepresentation::kWord16: | 1099 case MachineRepresentation::kWord16: |
1099 result = jsgraph()->Int32Constant(0); | 1100 result = jsgraph()->Int32Constant(0); |
1100 break; | 1101 break; |
1101 case MachineRepresentation::kWord8: | 1102 case MachineRepresentation::kWord8: |
1102 // No need to change endianness for byte size, return original node | 1103 // No need to change endianness for byte size, return original node |
1103 return node; | 1104 return node; |
1104 break; | 1105 break; |
| 1106 case MachineRepresentation::kSimd128: |
| 1107 DCHECK(ReverseBytesSupported(m, valueSizeInBytes)); |
| 1108 break; |
1105 default: | 1109 default: |
1106 UNREACHABLE(); | 1110 UNREACHABLE(); |
1107 break; | 1111 break; |
1108 } | 1112 } |
1109 | 1113 |
1110 int i; | 1114 int i; |
1111 uint32_t shiftCount; | 1115 uint32_t shiftCount; |
1112 | 1116 |
1113 if (ReverseBytesSupported(m, valueSizeInBytes < 4 ? 4 : valueSizeInBytes)) { | 1117 if (ReverseBytesSupported(m, valueSizeInBytes < 4 ? 4 : valueSizeInBytes)) { |
1114 switch (valueSizeInBytes) { | 1118 switch (valueSizeInBytes) { |
1115 case 2: | 1119 case 2: |
1116 result = | 1120 result = |
1117 graph()->NewNode(m->Word32ReverseBytes().op(), | 1121 graph()->NewNode(m->Word32ReverseBytes().op(), |
1118 graph()->NewNode(m->Word32Shl(), value, | 1122 graph()->NewNode(m->Word32Shl(), value, |
1119 jsgraph()->Int32Constant(16))); | 1123 jsgraph()->Int32Constant(16))); |
1120 break; | 1124 break; |
1121 case 4: | 1125 case 4: |
1122 result = graph()->NewNode(m->Word32ReverseBytes().op(), value); | 1126 result = graph()->NewNode(m->Word32ReverseBytes().op(), value); |
1123 break; | 1127 break; |
1124 case 8: | 1128 case 8: |
1125 result = graph()->NewNode(m->Word64ReverseBytes().op(), value); | 1129 result = graph()->NewNode(m->Word64ReverseBytes().op(), value); |
1126 break; | 1130 break; |
| 1131 case 16: { |
| 1132 Node* byte_reversed_lanes[4]; |
| 1133 for (int lane = 0; lane < 4; lane++) { |
| 1134 byte_reversed_lanes[lane] = graph()->NewNode( |
| 1135 m->Word32ReverseBytes().op(), |
| 1136 graph()->NewNode(jsgraph()->machine()->I32x4ExtractLane(lane), |
| 1137 value)); |
| 1138 } |
| 1139 |
| 1140 // This is making a copy of the value. |
| 1141 result = |
| 1142 graph()->NewNode(jsgraph()->machine()->S128And(), value, value); |
| 1143 |
| 1144 for (int lane = 0; lane < 4; lane++) { |
| 1145 result = |
| 1146 graph()->NewNode(jsgraph()->machine()->I32x4ReplaceLane(3 - lane), |
| 1147 result, byte_reversed_lanes[lane]); |
| 1148 } |
| 1149 |
| 1150 break; |
| 1151 } |
1127 default: | 1152 default: |
1128 UNREACHABLE(); | 1153 UNREACHABLE(); |
1129 } | 1154 } |
1130 } else { | 1155 } else { |
1131 for (i = 0, shiftCount = valueSizeInBits - 8; i < valueSizeInBits / 2; | 1156 for (i = 0, shiftCount = valueSizeInBits - 8; i < valueSizeInBits / 2; |
1132 i += 8, shiftCount -= 16) { | 1157 i += 8, shiftCount -= 16) { |
1133 Node* shiftLower; | 1158 Node* shiftLower; |
1134 Node* shiftHigher; | 1159 Node* shiftHigher; |
1135 Node* lowerByte; | 1160 Node* lowerByte; |
1136 Node* higherByte; | 1161 Node* higherByte; |
(...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4142 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { | 4167 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { |
4143 WasmCompilationUnit unit(isolate, module_env, function); | 4168 WasmCompilationUnit unit(isolate, module_env, function); |
4144 unit.InitializeHandles(); | 4169 unit.InitializeHandles(); |
4145 unit.ExecuteCompilation(); | 4170 unit.ExecuteCompilation(); |
4146 return unit.FinishCompilation(thrower); | 4171 return unit.FinishCompilation(thrower); |
4147 } | 4172 } |
4148 | 4173 |
4149 } // namespace compiler | 4174 } // namespace compiler |
4150 } // namespace internal | 4175 } // namespace internal |
4151 } // namespace v8 | 4176 } // namespace v8 |
OLD | NEW |