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 2172 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 = 3000;" |
| 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 = 20000;" |
| 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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3626 for (int i = 0; i < 4; i++) { | 3657 for (int i = 0; i < 4; i++) { |
3627 heap->CollectAllGarbage(false); | 3658 heap->CollectAllGarbage(false); |
3628 } | 3659 } |
3629 | 3660 |
3630 // 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 |
3631 // longer referred to by dependent_code(). | 3662 // longer referred to by dependent_code(). |
3632 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3663 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3633 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3664 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3634 CHECK(!(site->dependent_code()->is_code_at(index))); | 3665 CHECK(!(site->dependent_code()->is_code_at(index))); |
3635 } | 3666 } |
OLD | NEW |