OLD | NEW |
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 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 v8::Local<v8::Value> res = CompileRun( | 1790 v8::Local<v8::Value> res = CompileRun( |
1791 "function f() { return o.x; }" | 1791 "function f() { return o.x; }" |
1792 "for (var i = 0; i < 10; ++i) f();" | 1792 "for (var i = 0; i < 10; ++i) f();" |
1793 "%OptimizeFunctionOnNextCall(f);" | 1793 "%OptimizeFunctionOnNextCall(f);" |
1794 "f();"); | 1794 "f();"); |
1795 CHECK_EQ(42, res->Int32Value()); | 1795 CHECK_EQ(42, res->Int32Value()); |
1796 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); | 1796 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); |
1797 ctx2->Exit(); | 1797 ctx2->Exit(); |
1798 v8::Local<v8::Context>::New(isolate, ctx1)->Exit(); | 1798 v8::Local<v8::Context>::New(isolate, ctx1)->Exit(); |
1799 ctx1p.Reset(); | 1799 ctx1p.Reset(); |
1800 v8::V8::ContextDisposedNotification(); | 1800 isolate->ContextDisposedNotification(); |
1801 } | 1801 } |
1802 CcTest::heap()->CollectAllAvailableGarbage(); | 1802 CcTest::heap()->CollectAllAvailableGarbage(); |
1803 CHECK_EQ(2, NumberOfGlobalObjects()); | 1803 CHECK_EQ(2, NumberOfGlobalObjects()); |
1804 ctx2p.Reset(); | 1804 ctx2p.Reset(); |
1805 CcTest::heap()->CollectAllAvailableGarbage(); | 1805 CcTest::heap()->CollectAllAvailableGarbage(); |
1806 CHECK_EQ(0, NumberOfGlobalObjects()); | 1806 CHECK_EQ(0, NumberOfGlobalObjects()); |
1807 } | 1807 } |
1808 | 1808 |
1809 | 1809 |
1810 // Test that we don't embed functions from foreign contexts into | 1810 // Test that we don't embed functions from foreign contexts into |
(...skipping 25 matching lines...) Expand all Loading... |
1836 v8::Local<v8::Value> res = CompileRun( | 1836 v8::Local<v8::Value> res = CompileRun( |
1837 "function f(x) { return x(); }" | 1837 "function f(x) { return x(); }" |
1838 "for (var i = 0; i < 10; ++i) f(o);" | 1838 "for (var i = 0; i < 10; ++i) f(o);" |
1839 "%OptimizeFunctionOnNextCall(f);" | 1839 "%OptimizeFunctionOnNextCall(f);" |
1840 "f(o);"); | 1840 "f(o);"); |
1841 CHECK_EQ(42, res->Int32Value()); | 1841 CHECK_EQ(42, res->Int32Value()); |
1842 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); | 1842 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); |
1843 ctx2->Exit(); | 1843 ctx2->Exit(); |
1844 ctx1->Exit(); | 1844 ctx1->Exit(); |
1845 ctx1p.Reset(); | 1845 ctx1p.Reset(); |
1846 v8::V8::ContextDisposedNotification(); | 1846 isolate->ContextDisposedNotification(); |
1847 } | 1847 } |
1848 CcTest::heap()->CollectAllAvailableGarbage(); | 1848 CcTest::heap()->CollectAllAvailableGarbage(); |
1849 CHECK_EQ(2, NumberOfGlobalObjects()); | 1849 CHECK_EQ(2, NumberOfGlobalObjects()); |
1850 ctx2p.Reset(); | 1850 ctx2p.Reset(); |
1851 CcTest::heap()->CollectAllAvailableGarbage(); | 1851 CcTest::heap()->CollectAllAvailableGarbage(); |
1852 CHECK_EQ(0, NumberOfGlobalObjects()); | 1852 CHECK_EQ(0, NumberOfGlobalObjects()); |
1853 } | 1853 } |
1854 | 1854 |
1855 | 1855 |
1856 TEST(LeakNativeContextViaMapKeyed) { | 1856 TEST(LeakNativeContextViaMapKeyed) { |
(...skipping 23 matching lines...) Expand all Loading... |
1880 v8::Local<v8::Value> res = CompileRun( | 1880 v8::Local<v8::Value> res = CompileRun( |
1881 "function f() { return o[0]; }" | 1881 "function f() { return o[0]; }" |
1882 "for (var i = 0; i < 10; ++i) f();" | 1882 "for (var i = 0; i < 10; ++i) f();" |
1883 "%OptimizeFunctionOnNextCall(f);" | 1883 "%OptimizeFunctionOnNextCall(f);" |
1884 "f();"); | 1884 "f();"); |
1885 CHECK_EQ(42, res->Int32Value()); | 1885 CHECK_EQ(42, res->Int32Value()); |
1886 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); | 1886 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); |
1887 ctx2->Exit(); | 1887 ctx2->Exit(); |
1888 ctx1->Exit(); | 1888 ctx1->Exit(); |
1889 ctx1p.Reset(); | 1889 ctx1p.Reset(); |
1890 v8::V8::ContextDisposedNotification(); | 1890 isolate->ContextDisposedNotification(); |
1891 } | 1891 } |
1892 CcTest::heap()->CollectAllAvailableGarbage(); | 1892 CcTest::heap()->CollectAllAvailableGarbage(); |
1893 CHECK_EQ(2, NumberOfGlobalObjects()); | 1893 CHECK_EQ(2, NumberOfGlobalObjects()); |
1894 ctx2p.Reset(); | 1894 ctx2p.Reset(); |
1895 CcTest::heap()->CollectAllAvailableGarbage(); | 1895 CcTest::heap()->CollectAllAvailableGarbage(); |
1896 CHECK_EQ(0, NumberOfGlobalObjects()); | 1896 CHECK_EQ(0, NumberOfGlobalObjects()); |
1897 } | 1897 } |
1898 | 1898 |
1899 | 1899 |
1900 TEST(LeakNativeContextViaMapProto) { | 1900 TEST(LeakNativeContextViaMapProto) { |
(...skipping 27 matching lines...) Expand all Loading... |
1928 " return p.x;" | 1928 " return p.x;" |
1929 "}" | 1929 "}" |
1930 "for (var i = 0; i < 10; ++i) f();" | 1930 "for (var i = 0; i < 10; ++i) f();" |
1931 "%OptimizeFunctionOnNextCall(f);" | 1931 "%OptimizeFunctionOnNextCall(f);" |
1932 "f();"); | 1932 "f();"); |
1933 CHECK_EQ(42, res->Int32Value()); | 1933 CHECK_EQ(42, res->Int32Value()); |
1934 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); | 1934 ctx2->Global()->Set(v8_str("o"), v8::Int32::New(isolate, 0)); |
1935 ctx2->Exit(); | 1935 ctx2->Exit(); |
1936 ctx1->Exit(); | 1936 ctx1->Exit(); |
1937 ctx1p.Reset(); | 1937 ctx1p.Reset(); |
1938 v8::V8::ContextDisposedNotification(); | 1938 isolate->ContextDisposedNotification(); |
1939 } | 1939 } |
1940 CcTest::heap()->CollectAllAvailableGarbage(); | 1940 CcTest::heap()->CollectAllAvailableGarbage(); |
1941 CHECK_EQ(2, NumberOfGlobalObjects()); | 1941 CHECK_EQ(2, NumberOfGlobalObjects()); |
1942 ctx2p.Reset(); | 1942 ctx2p.Reset(); |
1943 CcTest::heap()->CollectAllAvailableGarbage(); | 1943 CcTest::heap()->CollectAllAvailableGarbage(); |
1944 CHECK_EQ(0, NumberOfGlobalObjects()); | 1944 CHECK_EQ(0, NumberOfGlobalObjects()); |
1945 } | 1945 } |
1946 | 1946 |
1947 | 1947 |
1948 TEST(InstanceOfStubWriteBarrier) { | 1948 TEST(InstanceOfStubWriteBarrier) { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 *v8::Handle<v8::Function>::Cast( | 2089 *v8::Handle<v8::Function>::Cast( |
2090 CcTest::global()->Get(v8_str("f")))); | 2090 CcTest::global()->Get(v8_str("f")))); |
2091 CHECK(f->IsOptimized()); | 2091 CHECK(f->IsOptimized()); |
2092 | 2092 |
2093 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 2093 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
2094 marking->Abort(); | 2094 marking->Abort(); |
2095 marking->Start(); | 2095 marking->Start(); |
2096 | 2096 |
2097 // The following two calls will increment CcTest::heap()->global_ic_age(). | 2097 // The following two calls will increment CcTest::heap()->global_ic_age(). |
2098 const int kLongIdlePauseInMs = 1000; | 2098 const int kLongIdlePauseInMs = 1000; |
2099 v8::V8::ContextDisposedNotification(); | 2099 CcTest::isolate()->ContextDisposedNotification(); |
2100 v8::V8::IdleNotification(kLongIdlePauseInMs); | 2100 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs); |
2101 | 2101 |
2102 while (!marking->IsStopped() && !marking->IsComplete()) { | 2102 while (!marking->IsStopped() && !marking->IsComplete()) { |
2103 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 2103 marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
2104 } | 2104 } |
2105 if (!marking->IsStopped() || marking->should_hurry()) { | 2105 if (!marking->IsStopped() || marking->should_hurry()) { |
2106 // We don't normally finish a GC via Step(), we normally finish by | 2106 // We don't normally finish a GC via Step(), we normally finish by |
2107 // setting the stack guard and then do the final steps in the stack | 2107 // setting the stack guard and then do the final steps in the stack |
2108 // guard interrupt. But here we didn't ask for that, and there is no | 2108 // guard interrupt. But here we didn't ask for that, and there is no |
2109 // JS code running to trigger the interrupt, so we explicitly finalize | 2109 // JS code running to trigger the interrupt, so we explicitly finalize |
2110 // here. | 2110 // here. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 v8::Utils::OpenHandle( | 2145 v8::Utils::OpenHandle( |
2146 *v8::Handle<v8::Function>::Cast( | 2146 *v8::Handle<v8::Function>::Cast( |
2147 CcTest::global()->Get(v8_str("f")))); | 2147 CcTest::global()->Get(v8_str("f")))); |
2148 CHECK(f->IsOptimized()); | 2148 CHECK(f->IsOptimized()); |
2149 | 2149 |
2150 CcTest::heap()->incremental_marking()->Abort(); | 2150 CcTest::heap()->incremental_marking()->Abort(); |
2151 | 2151 |
2152 // The following two calls will increment CcTest::heap()->global_ic_age(). | 2152 // The following two calls will increment CcTest::heap()->global_ic_age(). |
2153 // Since incremental marking is off, IdleNotification will do full GC. | 2153 // Since incremental marking is off, IdleNotification will do full GC. |
2154 const int kLongIdlePauseInMs = 1000; | 2154 const int kLongIdlePauseInMs = 1000; |
2155 v8::V8::ContextDisposedNotification(); | 2155 CcTest::isolate()->ContextDisposedNotification(); |
2156 v8::V8::IdleNotification(kLongIdlePauseInMs); | 2156 CcTest::isolate()->IdleNotification(kLongIdlePauseInMs); |
2157 | 2157 |
2158 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); | 2158 CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); |
2159 CHECK_EQ(0, f->shared()->opt_count()); | 2159 CHECK_EQ(0, f->shared()->opt_count()); |
2160 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); | 2160 CHECK_EQ(0, f->shared()->code()->profiler_ticks()); |
2161 } | 2161 } |
2162 | 2162 |
2163 | 2163 |
2164 // Test that HAllocateObject will always return an object in new-space. | 2164 // Test that HAllocateObject will always return an object in new-space. |
2165 TEST(OptimizedAllocationAlwaysInNewSpace) { | 2165 TEST(OptimizedAllocationAlwaysInNewSpace) { |
2166 i::FLAG_allow_natives_syntax = true; | 2166 i::FLAG_allow_natives_syntax = true; |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); | 3200 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); |
3201 Handle<JSFunction> f = | 3201 Handle<JSFunction> f = |
3202 v8::Utils::OpenHandle( | 3202 v8::Utils::OpenHandle( |
3203 *v8::Handle<v8::Function>::Cast( | 3203 *v8::Handle<v8::Function>::Cast( |
3204 CcTest::global()->Get(v8_str("f")))); | 3204 CcTest::global()->Get(v8_str("f")))); |
3205 | 3205 |
3206 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3206 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
3207 CHECK(ic_before->ic_state() == MONOMORPHIC); | 3207 CHECK(ic_before->ic_state() == MONOMORPHIC); |
3208 | 3208 |
3209 // Fire context dispose notification. | 3209 // Fire context dispose notification. |
3210 v8::V8::ContextDisposedNotification(); | 3210 CcTest::isolate()->ContextDisposedNotification(); |
3211 SimulateIncrementalMarking(); | 3211 SimulateIncrementalMarking(); |
3212 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 3212 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
3213 | 3213 |
3214 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3214 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
3215 CHECK(IC::IsCleared(ic_after)); | 3215 CHECK(IC::IsCleared(ic_after)); |
3216 } | 3216 } |
3217 | 3217 |
3218 | 3218 |
3219 TEST(IncrementalMarkingClearsPolymorphicIC) { | 3219 TEST(IncrementalMarkingClearsPolymorphicIC) { |
3220 if (i::FLAG_always_opt) return; | 3220 if (i::FLAG_always_opt) return; |
(...skipping 20 matching lines...) Expand all Loading... |
3241 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); | 3241 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); |
3242 Handle<JSFunction> f = | 3242 Handle<JSFunction> f = |
3243 v8::Utils::OpenHandle( | 3243 v8::Utils::OpenHandle( |
3244 *v8::Handle<v8::Function>::Cast( | 3244 *v8::Handle<v8::Function>::Cast( |
3245 CcTest::global()->Get(v8_str("f")))); | 3245 CcTest::global()->Get(v8_str("f")))); |
3246 | 3246 |
3247 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3247 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
3248 CHECK(ic_before->ic_state() == POLYMORPHIC); | 3248 CHECK(ic_before->ic_state() == POLYMORPHIC); |
3249 | 3249 |
3250 // Fire context dispose notification. | 3250 // Fire context dispose notification. |
3251 v8::V8::ContextDisposedNotification(); | 3251 CcTest::isolate()->ContextDisposedNotification(); |
3252 SimulateIncrementalMarking(); | 3252 SimulateIncrementalMarking(); |
3253 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 3253 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
3254 | 3254 |
3255 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 3255 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
3256 CHECK(IC::IsCleared(ic_after)); | 3256 CHECK(IC::IsCleared(ic_after)); |
3257 } | 3257 } |
3258 | 3258 |
3259 | 3259 |
3260 class SourceResource: public v8::String::ExternalAsciiStringResource { | 3260 class SourceResource: public v8::String::ExternalAsciiStringResource { |
3261 public: | 3261 public: |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4408 #ifdef DEBUG | 4408 #ifdef DEBUG |
4409 TEST(PathTracer) { | 4409 TEST(PathTracer) { |
4410 CcTest::InitializeVM(); | 4410 CcTest::InitializeVM(); |
4411 v8::HandleScope scope(CcTest::isolate()); | 4411 v8::HandleScope scope(CcTest::isolate()); |
4412 | 4412 |
4413 v8::Local<v8::Value> result = CompileRun("'abc'"); | 4413 v8::Local<v8::Value> result = CompileRun("'abc'"); |
4414 Handle<Object> o = v8::Utils::OpenHandle(*result); | 4414 Handle<Object> o = v8::Utils::OpenHandle(*result); |
4415 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 4415 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
4416 } | 4416 } |
4417 #endif // DEBUG | 4417 #endif // DEBUG |
OLD | NEW |