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

Side by Side Diff: test/unittests/interpreter/source-position-table-unittest.cc

Issue 2081703002: Use zig-zag encoding in the source position table. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 4 years, 6 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 | « src/interpreter/source-position-table.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 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/interpreter/source-position-table.h" 7 #include "src/interpreter/source-position-table.h"
8 #include "test/unittests/test-utils.h" 8 #include "test/unittests/test-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 SourcePositionTableBuilder builder(isolate(), zone()); 49 SourcePositionTableBuilder builder(isolate(), zone());
50 for (int i = 0; i < arraysize(offsets); i++) { 50 for (int i = 0; i < arraysize(offsets); i++) {
51 builder.AddPosition(offsets[i], offsets[i], false); 51 builder.AddPosition(offsets[i], offsets[i], false);
52 } 52 }
53 CHECK(!builder.ToSourcePositionTable().is_null()); 53 CHECK(!builder.ToSourcePositionTable().is_null());
54 } 54 }
55 55
56 TEST_F(SourcePositionTableTest, EncodeAscending) { 56 TEST_F(SourcePositionTableTest, EncodeAscending) {
57 SourcePositionTableBuilder builder(isolate(), zone()); 57 SourcePositionTableBuilder builder(isolate(), zone());
58 58
59 int accumulator = 0; 59 int code_offset = 0;
60 int source_position = 0;
60 for (int i = 0; i < arraysize(offsets); i++) { 61 for (int i = 0; i < arraysize(offsets); i++) {
61 accumulator += offsets[i]; 62 code_offset += offsets[i];
63 source_position += offsets[i];
62 if (i % 2) { 64 if (i % 2) {
63 builder.AddPosition(accumulator, accumulator, true); 65 builder.AddPosition(code_offset, source_position, true);
64 } else { 66 } else {
65 builder.AddPosition(accumulator, accumulator, false); 67 builder.AddPosition(code_offset, source_position, false);
66 } 68 }
67 } 69 }
68 70
69 // Also test negative offsets: 71 // Also test negative offsets for source positions:
70 for (int i = 0; i < arraysize(offsets); i++) { 72 for (int i = 0; i < arraysize(offsets); i++) {
71 accumulator -= offsets[i]; 73 code_offset += offsets[i];
74 source_position -= offsets[i];
72 if (i % 2) { 75 if (i % 2) {
73 builder.AddPosition(accumulator, accumulator, true); 76 builder.AddPosition(code_offset, source_position, true);
74 } else { 77 } else {
75 builder.AddPosition(accumulator, accumulator, false); 78 builder.AddPosition(code_offset, source_position, false);
76 } 79 }
77 } 80 }
78 81
79 CHECK(!builder.ToSourcePositionTable().is_null()); 82 CHECK(!builder.ToSourcePositionTable().is_null());
80 } 83 }
81 84
82 } // namespace interpreter 85 } // namespace interpreter
83 } // namespace internal 86 } // namespace internal
84 } // namespace v8 87 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/source-position-table.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698