Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: test/unittests/interpreter/bytecode-register-allocator-unittest.cc

Issue 1587033002: [Interpreter] Ensure we always have an outer register allocation scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_mythri
Patch Set: Similarity 20 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/interpreter/bytecode-register-allocator-unittest.cc
diff --git a/test/unittests/interpreter/bytecode-register-allocator-unittest.cc b/test/unittests/interpreter/bytecode-register-allocator-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..062032216295d132df24e6e91a7bc03463414640
--- /dev/null
+++ b/test/unittests/interpreter/bytecode-register-allocator-unittest.cc
@@ -0,0 +1,67 @@
+// Copyright 2014 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 "src/v8.h"
+
+#include "src/interpreter/bytecode-array-builder.h"
+#include "src/interpreter/bytecode-register-allocator.h"
+#include "test/unittests/test-utils.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+class BytecodeRegisterAllocatorTest : public TestWithIsolateAndZone {
+ public:
+ BytecodeRegisterAllocatorTest() {}
+ ~BytecodeRegisterAllocatorTest() override {}
+};
+
+
+TEST_F(BytecodeRegisterAllocatorTest, TemporariesRecycled) {
+ BytecodeArrayBuilder builder(isolate(), zone());
+ builder.set_parameter_count(0);
+ builder.set_locals_count(0);
+ builder.set_context_count(0);
+
+ int first;
+ {
+ BytecodeRegisterAllocator temporaries(&builder);
+ first = temporaries.NewRegister().index();
+ temporaries.NewRegister();
+ temporaries.NewRegister();
+ temporaries.NewRegister();
+ }
+
+ int second;
+ {
+ BytecodeRegisterAllocator temporaries(&builder);
+ second = temporaries.NewRegister().index();
+ }
+
+ CHECK_EQ(first, second);
+}
+
+
+TEST_F(BytecodeRegisterAllocatorTest, ConsecutiveRegisters) {
+ BytecodeArrayBuilder builder(isolate(), zone());
+ builder.set_parameter_count(0);
+ builder.set_locals_count(0);
+ builder.set_context_count(0);
+
+ BytecodeRegisterAllocator temporaries(&builder);
+ temporaries.PrepareForConsecutiveAllocations(4);
+ Register reg0 = temporaries.NextConsecutiveRegister();
+ Register other = temporaries.NewRegister();
+ Register reg1 = temporaries.NextConsecutiveRegister();
+ Register reg2 = temporaries.NextConsecutiveRegister();
+ Register reg3 = temporaries.NextConsecutiveRegister();
+ USE(other);
+
+ CHECK(Register::AreContiguous(reg0, reg1, reg2, reg3));
+}
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698