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

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

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/api.h" 7 #include "src/api.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/interpreter/bytecode-array-writer.h" 9 #include "src/interpreter/bytecode-array-writer.h"
10 #include "src/interpreter/bytecode-label.h" 10 #include "src/interpreter/bytecode-label.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 isolate(), 0, 0, factory()->empty_fixed_array()); 129 isolate(), 0, 0, factory()->empty_fixed_array());
130 CHECK_EQ(bytecodes()->size(), arraysize(bytes)); 130 CHECK_EQ(bytecodes()->size(), arraysize(bytes));
131 131
132 PositionTableEntry expected_positions[] = { 132 PositionTableEntry expected_positions[] = {
133 {0, 10, false}, {1, 55, true}, {7, 70, true}}; 133 {0, 10, false}, {1, 55, true}, {7, 70, true}};
134 SourcePositionTableIterator source_iterator( 134 SourcePositionTableIterator source_iterator(
135 bytecode_array->source_position_table()); 135 bytecode_array->source_position_table());
136 for (size_t i = 0; i < arraysize(expected_positions); ++i) { 136 for (size_t i = 0; i < arraysize(expected_positions); ++i) {
137 const PositionTableEntry& expected = expected_positions[i]; 137 const PositionTableEntry& expected = expected_positions[i];
138 CHECK_EQ(source_iterator.code_offset(), expected.code_offset); 138 CHECK_EQ(source_iterator.code_offset(), expected.code_offset);
139 CHECK_EQ(source_iterator.source_position(), expected.source_position); 139 CHECK_EQ(source_iterator.source_position().ScriptOffset(),
140 expected.source_position);
140 CHECK_EQ(source_iterator.is_statement(), expected.is_statement); 141 CHECK_EQ(source_iterator.is_statement(), expected.is_statement);
141 source_iterator.Advance(); 142 source_iterator.Advance();
142 } 143 }
143 CHECK(source_iterator.done()); 144 CHECK(source_iterator.done());
144 } 145 }
145 146
146 TEST_F(BytecodeArrayWriterUnittest, ComplexExample) { 147 TEST_F(BytecodeArrayWriterUnittest, ComplexExample) {
147 static const uint8_t expected_bytes[] = { 148 static const uint8_t expected_bytes[] = {
148 // clang-format off 149 // clang-format off
149 /* 0 30 E> */ B(StackCheck), 150 /* 0 30 E> */ B(StackCheck),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 static_cast<int>(expected_bytes[i])); 216 static_cast<int>(expected_bytes[i]));
216 } 217 }
217 218
218 Handle<BytecodeArray> bytecode_array = writer()->ToBytecodeArray( 219 Handle<BytecodeArray> bytecode_array = writer()->ToBytecodeArray(
219 isolate(), 0, 0, factory()->empty_fixed_array()); 220 isolate(), 0, 0, factory()->empty_fixed_array());
220 SourcePositionTableIterator source_iterator( 221 SourcePositionTableIterator source_iterator(
221 bytecode_array->source_position_table()); 222 bytecode_array->source_position_table());
222 for (size_t i = 0; i < arraysize(expected_positions); ++i) { 223 for (size_t i = 0; i < arraysize(expected_positions); ++i) {
223 const PositionTableEntry& expected = expected_positions[i]; 224 const PositionTableEntry& expected = expected_positions[i];
224 CHECK_EQ(source_iterator.code_offset(), expected.code_offset); 225 CHECK_EQ(source_iterator.code_offset(), expected.code_offset);
225 CHECK_EQ(source_iterator.source_position(), expected.source_position); 226 CHECK_EQ(source_iterator.source_position().ScriptOffset(),
227 expected.source_position);
226 CHECK_EQ(source_iterator.is_statement(), expected.is_statement); 228 CHECK_EQ(source_iterator.is_statement(), expected.is_statement);
227 source_iterator.Advance(); 229 source_iterator.Advance();
228 } 230 }
229 CHECK(source_iterator.done()); 231 CHECK(source_iterator.done());
230 } 232 }
231 233
232 } // namespace interpreter 234 } // namespace interpreter
233 } // namespace internal 235 } // namespace internal
234 } // namespace v8 236 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698