| 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Load Splay tree and CodeMap implementations from <project root>/tools. | 28 // Load Splay tree and CodeMap implementations from <project root>/tools. |
| 29 // Files: tools/splaytree.js tools/codemap.js | 29 // Files: tools/splaytree.js tools/codemap.js |
| 30 | 30 |
| 31 | 31 |
| 32 function newCodeEntry(size, name) { | 32 function newCodeEntry(size, name) { |
| 33 return new CodeMap.CodeEntry(size, name); | 33 return new CodeMap.CodeEntry(size, name); |
| 34 }; | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 function assertEntry(codeMap, expected_name, addr) { | 37 function assertEntry(codeMap, expected_name, addr) { |
| 38 var entry = codeMap.findEntry(addr); | 38 var entry = codeMap.findEntry(addr); |
| 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 testLibrariesAndStaticCode() { | 49 (function testLibrariesAndStaticCode() { |
| 50 var codeMap = new CodeMap(); | 50 var codeMap = new CodeMap(); |
| 51 codeMap.addLibrary(0x1500, newCodeEntry(0x3000, 'lib1')); | 51 codeMap.addLibrary(0x1500, newCodeEntry(0x3000, 'lib1')); |
| 52 codeMap.addLibrary(0x15500, newCodeEntry(0x5000, 'lib2')); | 52 codeMap.addLibrary(0x15500, newCodeEntry(0x5000, 'lib2')); |
| 53 codeMap.addLibrary(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); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 assertEquals(['code1: 200', 'code2: 100', 'code3: 50'], allDynamics); | 174 assertEquals(['code1: 200', 'code2: 100', 'code3: 50'], allDynamics); |
| 175 codeMap.deleteCode(0x1700); | 175 codeMap.deleteCode(0x1700); |
| 176 var allDynamics2 = codeMap.getAllDynamicEntries(); | 176 var allDynamics2 = codeMap.getAllDynamicEntries(); |
| 177 allDynamics2 = allDynamics2.map(String); | 177 allDynamics2 = allDynamics2.map(String); |
| 178 allDynamics2.sort(); | 178 allDynamics2.sort(); |
| 179 assertEquals(['code1: 200', 'code3: 50'], allDynamics2); | 179 assertEquals(['code1: 200', 'code3: 50'], allDynamics2); |
| 180 codeMap.deleteCode(0x1500); | 180 codeMap.deleteCode(0x1500); |
| 181 var allDynamics3 = codeMap.getAllDynamicEntries(); | 181 var allDynamics3 = codeMap.getAllDynamicEntries(); |
| 182 assertEquals(['code3: 50'], allDynamics3.map(String)); | 182 assertEquals(['code3: 50'], allDynamics3.map(String)); |
| 183 })(); | 183 })(); |
| OLD | NEW |