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 // [100, 200) |
| 2522 map.AddRange(ToAddress(100), 100, 1U); |
| 2523 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(50))); |
| 2524 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(100))); |
| 2525 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(150))); |
| 2526 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(100 + 100))); |
| 2527 CHECK_EQ(1, map.size()); |
| 2528 |
| 2529 // [100, 200), [200, 300) |
| 2530 map.AddRange(ToAddress(200), 100, 2U); |
| 2531 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(250))); |
| 2532 CHECK_EQ(2, map.size()); |
| 2533 |
| 2534 // [100, 150), [150, 250), [250, 300) |
| 2535 map.AddRange(ToAddress(150), 100, 3U); |
| 2536 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(149))); |
| 2537 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(250))); |
| 2538 CHECK_EQ(3, map.GetTraceNodeId(ToAddress(150))); |
| 2539 CHECK_EQ(3, map.size()); |
| 2540 |
| 2541 // [100, 150), [150, 250), [250, 300), [400, 500) |
| 2542 map.AddRange(ToAddress(400), 100, 4U); |
| 2543 CHECK_EQ(1, map.GetTraceNodeId(ToAddress(149))); |
| 2544 CHECK_EQ(2, map.GetTraceNodeId(ToAddress(250))); |
| 2545 CHECK_EQ(3, map.GetTraceNodeId(ToAddress(150))); |
| 2546 CHECK_EQ(4, map.GetTraceNodeId(ToAddress(450))); |
| 2547 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(500))); |
| 2548 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(350))); |
| 2549 CHECK_EQ(4, map.size()); |
| 2550 |
| 2551 // [100, 150), [150, 200), [200, 600) |
| 2552 map.AddRange(ToAddress(200), 400, 5U); |
| 2553 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(200))); |
| 2554 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(400))); |
| 2555 CHECK_EQ(3, map.size()); |
| 2556 |
| 2557 // [100, 150), [150, 200), [200, 600) |
| 2558 map.AddRange(ToAddress(150), 50, 6U); |
| 2559 map.AddRange(ToAddress(150), 50, 7U); |
| 2560 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(150))); |
| 2561 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(200))); |
| 2562 CHECK_EQ(3, map.size()); |
| 2563 |
| 2564 map.Clear(); |
| 2565 CHECK_EQ(0, map.size()); |
| 2566 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(400))); |
| 2567 } |
OLD | NEW |