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

Side by Side Diff: test/unittests/interpreter/bytecode-array-builder-unittest.cc

Issue 1555713002: [Interpreter] Bytecodes for exchanging registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/interpreter/bytecode-array-builder.h" 7 #include "src/interpreter/bytecode-array-builder.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "test/unittests/test-utils.h" 9 #include "test/unittests/test-utils.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace interpreter { 13 namespace interpreter {
14 14
15 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone { 15 class BytecodeArrayBuilderTest : public TestWithIsolateAndZone {
16 public: 16 public:
17 BytecodeArrayBuilderTest() {} 17 BytecodeArrayBuilderTest() {}
18 ~BytecodeArrayBuilderTest() override {} 18 ~BytecodeArrayBuilderTest() override {}
19 }; 19 };
20 20
21 21
22 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { 22 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
23 BytecodeArrayBuilder builder(isolate(), zone()); 23 BytecodeArrayBuilder builder(isolate(), zone());
24 24
25 builder.set_locals_count(2); 25 builder.set_locals_count(200);
26 builder.set_context_count(1); 26 builder.set_context_count(1);
27 builder.set_parameter_count(0); 27 builder.set_parameter_count(0);
28 CHECK_EQ(builder.locals_count(), 2); 28 CHECK_EQ(builder.locals_count(), 200);
29 CHECK_EQ(builder.context_count(), 1); 29 CHECK_EQ(builder.context_count(), 1);
30 CHECK_EQ(builder.fixed_register_count(), 3); 30 CHECK_EQ(builder.fixed_register_count(), 201);
31 31
32 // Emit constant loads. 32 // Emit constant loads.
33 builder.LoadLiteral(Smi::FromInt(0)) 33 builder.LoadLiteral(Smi::FromInt(0))
34 .LoadLiteral(Smi::FromInt(8)) 34 .LoadLiteral(Smi::FromInt(8))
35 .LoadLiteral(Smi::FromInt(10000000)) 35 .LoadLiteral(Smi::FromInt(10000000))
36 .LoadUndefined() 36 .LoadUndefined()
37 .LoadNull() 37 .LoadNull()
38 .LoadTheHole() 38 .LoadTheHole()
39 .LoadTrue() 39 .LoadTrue()
40 .LoadFalse(); 40 .LoadFalse();
41 41
42 // Emit accumulator transfers. Stores followed by loads to the same register 42 // Emit accumulator transfers. Stores followed by loads to the same register
43 // are not generated. Hence, a dummy instruction in between. 43 // are not generated. Hence, a dummy instruction in between.
44 Register reg(0); 44 Register reg(0);
45 builder.LoadAccumulatorWithRegister(reg) 45 builder.LoadAccumulatorWithRegister(reg)
46 .LoadNull() 46 .LoadNull()
47 .StoreAccumulatorInRegister(reg); 47 .StoreAccumulatorInRegister(reg);
48 48
49 // Emit register-register transfer. 49 // Emit register-register transfer.
50 Register other(1); 50 Register other(1);
51 builder.MoveRegister(reg, other); 51 builder.MoveRegister(reg, other);
52 52
53 // Emit register-register exchanges.
54 Register wide(150);
55 builder.ExchangeRegisters(reg, wide);
56 builder.ExchangeRegisters(wide, reg);
57 Register wider(151);
58 builder.ExchangeRegisters(wide, wider);
59
53 // Emit global load / store operations. 60 // Emit global load / store operations.
54 Factory* factory = isolate()->factory(); 61 Factory* factory = isolate()->factory();
55 Handle<String> name = factory->NewStringFromStaticChars("var_name"); 62 Handle<String> name = factory->NewStringFromStaticChars("var_name");
56 builder.LoadGlobal(name, 1, LanguageMode::SLOPPY, 63 builder.LoadGlobal(name, 1, LanguageMode::SLOPPY,
57 TypeofMode::NOT_INSIDE_TYPEOF) 64 TypeofMode::NOT_INSIDE_TYPEOF)
58 .LoadGlobal(name, 1, LanguageMode::STRICT, TypeofMode::NOT_INSIDE_TYPEOF) 65 .LoadGlobal(name, 1, LanguageMode::STRICT, TypeofMode::NOT_INSIDE_TYPEOF)
59 .LoadGlobal(name, 1, LanguageMode::SLOPPY, TypeofMode::INSIDE_TYPEOF) 66 .LoadGlobal(name, 1, LanguageMode::SLOPPY, TypeofMode::INSIDE_TYPEOF)
60 .LoadGlobal(name, 1, LanguageMode::STRICT, TypeofMode::INSIDE_TYPEOF) 67 .LoadGlobal(name, 1, LanguageMode::STRICT, TypeofMode::INSIDE_TYPEOF)
61 .StoreGlobal(name, 1, LanguageMode::SLOPPY) 68 .StoreGlobal(name, 1, LanguageMode::SLOPPY)
62 .StoreGlobal(name, 1, LanguageMode::STRICT); 69 .StoreGlobal(name, 1, LanguageMode::STRICT);
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 iterator.Advance(); 681 iterator.Advance();
675 } 682 }
676 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 683 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
677 iterator.Advance(); 684 iterator.Advance();
678 CHECK(iterator.done()); 685 CHECK(iterator.done());
679 } 686 }
680 687
681 } // namespace interpreter 688 } // namespace interpreter
682 } // namespace internal 689 } // namespace internal
683 } // namespace v8 690 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/interpreter-assembler-unittest.cc ('k') | test/unittests/interpreter/bytecodes-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698