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

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

Issue 805453002: Introduced PropertyType ACCESSOR_FIELD. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 6 years 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 | « src/property-details.h ('k') | test/cctest/test-transitions.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 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 CHECK_NE(NULL, func); 1909 CHECK_NE(NULL, func);
1910 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter"); 1910 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithGetter");
1911 CHECK_EQ(NULL, func); 1911 CHECK_EQ(NULL, func);
1912 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter"); 1912 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set propWithSetter");
1913 CHECK_NE(NULL, func); 1913 CHECK_NE(NULL, func);
1914 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter"); 1914 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get propWithSetter");
1915 CHECK_EQ(NULL, func); 1915 CHECK_EQ(NULL, func);
1916 } 1916 }
1917 1917
1918 1918
1919 TEST(FastCaseRedefinedAccessors) {
1920 LocalContext env;
1921 v8::HandleScope scope(env->GetIsolate());
1922 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1923
1924 CompileRun(
1925 "var obj1 = {};\n"
1926 "Object.defineProperty(obj1, 'prop', { "
1927 " get: function() { return 42; },\n"
1928 " set: function(value) { return this.prop_ = value; },\n"
1929 " configurable: true,\n"
1930 " enumerable: true,\n"
1931 "});\n"
1932 "Object.defineProperty(obj1, 'prop', { "
1933 " get: function() { return 153; },\n"
1934 " set: function(value) { return this.prop_ = value; },\n"
1935 " configurable: true,\n"
1936 " enumerable: true,\n"
1937 "});\n");
1938 v8::Local<v8::Object> js_global =
1939 env->Global()->GetPrototype().As<v8::Object>();
1940 i::Handle<i::JSObject> js_obj1 =
1941 v8::Utils::OpenHandle(*js_global->Get(v8_str("obj1")).As<v8::Object>());
1942 USE(js_obj1);
1943
1944 const v8::HeapSnapshot* snapshot =
1945 heap_profiler->TakeHeapSnapshot(v8_str("fastCaseAccessors"));
1946 CHECK(ValidateSnapshot(snapshot));
1947 const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1948 CHECK_NE(NULL, global);
1949 const v8::HeapGraphNode* obj1 =
1950 GetProperty(global, v8::HeapGraphEdge::kProperty, "obj1");
1951 CHECK_NE(NULL, obj1);
1952 const v8::HeapGraphNode* func;
1953 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "get prop");
1954 CHECK_NE(NULL, func);
1955 func = GetProperty(obj1, v8::HeapGraphEdge::kProperty, "set prop");
1956 CHECK_NE(NULL, func);
1957 }
1958
1959
1919 TEST(SlowCaseAccessors) { 1960 TEST(SlowCaseAccessors) {
1920 LocalContext env; 1961 LocalContext env;
1921 v8::HandleScope scope(env->GetIsolate()); 1962 v8::HandleScope scope(env->GetIsolate());
1922 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1963 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1923 1964
1924 CompileRun("var obj1 = {};\n" 1965 CompileRun("var obj1 = {};\n"
1925 "for (var i = 0; i < 100; ++i) obj1['z' + i] = {};" 1966 "for (var i = 0; i < 100; ++i) obj1['z' + i] = {};"
1926 "obj1.__defineGetter__('propWithGetter', function Y() {\n" 1967 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1927 " return 42;\n" 1968 " return 42;\n"
1928 "});\n" 1969 "});\n"
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 map.AddRange(ToAddress(0x180), 0x80, 6U); 2838 map.AddRange(ToAddress(0x180), 0x80, 6U);
2798 map.AddRange(ToAddress(0x180), 0x80, 7U); 2839 map.AddRange(ToAddress(0x180), 0x80, 7U);
2799 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); 2840 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180)));
2800 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); 2841 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200)));
2801 CHECK_EQ(3, static_cast<int>(map.size())); 2842 CHECK_EQ(3, static_cast<int>(map.size()));
2802 2843
2803 map.Clear(); 2844 map.Clear();
2804 CHECK_EQ(0, static_cast<int>(map.size())); 2845 CHECK_EQ(0, static_cast<int>(map.size()));
2805 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); 2846 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400)));
2806 } 2847 }
OLDNEW
« no previous file with comments | « src/property-details.h ('k') | test/cctest/test-transitions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698