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

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

Issue 1412683011: [Interpreter] Enable assignments in expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Sync test bytecode sequences to avoid unnecessary Ldar/Star instructions. Created 5 years, 1 month 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
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(1); 25 builder.set_locals_count(2);
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(), 1); 28 CHECK_EQ(builder.locals_count(), 2);
29 CHECK_EQ(builder.context_count(), 1); 29 CHECK_EQ(builder.context_count(), 1);
30 CHECK_EQ(builder.fixed_register_count(), 2); 30 CHECK_EQ(builder.fixed_register_count(), 3);
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.
50 Register other(1);
51 builder.MoveRegister(reg, other);
52
49 // Emit global load / store operations. 53 // Emit global load / store operations.
50 builder.LoadGlobal(0, 1, LanguageMode::SLOPPY, TypeofMode::NOT_INSIDE_TYPEOF) 54 builder.LoadGlobal(0, 1, LanguageMode::SLOPPY, TypeofMode::NOT_INSIDE_TYPEOF)
51 .LoadGlobal(0, 1, LanguageMode::STRICT, TypeofMode::NOT_INSIDE_TYPEOF) 55 .LoadGlobal(0, 1, LanguageMode::STRICT, TypeofMode::NOT_INSIDE_TYPEOF)
52 .LoadGlobal(0, 1, LanguageMode::SLOPPY, TypeofMode::INSIDE_TYPEOF) 56 .LoadGlobal(0, 1, LanguageMode::SLOPPY, TypeofMode::INSIDE_TYPEOF)
53 .LoadGlobal(0, 1, LanguageMode::STRICT, TypeofMode::INSIDE_TYPEOF) 57 .LoadGlobal(0, 1, LanguageMode::STRICT, TypeofMode::INSIDE_TYPEOF)
54 .StoreGlobal(0, 1, LanguageMode::SLOPPY) 58 .StoreGlobal(0, 1, LanguageMode::SLOPPY)
55 .StoreGlobal(0, 1, LanguageMode::STRICT); 59 .StoreGlobal(0, 1, LanguageMode::STRICT);
56 60
57 // Emit wide global load / store operations. 61 // Emit wide global load / store operations.
58 builder.LoadGlobal(0, 1024, LanguageMode::SLOPPY, 62 builder.LoadGlobal(0, 1024, LanguageMode::SLOPPY,
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 706
703 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 707 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
704 iterator.Advance(); 708 iterator.Advance();
705 CHECK(iterator.done()); 709 CHECK(iterator.done());
706 } 710 }
707 711
708 712
709 } // namespace interpreter 713 } // namespace interpreter
710 } // namespace internal 714 } // namespace internal
711 } // namespace v8 715 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698