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

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

Issue 1428793002: Reland v8::Private and related APIs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month 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
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 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 CompileRun( 1976 CompileRun(
1977 "function C(x) { this.a = this; this.b = x; }\n" 1977 "function C(x) { this.a = this; this.b = x; }\n"
1978 "c = new C(2012);\n"); 1978 "c = new C(2012);\n");
1979 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 1979 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
1980 CHECK(ValidateSnapshot(snapshot)); 1980 CHECK(ValidateSnapshot(snapshot));
1981 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1981 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1982 const v8::HeapGraphNode* c = 1982 const v8::HeapGraphNode* c =
1983 GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); 1983 GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1984 CHECK(c); 1984 CHECK(c);
1985 const v8::HeapGraphNode* hidden_props = 1985 const v8::HeapGraphNode* hidden_props =
1986 GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties"); 1986 GetProperty(c, v8::HeapGraphEdge::kProperty, "<symbol>");
1987 CHECK(!hidden_props); 1987 CHECK(!hidden_props);
1988 1988
1989 v8::Handle<v8::Value> cHandle = 1989 v8::Handle<v8::Value> cHandle =
1990 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c")); 1990 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "c"));
1991 CHECK(!cHandle.IsEmpty() && cHandle->IsObject()); 1991 CHECK(!cHandle.IsEmpty() && cHandle->IsObject());
1992 cHandle->ToObject(isolate)->SetHiddenValue(v8_str("key"), v8_str("val")); 1992 cHandle->ToObject(isolate)
1993 ->SetPrivate(env.local(),
1994 v8::Private::ForApi(env->GetIsolate(), v8_str("key")),
1995 v8_str("val"))
1996 .FromJust();
1993 1997
1994 snapshot = heap_profiler->TakeHeapSnapshot(); 1998 snapshot = heap_profiler->TakeHeapSnapshot();
1995 CHECK(ValidateSnapshot(snapshot)); 1999 CHECK(ValidateSnapshot(snapshot));
1996 global = GetGlobalObject(snapshot); 2000 global = GetGlobalObject(snapshot);
1997 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c"); 2001 c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1998 CHECK(c); 2002 CHECK(c);
1999 hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal, 2003 hidden_props = GetProperty(c, v8::HeapGraphEdge::kProperty, "<symbol>");
2000 "hidden_properties");
2001 CHECK(hidden_props); 2004 CHECK(hidden_props);
2002 } 2005 }
2003 2006
2004 2007
2005 TEST(AccessorInfo) { 2008 TEST(AccessorInfo) {
2006 LocalContext env; 2009 LocalContext env;
2007 v8::HandleScope scope(env->GetIsolate()); 2010 v8::HandleScope scope(env->GetIsolate());
2008 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 2011 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
2009 2012
2010 CompileRun("function foo(x) { }\n"); 2013 CompileRun("function foo(x) { }\n");
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 map.AddRange(ToAddress(0x180), 0x80, 6U); 2799 map.AddRange(ToAddress(0x180), 0x80, 6U);
2797 map.AddRange(ToAddress(0x180), 0x80, 7U); 2800 map.AddRange(ToAddress(0x180), 0x80, 7U);
2798 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2801 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2799 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2802 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2800 CHECK_EQ(3u, map.size()); 2803 CHECK_EQ(3u, map.size());
2801 2804
2802 map.Clear(); 2805 map.Clear();
2803 CHECK_EQ(0u, map.size()); 2806 CHECK_EQ(0u, map.size());
2804 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2807 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2805 } 2808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698