OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 28 matching lines...) Expand all Loading... |
39 assertNotNull(entry, 'no entry at ' + addr.toString(16)); | 39 assertNotNull(entry, 'no entry at ' + addr.toString(16)); |
40 assertEquals(expected_name, entry.name, 'at ' + addr.toString(16)); | 40 assertEquals(expected_name, entry.name, 'at ' + addr.toString(16)); |
41 }; | 41 }; |
42 | 42 |
43 | 43 |
44 function assertNoEntry(codeMap, addr) { | 44 function assertNoEntry(codeMap, addr) { |
45 assertNull(codeMap.findEntry(addr), 'at ' + addr.toString(16)); | 45 assertNull(codeMap.findEntry(addr), 'at ' + addr.toString(16)); |
46 }; | 46 }; |
47 | 47 |
48 | 48 |
49 (function testStaticCode() { | 49 (function testLibrariesAndStaticCode() { |
50 var codeMap = new devtools.profiler.CodeMap(); | 50 var codeMap = new devtools.profiler.CodeMap(); |
51 codeMap.addStaticCode(0x1500, newCodeEntry(0x3000, 'lib1')); | 51 codeMap.addLibrary(0x1500, newCodeEntry(0x3000, 'lib1')); |
52 codeMap.addStaticCode(0x15500, newCodeEntry(0x5000, 'lib2')); | 52 codeMap.addLibrary(0x15500, newCodeEntry(0x5000, 'lib2')); |
53 codeMap.addStaticCode(0x155500, newCodeEntry(0x10000, 'lib3')); | 53 codeMap.addLibrary(0x155500, newCodeEntry(0x10000, 'lib3')); |
54 assertNoEntry(codeMap, 0); | 54 assertNoEntry(codeMap, 0); |
55 assertNoEntry(codeMap, 0x1500 - 1); | 55 assertNoEntry(codeMap, 0x1500 - 1); |
56 assertEntry(codeMap, 'lib1', 0x1500); | 56 assertEntry(codeMap, 'lib1', 0x1500); |
57 assertEntry(codeMap, 'lib1', 0x1500 + 0x100); | 57 assertEntry(codeMap, 'lib1', 0x1500 + 0x100); |
58 assertEntry(codeMap, 'lib1', 0x1500 + 0x1000); | 58 assertEntry(codeMap, 'lib1', 0x1500 + 0x1000); |
59 assertEntry(codeMap, 'lib1', 0x1500 + 0x3000 - 1); | 59 assertEntry(codeMap, 'lib1', 0x1500 + 0x3000 - 1); |
60 assertNoEntry(codeMap, 0x1500 + 0x3000); | 60 assertNoEntry(codeMap, 0x1500 + 0x3000); |
61 assertNoEntry(codeMap, 0x15500 - 1); | 61 assertNoEntry(codeMap, 0x15500 - 1); |
62 assertEntry(codeMap, 'lib2', 0x15500); | 62 assertEntry(codeMap, 'lib2', 0x15500); |
63 assertEntry(codeMap, 'lib2', 0x15500 + 0x100); | 63 assertEntry(codeMap, 'lib2', 0x15500 + 0x100); |
64 assertEntry(codeMap, 'lib2', 0x15500 + 0x1000); | 64 assertEntry(codeMap, 'lib2', 0x15500 + 0x1000); |
65 assertEntry(codeMap, 'lib2', 0x15500 + 0x5000 - 1); | 65 assertEntry(codeMap, 'lib2', 0x15500 + 0x5000 - 1); |
66 assertNoEntry(codeMap, 0x15500 + 0x5000); | 66 assertNoEntry(codeMap, 0x15500 + 0x5000); |
67 assertNoEntry(codeMap, 0x155500 - 1); | 67 assertNoEntry(codeMap, 0x155500 - 1); |
68 assertEntry(codeMap, 'lib3', 0x155500); | 68 assertEntry(codeMap, 'lib3', 0x155500); |
69 assertEntry(codeMap, 'lib3', 0x155500 + 0x100); | 69 assertEntry(codeMap, 'lib3', 0x155500 + 0x100); |
70 assertEntry(codeMap, 'lib3', 0x155500 + 0x1000); | 70 assertEntry(codeMap, 'lib3', 0x155500 + 0x1000); |
71 assertEntry(codeMap, 'lib3', 0x155500 + 0x10000 - 1); | 71 assertEntry(codeMap, 'lib3', 0x155500 + 0x10000 - 1); |
72 assertNoEntry(codeMap, 0x155500 + 0x10000); | 72 assertNoEntry(codeMap, 0x155500 + 0x10000); |
73 assertNoEntry(codeMap, 0xFFFFFFFF); | 73 assertNoEntry(codeMap, 0xFFFFFFFF); |
| 74 |
| 75 codeMap.addStaticCode(0x1510, newCodeEntry(0x30, 'lib1-f1')); |
| 76 codeMap.addStaticCode(0x1600, newCodeEntry(0x50, 'lib1-f2')); |
| 77 codeMap.addStaticCode(0x15520, newCodeEntry(0x100, 'lib2-f1')); |
| 78 assertEntry(codeMap, 'lib1', 0x1500); |
| 79 assertEntry(codeMap, 'lib1', 0x1510 - 1); |
| 80 assertEntry(codeMap, 'lib1-f1', 0x1510); |
| 81 assertEntry(codeMap, 'lib1-f1', 0x1510 + 0x15); |
| 82 assertEntry(codeMap, 'lib1-f1', 0x1510 + 0x30 - 1); |
| 83 assertEntry(codeMap, 'lib1', 0x1510 + 0x30); |
| 84 assertEntry(codeMap, 'lib1', 0x1600 - 1); |
| 85 assertEntry(codeMap, 'lib1-f2', 0x1600); |
| 86 assertEntry(codeMap, 'lib1-f2', 0x1600 + 0x30); |
| 87 assertEntry(codeMap, 'lib1-f2', 0x1600 + 0x50 - 1); |
| 88 assertEntry(codeMap, 'lib1', 0x1600 + 0x50); |
| 89 assertEntry(codeMap, 'lib2', 0x15500); |
| 90 assertEntry(codeMap, 'lib2', 0x15520 - 1); |
| 91 assertEntry(codeMap, 'lib2-f1', 0x15520); |
| 92 assertEntry(codeMap, 'lib2-f1', 0x15520 + 0x80); |
| 93 assertEntry(codeMap, 'lib2-f1', 0x15520 + 0x100 - 1); |
| 94 assertEntry(codeMap, 'lib2', 0x15520 + 0x100); |
| 95 |
74 })(); | 96 })(); |
75 | 97 |
76 | 98 |
77 (function testDynamicCode() { | 99 (function testDynamicCode() { |
78 var codeMap = new devtools.profiler.CodeMap(); | 100 var codeMap = new devtools.profiler.CodeMap(); |
79 codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1')); | 101 codeMap.addCode(0x1500, newCodeEntry(0x200, 'code1')); |
80 codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2')); | 102 codeMap.addCode(0x1700, newCodeEntry(0x100, 'code2')); |
81 codeMap.addCode(0x1900, newCodeEntry(0x50, 'code3')); | 103 codeMap.addCode(0x1900, newCodeEntry(0x50, 'code3')); |
82 codeMap.addCode(0x1950, newCodeEntry(0x10, 'code4')); | 104 codeMap.addCode(0x1950, newCodeEntry(0x10, 'code4')); |
83 assertNoEntry(codeMap, 0); | 105 assertNoEntry(codeMap, 0); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 allDynamics.sort(); | 171 allDynamics.sort(); |
150 assertEquals(['code1: 200', 'code2: 100', 'code3: 50'], allDynamics); | 172 assertEquals(['code1: 200', 'code2: 100', 'code3: 50'], allDynamics); |
151 codeMap.deleteCode(0x1700); | 173 codeMap.deleteCode(0x1700); |
152 var allDynamics2 = codeMap.getAllDynamicEntries(); | 174 var allDynamics2 = codeMap.getAllDynamicEntries(); |
153 allDynamics2.sort(); | 175 allDynamics2.sort(); |
154 assertEquals(['code1: 200', 'code3: 50'], allDynamics2); | 176 assertEquals(['code1: 200', 'code3: 50'], allDynamics2); |
155 codeMap.deleteCode(0x1500); | 177 codeMap.deleteCode(0x1500); |
156 var allDynamics3 = codeMap.getAllDynamicEntries(); | 178 var allDynamics3 = codeMap.getAllDynamicEntries(); |
157 assertEquals(['code3: 50'], allDynamics3); | 179 assertEquals(['code3: 50'], allDynamics3); |
158 })(); | 180 })(); |
OLD | NEW |