| 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 "test/unittests/interpreter/interpreter-assembler-unittest.h" | 5 #include "test/unittests/interpreter/interpreter-assembler-unittest.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/interface-descriptors.h" | 9 #include "src/interface-descriptors.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) | 44 return kPointerSize == 8 ? IsInt64Add(lhs_matcher, rhs_matcher) |
| 45 : IsInt32Add(lhs_matcher, rhs_matcher); | 45 : IsInt32Add(lhs_matcher, rhs_matcher); |
| 46 } | 46 } |
| 47 | 47 |
| 48 Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, | 48 Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher, |
| 49 const Matcher<Node*>& rhs_matcher) { | 49 const Matcher<Node*>& rhs_matcher) { |
| 50 return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) | 50 return kPointerSize == 8 ? IsInt64Sub(lhs_matcher, rhs_matcher) |
| 51 : IsInt32Sub(lhs_matcher, rhs_matcher); | 51 : IsInt32Sub(lhs_matcher, rhs_matcher); |
| 52 } | 52 } |
| 53 | 53 |
| 54 Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher, |
| 55 const Matcher<Node*>& rhs_matcher) { |
| 56 return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher) |
| 57 : IsInt32Mul(lhs_matcher, rhs_matcher); |
| 58 } |
| 59 |
| 54 Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, | 60 Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher, |
| 55 const Matcher<Node*>& rhs_matcher) { | 61 const Matcher<Node*>& rhs_matcher) { |
| 56 return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) | 62 return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher) |
| 57 : IsWord32Shl(lhs_matcher, rhs_matcher); | 63 : IsWord32Shl(lhs_matcher, rhs_matcher); |
| 58 } | 64 } |
| 59 | 65 |
| 60 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, | 66 Matcher<Node*> IsWordSar(const Matcher<Node*>& lhs_matcher, |
| 61 const Matcher<Node*>& rhs_matcher) { | 67 const Matcher<Node*>& rhs_matcher) { |
| 62 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) | 68 return kPointerSize == 8 ? IsWord64Sar(lhs_matcher, rhs_matcher) |
| 63 : IsWord32Sar(lhs_matcher, rhs_matcher); | 69 : IsWord32Sar(lhs_matcher, rhs_matcher); |
| 64 } | 70 } |
| 65 | 71 |
| 66 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, | 72 Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher, |
| 67 const Matcher<Node*>& rhs_matcher) { | 73 const Matcher<Node*>& rhs_matcher) { |
| 68 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) | 74 return kPointerSize == 8 ? IsWord64Or(lhs_matcher, rhs_matcher) |
| 69 : IsWord32Or(lhs_matcher, rhs_matcher); | 75 : IsWord32Or(lhs_matcher, rhs_matcher); |
| 70 } | 76 } |
| 71 | 77 |
| 78 Matcher<Node*> IsChangeInt32ToIntPtr(const Matcher<Node*>& matcher) { |
| 79 return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher; |
| 80 } |
| 81 |
| 82 Matcher<Node*> IsChangeUint32ToWord(const Matcher<Node*>& matcher) { |
| 83 return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher; |
| 84 } |
| 85 |
| 86 Matcher<Node*> IsTruncateWordToWord32(const Matcher<Node*>& matcher) { |
| 87 return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher; |
| 88 } |
| 89 |
| 72 InterpreterAssemblerTest::InterpreterAssemblerForTest:: | 90 InterpreterAssemblerTest::InterpreterAssemblerForTest:: |
| 73 ~InterpreterAssemblerForTest() { | 91 ~InterpreterAssemblerForTest() { |
| 74 // Tests don't necessarily read and write accumulator but | 92 // Tests don't necessarily read and write accumulator but |
| 75 // InterpreterAssembler checks accumulator uses. | 93 // InterpreterAssembler checks accumulator uses. |
| 76 if (Bytecodes::ReadsAccumulator(bytecode())) { | 94 if (Bytecodes::ReadsAccumulator(bytecode())) { |
| 77 GetAccumulator(); | 95 GetAccumulator(); |
| 78 } | 96 } |
| 79 if (Bytecodes::WritesAccumulator(bytecode())) { | 97 if (Bytecodes::WritesAccumulator(bytecode())) { |
| 80 SetAccumulator(nullptr); | 98 SetAccumulator(nullptr); |
| 81 } | 99 } |
| 82 } | 100 } |
| 83 | 101 |
| 84 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( | 102 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsLoad( |
| 85 const Matcher<LoadRepresentation>& rep_matcher, | 103 const Matcher<LoadRepresentation>& rep_matcher, |
| 86 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { | 104 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher) { |
| 87 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); | 105 return ::i::compiler::IsLoad(rep_matcher, base_matcher, index_matcher, _, _); |
| 88 } | 106 } |
| 89 | 107 |
| 90 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( | 108 Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore( |
| 91 const Matcher<StoreRepresentation>& rep_matcher, | 109 const Matcher<StoreRepresentation>& rep_matcher, |
| 92 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, | 110 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher, |
| 93 const Matcher<Node*>& value_matcher) { | 111 const Matcher<Node*>& value_matcher) { |
| 94 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, | 112 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, |
| 95 value_matcher, _, _); | 113 value_matcher, _, _); |
| 96 } | 114 } |
| 97 | 115 |
| 98 Matcher<Node*> | 116 Matcher<Node*> |
| 99 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( | 117 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( |
| 100 int offset) { | 118 int offset) { |
| 101 return IsLoad( | 119 Matcher<Node*> load_matcher = IsLoad( |
| 102 MachineType::Uint8(), | 120 MachineType::Uint8(), |
| 103 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 121 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 104 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 122 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 105 IsIntPtrConstant(offset))); | 123 IsIntPtrConstant(offset))); |
| 124 return IsChangeUint32ToWord(load_matcher); |
| 106 } | 125 } |
| 107 | 126 |
| 108 Matcher<Node*> | 127 Matcher<Node*> |
| 109 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( | 128 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( |
| 110 int offset) { | 129 int offset) { |
| 111 Matcher<Node*> load_matcher = IsLoad( | 130 Matcher<Node*> load_matcher = IsLoad( |
| 112 MachineType::Int8(), | 131 MachineType::Int8(), |
| 113 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 132 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 114 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 133 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 115 IsIntPtrConstant(offset))); | 134 IsIntPtrConstant(offset))); |
| 116 if (kPointerSize == 8) { | 135 return IsChangeInt32ToIntPtr(load_matcher); |
| 117 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
| 118 } | |
| 119 return load_matcher; | |
| 120 } | 136 } |
| 121 | 137 |
| 122 Matcher<Node*> | 138 Matcher<Node*> |
| 123 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( | 139 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( |
| 124 int offset) { | 140 int offset) { |
| 141 Matcher<Node*> load_matcher; |
| 125 if (TargetSupportsUnalignedAccess()) { | 142 if (TargetSupportsUnalignedAccess()) { |
| 126 return IsLoad( | 143 load_matcher = IsLoad( |
| 127 MachineType::Uint16(), | 144 MachineType::Uint16(), |
| 128 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 145 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 129 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 146 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 130 IsIntPtrConstant(offset))); | 147 IsIntPtrConstant(offset))); |
| 131 } else { | 148 } else { |
| 132 #if V8_TARGET_LITTLE_ENDIAN | 149 #if V8_TARGET_LITTLE_ENDIAN |
| 133 const int kStep = -1; | 150 const int kStep = -1; |
| 134 const int kMsbOffset = 1; | 151 const int kMsbOffset = 1; |
| 135 #elif V8_TARGET_BIG_ENDIAN | 152 #elif V8_TARGET_BIG_ENDIAN |
| 136 const int kStep = 1; | 153 const int kStep = 1; |
| 137 const int kMsbOffset = 0; | 154 const int kMsbOffset = 0; |
| 138 #else | 155 #else |
| 139 #error "Unknown Architecture" | 156 #error "Unknown Architecture" |
| 140 #endif | 157 #endif |
| 141 Matcher<Node*> bytes[2]; | 158 Matcher<Node*> bytes[2]; |
| 142 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { | 159 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 143 bytes[i] = IsLoad( | 160 bytes[i] = IsLoad( |
| 144 MachineType::Uint8(), | 161 MachineType::Uint8(), |
| 145 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 162 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 146 IsIntPtrAdd( | 163 IsIntPtrAdd( |
| 147 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 164 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 148 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 165 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 149 } | 166 } |
| 150 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), | 167 load_matcher = IsWord32Or( |
| 151 bytes[1]); | 168 IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]); |
| 152 } | 169 } |
| 170 return IsChangeUint32ToWord(load_matcher); |
| 153 } | 171 } |
| 154 | 172 |
| 155 Matcher<Node*> | 173 Matcher<Node*> |
| 156 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( | 174 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( |
| 157 int offset) { | 175 int offset) { |
| 158 Matcher<Node*> load_matcher; | 176 Matcher<Node*> load_matcher; |
| 159 if (TargetSupportsUnalignedAccess()) { | 177 if (TargetSupportsUnalignedAccess()) { |
| 160 load_matcher = IsLoad( | 178 load_matcher = IsLoad( |
| 161 MachineType::Int16(), | 179 MachineType::Int16(), |
| 162 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 180 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 177 bytes[i] = IsLoad( | 195 bytes[i] = IsLoad( |
| 178 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), | 196 (i == 0) ? MachineType::Int8() : MachineType::Uint8(), |
| 179 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 197 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 180 IsIntPtrAdd( | 198 IsIntPtrAdd( |
| 181 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 199 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 182 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 200 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 183 } | 201 } |
| 184 load_matcher = IsWord32Or( | 202 load_matcher = IsWord32Or( |
| 185 IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]); | 203 IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]); |
| 186 } | 204 } |
| 187 | 205 return IsChangeInt32ToIntPtr(load_matcher); |
| 188 if (kPointerSize == 8) { | |
| 189 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
| 190 } | |
| 191 return load_matcher; | |
| 192 } | 206 } |
| 193 | 207 |
| 194 Matcher<Node*> | 208 Matcher<Node*> |
| 195 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( | 209 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( |
| 196 int offset) { | 210 int offset) { |
| 211 Matcher<Node*> load_matcher; |
| 197 if (TargetSupportsUnalignedAccess()) { | 212 if (TargetSupportsUnalignedAccess()) { |
| 198 return IsLoad( | 213 load_matcher = IsLoad( |
| 199 MachineType::Uint32(), | 214 MachineType::Uint32(), |
| 200 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 215 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 201 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 216 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 202 IsIntPtrConstant(offset))); | 217 IsIntPtrConstant(offset))); |
| 203 } else { | 218 } else { |
| 204 #if V8_TARGET_LITTLE_ENDIAN | 219 #if V8_TARGET_LITTLE_ENDIAN |
| 205 const int kStep = -1; | 220 const int kStep = -1; |
| 206 const int kMsbOffset = 3; | 221 const int kMsbOffset = 3; |
| 207 #elif V8_TARGET_BIG_ENDIAN | 222 #elif V8_TARGET_BIG_ENDIAN |
| 208 const int kStep = 1; | 223 const int kStep = 1; |
| 209 const int kMsbOffset = 0; | 224 const int kMsbOffset = 0; |
| 210 #else | 225 #else |
| 211 #error "Unknown Architecture" | 226 #error "Unknown Architecture" |
| 212 #endif | 227 #endif |
| 213 Matcher<Node*> bytes[4]; | 228 Matcher<Node*> bytes[4]; |
| 214 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { | 229 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 215 bytes[i] = IsLoad( | 230 bytes[i] = IsLoad( |
| 216 MachineType::Uint8(), | 231 MachineType::Uint8(), |
| 217 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 232 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 218 IsIntPtrAdd( | 233 IsIntPtrAdd( |
| 219 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 234 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 220 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 235 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 221 } | 236 } |
| 222 return IsWord32Or( | 237 load_matcher = IsWord32Or( |
| 223 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), | 238 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), |
| 224 IsWord32Or( | 239 IsWord32Or( |
| 225 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), | 240 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
| 226 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), | 241 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
| 227 bytes[3]))); | 242 bytes[3]))); |
| 228 } | 243 } |
| 244 return IsChangeUint32ToWord(load_matcher); |
| 229 } | 245 } |
| 230 | 246 |
| 231 Matcher<Node*> | 247 Matcher<Node*> |
| 232 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( | 248 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( |
| 233 int offset) { | 249 int offset) { |
| 234 Matcher<Node*> load_matcher; | 250 Matcher<Node*> load_matcher; |
| 235 if (TargetSupportsUnalignedAccess()) { | 251 if (TargetSupportsUnalignedAccess()) { |
| 236 load_matcher = IsLoad( | 252 load_matcher = IsLoad( |
| 237 MachineType::Int32(), | 253 MachineType::Int32(), |
| 238 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 254 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 257 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 273 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 258 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 274 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); |
| 259 } | 275 } |
| 260 load_matcher = IsWord32Or( | 276 load_matcher = IsWord32Or( |
| 261 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), | 277 IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)), |
| 262 IsWord32Or( | 278 IsWord32Or( |
| 263 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), | 279 IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)), |
| 264 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), | 280 IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)), |
| 265 bytes[3]))); | 281 bytes[3]))); |
| 266 } | 282 } |
| 267 | 283 return IsChangeInt32ToIntPtr(load_matcher); |
| 268 if (kPointerSize == 8) { | |
| 269 load_matcher = IsChangeInt32ToInt64(load_matcher); | |
| 270 } | |
| 271 return load_matcher; | |
| 272 } | 284 } |
| 273 | 285 |
| 274 Matcher<Node*> | 286 Matcher<Node*> |
| 275 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( | 287 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedOperand( |
| 276 int offset, OperandSize operand_size) { | 288 int offset, OperandSize operand_size) { |
| 277 switch (operand_size) { | 289 switch (operand_size) { |
| 278 case OperandSize::kByte: | 290 case OperandSize::kByte: |
| 279 return IsSignedByteOperand(offset); | 291 return IsSignedByteOperand(offset); |
| 280 case OperandSize::kShort: | 292 case OperandSize::kShort: |
| 281 return IsSignedShortOperand(offset); | 293 return IsSignedShortOperand(offset); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 311 | 323 |
| 312 OperandScale operand_scale = OperandScale::kSingle; | 324 OperandScale operand_scale = OperandScale::kSingle; |
| 313 Matcher<Node*> next_bytecode_offset_matcher = | 325 Matcher<Node*> next_bytecode_offset_matcher = |
| 314 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 326 IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 315 IsIntPtrConstant( | 327 IsIntPtrConstant( |
| 316 interpreter::Bytecodes::Size(bytecode, operand_scale))); | 328 interpreter::Bytecodes::Size(bytecode, operand_scale))); |
| 317 Matcher<Node*> target_bytecode_matcher = | 329 Matcher<Node*> target_bytecode_matcher = |
| 318 m.IsLoad(MachineType::Uint8(), | 330 m.IsLoad(MachineType::Uint8(), |
| 319 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 331 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 320 next_bytecode_offset_matcher); | 332 next_bytecode_offset_matcher); |
| 321 if (kPointerSize == 8) { | 333 target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); |
| 322 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); | |
| 323 } | |
| 324 Matcher<Node*> code_target_matcher = m.IsLoad( | 334 Matcher<Node*> code_target_matcher = m.IsLoad( |
| 325 MachineType::Pointer(), | 335 MachineType::Pointer(), |
| 326 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 336 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
| 327 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); | 337 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); |
| 328 | 338 |
| 329 if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { | 339 if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { |
| 330 Matcher<Node*> after_lookahead_offset = | 340 Matcher<Node*> after_lookahead_offset = |
| 331 IsIntPtrAdd(next_bytecode_offset_matcher, | 341 IsIntPtrAdd(next_bytecode_offset_matcher, |
| 332 IsIntPtrConstant(interpreter::Bytecodes::Size( | 342 IsIntPtrConstant(interpreter::Bytecodes::Size( |
| 333 Bytecode::kStar, operand_scale))); | 343 Bytecode::kStar, operand_scale))); |
| 334 next_bytecode_offset_matcher = | 344 next_bytecode_offset_matcher = |
| 335 IsPhi(MachineType::PointerRepresentation(), | 345 IsPhi(MachineType::PointerRepresentation(), |
| 336 next_bytecode_offset_matcher, after_lookahead_offset, _); | 346 next_bytecode_offset_matcher, after_lookahead_offset, _); |
| 337 Matcher<Node*> after_lookahead_bytecode = | 347 Matcher<Node*> after_lookahead_bytecode = |
| 338 m.IsLoad(MachineType::Uint8(), | 348 m.IsLoad(MachineType::Uint8(), |
| 339 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 349 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 340 after_lookahead_offset); | 350 after_lookahead_offset); |
| 341 if (kPointerSize == 8) { | 351 after_lookahead_bytecode = IsChangeUint32ToWord(after_lookahead_bytecode); |
| 342 after_lookahead_bytecode = | |
| 343 IsChangeUint32ToUint64(after_lookahead_bytecode); | |
| 344 } | |
| 345 target_bytecode_matcher = | 352 target_bytecode_matcher = |
| 346 IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher, | 353 IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher, |
| 347 after_lookahead_bytecode, _); | 354 after_lookahead_bytecode, _); |
| 348 code_target_matcher = | 355 code_target_matcher = |
| 349 m.IsLoad(MachineType::Pointer(), | 356 m.IsLoad(MachineType::Pointer(), |
| 350 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 357 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
| 351 IsWordShl(target_bytecode_matcher, | 358 IsWordShl(target_bytecode_matcher, |
| 352 IsIntPtrConstant(kPointerSizeLog2))); | 359 IsIntPtrConstant(kPointerSizeLog2))); |
| 353 } | 360 } |
| 354 | 361 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 374 | 381 |
| 375 InterpreterAssemblerTestState state(this, bytecode); | 382 InterpreterAssemblerTestState state(this, bytecode); |
| 376 InterpreterAssemblerForTest m(&state, bytecode); | 383 InterpreterAssemblerForTest m(&state, bytecode); |
| 377 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); | 384 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); |
| 378 | 385 |
| 379 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 386 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
| 380 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), | 387 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset), |
| 381 IsIntPtrConstant(jump_offset)); | 388 IsIntPtrConstant(jump_offset)); |
| 382 Matcher<Node*> target_bytecode_matcher = | 389 Matcher<Node*> target_bytecode_matcher = |
| 383 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); | 390 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); |
| 384 if (kPointerSize == 8) { | 391 target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher); |
| 385 target_bytecode_matcher = | |
| 386 IsChangeUint32ToUint64(target_bytecode_matcher); | |
| 387 } | |
| 388 Matcher<Node*> code_target_matcher = | 392 Matcher<Node*> code_target_matcher = |
| 389 m.IsLoad(MachineType::Pointer(), | 393 m.IsLoad(MachineType::Pointer(), |
| 390 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), | 394 IsParameter(InterpreterDispatchDescriptor::kDispatchTable), |
| 391 IsWordShl(target_bytecode_matcher, | 395 IsWordShl(target_bytecode_matcher, |
| 392 IsIntPtrConstant(kPointerSizeLog2))); | 396 IsIntPtrConstant(kPointerSizeLog2))); |
| 393 | 397 |
| 394 EXPECT_THAT( | 398 EXPECT_THAT( |
| 395 tail_call_node, | 399 tail_call_node, |
| 396 IsTailCall(_, code_target_matcher, | 400 IsTailCall(_, code_target_matcher, |
| 397 IsParameter(InterpreterDispatchDescriptor::kAccumulator), | 401 IsParameter(InterpreterDispatchDescriptor::kAccumulator), |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 Node* a = m.IntPtrConstant(0); | 596 Node* a = m.IntPtrConstant(0); |
| 593 Node* add = m.WordShl(a, 10); | 597 Node* add = m.WordShl(a, 10); |
| 594 EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); | 598 EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10))); |
| 595 } | 599 } |
| 596 } | 600 } |
| 597 | 601 |
| 598 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { | 602 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { |
| 599 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 603 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 600 InterpreterAssemblerTestState state(this, bytecode); | 604 InterpreterAssemblerTestState state(this, bytecode); |
| 601 InterpreterAssemblerForTest m(&state, bytecode); | 605 InterpreterAssemblerForTest m(&state, bytecode); |
| 602 Node* index = m.IntPtrConstant(2); | 606 { |
| 603 Node* load_constant = m.LoadConstantPoolEntry(index); | 607 Node* index = m.IntPtrConstant(2); |
| 604 Matcher<Node*> constant_pool_matcher = m.IsLoad( | 608 Node* load_constant = m.LoadConstantPoolEntry(index); |
| 605 MachineType::AnyTagged(), | 609 Matcher<Node*> constant_pool_matcher = |
| 606 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), | 610 m.IsLoad(MachineType::AnyTagged(), |
| 607 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); | 611 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 608 EXPECT_THAT( | 612 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - |
| 609 load_constant, | 613 kHeapObjectTag)); |
| 610 m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, | 614 EXPECT_THAT(load_constant, |
| 611 IsIntPtrAdd( | 615 m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher, |
| 612 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 616 IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - |
| 613 IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2))))); | 617 kHeapObjectTag))); |
| 618 } |
| 619 { |
| 620 Node* index = m.Parameter(2); |
| 621 Node* load_constant = m.LoadConstantPoolEntry(index); |
| 622 Matcher<Node*> constant_pool_matcher = |
| 623 m.IsLoad(MachineType::AnyTagged(), |
| 624 IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), |
| 625 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - |
| 626 kHeapObjectTag)); |
| 627 EXPECT_THAT( |
| 628 load_constant, |
| 629 m.IsLoad( |
| 630 MachineType::AnyTagged(), constant_pool_matcher, |
| 631 IsIntPtrAdd( |
| 632 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 633 IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2))))); |
| 634 } |
| 614 } | 635 } |
| 615 } | 636 } |
| 616 | 637 |
| 617 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { | 638 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { |
| 618 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 639 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 619 InterpreterAssemblerTestState state(this, bytecode); | 640 InterpreterAssemblerTestState state(this, bytecode); |
| 620 InterpreterAssemblerForTest m(&state, bytecode); | 641 InterpreterAssemblerForTest m(&state, bytecode); |
| 621 Node* object = m.IntPtrConstant(0xdeadbeef); | 642 Node* object = m.IntPtrConstant(0xdeadbeef); |
| 622 int offset = 16; | 643 int offset = 16; |
| 623 Node* load_field = m.LoadObjectField(object, offset); | 644 Node* load_field = m.LoadObjectField(object, offset); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 641 } | 662 } |
| 642 | 663 |
| 643 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { | 664 TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) { |
| 644 const int kResultSizes[] = {1, 2}; | 665 const int kResultSizes[] = {1, 2}; |
| 645 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 666 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 646 TRACED_FOREACH(int, result_size, kResultSizes) { | 667 TRACED_FOREACH(int, result_size, kResultSizes) { |
| 647 InterpreterAssemblerTestState state(this, bytecode); | 668 InterpreterAssemblerTestState state(this, bytecode); |
| 648 InterpreterAssemblerForTest m(&state, bytecode); | 669 InterpreterAssemblerForTest m(&state, bytecode); |
| 649 Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size); | 670 Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size); |
| 650 | 671 |
| 651 Node* function_id = m.Int32Constant(0); | 672 Node* function_id = m.IntPtrConstant(0); |
| 652 Node* first_arg = m.Int32Constant(1); | 673 Node* first_arg = m.IntPtrConstant(1); |
| 653 Node* arg_count = m.Int32Constant(2); | 674 Node* arg_count = m.IntPtrConstant(2); |
| 654 Node* context = m.Int32Constant(4); | 675 Node* context = m.IntPtrConstant(4); |
| 655 | 676 |
| 656 Matcher<Node*> function_table = IsExternalConstant( | 677 Matcher<Node*> function_table = IsExternalConstant( |
| 657 ExternalReference::runtime_function_table_address(isolate())); | 678 ExternalReference::runtime_function_table_address(isolate())); |
| 658 Matcher<Node*> function = IsIntPtrAdd( | 679 Matcher<Node*> function = |
| 659 function_table, | 680 IsIntPtrAdd(function_table, |
| 660 IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function)))); | 681 IsIntPtrMul(function_id, |
| 682 IsIntPtrConstant(sizeof(Runtime::Function)))); |
| 661 Matcher<Node*> function_entry = | 683 Matcher<Node*> function_entry = |
| 662 m.IsLoad(MachineType::Pointer(), function, | 684 m.IsLoad(MachineType::Pointer(), function, |
| 663 IsIntPtrConstant(offsetof(Runtime::Function, entry))); | 685 IsIntPtrConstant(offsetof(Runtime::Function, entry))); |
| 664 | 686 |
| 665 Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, | 687 Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg, |
| 666 arg_count, result_size); | 688 arg_count, result_size); |
| 667 EXPECT_THAT(call_runtime, | 689 EXPECT_THAT(call_runtime, |
| 668 IsCall(_, IsHeapConstant(builtin.code()), arg_count, | 690 IsCall(_, IsHeapConstant(builtin.code()), |
| 669 first_arg, function_entry, context, _, _)); | 691 IsTruncateWordToWord32(arg_count), first_arg, |
| 692 function_entry, context, _, _)); |
| 670 } | 693 } |
| 671 } | 694 } |
| 672 } | 695 } |
| 673 | 696 |
| 674 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) { | 697 TARGET_TEST_F(InterpreterAssemblerTest, CallJS) { |
| 675 TailCallMode tail_call_modes[] = {TailCallMode::kDisallow, | 698 TailCallMode tail_call_modes[] = {TailCallMode::kDisallow, |
| 676 TailCallMode::kAllow}; | 699 TailCallMode::kAllow}; |
| 677 TRACED_FOREACH(TailCallMode, tail_call_mode, tail_call_modes) { | 700 TRACED_FOREACH(TailCallMode, tail_call_mode, tail_call_modes) { |
| 678 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 701 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 679 InterpreterAssemblerTestState state(this, bytecode); | 702 InterpreterAssemblerTestState state(this, bytecode); |
| 680 InterpreterAssemblerForTest m(&state, bytecode); | 703 InterpreterAssemblerForTest m(&state, bytecode); |
| 681 Callable builtin = | 704 Callable builtin = |
| 682 CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode); | 705 CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode); |
| 683 Node* function = m.Int32Constant(0); | 706 Node* function = m.IntPtrConstant(0); |
| 684 Node* first_arg = m.Int32Constant(1); | 707 Node* first_arg = m.IntPtrConstant(1); |
| 685 Node* arg_count = m.Int32Constant(2); | 708 Node* arg_count = m.IntPtrConstant(2); |
| 686 Node* context = m.Int32Constant(3); | 709 Node* context = m.IntPtrConstant(3); |
| 687 Node* call_js = | 710 Node* call_js = |
| 688 m.CallJS(function, context, first_arg, arg_count, tail_call_mode); | 711 m.CallJS(function, context, first_arg, arg_count, tail_call_mode); |
| 689 EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), arg_count, | 712 EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), |
| 690 first_arg, function, context, _, _)); | 713 IsTruncateWordToWord32(arg_count), first_arg, |
| 714 function, context, _, _)); |
| 691 } | 715 } |
| 692 } | 716 } |
| 693 } | 717 } |
| 694 | 718 |
| 695 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { | 719 TARGET_TEST_F(InterpreterAssemblerTest, LoadTypeFeedbackVector) { |
| 696 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 720 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 697 InterpreterAssemblerTestState state(this, bytecode); | 721 InterpreterAssemblerTestState state(this, bytecode); |
| 698 InterpreterAssemblerForTest m(&state, bytecode); | 722 InterpreterAssemblerForTest m(&state, bytecode); |
| 699 Node* feedback_vector = m.LoadTypeFeedbackVector(); | 723 Node* feedback_vector = m.LoadTypeFeedbackVector(); |
| 700 | 724 |
| 701 Matcher<Node*> load_function_matcher = | 725 Matcher<Node*> load_function_matcher = |
| 702 m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), | 726 m.IsLoad(MachineType::AnyTagged(), IsLoadParentFramePointer(), |
| 703 IsIntPtrConstant(Register::function_closure().ToOperand() | 727 IsIntPtrConstant(Register::function_closure().ToOperand() |
| 704 << kPointerSizeLog2)); | 728 << kPointerSizeLog2)); |
| 705 Matcher<Node*> load_literals_matcher = m.IsLoad( | 729 Matcher<Node*> load_literals_matcher = m.IsLoad( |
| 706 MachineType::AnyTagged(), load_function_matcher, | 730 MachineType::AnyTagged(), load_function_matcher, |
| 707 IsIntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag)); | 731 IsIntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag)); |
| 708 | 732 |
| 709 EXPECT_THAT(feedback_vector, | 733 EXPECT_THAT(feedback_vector, |
| 710 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 734 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
| 711 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 735 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
| 712 kHeapObjectTag))); | 736 kHeapObjectTag))); |
| 713 } | 737 } |
| 714 } | 738 } |
| 715 | 739 |
| 716 } // namespace interpreter | 740 } // namespace interpreter |
| 717 } // namespace internal | 741 } // namespace internal |
| 718 } // namespace v8 | 742 } // namespace v8 |
| OLD | NEW |