node/deps/v8/test/unittests/interpreter/bytecodes-unittest.cc
Ali Ijaz Sheikh 8a43a3d761 deps: upgrade V8 to 4.7.80.24
Pick up the latest branch head for V8 4.7:
be169f8df0

Full change history for the 4.7 branch:
https://chromium.googlesource.com/v8/v8.git/+log/branch-heads/4.7

V8 blog post about what is new on V8 4.7:
http://v8project.blogspot.de/2015/10/v8-release-47.html

PR-URL: https://github.com/nodejs/node/pull/4106
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: rvagg - Rod Vagg <rod@vagg.org>
2015-12-04 00:06:01 -08:00

64 lines
1.7 KiB
C++

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "src/v8.h"
#include "src/interpreter/bytecodes.h"
#include "test/unittests/test-utils.h"
namespace v8 {
namespace internal {
namespace interpreter {
TEST(OperandConversion, Registers) {
for (int i = 0; i < 128; i++) {
uint8_t operand_value = Register(i).ToOperand();
Register r = Register::FromOperand(operand_value);
CHECK_EQ(i, r.index());
}
}
TEST(OperandConversion, Parameters) {
int parameter_counts[] = {7, 13, 99};
size_t count = sizeof(parameter_counts) / sizeof(parameter_counts[0]);
for (size_t p = 0; p < count; p++) {
int parameter_count = parameter_counts[p];
for (int i = 0; i < parameter_count; i++) {
Register r = Register::FromParameterIndex(i, parameter_count);
uint8_t operand_value = r.ToOperand();
Register s = Register::FromOperand(operand_value);
CHECK_EQ(i, s.ToParameterIndex(parameter_count));
}
}
}
TEST(OperandConversion, RegistersParametersNoOverlap) {
std::vector<uint8_t> operand_count(256);
for (int i = 0; i <= Register::kMaxRegisterIndex; i++) {
Register r = Register(i);
uint8_t operand = r.ToOperand();
operand_count[operand] += 1;
CHECK_EQ(operand_count[operand], 1);
}
int parameter_count = Register::MaxParameterIndex() + 1;
for (int i = 0; i < parameter_count; i++) {
Register r = Register::FromParameterIndex(i, parameter_count);
uint8_t operand = r.ToOperand();
operand_count[operand] += 1;
CHECK_EQ(operand_count[operand], 1);
}
}
} // namespace interpreter
} // namespace internal
} // namespace v8