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 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 } | 1681 } |
1682 CHECK_EQ(1, count); | 1682 CHECK_EQ(1, count); |
1683 } | 1683 } |
1684 | 1684 |
1685 | 1685 |
1686 TEST(GetHeapValueForNode) { | 1686 TEST(GetHeapValueForNode) { |
1687 LocalContext env; | 1687 LocalContext env; |
1688 v8::HandleScope scope(env->GetIsolate()); | 1688 v8::HandleScope scope(env->GetIsolate()); |
1689 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1689 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1690 | 1690 |
1691 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };"); | 1691 CompileRun("a = { s_prop: \'value\', n_prop: \'value2\' };"); |
1692 const v8::HeapSnapshot* snapshot = | 1692 const v8::HeapSnapshot* snapshot = |
1693 heap_profiler->TakeHeapSnapshot(v8_str("value")); | 1693 heap_profiler->TakeHeapSnapshot(v8_str("value")); |
1694 CHECK(ValidateSnapshot(snapshot)); | 1694 CHECK(ValidateSnapshot(snapshot)); |
1695 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 1695 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); |
1696 CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject()); | 1696 CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject()); |
1697 v8::Local<v8::Object> js_global = | 1697 v8::Local<v8::Object> js_global = |
1698 env->Global()->GetPrototype().As<v8::Object>(); | 1698 env->Global()->GetPrototype().As<v8::Object>(); |
1699 CHECK(js_global == heap_profiler->FindObjectById(global->GetId())); | 1699 CHECK(js_global == heap_profiler->FindObjectById(global->GetId())); |
1700 const v8::HeapGraphNode* obj = GetProperty( | 1700 const v8::HeapGraphNode* obj = GetProperty( |
1701 global, v8::HeapGraphEdge::kProperty, "a"); | 1701 global, v8::HeapGraphEdge::kProperty, "a"); |
1702 CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject()); | 1702 CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject()); |
1703 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); | 1703 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); |
1704 CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId())); | 1704 CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId())); |
1705 const v8::HeapGraphNode* s_prop = | 1705 const v8::HeapGraphNode* s_prop = |
1706 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); | 1706 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); |
1707 v8::Local<v8::String> js_s_prop = | 1707 v8::Local<v8::String> js_s_prop = |
1708 js_obj->Get(v8_str("s_prop")).As<v8::String>(); | 1708 js_obj->Get(v8_str("s_prop")).As<v8::String>(); |
1709 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId())); | 1709 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId())); |
1710 const v8::HeapGraphNode* n_prop = | 1710 const v8::HeapGraphNode* n_prop = |
1711 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); | 1711 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); |
1712 v8::Local<v8::Number> js_n_prop = | 1712 v8::Local<v8::String> js_n_prop = |
1713 js_obj->Get(v8_str("n_prop")).As<v8::Number>(); | 1713 js_obj->Get(v8_str("n_prop")).As<v8::String>(); |
1714 CHECK(js_n_prop->NumberValue() == | 1714 CHECK(js_n_prop == heap_profiler->FindObjectById(n_prop->GetId())); |
1715 heap_profiler->FindObjectById(n_prop->GetId())->NumberValue()); | |
1716 } | 1715 } |
1717 | 1716 |
1718 | 1717 |
1719 TEST(GetHeapValueForDeletedObject) { | 1718 TEST(GetHeapValueForDeletedObject) { |
1720 LocalContext env; | 1719 LocalContext env; |
1721 v8::HandleScope scope(env->GetIsolate()); | 1720 v8::HandleScope scope(env->GetIsolate()); |
1722 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1721 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
1723 | 1722 |
1724 // It is impossible to delete a global property, so we are about to delete a | 1723 // It is impossible to delete a global property, so we are about to delete a |
1725 // property of the "a" object. Also, the "p" object can't be an empty one | 1724 // property of the "a" object. Also, the "p" object can't be an empty one |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2676 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2678 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2677 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2679 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2678 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); |
2680 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2679 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); |
2681 CHECK_EQ(3, static_cast<int>(map.size())); | 2680 CHECK_EQ(3, static_cast<int>(map.size())); |
2682 | 2681 |
2683 map.Clear(); | 2682 map.Clear(); |
2684 CHECK_EQ(0, static_cast<int>(map.size())); | 2683 CHECK_EQ(0, static_cast<int>(map.size())); |
2685 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2684 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); |
2686 } | 2685 } |
OLD | NEW |