Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 19267023: Do not report unessential weak references in heap snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated tests. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 1721
1722 CHECK(!HasWeakGlobalHandle()); 1722 CHECK(!HasWeakGlobalHandle());
1723 1723
1724 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New()); 1724 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New());
1725 handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback); 1725 handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback);
1726 1726
1727 CHECK(HasWeakGlobalHandle()); 1727 CHECK(HasWeakGlobalHandle());
1728 } 1728 }
1729 1729
1730 1730
1731 TEST(WeakNativeContextRefs) {
1732 LocalContext env;
1733 v8::HandleScope scope(env->GetIsolate());
1734 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1735
1736 const v8::HeapSnapshot* snapshot =
1737 heap_profiler->TakeHeapSnapshot(v8_str("weaks"));
1738 CHECK(ValidateSnapshot(snapshot));
1739 const v8::HeapGraphNode* gc_roots = GetNode(
1740 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)");
1741 CHECK_NE(NULL, gc_roots);
1742 const v8::HeapGraphNode* global_handles = GetNode(
1743 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)");
1744 CHECK_NE(NULL, global_handles);
1745 const v8::HeapGraphNode* native_context = GetNode(
1746 global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext");
1747 CHECK_NE(NULL, native_context);
1748 CHECK(HasWeakEdge(native_context));
1749 }
1750
1751
1752 TEST(SfiAndJsFunctionWeakRefs) { 1731 TEST(SfiAndJsFunctionWeakRefs) {
1753 LocalContext env; 1732 LocalContext env;
1754 v8::HandleScope scope(env->GetIsolate()); 1733 v8::HandleScope scope(env->GetIsolate());
1755 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1734 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1756 1735
1757 CompileRun( 1736 CompileRun(
1758 "fun = (function (x) { return function () { return x + 1; } })(1);"); 1737 "fun = (function (x) { return function () { return x + 1; } })(1);");
1759 const v8::HeapSnapshot* snapshot = 1738 const v8::HeapSnapshot* snapshot =
1760 heap_profiler->TakeHeapSnapshot(v8_str("fun")); 1739 heap_profiler->TakeHeapSnapshot(v8_str("fun"));
1761 CHECK(ValidateSnapshot(snapshot)); 1740 CHECK(ValidateSnapshot(snapshot));
1762 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1741 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1763 CHECK_NE(NULL, global); 1742 CHECK_NE(NULL, global);
1764 const v8::HeapGraphNode* fun = 1743 const v8::HeapGraphNode* fun =
1765 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); 1744 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun");
1766 CHECK(HasWeakEdge(fun)); 1745 CHECK(!HasWeakEdge(fun));
1767 const v8::HeapGraphNode* shared = 1746 const v8::HeapGraphNode* shared =
1768 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); 1747 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared");
1769 CHECK(HasWeakEdge(shared)); 1748 CHECK(!HasWeakEdge(shared));
1770 } 1749 }
1771 1750
1772 1751
1773 #ifdef ENABLE_DEBUGGER_SUPPORT 1752 #ifdef ENABLE_DEBUGGER_SUPPORT
1774 TEST(NoDebugObjectInSnapshot) { 1753 TEST(NoDebugObjectInSnapshot) {
1775 LocalContext env; 1754 LocalContext env;
1776 v8::HandleScope scope(env->GetIsolate()); 1755 v8::HandleScope scope(env->GetIsolate());
1777 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1756 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1778 1757
1779 v8::internal::Isolate::Current()->debug()->Load(); 1758 v8::internal::Isolate::Current()->debug()->Load();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); 1953 heap_profiler->TakeHeapSnapshot(v8_str("snapshot"));
1975 CHECK(ValidateSnapshot(snapshot)); 1954 CHECK(ValidateSnapshot(snapshot));
1976 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1955 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1977 const v8::HeapGraphNode* foo_func = 1956 const v8::HeapGraphNode* foo_func =
1978 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); 1957 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo");
1979 CHECK_NE(NULL, foo_func); 1958 CHECK_NE(NULL, foo_func);
1980 const v8::HeapGraphNode* code = 1959 const v8::HeapGraphNode* code =
1981 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code"); 1960 GetProperty(foo_func, v8::HeapGraphEdge::kInternal, "code");
1982 CHECK_NE(NULL, code); 1961 CHECK_NE(NULL, code);
1983 } 1962 }
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698