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

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

Issue 118523003: More API cleanup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback Created 7 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap-profiler.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p); 1783 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
1784 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v")); 1784 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
1785 ctx2->Enter(); 1785 ctx2->Enter();
1786 ctx2->Global()->Set(v8_str("o"), v); 1786 ctx2->Global()->Set(v8_str("o"), v);
1787 v8::Local<v8::Value> res = CompileRun( 1787 v8::Local<v8::Value> res = CompileRun(
1788 "function f() { return o.x; }" 1788 "function f() { return o.x; }"
1789 "for (var i = 0; i < 10; ++i) f();" 1789 "for (var i = 0; i < 10; ++i) f();"
1790 "%OptimizeFunctionOnNextCall(f);" 1790 "%OptimizeFunctionOnNextCall(f);"
1791 "f();"); 1791 "f();");
1792 CHECK_EQ(42, res->Int32Value()); 1792 CHECK_EQ(42, res->Int32Value());
1793 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1793 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
1794 ctx2->Exit(); 1794 ctx2->Exit();
1795 v8::Local<v8::Context>::New(isolate, ctx1)->Exit(); 1795 v8::Local<v8::Context>::New(isolate, ctx1)->Exit();
1796 ctx1p.Reset(); 1796 ctx1p.Reset();
1797 v8::V8::ContextDisposedNotification(); 1797 v8::V8::ContextDisposedNotification();
1798 } 1798 }
1799 CcTest::heap()->CollectAllAvailableGarbage(); 1799 CcTest::heap()->CollectAllAvailableGarbage();
1800 CHECK_EQ(2, NumberOfGlobalObjects()); 1800 CHECK_EQ(2, NumberOfGlobalObjects());
1801 ctx2p.Reset(); 1801 ctx2p.Reset();
1802 CcTest::heap()->CollectAllAvailableGarbage(); 1802 CcTest::heap()->CollectAllAvailableGarbage();
1803 CHECK_EQ(0, NumberOfGlobalObjects()); 1803 CHECK_EQ(0, NumberOfGlobalObjects());
(...skipping 25 matching lines...) Expand all
1829 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p); 1829 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
1830 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v")); 1830 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
1831 ctx2->Enter(); 1831 ctx2->Enter();
1832 ctx2->Global()->Set(v8_str("o"), v); 1832 ctx2->Global()->Set(v8_str("o"), v);
1833 v8::Local<v8::Value> res = CompileRun( 1833 v8::Local<v8::Value> res = CompileRun(
1834 "function f(x) { return x(); }" 1834 "function f(x) { return x(); }"
1835 "for (var i = 0; i < 10; ++i) f(o);" 1835 "for (var i = 0; i < 10; ++i) f(o);"
1836 "%OptimizeFunctionOnNextCall(f);" 1836 "%OptimizeFunctionOnNextCall(f);"
1837 "f(o);"); 1837 "f(o);");
1838 CHECK_EQ(42, res->Int32Value()); 1838 CHECK_EQ(42, res->Int32Value());
1839 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1839 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
1840 ctx2->Exit(); 1840 ctx2->Exit();
1841 ctx1->Exit(); 1841 ctx1->Exit();
1842 ctx1p.Reset(); 1842 ctx1p.Reset();
1843 v8::V8::ContextDisposedNotification(); 1843 v8::V8::ContextDisposedNotification();
1844 } 1844 }
1845 CcTest::heap()->CollectAllAvailableGarbage(); 1845 CcTest::heap()->CollectAllAvailableGarbage();
1846 CHECK_EQ(2, NumberOfGlobalObjects()); 1846 CHECK_EQ(2, NumberOfGlobalObjects());
1847 ctx2p.Reset(); 1847 ctx2p.Reset();
1848 CcTest::heap()->CollectAllAvailableGarbage(); 1848 CcTest::heap()->CollectAllAvailableGarbage();
1849 CHECK_EQ(0, NumberOfGlobalObjects()); 1849 CHECK_EQ(0, NumberOfGlobalObjects());
(...skipping 23 matching lines...) Expand all
1873 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p); 1873 v8::Local<v8::Context> ctx2 = v8::Local<v8::Context>::New(isolate, ctx2p);
1874 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v")); 1874 v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
1875 ctx2->Enter(); 1875 ctx2->Enter();
1876 ctx2->Global()->Set(v8_str("o"), v); 1876 ctx2->Global()->Set(v8_str("o"), v);
1877 v8::Local<v8::Value> res = CompileRun( 1877 v8::Local<v8::Value> res = CompileRun(
1878 "function f() { return o[0]; }" 1878 "function f() { return o[0]; }"
1879 "for (var i = 0; i < 10; ++i) f();" 1879 "for (var i = 0; i < 10; ++i) f();"
1880 "%OptimizeFunctionOnNextCall(f);" 1880 "%OptimizeFunctionOnNextCall(f);"
1881 "f();"); 1881 "f();");
1882 CHECK_EQ(42, res->Int32Value()); 1882 CHECK_EQ(42, res->Int32Value());
1883 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1883 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
1884 ctx2->Exit(); 1884 ctx2->Exit();
1885 ctx1->Exit(); 1885 ctx1->Exit();
1886 ctx1p.Reset(); 1886 ctx1p.Reset();
1887 v8::V8::ContextDisposedNotification(); 1887 v8::V8::ContextDisposedNotification();
1888 } 1888 }
1889 CcTest::heap()->CollectAllAvailableGarbage(); 1889 CcTest::heap()->CollectAllAvailableGarbage();
1890 CHECK_EQ(2, NumberOfGlobalObjects()); 1890 CHECK_EQ(2, NumberOfGlobalObjects());
1891 ctx2p.Reset(); 1891 ctx2p.Reset();
1892 CcTest::heap()->CollectAllAvailableGarbage(); 1892 CcTest::heap()->CollectAllAvailableGarbage();
1893 CHECK_EQ(0, NumberOfGlobalObjects()); 1893 CHECK_EQ(0, NumberOfGlobalObjects());
(...skipping 27 matching lines...) Expand all
1921 v8::Local<v8::Value> res = CompileRun( 1921 v8::Local<v8::Value> res = CompileRun(
1922 "function f() {" 1922 "function f() {"
1923 " var p = {x: 42};" 1923 " var p = {x: 42};"
1924 " p.__proto__ = o;" 1924 " p.__proto__ = o;"
1925 " return p.x;" 1925 " return p.x;"
1926 "}" 1926 "}"
1927 "for (var i = 0; i < 10; ++i) f();" 1927 "for (var i = 0; i < 10; ++i) f();"
1928 "%OptimizeFunctionOnNextCall(f);" 1928 "%OptimizeFunctionOnNextCall(f);"
1929 "f();"); 1929 "f();");
1930 CHECK_EQ(42, res->Int32Value()); 1930 CHECK_EQ(42, res->Int32Value());
1931 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0)); 1931 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0));
1932 ctx2->Exit(); 1932 ctx2->Exit();
1933 ctx1->Exit(); 1933 ctx1->Exit();
1934 ctx1p.Reset(); 1934 ctx1p.Reset();
1935 v8::V8::ContextDisposedNotification(); 1935 v8::V8::ContextDisposedNotification();
1936 } 1936 }
1937 CcTest::heap()->CollectAllAvailableGarbage(); 1937 CcTest::heap()->CollectAllAvailableGarbage();
1938 CHECK_EQ(2, NumberOfGlobalObjects()); 1938 CHECK_EQ(2, NumberOfGlobalObjects());
1939 ctx2p.Reset(); 1939 ctx2p.Reset();
1940 CcTest::heap()->CollectAllAvailableGarbage(); 1940 CcTest::heap()->CollectAllAvailableGarbage();
1941 CHECK_EQ(0, NumberOfGlobalObjects()); 1941 CHECK_EQ(0, NumberOfGlobalObjects());
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2761 TEST(Regress2211) { 2761 TEST(Regress2211) {
2762 CcTest::InitializeVM(); 2762 CcTest::InitializeVM();
2763 v8::HandleScope scope(CcTest::isolate()); 2763 v8::HandleScope scope(CcTest::isolate());
2764 2764
2765 v8::Handle<v8::String> value = v8_str("val string"); 2765 v8::Handle<v8::String> value = v8_str("val string");
2766 Smi* hash = Smi::FromInt(321); 2766 Smi* hash = Smi::FromInt(321);
2767 Heap* heap = CcTest::heap(); 2767 Heap* heap = CcTest::heap();
2768 2768
2769 for (int i = 0; i < 2; i++) { 2769 for (int i = 0; i < 2; i++) {
2770 // Store identity hash first and common hidden property second. 2770 // Store identity hash first and common hidden property second.
2771 v8::Handle<v8::Object> obj = v8::Object::New(); 2771 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate());
2772 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); 2772 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj);
2773 CHECK(internal_obj->HasFastProperties()); 2773 CHECK(internal_obj->HasFastProperties());
2774 2774
2775 // In the first iteration, set hidden value first and identity hash second. 2775 // In the first iteration, set hidden value first and identity hash second.
2776 // In the second iteration, reverse the order. 2776 // In the second iteration, reverse the order.
2777 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); 2777 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value);
2778 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate())); 2778 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate()));
2779 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); 2779 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value);
2780 2780
2781 // Check values. 2781 // Check values.
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 "}" 3330 "}"
3331 "obj = fastliteralcase(get_standard_literal(), 1);" 3331 "obj = fastliteralcase(get_standard_literal(), 1);"
3332 "obj = fastliteralcase(get_standard_literal(), 1.5);" 3332 "obj = fastliteralcase(get_standard_literal(), 1.5);"
3333 "obj = fastliteralcase(get_standard_literal(), 2);"); 3333 "obj = fastliteralcase(get_standard_literal(), 2);");
3334 3334
3335 // prepare the heap 3335 // prepare the heap
3336 v8::Local<v8::String> mote_code_string = 3336 v8::Local<v8::String> mote_code_string =
3337 v8_str("fastliteralcase(mote, 2.5);"); 3337 v8_str("fastliteralcase(mote, 2.5);");
3338 3338
3339 v8::Local<v8::String> array_name = v8_str("mote"); 3339 v8::Local<v8::String> array_name = v8_str("mote");
3340 CcTest::global()->Set(array_name, v8::Int32::New(0)); 3340 CcTest::global()->Set(array_name, v8::Int32::New(CcTest::isolate(), 0));
3341 3341
3342 // First make sure we flip spaces 3342 // First make sure we flip spaces
3343 CcTest::heap()->CollectGarbage(NEW_SPACE); 3343 CcTest::heap()->CollectGarbage(NEW_SPACE);
3344 3344
3345 // Allocate the object. 3345 // Allocate the object.
3346 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); 3346 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED);
3347 array_data->set(0, Smi::FromInt(1)); 3347 array_data->set(0, Smi::FromInt(1));
3348 array_data->set(1, Smi::FromInt(2)); 3348 array_data->set(1, Smi::FromInt(2));
3349 3349
3350 AllocateAllButNBytes(CcTest::heap()->new_space(), 3350 AllocateAllButNBytes(CcTest::heap()->new_space(),
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 for (int i = 0; i < 4; i++) { 3627 for (int i = 0; i < 4; i++) {
3628 heap->CollectAllGarbage(false); 3628 heap->CollectAllGarbage(false);
3629 } 3629 }
3630 3630
3631 // The site still exists because of our global handle, but the code is no 3631 // The site still exists because of our global handle, but the code is no
3632 // longer referred to by dependent_code(). 3632 // longer referred to by dependent_code().
3633 DependentCode::GroupStartIndexes starts(site->dependent_code()); 3633 DependentCode::GroupStartIndexes starts(site->dependent_code());
3634 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); 3634 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup);
3635 CHECK(!(site->dependent_code()->is_code_at(index))); 3635 CHECK(!(site->dependent_code()->is_code_at(index)));
3636 } 3636 }
OLDNEW
« no previous file with comments | « test/cctest/test-global-object.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698