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

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

Issue 1370893002: [Interpreter] Add support for short (16 bit) operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 2 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
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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
(...skipping 19 matching lines...) Expand all
30 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718); 30 Handle<HeapObject> heap_num_0 = factory->NewHeapNumber(2.718);
31 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647); 31 Handle<HeapObject> heap_num_1 = factory->NewHeapNumber(2147483647);
32 Smi* zero = Smi::FromInt(0); 32 Smi* zero = Smi::FromInt(0);
33 Smi* smi_0 = Smi::FromInt(64); 33 Smi* smi_0 = Smi::FromInt(64);
34 Smi* smi_1 = Smi::FromInt(-65536); 34 Smi* smi_1 = Smi::FromInt(-65536);
35 Register reg_0(0); 35 Register reg_0(0);
36 Register reg_1(1); 36 Register reg_1(1);
37 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count()); 37 Register reg_2 = Register::FromParameterIndex(2, builder.parameter_count());
38 int feedback_slot = 97; 38 int feedback_slot = 97;
39 39
40 // TODO(rmcilroy): Add a test for a bytecode with a short operand when
41 // the CallRuntime bytecode is landed.
42
40 builder.LoadLiteral(heap_num_0) 43 builder.LoadLiteral(heap_num_0)
41 .LoadLiteral(heap_num_1) 44 .LoadLiteral(heap_num_1)
42 .LoadLiteral(zero) 45 .LoadLiteral(zero)
43 .LoadLiteral(smi_0) 46 .LoadLiteral(smi_0)
44 .LoadLiteral(smi_1) 47 .LoadLiteral(smi_1)
45 .LoadAccumulatorWithRegister(reg_0) 48 .LoadAccumulatorWithRegister(reg_0)
46 .LoadNamedProperty(reg_1, feedback_slot, LanguageMode::SLOPPY) 49 .LoadNamedProperty(reg_1, feedback_slot, LanguageMode::SLOPPY)
47 .StoreAccumulatorInRegister(reg_2) 50 .StoreAccumulatorInRegister(reg_2)
48 .Return(); 51 .Return();
49 52
50 // Test iterator sees the expected output from the builder. 53 // Test iterator sees the expected output from the builder.
51 BytecodeArrayIterator iterator(builder.ToBytecodeArray()); 54 BytecodeArrayIterator iterator(builder.ToBytecodeArray());
52 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); 55 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant);
53 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0)); 56 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_0));
54 CHECK(!iterator.done()); 57 CHECK(!iterator.done());
55 iterator.Advance(); 58 iterator.Advance();
56 59
57 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); 60 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant);
58 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1)); 61 CHECK(iterator.GetConstantForIndexOperand(0).is_identical_to(heap_num_1));
59 CHECK(!iterator.done()); 62 CHECK(!iterator.done());
60 iterator.Advance(); 63 iterator.Advance();
61 64
62 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaZero); 65 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaZero);
63 CHECK(!iterator.done()); 66 CHECK(!iterator.done());
64 iterator.Advance(); 67 iterator.Advance();
65 68
66 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi8); 69 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaSmi8);
67 CHECK_EQ(Smi::FromInt(iterator.GetSmi8Operand(0)), smi_0); 70 CHECK_EQ(Smi::FromInt(iterator.GetImmediateOperand(0)), smi_0);
68 CHECK(!iterator.done()); 71 CHECK(!iterator.done());
69 iterator.Advance(); 72 iterator.Advance();
70 73
71 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); 74 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant);
72 CHECK_EQ(*iterator.GetConstantForIndexOperand(0), smi_1); 75 CHECK_EQ(*iterator.GetConstantForIndexOperand(0), smi_1);
73 CHECK(!iterator.done()); 76 CHECK(!iterator.done());
74 iterator.Advance(); 77 iterator.Advance();
75 78
76 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdar); 79 CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdar);
77 CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index()); 80 CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_0.index());
(...skipping 13 matching lines...) Expand all
91 94
92 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); 95 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn);
93 CHECK(!iterator.done()); 96 CHECK(!iterator.done());
94 iterator.Advance(); 97 iterator.Advance();
95 CHECK(iterator.done()); 98 CHECK(iterator.done());
96 } 99 }
97 100
98 } // namespace interpreter 101 } // namespace interpreter
99 } // namespace internal 102 } // namespace internal
100 } // namespace v8 103 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/interpreter/bytecode-array-builder-unittest.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698