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

Side by Side Diff: test/mjsunit/tools/codemap.js

Issue 67191: Reimplement (address -> code) mapping from tickprocessor.py in JS. (Closed)
Patch Set: Added a comment to deleted_ member Created 11 years, 8 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/mjsunit/mjsunit.js ('k') | tools/codemap.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Load Splay tree and CodeMap implementations from <project root>/tools.
29 // Files: tools/splaytree.js tools/codemap.js
30
31
32 function newCodeEntry(size, name) {
33 return new devtools.profiler.CodeMap.CodeEntry(size, name);
34 };
35
36
37 function assertEntry(codeMap, expected_name, addr) {
38 var entry = codeMap.findEntry(addr);
39 assertNotNull(entry, 'no entry at ' + addr.toString(16));
40 assertEquals(expected_name, entry.name, 'at ' + addr.toString(16));
41 };
42
43
44 function assertNoEntry(codeMap, addr) {
45 assertNull(codeMap.findEntry(addr), 'at ' + addr.toString(16));
46 };
47
48
49 (function testStaticCode() {
50 var codeMap = new devtools.profiler.CodeMap();
51 codeMap.addStaticCode(0x1500, newCodeEntry(0x3000, 'lib1'));
52 codeMap.addStaticCode(0x15500, newCodeEntry(0x5000, 'lib2'));
53 codeMap.addStaticCode(0x155500, newCodeEntry(0x10000, 'lib3'));
54 assertNoEntry(codeMap, 0);
55 assertNoEntry(codeMap, 0x1500 - 1);
56 assertEntry(codeMap, 'lib1', 0x1500);
57 assertEntry(codeMap, 'lib1', 0x1500 + 0x100);
58 assertEntry(codeMap, 'lib1', 0x1500 + 0x1000);
59 assertEntry(codeMap, 'lib1', 0x1500 + 0x3000 - 1);
60 assertNoEntry(codeMap, 0x1500 + 0x3000);
61 assertNoEntry(codeMap, 0x15500 - 1);
62 assertEntry(codeMap, 'lib2', 0x15500);
63 assertEntry(codeMap, 'lib2', 0x15500 + 0x100);
64 assertEntry(codeMap, 'lib2', 0x15500 + 0x1000);
65 assertEntry(codeMap, 'lib2', 0x15500 + 0x5000 - 1);
66 assertNoEntry(codeMap, 0x15500 + 0x5000);
67 assertNoEntry(codeMap, 0x155500 - 1);
68 assertEntry(codeMap, 'lib3', 0x155500);
69 assertEntry(codeMap, 'lib3', 0x155500 + 0x100);
70 assertEntry(codeMap, 'lib3', 0x155500 + 0x1000);
71 assertEntry(codeMap, 'lib3', 0x155500 + 0x10000 - 1);
72 assertNoEntry(codeMap, 0x155500 + 0x10000);
73 assertNoEntry(codeMap, 0xFFFFFFFF);
74 })();
75
76
77 (function testDynamicCode() {
78 var codeMap = new devtools.profiler.CodeMap();
79 codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
80 codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
81 codeMap.addCode(0x1900, newCodeEntry(0x50, 'code3'));
82 codeMap.addCode(0x1950, newCodeEntry(0x10, 'code4'));
83 assertNoEntry(codeMap, 0);
84 assertNoEntry(codeMap, 0x1500 - 1);
85 assertEntry(codeMap, 'code1', 0x1500);
86 assertEntry(codeMap, 'code1', 0x1500 + 0x100);
87 assertEntry(codeMap, 'code1', 0x1500 + 0x200 - 1);
88 assertEntry(codeMap, 'code2', 0x1700);
89 assertEntry(codeMap, 'code2', 0x1700 + 0x50);
90 assertEntry(codeMap, 'code2', 0x1700 + 0x100 - 1);
91 assertNoEntry(codeMap, 0x1700 + 0x100);
92 assertNoEntry(codeMap, 0x1900 - 1);
93 assertEntry(codeMap, 'code3', 0x1900);
94 assertEntry(codeMap, 'code3', 0x1900 + 0x28);
95 assertEntry(codeMap, 'code4', 0x1950);
96 assertEntry(codeMap, 'code4', 0x1950 + 0x7);
97 assertEntry(codeMap, 'code4', 0x1950 + 0x10 - 1);
98 assertNoEntry(codeMap, 0x1950 + 0x10);
99 assertNoEntry(codeMap, 0xFFFFFFFF);
100 })();
101
102
103 (function testCodeMovesAndDeletions() {
104 var codeMap = new devtools.profiler.CodeMap();
105 codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1'));
106 codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2'));
107 assertEntry(codeMap, 'code1', 0x1500);
108 assertEntry(codeMap, 'code2', 0x1700);
109 codeMap.moveCode(0x1500, 0x1800);
110 assertNoEntry(codeMap, 0x1500);
111 assertEntry(codeMap, 'code2', 0x1700);
112 assertEntry(codeMap, 'code1', 0x1800);
113 codeMap.deleteCode(0x1700);
114 assertNoEntry(codeMap, 0x1700);
115 assertEntry(codeMap, 'code1', 0x1800);
116 })();
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.js ('k') | tools/codemap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698