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 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 2509 |
2510 | 2510 |
| 2511 TEST(WeakContainers) { |
| 2512 i::FLAG_allow_natives_syntax = true; |
| 2513 LocalContext env; |
| 2514 v8::HandleScope scope(env->GetIsolate()); |
| 2515 if (!CcTest::i_isolate()->use_crankshaft()) return; |
| 2516 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 2517 CompileRun( |
| 2518 "function foo(a) { return a.x; }\n" |
| 2519 "obj = {x : 123};\n" |
| 2520 "foo(obj);\n" |
| 2521 "foo(obj);\n" |
| 2522 "%OptimizeFunctionOnNextCall(foo);\n" |
| 2523 "foo(obj);\n"); |
| 2524 const v8::HeapSnapshot* snapshot = |
| 2525 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
| 2526 CHECK(ValidateSnapshot(snapshot)); |
| 2527 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
| 2528 const v8::HeapGraphNode* obj = |
| 2529 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj"); |
| 2530 CHECK_NE(NULL, obj); |
| 2531 const v8::HeapGraphNode* map = |
| 2532 GetProperty(obj, v8::HeapGraphEdge::kInternal, "map"); |
| 2533 CHECK_NE(NULL, map); |
| 2534 const v8::HeapGraphNode* dependent_code = |
| 2535 GetProperty(map, v8::HeapGraphEdge::kInternal, "dependent_code"); |
| 2536 if (!dependent_code) return; |
| 2537 int count = dependent_code->GetChildrenCount(); |
| 2538 CHECK_NE(0, count); |
| 2539 for (int i = 0; i < count; ++i) { |
| 2540 const v8::HeapGraphEdge* prop = dependent_code->GetChild(i); |
| 2541 CHECK_EQ(v8::HeapGraphEdge::kWeak, prop->GetType()); |
| 2542 } |
| 2543 } |
| 2544 |
| 2545 |
2511 static inline i::Address ToAddress(int n) { | 2546 static inline i::Address ToAddress(int n) { |
2512 return reinterpret_cast<i::Address>(n); | 2547 return reinterpret_cast<i::Address>(n); |
2513 } | 2548 } |
2514 | 2549 |
2515 | 2550 |
2516 TEST(AddressToTraceMap) { | 2551 TEST(AddressToTraceMap) { |
2517 i::AddressToTraceMap map; | 2552 i::AddressToTraceMap map; |
2518 | 2553 |
2519 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(150))); | 2554 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(150))); |
2520 | 2555 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2559 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2594 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2560 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2595 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2561 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2596 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
2562 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2597 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
2563 CHECK_EQ(3, static_cast<int>(map.size())); | 2598 CHECK_EQ(3, static_cast<int>(map.size())); |
2564 | 2599 |
2565 map.Clear(); | 2600 map.Clear(); |
2566 CHECK_EQ(0, static_cast<int>(map.size())); | 2601 CHECK_EQ(0, static_cast<int>(map.size())); |
2567 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2602 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
2568 } | 2603 } |
OLD | NEW |