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

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

Issue 8551006: Version 3.7.9. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/string-externalize.js » ('j') | 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 // 2 //
3 // Tests for heap profiler 3 // Tests for heap profiler
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "cctest.h" 7 #include "cctest.h"
8 #include "heap-profiler.h" 8 #include "heap-profiler.h"
9 #include "snapshot.h" 9 #include "snapshot.h"
10 #include "utils-inl.h" 10 #include "utils-inl.h"
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 const v8::HeapSnapshot* snapshot = 888 const v8::HeapSnapshot* snapshot =
889 v8::HeapProfiler::TakeSnapshot(v8_str("document")); 889 v8::HeapProfiler::TakeSnapshot(v8_str("document"));
890 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 890 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
891 CHECK_NE(NULL, global); 891 CHECK_NE(NULL, global);
892 CHECK_EQ("Object", 892 CHECK_EQ("Object",
893 const_cast<i::HeapEntry*>( 893 const_cast<i::HeapEntry*>(
894 reinterpret_cast<const i::HeapEntry*>(global))->name()); 894 reinterpret_cast<const i::HeapEntry*>(global))->name());
895 } 895 }
896 896
897 897
898 TEST(NoHandleLeaks) {
899 v8::HandleScope scope;
900 LocalContext env;
901
902 CompileRun("document = { URL:\"abcdefgh\" };");
903
904 v8::Handle<v8::String> name(v8_str("leakz"));
905 int count_before = i::HandleScope::NumberOfHandles();
906 v8::HeapProfiler::TakeSnapshot(name);
907 int count_after = i::HandleScope::NumberOfHandles();
908 CHECK_EQ(count_before, count_after);
909 }
910
911
898 TEST(NodesIteration) { 912 TEST(NodesIteration) {
899 v8::HandleScope scope; 913 v8::HandleScope scope;
900 LocalContext env; 914 LocalContext env;
901 const v8::HeapSnapshot* snapshot = 915 const v8::HeapSnapshot* snapshot =
902 v8::HeapProfiler::TakeSnapshot(v8_str("iteration")); 916 v8::HeapProfiler::TakeSnapshot(v8_str("iteration"));
903 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 917 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
904 CHECK_NE(NULL, global); 918 CHECK_NE(NULL, global);
905 // Verify that we can find this object by iteration. 919 // Verify that we can find this object by iteration.
906 const int nodes_count = snapshot->GetNodesCount(); 920 const int nodes_count = snapshot->GetNodesCount();
907 int count = 0; 921 int count = 0;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); 1031 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>();
1018 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); 1032 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5);
1019 CHECK_EQ(0, StringCmp( 1033 CHECK_EQ(0, StringCmp(
1020 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); 1034 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5)));
1021 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); 1035 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>();
1022 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); 1036 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6);
1023 CHECK_EQ(0, StringCmp( 1037 CHECK_EQ(0, StringCmp(
1024 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); 1038 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6)));
1025 } 1039 }
1026 1040
1041
1027 TEST(FastCaseGetter) { 1042 TEST(FastCaseGetter) {
1028 v8::HandleScope scope; 1043 v8::HandleScope scope;
1029 LocalContext env; 1044 LocalContext env;
1030 1045
1031 CompileRun("var obj1 = {};\n" 1046 CompileRun("var obj1 = {};\n"
1032 "obj1.__defineGetter__('propWithGetter', function Y() {\n" 1047 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1033 " return 42;\n" 1048 " return 42;\n"
1034 "});\n" 1049 "});\n"
1035 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n" 1050 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1036 " return this.value_ = value;\n" 1051 " return this.value_ = value;\n"
1037 "});\n"); 1052 "});\n");
1038 const v8::HeapSnapshot* snapshot = 1053 const v8::HeapSnapshot* snapshot =
1039 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter")); 1054 v8::HeapProfiler::TakeSnapshot(v8_str("fastCaseGetter"));
1040 1055
1041 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1056 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1042 CHECK_NE(NULL, global); 1057 CHECK_NE(NULL, global);
1043 const v8::HeapGraphNode* obj1 = 1058 const v8::HeapGraphNode* obj1 =
1044 GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1"); 1059 GetProperty(global, v8::HeapGraphEdge::kShortcut, "obj1");
1045 CHECK_NE(NULL, obj1); 1060 CHECK_NE(NULL, obj1);
1046 const v8::HeapGraphNode* getterFunction = 1061 const v8::HeapGraphNode* getterFunction =
1047 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter"); 1062 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get-propWithGetter");
1048 CHECK_NE(NULL, getterFunction); 1063 CHECK_NE(NULL, getterFunction);
1049 const v8::HeapGraphNode* setterFunction = 1064 const v8::HeapGraphNode* setterFunction =
1050 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter"); 1065 GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set-propWithSetter");
1051 CHECK_NE(NULL, setterFunction); 1066 CHECK_NE(NULL, setterFunction);
1052 } 1067 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/string-externalize.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698