| 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/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const Matcher<Node*>& value_matcher) { | 86 const Matcher<Node*>& value_matcher) { |
| 87 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, | 87 return ::i::compiler::IsStore(rep_matcher, base_matcher, index_matcher, |
| 88 value_matcher, _, _); | 88 value_matcher, _, _); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Matcher<Node*> | 91 Matcher<Node*> |
| 92 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( | 92 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand( |
| 93 int offset) { | 93 int offset) { |
| 94 return IsLoad( | 94 return IsLoad( |
| 95 MachineType::Uint8(), | 95 MachineType::Uint8(), |
| 96 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 97 IsIntPtrAdd( | 96 IsIntPtrAdd( |
| 98 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 97 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 99 IsIntPtrConstant(offset))); | 98 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 99 IsIntPtrConstant(offset)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 Matcher<Node*> | 102 Matcher<Node*> |
| 103 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( | 103 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand( |
| 104 int offset) { | 104 int offset) { |
| 105 Matcher<Node*> load_matcher = IsLoad( | 105 Matcher<Node*> load_matcher = IsLoad( |
| 106 MachineType::Int8(), | 106 MachineType::Int8(), |
| 107 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 108 IsIntPtrAdd( | 107 IsIntPtrAdd( |
| 109 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 108 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 110 IsIntPtrConstant(offset))); | 109 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 110 IsIntPtrConstant(offset)); |
| 111 if (kPointerSize == 8) { | 111 if (kPointerSize == 8) { |
| 112 load_matcher = IsChangeInt32ToInt64(load_matcher); | 112 load_matcher = IsChangeInt32ToInt64(load_matcher); |
| 113 } | 113 } |
| 114 return load_matcher; | 114 return load_matcher; |
| 115 } | 115 } |
| 116 | 116 |
| 117 Matcher<Node*> | 117 Matcher<Node*> |
| 118 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( | 118 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand( |
| 119 int offset) { | 119 int offset) { |
| 120 if (TargetSupportsUnalignedAccess()) { | 120 if (TargetSupportsUnalignedAccess()) { |
| 121 return IsLoad( | 121 return IsLoad( |
| 122 MachineType::Uint16(), | 122 MachineType::Uint16(), |
| 123 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 124 IsIntPtrAdd( | 123 IsIntPtrAdd( |
| 124 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 125 IsParameter( | 125 IsParameter( |
| 126 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 126 InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 127 IsIntPtrConstant(offset))); | 127 IsIntPtrConstant(offset)); |
| 128 } else { | 128 } else { |
| 129 #if V8_TARGET_LITTLE_ENDIAN | 129 #if V8_TARGET_LITTLE_ENDIAN |
| 130 const int kStep = -1; | 130 const int kStep = -1; |
| 131 const int kMsbOffset = 1; | 131 const int kMsbOffset = 1; |
| 132 #elif V8_TARGET_BIG_ENDIAN | 132 #elif V8_TARGET_BIG_ENDIAN |
| 133 const int kStep = 1; | 133 const int kStep = 1; |
| 134 const int kMsbOffset = 0; | 134 const int kMsbOffset = 0; |
| 135 #else | 135 #else |
| 136 #error "Unknown Architecture" | 136 #error "Unknown Architecture" |
| 137 #endif | 137 #endif |
| 138 Matcher<Node*> bytes[2]; | 138 Matcher<Node*> bytes[2]; |
| 139 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { | 139 for (int i = 0; i < static_cast<int>(arraysize(bytes)); i++) { |
| 140 bytes[i] = IsLoad( | 140 bytes[i] = IsLoad( |
| 141 MachineType::Uint8(), | 141 MachineType::Uint8(), |
| 142 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 143 IsIntPtrAdd( | 142 IsIntPtrAdd( |
| 144 IsParameter( | 143 IsParameter( |
| 145 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 144 InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 146 IsIntPtrConstant(offset + kMsbOffset + kStep * i))); | 145 IsParameter( |
| 146 InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 147 IsIntPtrConstant(offset + kMsbOffset + kStep * i)); |
| 147 } | 148 } |
| 148 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), | 149 return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), |
| 149 bytes[1]); | 150 bytes[1]); |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 Matcher<Node*> | 154 Matcher<Node*> |
| 154 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( | 155 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand( |
| 155 int offset) { | 156 int offset) { |
| 156 Matcher<Node*> load_matcher; | 157 Matcher<Node*> load_matcher; |
| 157 if (TargetSupportsUnalignedAccess()) { | 158 if (TargetSupportsUnalignedAccess()) { |
| 158 load_matcher = IsLoad( | 159 load_matcher = IsLoad( |
| 159 MachineType::Int16(), | 160 MachineType::Int16(), |
| 160 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 161 IsIntPtrAdd( | 161 IsIntPtrAdd( |
| 162 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 162 IsParameter( | 163 IsParameter( |
| 163 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 164 InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 164 IsIntPtrConstant(offset))); | 165 IsIntPtrConstant(offset)); |
| 165 } else { | 166 } else { |
| 166 #if V8_TARGET_LITTLE_ENDIAN | 167 #if V8_TARGET_LITTLE_ENDIAN |
| 167 const int kStep = -1; | 168 const int kStep = -1; |
| 168 const int kMsbOffset = 1; | 169 const int kMsbOffset = 1; |
| 169 #elif V8_TARGET_BIG_ENDIAN | 170 #elif V8_TARGET_BIG_ENDIAN |
| 170 const int kStep = 1; | 171 const int kStep = 1; |
| 171 const int kMsbOffset = 0; | 172 const int kMsbOffset = 0; |
| 172 #else | 173 #else |
| 173 #error "Unknown Architecture" | 174 #error "Unknown Architecture" |
| 174 #endif | 175 #endif |
| (...skipping 16 matching lines...) Expand all Loading... |
| 191 } | 192 } |
| 192 return load_matcher; | 193 return load_matcher; |
| 193 } | 194 } |
| 194 | 195 |
| 195 Matcher<Node*> | 196 Matcher<Node*> |
| 196 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( | 197 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand( |
| 197 int offset) { | 198 int offset) { |
| 198 if (TargetSupportsUnalignedAccess()) { | 199 if (TargetSupportsUnalignedAccess()) { |
| 199 return IsLoad( | 200 return IsLoad( |
| 200 MachineType::Uint32(), | 201 MachineType::Uint32(), |
| 201 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 202 IsIntPtrAdd( | 202 IsIntPtrAdd( |
| 203 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 203 IsParameter( | 204 IsParameter( |
| 204 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 205 InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 205 IsIntPtrConstant(offset))); | 206 IsIntPtrConstant(offset)); |
| 206 } else { | 207 } else { |
| 207 #if V8_TARGET_LITTLE_ENDIAN | 208 #if V8_TARGET_LITTLE_ENDIAN |
| 208 const int kStep = -1; | 209 const int kStep = -1; |
| 209 const int kMsbOffset = 3; | 210 const int kMsbOffset = 3; |
| 210 #elif V8_TARGET_BIG_ENDIAN | 211 #elif V8_TARGET_BIG_ENDIAN |
| 211 const int kStep = 1; | 212 const int kStep = 1; |
| 212 const int kMsbOffset = 0; | 213 const int kMsbOffset = 0; |
| 213 #else | 214 #else |
| 214 #error "Unknown Architecture" | 215 #error "Unknown Architecture" |
| 215 #endif | 216 #endif |
| (...skipping 16 matching lines...) Expand all Loading... |
| 232 } | 233 } |
| 233 } | 234 } |
| 234 | 235 |
| 235 Matcher<Node*> | 236 Matcher<Node*> |
| 236 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( | 237 InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand( |
| 237 int offset) { | 238 int offset) { |
| 238 Matcher<Node*> load_matcher; | 239 Matcher<Node*> load_matcher; |
| 239 if (TargetSupportsUnalignedAccess()) { | 240 if (TargetSupportsUnalignedAccess()) { |
| 240 load_matcher = IsLoad( | 241 load_matcher = IsLoad( |
| 241 MachineType::Int32(), | 242 MachineType::Int32(), |
| 242 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | |
| 243 IsIntPtrAdd( | 243 IsIntPtrAdd( |
| 244 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 244 IsParameter( | 245 IsParameter( |
| 245 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 246 InterpreterDispatchDescriptor::kBytecodeOffsetParameter)), |
| 246 IsIntPtrConstant(offset))); | 247 IsIntPtrConstant(offset)); |
| 247 } else { | 248 } else { |
| 248 #if V8_TARGET_LITTLE_ENDIAN | 249 #if V8_TARGET_LITTLE_ENDIAN |
| 249 const int kStep = -1; | 250 const int kStep = -1; |
| 250 int kMsbOffset = 3; | 251 int kMsbOffset = 3; |
| 251 #elif V8_TARGET_BIG_ENDIAN | 252 #elif V8_TARGET_BIG_ENDIAN |
| 252 const int kStep = 1; | 253 const int kStep = 1; |
| 253 int kMsbOffset = 0; | 254 int kMsbOffset = 0; |
| 254 #else | 255 #else |
| 255 #error "Unknown Architecture" | 256 #error "Unknown Architecture" |
| 256 #endif | 257 #endif |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 EXPECT_THAT(feedback_vector, | 704 EXPECT_THAT(feedback_vector, |
| 704 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 705 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
| 705 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 706 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
| 706 kHeapObjectTag))); | 707 kHeapObjectTag))); |
| 707 } | 708 } |
| 708 } | 709 } |
| 709 | 710 |
| 710 } // namespace interpreter | 711 } // namespace interpreter |
| 711 } // namespace internal | 712 } // namespace internal |
| 712 } // namespace v8 | 713 } // namespace v8 |
| OLD | NEW |