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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
10 #include "test/unittests/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 TEST(Bytecodes, DecodeBytecodeAndOperands) { | 180 TEST(Bytecodes, DecodeBytecodeAndOperands) { |
181 struct BytecodesAndResult { | 181 struct BytecodesAndResult { |
182 const uint8_t bytecode[32]; | 182 const uint8_t bytecode[32]; |
183 const size_t length; | 183 const size_t length; |
184 int parameter_count; | 184 int parameter_count; |
185 const char* output; | 185 const char* output; |
186 }; | 186 }; |
187 | 187 |
188 #define B(Name) static_cast<uint8_t>(Bytecode::k##Name) | 188 #define B(Name) static_cast<uint8_t>(Bytecode::k##Name) |
189 const BytecodesAndResult cases[] = { | 189 const BytecodesAndResult cases[] = { |
190 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"}, | 190 #if V8_TARGET_BIG_ENDIAN |
191 {{B(Wide), B(LdaSmi), 0xe8, 0x03}, 4, 0, " LdaSmi.Wide [1000]"}, | 191 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"}, |
192 {{B(ExtraWide), B(LdaSmi), 0xa0, 0x86, 0x01, 0x00}, | 192 {{B(Wide), B(LdaSmi), 0x03, 0xe8}, 4, 0, " LdaSmi.Wide [1000]"}, |
193 6, | 193 {{B(ExtraWide), B(LdaSmi), 0x00, 0x01, 0x86, 0xa0}, |
194 0, | 194 6, |
195 "LdaSmi.ExtraWide [100000]"}, | 195 0, |
196 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"}, | 196 "LdaSmi.ExtraWide [100000]"}, |
197 {{B(Wide), B(LdaSmi), 0x18, 0xfc}, 4, 0, " LdaSmi.Wide [-1000]"}, | 197 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"}, |
198 {{B(ExtraWide), B(LdaSmi), 0x60, 0x79, 0xfe, 0xff}, | 198 {{B(Wide), B(LdaSmi), 0xfc, 0x18}, 4, 0, " LdaSmi.Wide [-1000]"}, |
199 6, | 199 {{B(ExtraWide), B(LdaSmi), 0xff, 0xfe, 0x79, 0x60}, |
200 0, | 200 6, |
201 "LdaSmi.ExtraWide [-100000]"}, | 201 0, |
202 {{B(Star), 0xfb}, 2, 0, " Star r5"}, | 202 "LdaSmi.ExtraWide [-100000]"}, |
203 {{B(Wide), B(Star), 0x78, 0xff}, 4, 0, " Star.Wide r136"}, | 203 {{B(Star), 0xfb}, 2, 0, " Star r5"}, |
204 {{B(Wide), B(Call), 0x7a, 0xff, 0x79, 0xff, 0x02, 0x00, 0xb1, 0x00}, | 204 {{B(Wide), B(Star), 0xff, 0x78}, 4, 0, " Star.Wide r136"}, |
205 10, | 205 {{B(Wide), B(Call), 0xff, 0x7a, 0xff, 0x79, 0x00, 0x02, 0x00, 0xb1}, |
206 0, | 206 10, |
207 "Call.Wide r134, r135, #2, [177]"}, | 207 0, |
208 {{B(Ldar), | 208 "Call.Wide r134, r135, #2, [177]"}, |
209 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())}, | 209 {{B(Ldar), |
210 2, | 210 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())}, |
211 3, | 211 2, |
212 " Ldar a1"}, | 212 3, |
213 {{B(Wide), B(CreateObjectLiteral), 0x01, 0x02, 0x03, 0x04, 0xa5}, | 213 " Ldar a1"}, |
214 7, | 214 {{B(Wide), B(CreateObjectLiteral), 0x02, 0x01, 0x04, 0x03, 0xa5}, |
215 0, | 215 7, |
216 "CreateObjectLiteral.Wide [513], [1027], #165"}, | 216 0, |
217 {{B(ExtraWide), B(JumpIfNull), 0x15, 0xcd, 0x5b, 0x07}, | 217 "CreateObjectLiteral.Wide [513], [1027], #165"}, |
218 6, | 218 {{B(ExtraWide), B(JumpIfNull), 0x07, 0x5b, 0xcd, 0x15}, |
219 0, | 219 6, |
220 "JumpIfNull.ExtraWide [123456789]"}, | 220 0, |
221 "JumpIfNull.ExtraWide [123456789]"}, | |
222 #else | |
oth
2016/04/13 10:18:11
For consistency with similar endian paths, can thi
miran.karic
2016/04/13 10:40:15
Done.
| |
223 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"}, | |
224 {{B(Wide), B(LdaSmi), 0xe8, 0x03}, 4, 0, " LdaSmi.Wide [1000]"}, | |
225 {{B(ExtraWide), B(LdaSmi), 0xa0, 0x86, 0x01, 0x00}, | |
226 6, | |
227 0, | |
228 "LdaSmi.ExtraWide [100000]"}, | |
229 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"}, | |
230 {{B(Wide), B(LdaSmi), 0x18, 0xfc}, 4, 0, " LdaSmi.Wide [-1000]"}, | |
231 {{B(ExtraWide), B(LdaSmi), 0x60, 0x79, 0xfe, 0xff}, | |
232 6, | |
233 0, | |
234 "LdaSmi.ExtraWide [-100000]"}, | |
235 {{B(Star), 0xfb}, 2, 0, " Star r5"}, | |
236 {{B(Wide), B(Star), 0x78, 0xff}, 4, 0, " Star.Wide r136"}, | |
237 {{B(Wide), B(Call), 0x7a, 0xff, 0x79, 0xff, 0x02, 0x00, 0xb1, 0x00}, | |
238 10, | |
239 0, | |
240 "Call.Wide r134, r135, #2, [177]"}, | |
241 {{B(Ldar), | |
242 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())}, | |
243 2, | |
244 3, | |
245 " Ldar a1"}, | |
246 {{B(Wide), B(CreateObjectLiteral), 0x01, 0x02, 0x03, 0x04, 0xa5}, | |
247 7, | |
248 0, | |
249 "CreateObjectLiteral.Wide [513], [1027], #165"}, | |
250 {{B(ExtraWide), B(JumpIfNull), 0x15, 0xcd, 0x5b, 0x07}, | |
251 6, | |
252 0, | |
253 "JumpIfNull.ExtraWide [123456789]"}, | |
254 #endif | |
221 }; | 255 }; |
222 #undef B | 256 #undef B |
223 | 257 |
224 for (size_t i = 0; i < arraysize(cases); ++i) { | 258 for (size_t i = 0; i < arraysize(cases); ++i) { |
225 // Generate reference string by prepending formatted bytes. | 259 // Generate reference string by prepending formatted bytes. |
226 std::stringstream expected_ss; | 260 std::stringstream expected_ss; |
227 std::ios default_format(nullptr); | 261 std::ios default_format(nullptr); |
228 default_format.copyfmt(expected_ss); | 262 default_format.copyfmt(expected_ss); |
229 // Match format of Bytecodes::Decode() for byte representations. | 263 // Match format of Bytecodes::Decode() for byte representations. |
230 expected_ss.fill('0'); | 264 expected_ss.fill('0'); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); | 345 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); |
312 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); | 346 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); |
313 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); | 347 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); |
314 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); | 348 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); |
315 CHECK_EQ(names.size(), 4); | 349 CHECK_EQ(names.size(), 4); |
316 } | 350 } |
317 | 351 |
318 } // namespace interpreter | 352 } // namespace interpreter |
319 } // namespace internal | 353 } // namespace internal |
320 } // namespace v8 | 354 } // namespace v8 |
OLD | NEW |