Reviewers: rmcilroy,
Message:
Ross, PTAL, thanks!
Description:
[Interpreter] Register conversion fix and test.
BUG=v8:4280
LOG=N
Please review this at https://codereview.chromium.org/1294523002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -1 lines):
M src/interpreter/bytecode-array-builder.h
M test/unittests/interpreter/bytecode-array-builder-unittest.cc
Index: src/interpreter/bytecode-array-builder.h
diff --git a/src/interpreter/bytecode-array-builder.h
b/src/interpreter/bytecode-array-builder.h
index
70b881596419c1f6e1f850e7e88a7120c75e3648..c4ab816665800393986f0edcc565af3b7a51b0a9
100644
--- a/src/interpreter/bytecode-array-builder.h
+++ b/src/interpreter/bytecode-array-builder.h
@@ -84,7 +84,9 @@ class Register {
int index() { return index_; }
uint8_t ToOperand() { return static_cast<uint8_t>(-index_); }
- static Register FromOperand(uint8_t operand) { return
Register(-operand); }
+ static Register FromOperand(uint8_t operand) {
+ return Register(-static_cast<int8_t>(operand));
+ }
private:
void* operator new(size_t size);
Index: test/unittests/interpreter/bytecode-array-builder-unittest.cc
diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc
b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
index
ac46ec0ec7ea65b31876800f862f862d93a877f8..aead34770c6516c1d98bc2fc2fd51d3e71b2dfc2
100644
--- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc
+++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc
@@ -117,6 +117,21 @@ TEST_F(BytecodeArrayBuilderTest, TemporariesRecycled) {
CHECK_EQ(first, second);
}
+
+TEST_F(BytecodeArrayBuilderTest, RegisterValues) {
+ int index = 1;
+ uint8_t operand = static_cast<uint8_t>(-index);
+
+ Register the_register(index);
+ CHECK_EQ(the_register.index(), index);
+
+ int actual_operand = the_register.ToOperand();
+ CHECK_EQ(actual_operand, operand);
+
+ int actual_index = Register::FromOperand(actual_operand).index();
+ CHECK_EQ(actual_index, index);
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.