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/interpreter/bytecode-utils.h" | 10 #include "test/unittests/interpreter/bytecode-utils.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 247 } |
248 | 248 |
249 TEST(Bytecodes, PrefixMappings) { | 249 TEST(Bytecodes, PrefixMappings) { |
250 Bytecode prefixes[] = {Bytecode::kWide, Bytecode::kExtraWide}; | 250 Bytecode prefixes[] = {Bytecode::kWide, Bytecode::kExtraWide}; |
251 TRACED_FOREACH(Bytecode, prefix, prefixes) { | 251 TRACED_FOREACH(Bytecode, prefix, prefixes) { |
252 CHECK_EQ(prefix, Bytecodes::OperandScaleToPrefixBytecode( | 252 CHECK_EQ(prefix, Bytecodes::OperandScaleToPrefixBytecode( |
253 Bytecodes::PrefixBytecodeToOperandScale(prefix))); | 253 Bytecodes::PrefixBytecodeToOperandScale(prefix))); |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
257 TEST(Bytecodes, OperandScales) { | |
258 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kByte), | |
259 OperandScale::kSingle); | |
260 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kShort), | |
261 OperandScale::kDouble); | |
262 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kQuad), | |
263 OperandScale::kQuadruple); | |
264 CHECK_EQ( | |
265 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
266 OperandSize::kShort, OperandSize::kShort), | |
267 OperandScale::kDouble); | |
268 CHECK_EQ( | |
269 Bytecodes::OperandSizesToScale(OperandSize::kQuad, OperandSize::kShort, | |
270 OperandSize::kShort, OperandSize::kShort), | |
271 OperandScale::kQuadruple); | |
272 CHECK_EQ( | |
273 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kQuad, | |
274 OperandSize::kShort, OperandSize::kShort), | |
275 OperandScale::kQuadruple); | |
276 CHECK_EQ( | |
277 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
278 OperandSize::kQuad, OperandSize::kShort), | |
279 OperandScale::kQuadruple); | |
280 CHECK_EQ( | |
281 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
282 OperandSize::kShort, OperandSize::kQuad), | |
283 OperandScale::kQuadruple); | |
284 } | |
285 | |
286 TEST(Bytecodes, SizesForSignedOperands) { | 257 TEST(Bytecodes, SizesForSignedOperands) { |
287 CHECK(Bytecodes::SizeForSignedOperand(0) == OperandSize::kByte); | 258 CHECK(Bytecodes::SizeForSignedOperand(0) == OperandSize::kByte); |
288 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt8) == OperandSize::kByte); | 259 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt8) == OperandSize::kByte); |
289 CHECK(Bytecodes::SizeForSignedOperand(kMinInt8) == OperandSize::kByte); | 260 CHECK(Bytecodes::SizeForSignedOperand(kMinInt8) == OperandSize::kByte); |
290 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt8 + 1) == OperandSize::kShort); | 261 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt8 + 1) == OperandSize::kShort); |
291 CHECK(Bytecodes::SizeForSignedOperand(kMinInt8 - 1) == OperandSize::kShort); | 262 CHECK(Bytecodes::SizeForSignedOperand(kMinInt8 - 1) == OperandSize::kShort); |
292 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt16) == OperandSize::kShort); | 263 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt16) == OperandSize::kShort); |
293 CHECK(Bytecodes::SizeForSignedOperand(kMinInt16) == OperandSize::kShort); | 264 CHECK(Bytecodes::SizeForSignedOperand(kMinInt16) == OperandSize::kShort); |
294 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt16 + 1) == OperandSize::kQuad); | 265 CHECK(Bytecodes::SizeForSignedOperand(kMaxInt16 + 1) == OperandSize::kQuad); |
295 CHECK(Bytecodes::SizeForSignedOperand(kMinInt16 - 1) == OperandSize::kQuad); | 266 CHECK(Bytecodes::SizeForSignedOperand(kMinInt16 - 1) == OperandSize::kQuad); |
(...skipping 29 matching lines...) Expand all Loading... |
325 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); | 296 CHECK(!Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kSingle)); |
326 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); | 297 CHECK(Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kDouble)); |
327 CHECK( | 298 CHECK( |
328 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); | 299 Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale::kQuadruple)); |
329 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == | 300 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kDouble) == |
330 Bytecode::kWide); | 301 Bytecode::kWide); |
331 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == | 302 CHECK(Bytecodes::OperandScaleToPrefixBytecode(OperandScale::kQuadruple) == |
332 Bytecode::kExtraWide); | 303 Bytecode::kExtraWide); |
333 } | 304 } |
334 | 305 |
335 TEST(Bytecodes, OperandSizesToScale) { | |
336 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kByte), | |
337 OperandScale::kSingle); | |
338 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kShort), | |
339 OperandScale::kDouble); | |
340 CHECK_EQ(Bytecodes::OperandSizesToScale(OperandSize::kQuad), | |
341 OperandScale::kQuadruple); | |
342 CHECK_EQ( | |
343 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
344 OperandSize::kShort, OperandSize::kShort), | |
345 OperandScale::kDouble); | |
346 CHECK_EQ( | |
347 Bytecodes::OperandSizesToScale(OperandSize::kQuad, OperandSize::kShort, | |
348 OperandSize::kShort, OperandSize::kShort), | |
349 OperandScale::kQuadruple); | |
350 CHECK_EQ( | |
351 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kQuad, | |
352 OperandSize::kShort, OperandSize::kShort), | |
353 OperandScale::kQuadruple); | |
354 CHECK_EQ( | |
355 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
356 OperandSize::kQuad, OperandSize::kShort), | |
357 OperandScale::kQuadruple); | |
358 CHECK_EQ( | |
359 Bytecodes::OperandSizesToScale(OperandSize::kShort, OperandSize::kShort, | |
360 OperandSize::kShort, OperandSize::kQuad), | |
361 OperandScale::kQuadruple); | |
362 } | |
363 | |
364 TEST(AccumulatorUse, LogicalOperators) { | 306 TEST(AccumulatorUse, LogicalOperators) { |
365 CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, | 307 CHECK_EQ(AccumulatorUse::kNone | AccumulatorUse::kRead, |
366 AccumulatorUse::kRead); | 308 AccumulatorUse::kRead); |
367 CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, | 309 CHECK_EQ(AccumulatorUse::kRead | AccumulatorUse::kWrite, |
368 AccumulatorUse::kReadWrite); | 310 AccumulatorUse::kReadWrite); |
369 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, | 311 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kReadWrite, |
370 AccumulatorUse::kRead); | 312 AccumulatorUse::kRead); |
371 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, | 313 CHECK_EQ(AccumulatorUse::kRead & AccumulatorUse::kWrite, |
372 AccumulatorUse::kNone); | 314 AccumulatorUse::kNone); |
373 } | 315 } |
(...skipping 17 matching lines...) Expand all Loading... |
391 std::set<std::string> names; | 333 std::set<std::string> names; |
392 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); | 334 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); |
393 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); | 335 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); |
394 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); | 336 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); |
395 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); | 337 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); |
396 CHECK_EQ(names.size(), 4); | 338 CHECK_EQ(names.size(), 4); |
397 } | 339 } |
398 } // namespace interpreter | 340 } // namespace interpreter |
399 } // namespace internal | 341 } // namespace internal |
400 } // namespace v8 | 342 } // namespace v8 |
OLD | NEW |