| 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 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 | 2183 |
| 2184 Handle<JSObject> o = | 2184 Handle<JSObject> o = |
| 2185 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2185 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2186 | 2186 |
| 2187 CHECK(CcTest::heap()->InNewSpace(*o)); | 2187 CHECK(CcTest::heap()->InNewSpace(*o)); |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 | 2190 |
| 2191 TEST(OptimizedPretenuringAllocationFolding) { | 2191 TEST(OptimizedPretenuringAllocationFolding) { |
| 2192 i::FLAG_allow_natives_syntax = true; | 2192 i::FLAG_allow_natives_syntax = true; |
| 2193 i::FLAG_allocation_site_pretenuring = false; | 2193 i::FLAG_max_new_space_size = 2048; |
| 2194 CcTest::InitializeVM(); | 2194 CcTest::InitializeVM(); |
| 2195 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2195 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2196 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2196 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2197 v8::HandleScope scope(CcTest::isolate()); | 2197 v8::HandleScope scope(CcTest::isolate()); |
| 2198 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | 2198 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); |
| 2199 | 2199 |
| 2200 v8::Local<v8::Value> res = CompileRun( | 2200 v8::Local<v8::Value> res = CompileRun( |
| 2201 "function DataObject() {" | 2201 "function DataObject() {" |
| 2202 " this.a = 1.1;" | 2202 " this.a = 1.1;" |
| 2203 " this.b = [{}];" | 2203 " this.b = [{}];" |
| 2204 " this.c = 1.2;" | 2204 " this.c = 1.2;" |
| 2205 " this.d = [{}];" | 2205 " this.d = [{}];" |
| 2206 " this.e = 1.3;" | 2206 " this.e = 1.3;" |
| 2207 " this.f = [{}];" | 2207 " this.f = [{}];" |
| 2208 "}" | 2208 "}" |
| 2209 "var number_elements = 20000;" |
| 2210 "var elements = new Array();" |
| 2209 "function f() {" | 2211 "function f() {" |
| 2210 " return new DataObject();" | 2212 " for (var i = 0; i < 20000-1; i++) {" |
| 2213 " elements[i] = new DataObject();" |
| 2214 " }" |
| 2215 " return new DataObject()" |
| 2211 "};" | 2216 "};" |
| 2212 "f(); f(); f();" | 2217 "f(); f(); f();" |
| 2213 "%OptimizeFunctionOnNextCall(f);" | 2218 "%OptimizeFunctionOnNextCall(f);" |
| 2214 "f();"); | 2219 "f();"); |
| 2215 | 2220 |
| 2216 Handle<JSObject> o = | 2221 Handle<JSObject> o = |
| 2217 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2222 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2218 | 2223 |
| 2219 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0))); | 2224 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0))); |
| 2220 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); | 2225 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); |
| 2221 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); | 2226 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); |
| 2222 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3))); | 2227 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3))); |
| 2223 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4))); | 2228 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4))); |
| 2224 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5))); | 2229 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5))); |
| 2225 } | 2230 } |
| 2226 | 2231 |
| 2227 | 2232 |
| 2228 TEST(OptimizedPretenuringAllocationFoldingBlocks) { | 2233 TEST(OptimizedPretenuringAllocationFoldingBlocks) { |
| 2229 i::FLAG_allow_natives_syntax = true; | 2234 i::FLAG_allow_natives_syntax = true; |
| 2230 i::FLAG_allocation_site_pretenuring = false; | 2235 i::FLAG_max_new_space_size = 2048; |
| 2231 CcTest::InitializeVM(); | 2236 CcTest::InitializeVM(); |
| 2232 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2237 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2233 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2238 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2234 v8::HandleScope scope(CcTest::isolate()); | 2239 v8::HandleScope scope(CcTest::isolate()); |
| 2235 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | 2240 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); |
| 2236 | 2241 |
| 2237 v8::Local<v8::Value> res = CompileRun( | 2242 v8::Local<v8::Value> res = CompileRun( |
| 2243 "var number_elements = 30000;" |
| 2244 "var elements = new Array(number_elements);" |
| 2238 "function DataObject() {" | 2245 "function DataObject() {" |
| 2239 " this.a = [{}];" | 2246 " this.a = [{}];" |
| 2240 " this.b = [{}];" | 2247 " this.b = [{}];" |
| 2241 " this.c = 1.1;" | 2248 " this.c = 1.1;" |
| 2242 " this.d = 1.2;" | 2249 " this.d = 1.2;" |
| 2243 " this.e = [{}];" | 2250 " this.e = [{}];" |
| 2244 " this.f = 1.3;" | 2251 " this.f = 1.3;" |
| 2245 "}" | 2252 "}" |
| 2246 "function f() {" | 2253 "function f() {" |
| 2247 " return new DataObject();" | 2254 " for (var i = 0; i < number_elements; i++) {" |
| 2255 " elements[i] = new DataObject();" |
| 2256 " }" |
| 2257 " return elements[number_elements - 1];" |
| 2248 "};" | 2258 "};" |
| 2249 "f(); f(); f();" | 2259 "f(); f(); f();" |
| 2250 "%OptimizeFunctionOnNextCall(f);" | 2260 "%OptimizeFunctionOnNextCall(f);" |
| 2251 "f();"); | 2261 "f();"); |
| 2252 | 2262 |
| 2253 Handle<JSObject> o = | 2263 Handle<JSObject> o = |
| 2254 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2264 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2255 | 2265 |
| 2256 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); | 2266 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); |
| 2257 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); | 2267 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); |
| 2258 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); | 2268 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); |
| 2259 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3))); | 2269 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3))); |
| 2260 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4))); | 2270 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4))); |
| 2261 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5))); | 2271 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5))); |
| 2262 } | 2272 } |
| 2263 | 2273 |
| 2264 | 2274 |
| 2265 TEST(OptimizedPretenuringObjectArrayLiterals) { | 2275 TEST(OptimizedPretenuringObjectArrayLiterals) { |
| 2266 i::FLAG_allow_natives_syntax = true; | 2276 i::FLAG_allow_natives_syntax = true; |
| 2267 i::FLAG_allocation_site_pretenuring = false; | 2277 i::FLAG_max_new_space_size = 2048; |
| 2268 CcTest::InitializeVM(); | 2278 CcTest::InitializeVM(); |
| 2269 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2279 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2270 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2280 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2271 v8::HandleScope scope(CcTest::isolate()); | 2281 v8::HandleScope scope(CcTest::isolate()); |
| 2272 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2273 | 2282 |
| 2274 v8::Local<v8::Value> res = CompileRun( | 2283 v8::Local<v8::Value> res = CompileRun( |
| 2284 "var number_elements = 20000;" |
| 2285 "var elements = new Array(number_elements);" |
| 2275 "function f() {" | 2286 "function f() {" |
| 2276 " var numbers = [{}, {}, {}];" | 2287 " for (var i = 0; i < number_elements; i++) {" |
| 2277 " return numbers;" | 2288 " elements[i] = [{}, {}, {}];" |
| 2289 " }" |
| 2290 " return elements[number_elements - 1];" |
| 2278 "};" | 2291 "};" |
| 2279 "f(); f(); f();" | 2292 "f(); f(); f();" |
| 2280 "%OptimizeFunctionOnNextCall(f);" | 2293 "%OptimizeFunctionOnNextCall(f);" |
| 2281 "f();"); | 2294 "f();"); |
| 2282 | 2295 |
| 2283 Handle<JSObject> o = | 2296 Handle<JSObject> o = |
| 2284 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2297 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2285 | 2298 |
| 2286 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); | 2299 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); |
| 2287 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2300 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2288 } | 2301 } |
| 2289 | 2302 |
| 2290 | 2303 |
| 2291 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2304 TEST(OptimizedPretenuringMixedInObjectProperties) { |
| 2292 i::FLAG_allow_natives_syntax = true; | 2305 i::FLAG_allow_natives_syntax = true; |
| 2293 i::FLAG_allocation_site_pretenuring = false; | 2306 i::FLAG_max_new_space_size = 2048; |
| 2294 CcTest::InitializeVM(); | 2307 CcTest::InitializeVM(); |
| 2295 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2308 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2296 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2309 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2297 v8::HandleScope scope(CcTest::isolate()); | 2310 v8::HandleScope scope(CcTest::isolate()); |
| 2298 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2299 | 2311 |
| 2300 v8::Local<v8::Value> res = CompileRun( | 2312 v8::Local<v8::Value> res = CompileRun( |
| 2313 "var number_elements = 20000;" |
| 2314 "var elements = new Array(number_elements);" |
| 2301 "function f() {" | 2315 "function f() {" |
| 2302 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" | 2316 " for (var i = 0; i < number_elements; i++) {" |
| 2303 " return numbers;" | 2317 " elements[i] = {a: {c: 2.2, d: {}}, b: 1.1};" |
| 2318 " }" |
| 2319 " return elements[number_elements - 1];" |
| 2304 "};" | 2320 "};" |
| 2305 "f(); f(); f();" | 2321 "f(); f(); f();" |
| 2306 "%OptimizeFunctionOnNextCall(f);" | 2322 "%OptimizeFunctionOnNextCall(f);" |
| 2307 "f();"); | 2323 "f();"); |
| 2308 | 2324 |
| 2309 Handle<JSObject> o = | 2325 Handle<JSObject> o = |
| 2310 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2326 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2311 | 2327 |
| 2312 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2328 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2313 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); | 2329 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); |
| 2314 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); | 2330 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); |
| 2315 | 2331 |
| 2316 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); | 2332 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); |
| 2317 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); | 2333 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); |
| 2318 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); | 2334 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); |
| 2319 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); | 2335 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); |
| 2320 } | 2336 } |
| 2321 | 2337 |
| 2322 | 2338 |
| 2323 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2339 TEST(OptimizedPretenuringDoubleArrayProperties) { |
| 2324 i::FLAG_allow_natives_syntax = true; | 2340 i::FLAG_allow_natives_syntax = true; |
| 2325 i::FLAG_allocation_site_pretenuring = false; | 2341 i::FLAG_max_new_space_size = 2048; |
| 2326 CcTest::InitializeVM(); | 2342 CcTest::InitializeVM(); |
| 2327 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2343 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2328 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2344 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2329 v8::HandleScope scope(CcTest::isolate()); | 2345 v8::HandleScope scope(CcTest::isolate()); |
| 2330 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2331 | 2346 |
| 2332 v8::Local<v8::Value> res = CompileRun( | 2347 v8::Local<v8::Value> res = CompileRun( |
| 2348 "var number_elements = 30000;" |
| 2349 "var elements = new Array(number_elements);" |
| 2333 "function f() {" | 2350 "function f() {" |
| 2334 " var numbers = {a: 1.1, b: 2.2};" | 2351 " for (var i = 0; i < number_elements; i++) {" |
| 2335 " return numbers;" | 2352 " elements[i] = {a: 1.1, b: 2.2};" |
| 2353 " }" |
| 2354 " return elements[i - 1];" |
| 2336 "};" | 2355 "};" |
| 2337 "f(); f(); f();" | 2356 "f(); f(); f();" |
| 2338 "%OptimizeFunctionOnNextCall(f);" | 2357 "%OptimizeFunctionOnNextCall(f);" |
| 2339 "f();"); | 2358 "f();"); |
| 2340 | 2359 |
| 2341 Handle<JSObject> o = | 2360 Handle<JSObject> o = |
| 2342 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2361 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2343 | 2362 |
| 2344 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2363 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2345 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); | 2364 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); |
| 2346 } | 2365 } |
| 2347 | 2366 |
| 2348 | 2367 |
| 2349 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2368 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
| 2350 i::FLAG_allow_natives_syntax = true; | 2369 i::FLAG_allow_natives_syntax = true; |
| 2351 i::FLAG_allocation_site_pretenuring = false; | 2370 i::FLAG_max_new_space_size = 2048; |
| 2352 CcTest::InitializeVM(); | 2371 CcTest::InitializeVM(); |
| 2353 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2372 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2354 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2373 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2355 v8::HandleScope scope(CcTest::isolate()); | 2374 v8::HandleScope scope(CcTest::isolate()); |
| 2356 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2357 | 2375 |
| 2358 v8::Local<v8::Value> res = CompileRun( | 2376 v8::Local<v8::Value> res = CompileRun( |
| 2377 "var number_elements = 20000;" |
| 2378 "var elements = new Array(number_elements);" |
| 2359 "function f() {" | 2379 "function f() {" |
| 2360 " var numbers = [1.1, 2.2, 3.3];" | 2380 " for (var i = 0; i < number_elements; i++) {" |
| 2361 " return numbers;" | 2381 " elements[i] = [1.1, 2.2, 3.3];" |
| 2382 " }" |
| 2383 " return elements[number_elements - 1];" |
| 2362 "};" | 2384 "};" |
| 2363 "f(); f(); f();" | 2385 "f(); f(); f();" |
| 2364 "%OptimizeFunctionOnNextCall(f);" | 2386 "%OptimizeFunctionOnNextCall(f);" |
| 2365 "f();"); | 2387 "f();"); |
| 2366 | 2388 |
| 2367 Handle<JSObject> o = | 2389 Handle<JSObject> o = |
| 2368 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2390 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2369 | 2391 |
| 2370 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); | 2392 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); |
| 2371 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2393 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2372 } | 2394 } |
| 2373 | 2395 |
| 2374 | 2396 |
| 2375 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2397 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
| 2376 i::FLAG_allow_natives_syntax = true; | 2398 i::FLAG_allow_natives_syntax = true; |
| 2377 i::FLAG_allocation_site_pretenuring = false; | 2399 i::FLAG_max_new_space_size = 2048; |
| 2378 CcTest::InitializeVM(); | 2400 CcTest::InitializeVM(); |
| 2379 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2401 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2380 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2402 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2381 v8::HandleScope scope(CcTest::isolate()); | 2403 v8::HandleScope scope(CcTest::isolate()); |
| 2382 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2383 | 2404 |
| 2384 v8::Local<v8::Value> res = CompileRun( | 2405 v8::Local<v8::Value> res = CompileRun( |
| 2406 "var number_elements = 20000;" |
| 2407 "var elements = new Array(number_elements);" |
| 2385 "function f() {" | 2408 "function f() {" |
| 2386 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" | 2409 " for (var i = 0; i < number_elements; i++) {" |
| 2387 " return numbers;" | 2410 " elements[i] = [[{}, {}, {}], [1.1, 2.2, 3.3]];" |
| 2411 " }" |
| 2412 " return elements[number_elements - 1];" |
| 2388 "};" | 2413 "};" |
| 2389 "f(); f(); f();" | 2414 "f(); f(); f();" |
| 2390 "%OptimizeFunctionOnNextCall(f);" | 2415 "%OptimizeFunctionOnNextCall(f);" |
| 2391 "f();"); | 2416 "f();"); |
| 2392 | 2417 |
| 2393 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2418 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
| 2394 Handle<JSObject> int_array_handle = | 2419 Handle<JSObject> int_array_handle = |
| 2395 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2420 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); |
| 2396 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); | 2421 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
| 2397 Handle<JSObject> double_array_handle = | 2422 Handle<JSObject> double_array_handle = |
| 2398 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2423 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
| 2399 | 2424 |
| 2400 Handle<JSObject> o = | 2425 Handle<JSObject> o = |
| 2401 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2426 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2402 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2427 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2403 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); | 2428 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); |
| 2404 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); | 2429 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); |
| 2405 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); | 2430 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); |
| 2406 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); | 2431 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); |
| 2407 } | 2432 } |
| 2408 | 2433 |
| 2409 | 2434 |
| 2410 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2435 TEST(OptimizedPretenuringNestedObjectLiterals) { |
| 2411 i::FLAG_allow_natives_syntax = true; | 2436 i::FLAG_allow_natives_syntax = true; |
| 2412 i::FLAG_allocation_site_pretenuring = false; | 2437 i::FLAG_max_new_space_size = 2048; |
| 2413 CcTest::InitializeVM(); | 2438 CcTest::InitializeVM(); |
| 2414 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2439 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2415 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2440 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2416 v8::HandleScope scope(CcTest::isolate()); | 2441 v8::HandleScope scope(CcTest::isolate()); |
| 2417 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2418 | 2442 |
| 2419 v8::Local<v8::Value> res = CompileRun( | 2443 v8::Local<v8::Value> res = CompileRun( |
| 2444 "var number_elements = 20000;" |
| 2445 "var elements = new Array(number_elements);" |
| 2420 "function f() {" | 2446 "function f() {" |
| 2421 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" | 2447 " for (var i = 0; i < number_elements; i++) {" |
| 2422 " return numbers;" | 2448 " elements[i] = [[{}, {}, {}],[{}, {}, {}]];" |
| 2449 " }" |
| 2450 " return elements[number_elements - 1];" |
| 2423 "};" | 2451 "};" |
| 2424 "f(); f(); f();" | 2452 "f(); f(); f();" |
| 2425 "%OptimizeFunctionOnNextCall(f);" | 2453 "%OptimizeFunctionOnNextCall(f);" |
| 2426 "f();"); | 2454 "f();"); |
| 2427 | 2455 |
| 2428 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); | 2456 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); |
| 2429 Handle<JSObject> int_array_handle_1 = | 2457 Handle<JSObject> int_array_handle_1 = |
| 2430 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); | 2458 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); |
| 2431 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); | 2459 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); |
| 2432 Handle<JSObject> int_array_handle_2 = | 2460 Handle<JSObject> int_array_handle_2 = |
| 2433 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); | 2461 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); |
| 2434 | 2462 |
| 2435 Handle<JSObject> o = | 2463 Handle<JSObject> o = |
| 2436 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2464 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
| 2437 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2465 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
| 2438 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); | 2466 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); |
| 2439 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); | 2467 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); |
| 2440 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); | 2468 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); |
| 2441 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); | 2469 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); |
| 2442 } | 2470 } |
| 2443 | 2471 |
| 2444 | 2472 |
| 2445 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2473 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
| 2446 i::FLAG_allow_natives_syntax = true; | 2474 i::FLAG_allow_natives_syntax = true; |
| 2447 i::FLAG_allocation_site_pretenuring = false; | 2475 i::FLAG_max_new_space_size = 2048; |
| 2448 CcTest::InitializeVM(); | 2476 CcTest::InitializeVM(); |
| 2449 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2477 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
| 2450 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2478 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
| 2451 v8::HandleScope scope(CcTest::isolate()); | 2479 v8::HandleScope scope(CcTest::isolate()); |
| 2452 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
| 2453 | 2480 |
| 2454 v8::Local<v8::Value> res = CompileRun( | 2481 v8::Local<v8::Value> res = CompileRun( |
| 2482 "var number_elements = 20000;" |
| 2483 "var elements = new Array(number_elements);" |
| 2455 "function f() {" | 2484 "function f() {" |
| 2456 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" | 2485 " for (var i = 0; i < number_elements; i++) {" |
| 2457 " return numbers;" | 2486 " elements[i] = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" |
| 2487 " }" |
| 2488 " return elements[number_elements - 1];" |
| 2458 "};" | 2489 "};" |
| 2459 "f(); f(); f();" | 2490 "f(); f(); f();" |
| 2460 "%OptimizeFunctionOnNextCall(f);" | 2491 "%OptimizeFunctionOnNextCall(f);" |
| 2461 "f();"); | 2492 "f();"); |
| 2462 | 2493 |
| 2463 v8::Local<v8::Value> double_array_1 = | 2494 v8::Local<v8::Value> double_array_1 = |
| 2464 v8::Object::Cast(*res)->Get(v8_str("0")); | 2495 v8::Object::Cast(*res)->Get(v8_str("0")); |
| 2465 Handle<JSObject> double_array_handle_1 = | 2496 Handle<JSObject> double_array_handle_1 = |
| 2466 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); | 2497 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); |
| 2467 v8::Local<v8::Value> double_array_2 = | 2498 v8::Local<v8::Value> double_array_2 = |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 TEST(Regress2211) { | 2792 TEST(Regress2211) { |
| 2762 CcTest::InitializeVM(); | 2793 CcTest::InitializeVM(); |
| 2763 v8::HandleScope scope(CcTest::isolate()); | 2794 v8::HandleScope scope(CcTest::isolate()); |
| 2764 | 2795 |
| 2765 v8::Handle<v8::String> value = v8_str("val string"); | 2796 v8::Handle<v8::String> value = v8_str("val string"); |
| 2766 Smi* hash = Smi::FromInt(321); | 2797 Smi* hash = Smi::FromInt(321); |
| 2767 Heap* heap = CcTest::heap(); | 2798 Heap* heap = CcTest::heap(); |
| 2768 | 2799 |
| 2769 for (int i = 0; i < 2; i++) { | 2800 for (int i = 0; i < 2; i++) { |
| 2770 // Store identity hash first and common hidden property second. | 2801 // Store identity hash first and common hidden property second. |
| 2771 v8::Handle<v8::Object> obj = v8::Object::New(); | 2802 v8::Handle<v8::Object> obj = v8::Object::New(CcTest::isolate()); |
| 2772 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); | 2803 Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj); |
| 2773 CHECK(internal_obj->HasFastProperties()); | 2804 CHECK(internal_obj->HasFastProperties()); |
| 2774 | 2805 |
| 2775 // In the first iteration, set hidden value first and identity hash second. | 2806 // In the first iteration, set hidden value first and identity hash second. |
| 2776 // In the second iteration, reverse the order. | 2807 // In the second iteration, reverse the order. |
| 2777 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); | 2808 if (i == 0) obj->SetHiddenValue(v8_str("key string"), value); |
| 2778 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate())); | 2809 JSObject::SetIdentityHash(internal_obj, handle(hash, CcTest::i_isolate())); |
| 2779 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); | 2810 if (i == 1) obj->SetHiddenValue(v8_str("key string"), value); |
| 2780 | 2811 |
| 2781 // Check values. | 2812 // Check values. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2832 | 2863 |
| 2833 CHECK_EQ(2, cells->CellCount()); | 2864 CHECK_EQ(2, cells->CellCount()); |
| 2834 CHECK(cells->GetCell(0)->value()->IsTheHole()); | 2865 CHECK(cells->GetCell(0)->value()->IsTheHole()); |
| 2835 CHECK(cells->GetCell(1)->value()->IsTheHole()); | 2866 CHECK(cells->GetCell(1)->value()->IsTheHole()); |
| 2836 } | 2867 } |
| 2837 | 2868 |
| 2838 | 2869 |
| 2839 static Code* FindFirstIC(Code* code, Code::Kind kind) { | 2870 static Code* FindFirstIC(Code* code, Code::Kind kind) { |
| 2840 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 2871 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
| 2841 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 2872 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
| 2842 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | | 2873 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
| 2843 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); | |
| 2844 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 2874 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
| 2845 RelocInfo* info = it.rinfo(); | 2875 RelocInfo* info = it.rinfo(); |
| 2846 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); | 2876 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); |
| 2847 if (target->is_inline_cache_stub() && target->kind() == kind) { | 2877 if (target->is_inline_cache_stub() && target->kind() == kind) { |
| 2848 return target; | 2878 return target; |
| 2849 } | 2879 } |
| 2850 } | 2880 } |
| 2851 return NULL; | 2881 return NULL; |
| 2852 } | 2882 } |
| 2853 | 2883 |
| 2854 | 2884 |
| 2855 TEST(IncrementalMarkingPreservesMonomorhpicIC) { | 2885 TEST(IncrementalMarkingPreservesMonomorphicIC) { |
| 2856 if (i::FLAG_always_opt) return; | 2886 if (i::FLAG_always_opt) return; |
| 2857 CcTest::InitializeVM(); | 2887 CcTest::InitializeVM(); |
| 2858 v8::HandleScope scope(CcTest::isolate()); | 2888 v8::HandleScope scope(CcTest::isolate()); |
| 2859 | 2889 |
| 2860 // Prepare function f that contains a monomorphic IC for object | 2890 // Prepare function f that contains a monomorphic IC for object |
| 2861 // originating from the same native context. | 2891 // originating from the same native context. |
| 2862 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" | 2892 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" |
| 2863 "function f(o) { return o.x; } f(obj); f(obj);"); | 2893 "function f(o) { return o.x; } f(obj); f(obj);"); |
| 2864 Handle<JSFunction> f = | 2894 Handle<JSFunction> f = |
| 2865 v8::Utils::OpenHandle( | 2895 v8::Utils::OpenHandle( |
| 2866 *v8::Handle<v8::Function>::Cast( | 2896 *v8::Handle<v8::Function>::Cast( |
| 2867 CcTest::global()->Get(v8_str("f")))); | 2897 CcTest::global()->Get(v8_str("f")))); |
| 2868 | 2898 |
| 2869 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2899 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 2870 CHECK(ic_before->ic_state() == MONOMORPHIC); | 2900 CHECK(ic_before->ic_state() == MONOMORPHIC); |
| 2871 | 2901 |
| 2872 SimulateIncrementalMarking(); | 2902 SimulateIncrementalMarking(); |
| 2873 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2903 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 2874 | 2904 |
| 2875 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2905 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 2876 CHECK(ic_after->ic_state() == MONOMORPHIC); | 2906 CHECK(ic_after->ic_state() == MONOMORPHIC); |
| 2877 } | 2907 } |
| 2878 | 2908 |
| 2879 | 2909 |
| 2880 TEST(IncrementalMarkingClearsMonomorhpicIC) { | 2910 TEST(IncrementalMarkingClearsMonomorphicIC) { |
| 2881 if (i::FLAG_always_opt) return; | 2911 if (i::FLAG_always_opt) return; |
| 2882 CcTest::InitializeVM(); | 2912 CcTest::InitializeVM(); |
| 2883 v8::HandleScope scope(CcTest::isolate()); | 2913 v8::HandleScope scope(CcTest::isolate()); |
| 2884 v8::Local<v8::Value> obj1; | 2914 v8::Local<v8::Value> obj1; |
| 2885 | 2915 |
| 2886 { | 2916 { |
| 2887 LocalContext env; | 2917 LocalContext env; |
| 2888 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 2918 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
| 2889 obj1 = env->Global()->Get(v8_str("obj")); | 2919 obj1 = env->Global()->Get(v8_str("obj")); |
| 2890 } | 2920 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2904 // Fire context dispose notification. | 2934 // Fire context dispose notification. |
| 2905 v8::V8::ContextDisposedNotification(); | 2935 v8::V8::ContextDisposedNotification(); |
| 2906 SimulateIncrementalMarking(); | 2936 SimulateIncrementalMarking(); |
| 2907 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2937 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 2908 | 2938 |
| 2909 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2939 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| 2910 CHECK(IC::IsCleared(ic_after)); | 2940 CHECK(IC::IsCleared(ic_after)); |
| 2911 } | 2941 } |
| 2912 | 2942 |
| 2913 | 2943 |
| 2914 TEST(IncrementalMarkingClearsPolymorhpicIC) { | 2944 TEST(IncrementalMarkingClearsPolymorphicIC) { |
| 2915 if (i::FLAG_always_opt) return; | 2945 if (i::FLAG_always_opt) return; |
| 2916 CcTest::InitializeVM(); | 2946 CcTest::InitializeVM(); |
| 2917 v8::HandleScope scope(CcTest::isolate()); | 2947 v8::HandleScope scope(CcTest::isolate()); |
| 2918 v8::Local<v8::Value> obj1, obj2; | 2948 v8::Local<v8::Value> obj1, obj2; |
| 2919 | 2949 |
| 2920 { | 2950 { |
| 2921 LocalContext env; | 2951 LocalContext env; |
| 2922 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 2952 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
| 2923 obj1 = env->Global()->Get(v8_str("obj")); | 2953 obj1 = env->Global()->Get(v8_str("obj")); |
| 2924 } | 2954 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 Isolate* isolate = CcTest::i_isolate(); | 3083 Isolate* isolate = CcTest::i_isolate(); |
| 3054 Heap* heap = isolate->heap(); | 3084 Heap* heap = isolate->heap(); |
| 3055 HandleScope scope(isolate); | 3085 HandleScope scope(isolate); |
| 3056 | 3086 |
| 3057 // First make sure that the uninitialized CallIC stub is on a single page | 3087 // First make sure that the uninitialized CallIC stub is on a single page |
| 3058 // that will later be selected as an evacuation candidate. | 3088 // that will later be selected as an evacuation candidate. |
| 3059 { | 3089 { |
| 3060 HandleScope inner_scope(isolate); | 3090 HandleScope inner_scope(isolate); |
| 3061 AlwaysAllocateScope always_allocate; | 3091 AlwaysAllocateScope always_allocate; |
| 3062 SimulateFullSpace(heap->code_space()); | 3092 SimulateFullSpace(heap->code_space()); |
| 3063 isolate->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET); | 3093 isolate->stub_cache()->ComputeCallInitialize(9, NOT_CONTEXTUAL); |
| 3064 } | 3094 } |
| 3065 | 3095 |
| 3066 // Second compile a CallIC and execute it once so that it gets patched to | 3096 // Second compile a CallIC and execute it once so that it gets patched to |
| 3067 // the pre-monomorphic stub. These code objects are on yet another page. | 3097 // the pre-monomorphic stub. These code objects are on yet another page. |
| 3068 { | 3098 { |
| 3069 HandleScope inner_scope(isolate); | 3099 HandleScope inner_scope(isolate); |
| 3070 AlwaysAllocateScope always_allocate; | 3100 AlwaysAllocateScope always_allocate; |
| 3071 SimulateFullSpace(heap->code_space()); | 3101 SimulateFullSpace(heap->code_space()); |
| 3072 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};" | 3102 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};" |
| 3073 "function call() { o.f(1,2,3,4,5,6,7,8,9); };" | 3103 "function call() { o.f(1,2,3,4,5,6,7,8,9); };" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3330 "}" | 3360 "}" |
| 3331 "obj = fastliteralcase(get_standard_literal(), 1);" | 3361 "obj = fastliteralcase(get_standard_literal(), 1);" |
| 3332 "obj = fastliteralcase(get_standard_literal(), 1.5);" | 3362 "obj = fastliteralcase(get_standard_literal(), 1.5);" |
| 3333 "obj = fastliteralcase(get_standard_literal(), 2);"); | 3363 "obj = fastliteralcase(get_standard_literal(), 2);"); |
| 3334 | 3364 |
| 3335 // prepare the heap | 3365 // prepare the heap |
| 3336 v8::Local<v8::String> mote_code_string = | 3366 v8::Local<v8::String> mote_code_string = |
| 3337 v8_str("fastliteralcase(mote, 2.5);"); | 3367 v8_str("fastliteralcase(mote, 2.5);"); |
| 3338 | 3368 |
| 3339 v8::Local<v8::String> array_name = v8_str("mote"); | 3369 v8::Local<v8::String> array_name = v8_str("mote"); |
| 3340 CcTest::global()->Set(array_name, v8::Int32::New(0)); | 3370 CcTest::global()->Set(array_name, v8::Int32::New(CcTest::isolate(), 0)); |
| 3341 | 3371 |
| 3342 // First make sure we flip spaces | 3372 // First make sure we flip spaces |
| 3343 CcTest::heap()->CollectGarbage(NEW_SPACE); | 3373 CcTest::heap()->CollectGarbage(NEW_SPACE); |
| 3344 | 3374 |
| 3345 // Allocate the object. | 3375 // Allocate the object. |
| 3346 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); | 3376 Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); |
| 3347 array_data->set(0, Smi::FromInt(1)); | 3377 array_data->set(0, Smi::FromInt(1)); |
| 3348 array_data->set(1, Smi::FromInt(2)); | 3378 array_data->set(1, Smi::FromInt(2)); |
| 3349 | 3379 |
| 3350 AllocateAllButNBytes(CcTest::heap()->new_space(), | 3380 AllocateAllButNBytes(CcTest::heap()->new_space(), |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 for (int i = 0; i < 4; i++) { | 3657 for (int i = 0; i < 4; i++) { |
| 3628 heap->CollectAllGarbage(false); | 3658 heap->CollectAllGarbage(false); |
| 3629 } | 3659 } |
| 3630 | 3660 |
| 3631 // The site still exists because of our global handle, but the code is no | 3661 // The site still exists because of our global handle, but the code is no |
| 3632 // longer referred to by dependent_code(). | 3662 // longer referred to by dependent_code(). |
| 3633 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3663 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
| 3634 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3664 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
| 3635 CHECK(!(site->dependent_code()->is_code_at(index))); | 3665 CHECK(!(site->dependent_code()->is_code_at(index))); |
| 3636 } | 3666 } |
| OLD | NEW |