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 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 TEST(GetConstructorName) { | 1811 TEST(GetConstructorName) { |
1812 LocalContext env; | 1812 LocalContext env; |
1813 v8::HandleScope scope(env->GetIsolate()); | 1813 v8::HandleScope scope(env->GetIsolate()); |
1814 | 1814 |
1815 CompileRun( | 1815 CompileRun( |
1816 "function Constructor1() {};\n" | 1816 "function Constructor1() {};\n" |
1817 "var obj1 = new Constructor1();\n" | 1817 "var obj1 = new Constructor1();\n" |
1818 "var Constructor2 = function() {};\n" | 1818 "var Constructor2 = function() {};\n" |
1819 "var obj2 = new Constructor2();\n" | 1819 "var obj2 = new Constructor2();\n" |
1820 "var obj3 = {};\n" | 1820 "var obj3 = {};\n" |
1821 "obj3.constructor = function Constructor3() {};\n" | 1821 "obj3.__proto__ = { constructor: function Constructor3() {} };\n" |
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.__proto__ = { 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 = | 1832 i::Handle<i::JSObject> js_obj1 = |
1833 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj1)); | 1833 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj1)); |
1834 CHECK_EQ(0, StringCmp( | 1834 CHECK_EQ(0, StringCmp( |
1835 "Constructor1", i::V8HeapExplorer::GetConstructorName(*js_obj1))); | 1835 "Constructor1", i::V8HeapExplorer::GetConstructorName(*js_obj1))); |
1836 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>(); |
1837 i::Handle<i::JSObject> js_obj2 = | 1837 i::Handle<i::JSObject> js_obj2 = |
1838 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj2)); | 1838 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj2)); |
1839 CHECK_EQ(0, StringCmp( | 1839 CHECK_EQ(0, StringCmp( |
1840 "Constructor2", i::V8HeapExplorer::GetConstructorName(*js_obj2))); | 1840 "Constructor2", i::V8HeapExplorer::GetConstructorName(*js_obj2))); |
1841 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>(); |
1842 i::Handle<i::JSObject> js_obj3 = | 1842 i::Handle<i::JSObject> js_obj3 = |
1843 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj3)); | 1843 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj3)); |
1844 // TODO(verwaest): Restore to Constructor3 once supported by the | 1844 CHECK_EQ(0, StringCmp("Constructor3", |
1845 // heap-snapshot-generator. | 1845 i::V8HeapExplorer::GetConstructorName(*js_obj3))); |
1846 CHECK_EQ( | |
1847 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj3))); | |
1848 v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>(); | 1846 v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>(); |
1849 i::Handle<i::JSObject> js_obj4 = | 1847 i::Handle<i::JSObject> js_obj4 = |
1850 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj4)); | 1848 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj4)); |
1851 // TODO(verwaest): Restore to Constructor4 once supported by the | 1849 CHECK_EQ(0, StringCmp("Constructor4", |
1852 // heap-snapshot-generator. | 1850 i::V8HeapExplorer::GetConstructorName(*js_obj4))); |
1853 CHECK_EQ( | |
1854 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj4))); | |
1855 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); | 1851 v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); |
1856 i::Handle<i::JSObject> js_obj5 = | 1852 i::Handle<i::JSObject> js_obj5 = |
1857 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj5)); | 1853 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj5)); |
1858 CHECK_EQ(0, StringCmp( | 1854 CHECK_EQ(0, StringCmp( |
1859 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); | 1855 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj5))); |
1860 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); | 1856 v8::Local<v8::Object> obj6 = js_global->Get(v8_str("obj6")).As<v8::Object>(); |
1861 i::Handle<i::JSObject> js_obj6 = | 1857 i::Handle<i::JSObject> js_obj6 = |
1862 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj6)); | 1858 i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj6)); |
1863 CHECK_EQ(0, StringCmp( | 1859 CHECK_EQ(0, StringCmp( |
1864 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); | 1860 "Object", i::V8HeapExplorer::GetConstructorName(*js_obj6))); |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2802 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2798 map.AddRange(ToAddress(0x180), 0x80, 6U); |
2803 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2799 map.AddRange(ToAddress(0x180), 0x80, 7U); |
2804 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); | 2800 CHECK_EQ(7u, map.GetTraceNodeId(ToAddress(0x180))); |
2805 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); | 2801 CHECK_EQ(5u, map.GetTraceNodeId(ToAddress(0x200))); |
2806 CHECK_EQ(3u, map.size()); | 2802 CHECK_EQ(3u, map.size()); |
2807 | 2803 |
2808 map.Clear(); | 2804 map.Clear(); |
2809 CHECK_EQ(0u, map.size()); | 2805 CHECK_EQ(0u, map.size()); |
2810 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); | 2806 CHECK_EQ(0u, map.GetTraceNodeId(ToAddress(0x400))); |
2811 } | 2807 } |
OLD | NEW |