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

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

Issue 1413463006: Map v8::Object to v8::internal::JSReceiver (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
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-macro-assembler-mips.cc » ('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 // 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 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 "var obj4 = {};\n" 1822 "var obj4 = {};\n"
1823 "// Slow properties\n" 1823 "// Slow properties\n"
1824 "for (var i=0; i<2000; ++i) obj4[\"p\" + i] = i;\n" 1824 "for (var i=0; i<2000; ++i) obj4[\"p\" + i] = i;\n"
1825 "obj4.constructor = function Constructor4() {};\n" 1825 "obj4.constructor = function Constructor4() {};\n"
1826 "var obj5 = {};\n" 1826 "var obj5 = {};\n"
1827 "var obj6 = {};\n" 1827 "var obj6 = {};\n"
1828 "obj6.constructor = 6;"); 1828 "obj6.constructor = 6;");
1829 v8::Local<v8::Object> js_global = 1829 v8::Local<v8::Object> js_global =
1830 env->Global()->GetPrototype().As<v8::Object>(); 1830 env->Global()->GetPrototype().As<v8::Object>();
1831 v8::Local<v8::Object> obj1 = js_global->Get(v8_str("obj1")).As<v8::Object>(); 1831 v8::Local<v8::Object> obj1 = js_global->Get(v8_str("obj1")).As<v8::Object>();
1832 i::Handle<i::JSObject> js_obj1 = v8::Utils::OpenHandle(*obj1); 1832 i::Handle<i::JSObject> js_obj1 =
1833 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj1));
1833 CHECK_EQ(0, StringCmp( 1834 CHECK_EQ(0, StringCmp(
1834 "Constructor1", i::V8HeapExplorer::GetConstructorName(*js_obj1))); 1835 "Constructor1", i::V8HeapExplorer::GetConstructorName(*js_obj1)));
1835 v8::Local<v8::Object> obj2 = js_global->Get(v8_str("obj2")).As<v8::Object>(); 1836 v8::Local<v8::Object> obj2 = js_global->Get(v8_str("obj2")).As<v8::Object>();
1836 i::Handle<i::JSObject> js_obj2 = v8::Utils::OpenHandle(*obj2); 1837 i::Handle<i::JSObject> js_obj2 =
1838 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj2));
1837 CHECK_EQ(0, StringCmp( 1839 CHECK_EQ(0, StringCmp(
1838 "Constructor2", i::V8HeapExplorer::GetConstructorName(*js_obj2))); 1840 "Constructor2", i::V8HeapExplorer::GetConstructorName(*js_obj2)));
1839 v8::Local<v8::Object> obj3 = js_global->Get(v8_str("obj3")).As<v8::Object>(); 1841 v8::Local<v8::Object> obj3 = js_global->Get(v8_str("obj3")).As<v8::Object>();
1840 i::Handle<i::JSObject> js_obj3 = v8::Utils::OpenHandle(*obj3); 1842 i::Handle<i::JSObject> js_obj3 =
1843 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj3));
1841 // TODO(verwaest): Restore to Constructor3 once supported by the 1844 // TODO(verwaest): Restore to Constructor3 once supported by the
1842 // heap-snapshot-generator. 1845 // heap-snapshot-generator.
1843 CHECK_EQ( 1846 CHECK_EQ(
1844 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj3))); 1847 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj3)));
1845 v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>(); 1848 v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>();
1846 i::Handle<i::JSObject> js_obj4 = v8::Utils::OpenHandle(*obj4); 1849 i::Handle<i::JSObject> js_obj4 =
1850 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj4));
1847 // TODO(verwaest): Restore to Constructor4 once supported by the 1851 // TODO(verwaest): Restore to Constructor4 once supported by the
1848 // heap-snapshot-generator. 1852 // heap-snapshot-generator.
1849 CHECK_EQ( 1853 CHECK_EQ(
1850 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj4))); 1854 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj4)));
1851 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); 1855 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>();
1852 i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); 1856 i::Handle<i::JSObject> js_obj5 =
1857 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj5));
1853 CHECK_EQ(0, StringCmp( 1858 CHECK_EQ(0, StringCmp(
1854 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); 1859 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5)));
1855 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); 1860 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>();
1856 i::Handle<i::JSObject> js_obj6 = v8::Utils::OpenHandle(*obj6); 1861 i::Handle<i::JSObject> js_obj6 =
1862 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj6));
1857 CHECK_EQ(0, StringCmp( 1863 CHECK_EQ(0, StringCmp(
1858 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); 1864 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6)));
1859 } 1865 }
1860 1866
1861 1867
1862 TEST(FastCaseAccessors) { 1868 TEST(FastCaseAccessors) {
1863 LocalContext env; 1869 LocalContext env;
1864 v8::HandleScope scope(env->GetIsolate()); 1870 v8::HandleScope scope(env->GetIsolate());
1865 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1871 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1866 1872
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 " enumerable: true,\n" 1911 " enumerable: true,\n"
1906 "});\n" 1912 "});\n"
1907 "Object.defineProperty(obj1, 'prop', { " 1913 "Object.defineProperty(obj1, 'prop', { "
1908 " get: function() { return 153; },\n" 1914 " get: function() { return 153; },\n"
1909 " set: function(value) { return this.prop_ = value; },\n" 1915 " set: function(value) { return this.prop_ = value; },\n"
1910 " configurable: true,\n" 1916 " configurable: true,\n"
1911 " enumerable: true,\n" 1917 " enumerable: true,\n"
1912 "});\n"); 1918 "});\n");
1913 v8::Local<v8::Object> js_global = 1919 v8::Local<v8::Object> js_global =
1914 env->Global()->GetPrototype().As<v8::Object>(); 1920 env->Global()->GetPrototype().As<v8::Object>();
1915 i::Handle<i::JSObject> js_obj1 = 1921 i::Handle<i::JSReceiver> js_obj1 =
1916 v8::Utils::OpenHandle(*js_global->Get(v8_str("obj1")).As<v8::Object>()); 1922 v8::Utils::OpenHandle(*js_global->Get(v8_str("obj1")).As<v8::Object>());
1917 USE(js_obj1); 1923 USE(js_obj1);
1918 1924
1919 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); 1925 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
1920 CHECK(ValidateSnapshot(snapshot)); 1926 CHECK(ValidateSnapshot(snapshot));
1921 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); 1927 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1922 CHECK(global); 1928 CHECK(global);
1923 const v8::HeapGraphNode* obj1 = 1929 const v8::HeapGraphNode* obj1 =
1924 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1"); 1930 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1");
1925 CHECK(obj1); 1931 CHECK(obj1);
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 map.AddRange(ToAddress(0x180), 0x80, 6U); 2802 map.AddRange(ToAddress(0x180), 0x80, 6U);
2797 map.AddRange(ToAddress(0x180), 0x80, 7U); 2803 map.AddRange(ToAddress(0x180), 0x80, 7U);
2798 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); 2804 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180)));
2799 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); 2805 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200)));
2800 CHECK_EQ(3u, map.size()); 2806 CHECK_EQ(3u, map.size());
2801 2807
2802 map.Clear(); 2808 map.Clear();
2803 CHECK_EQ(0u, map.size()); 2809 CHECK_EQ(0u, map.size());
2804 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); 2810 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400)));
2805 } 2811 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698