OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); | 2499 const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); |
2500 const v8::HeapGraphNode* box_node = | 2500 const v8::HeapGraphNode* box_node = |
2501 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); | 2501 GetProperty(global_node, v8::HeapGraphEdge::kElement, "0"); |
2502 CHECK_NE(NULL, box_node); | 2502 CHECK_NE(NULL, box_node); |
2503 v8::String::Utf8Value box_node_name(box_node->GetName()); | 2503 v8::String::Utf8Value box_node_name(box_node->GetName()); |
2504 CHECK_EQ("system / Box", *box_node_name); | 2504 CHECK_EQ("system / Box", *box_node_name); |
2505 const v8::HeapGraphNode* box_value = | 2505 const v8::HeapGraphNode* box_value = |
2506 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); | 2506 GetProperty(box_node, v8::HeapGraphEdge::kInternal, "value"); |
2507 CHECK_NE(NULL, box_value); | 2507 CHECK_NE(NULL, box_value); |
2508 } | 2508 } |
| 2509 |
| 2510 |
| 2511 static inline i::Address ToAddress(int n) { |
| 2512 return reinterpret_cast<i::Address>(n); |
| 2513 } |
| 2514 |
| 2515 |
| 2516 TEST(AddressToTraceMap) { |
| 2517 i::AddressToTraceMap map; |
| 2518 |
| 2519 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(150))); |
| 2520 |
| 2521 // [0x100, 0x200) -> 1 |
| 2522 map.AddRange(ToAddress(0x100), 0x100, 1U); |
| 2523 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x50))); |
| 2524 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(0x100))); |
| 2525 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(0x150))); |
| 2526 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x100 + 0x100))); |
| 2527 CHECK_EQ(1, map.size()); |
| 2528 |
| 2529 // [0x100, 0x200) -> 1, [0x200, 0x300) -> 2 |
| 2530 map.AddRange(ToAddress(0x200), 0x100, 2U); |
| 2531 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(0x2a0))); |
| 2532 CHECK_EQ(2, map.size()); |
| 2533 |
| 2534 // [0x100, 0x180) -> 1, [0x180, 0x280) -> 3, [0x280, 0x300) -> 2 |
| 2535 map.AddRange(ToAddress(0x180), 0x100, 3U); |
| 2536 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(0x17F))); |
| 2537 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(0x280))); |
| 2538 CHECK_EQ(3, map.GetTraceNodeId(ToAddress(0x180))); |
| 2539 CHECK_EQ(3, map.size()); |
| 2540 |
| 2541 // [0x100, 0x180) -> 1, [0x180, 0x280) -> 3, [0x280, 0x300) -> 2, |
| 2542 // [0x400, 0x500) -> 4 |
| 2543 map.AddRange(ToAddress(0x400), 0x100, 4U); |
| 2544 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(0x17F))); |
| 2545 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(0x280))); |
| 2546 CHECK_EQ(3, map.GetTraceNodeId(ToAddress(0x180))); |
| 2547 CHECK_EQ(4, map.GetTraceNodeId(ToAddress(0x450))); |
| 2548 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x500))); |
| 2549 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x350))); |
| 2550 CHECK_EQ(4, map.size()); |
| 2551 |
| 2552 // [0x100, 0x180) -> 1, [0x180, 0x200) -> 3, [0x200, 0x600) -> 5 |
| 2553 map.AddRange(ToAddress(0x200), 0x400, 5U); |
| 2554 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
| 2555 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x400))); |
| 2556 CHECK_EQ(3, map.size()); |
| 2557 |
| 2558 // [0x100, 0x180) -> 1, [0x180, 0x200) -> 7, [0x200, 0x600) ->5 |
| 2559 map.AddRange(ToAddress(0x180), 0x80, 6U); |
| 2560 map.AddRange(ToAddress(0x180), 0x80, 7U); |
| 2561 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
| 2562 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
| 2563 CHECK_EQ(3, map.size()); |
| 2564 |
| 2565 map.Clear(); |
| 2566 CHECK_EQ(0, map.size()); |
| 2567 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
| 2568 } |
OLD | NEW |