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; | |
2194 CcTest::InitializeVM(); | 2193 CcTest::InitializeVM(); |
2195 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2194 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2196 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2195 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2197 v8::HandleScope scope(CcTest::isolate()); | 2196 v8::HandleScope scope(CcTest::isolate()); |
2198 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | 2197 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); |
2199 | 2198 |
2200 v8::Local<v8::Value> res = CompileRun( | 2199 v8::Local<v8::Value> res = CompileRun( |
2201 "function DataObject() {" | 2200 "function DataObject() {" |
2202 " this.a = 1.1;" | 2201 " this.a = 1.1;" |
2203 " this.b = [{}];" | 2202 " this.b = [{}];" |
2204 " this.c = 1.2;" | 2203 " this.c = 1.2;" |
2205 " this.d = [{}];" | 2204 " this.d = [{}];" |
2206 " this.e = 1.3;" | 2205 " this.e = 1.3;" |
2207 " this.f = [{}];" | 2206 " this.f = [{}];" |
2208 "}" | 2207 "}" |
| 2208 "var number_elements = 100000;" |
| 2209 "var elements = new Array();" |
2209 "function f() {" | 2210 "function f() {" |
2210 " return new DataObject();" | 2211 " for (var i = 0; i < 100000-1; i++) {" |
| 2212 " elements[i] = new DataObject();" |
| 2213 " }" |
| 2214 " return new DataObject()" |
2211 "};" | 2215 "};" |
2212 "f(); f(); f();" | 2216 "f(); f(); f();" |
2213 "%OptimizeFunctionOnNextCall(f);" | 2217 "%OptimizeFunctionOnNextCall(f);" |
2214 "f();"); | 2218 "f();"); |
2215 | 2219 |
2216 Handle<JSObject> o = | 2220 Handle<JSObject> o = |
2217 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2221 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2218 | 2222 |
2219 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0))); | 2223 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0))); |
2220 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); | 2224 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); |
2221 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); | 2225 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); |
2222 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3))); | 2226 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3))); |
2223 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4))); | 2227 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4))); |
2224 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5))); | 2228 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5))); |
2225 } | 2229 } |
2226 | 2230 |
2227 | 2231 |
2228 TEST(OptimizedPretenuringAllocationFoldingBlocks) { | 2232 TEST(OptimizedPretenuringAllocationFoldingBlocks) { |
2229 i::FLAG_allow_natives_syntax = true; | 2233 i::FLAG_allow_natives_syntax = true; |
2230 i::FLAG_allocation_site_pretenuring = false; | |
2231 CcTest::InitializeVM(); | 2234 CcTest::InitializeVM(); |
2232 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2235 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2233 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2236 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2234 v8::HandleScope scope(CcTest::isolate()); | 2237 v8::HandleScope scope(CcTest::isolate()); |
2235 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | 2238 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); |
2236 | 2239 |
2237 v8::Local<v8::Value> res = CompileRun( | 2240 v8::Local<v8::Value> res = CompileRun( |
| 2241 "var number_elements = 3000;" |
| 2242 "var current_counter = 0;" |
| 2243 "var elements = new Array(number_elements * 4);" |
2238 "function DataObject() {" | 2244 "function DataObject() {" |
2239 " this.a = [{}];" | 2245 " this.a = [{}];" |
2240 " this.b = [{}];" | 2246 " this.b = [{}];" |
2241 " this.c = 1.1;" | 2247 " this.c = 1.1;" |
2242 " this.d = 1.2;" | 2248 " this.d = 1.2;" |
2243 " this.e = [{}];" | 2249 " this.e = [{}];" |
2244 " this.f = 1.3;" | 2250 " this.f = 1.3;" |
2245 "}" | 2251 "}" |
2246 "function f() {" | 2252 "function f() {" |
2247 " return new DataObject();" | 2253 " for (var i = 0; i < number_elements; i++) {" |
| 2254 " elements[current_counter] = new DataObject();" |
| 2255 " current_counter++;" |
| 2256 " }" |
| 2257 " return elements[current_counter - 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; | |
2268 CcTest::InitializeVM(); | 2277 CcTest::InitializeVM(); |
2269 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2278 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2270 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2279 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2271 v8::HandleScope scope(CcTest::isolate()); | 2280 v8::HandleScope scope(CcTest::isolate()); |
2272 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2273 | 2281 |
2274 v8::Local<v8::Value> res = CompileRun( | 2282 v8::Local<v8::Value> res = CompileRun( |
| 2283 "var number_elements = 100000;" |
| 2284 "var current_counter = 0;" |
| 2285 "var elements = new Array(number_elements * 4);" |
2275 "function f() {" | 2286 "function f() {" |
2276 " var numbers = [{}, {}, {}];" | 2287 " for (var i = 0; i < number_elements; i++) {" |
2277 " return numbers;" | 2288 " elements[current_counter] = [{}, {}, {}];" |
| 2289 " current_counter++;" |
| 2290 " }" |
| 2291 " return elements[current_counter - 1];" |
2278 "};" | 2292 "};" |
2279 "f(); f(); f();" | 2293 "f(); f(); f();" |
2280 "%OptimizeFunctionOnNextCall(f);" | 2294 "%OptimizeFunctionOnNextCall(f);" |
2281 "f();"); | 2295 "f();"); |
2282 | 2296 |
2283 Handle<JSObject> o = | 2297 Handle<JSObject> o = |
2284 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2298 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2285 | 2299 |
2286 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); | 2300 CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); |
2287 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2301 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2288 } | 2302 } |
2289 | 2303 |
2290 | 2304 |
2291 TEST(OptimizedPretenuringMixedInObjectProperties) { | 2305 TEST(OptimizedPretenuringMixedInObjectProperties) { |
2292 i::FLAG_allow_natives_syntax = true; | 2306 i::FLAG_allow_natives_syntax = true; |
2293 i::FLAG_allocation_site_pretenuring = false; | |
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 = 100000;" |
| 2314 "var current_counter = 0;" |
| 2315 "var elements = new Array(number_elements * 4);" |
2301 "function f() {" | 2316 "function f() {" |
2302 " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};" | 2317 " for (var i = 0; i < number_elements; i++) {" |
2303 " return numbers;" | 2318 " elements[current_counter] = {a: {c: 2.2, d: {}}, b: 1.1};" |
| 2319 " current_counter++;" |
| 2320 " }" |
| 2321 " return elements[current_counter - 1];" |
2304 "};" | 2322 "};" |
2305 "f(); f(); f();" | 2323 "f(); f(); f();" |
2306 "%OptimizeFunctionOnNextCall(f);" | 2324 "%OptimizeFunctionOnNextCall(f);" |
2307 "f();"); | 2325 "f();"); |
2308 | 2326 |
2309 Handle<JSObject> o = | 2327 Handle<JSObject> o = |
2310 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2328 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2311 | 2329 |
2312 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2330 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2313 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); | 2331 CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); |
2314 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); | 2332 CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); |
2315 | 2333 |
2316 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); | 2334 JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); |
2317 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); | 2335 CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); |
2318 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); | 2336 CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); |
2319 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); | 2337 CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); |
2320 } | 2338 } |
2321 | 2339 |
2322 | 2340 |
2323 TEST(OptimizedPretenuringDoubleArrayProperties) { | 2341 TEST(OptimizedPretenuringDoubleArrayProperties) { |
2324 i::FLAG_allow_natives_syntax = true; | 2342 i::FLAG_allow_natives_syntax = true; |
2325 i::FLAG_allocation_site_pretenuring = false; | |
2326 CcTest::InitializeVM(); | 2343 CcTest::InitializeVM(); |
2327 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2344 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2328 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2345 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2329 v8::HandleScope scope(CcTest::isolate()); | 2346 v8::HandleScope scope(CcTest::isolate()); |
2330 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2331 | 2347 |
2332 v8::Local<v8::Value> res = CompileRun( | 2348 v8::Local<v8::Value> res = CompileRun( |
| 2349 "var number_elements = 100000;" |
| 2350 "var current_counter = 0;" |
| 2351 "var elements = new Array(number_elements * 4);" |
2333 "function f() {" | 2352 "function f() {" |
2334 " var numbers = {a: 1.1, b: 2.2};" | 2353 " for (var i = 0; i < number_elements; i++) {" |
2335 " return numbers;" | 2354 " elements[current_counter] = {a: 1.1, b: 2.2};" |
| 2355 " current_counter++;" |
| 2356 " }" |
| 2357 " return elements[current_counter - 1];" |
2336 "};" | 2358 "};" |
2337 "f(); f(); f();" | 2359 "f(); f(); f();" |
2338 "%OptimizeFunctionOnNextCall(f);" | 2360 "%OptimizeFunctionOnNextCall(f);" |
2339 "f();"); | 2361 "f();"); |
2340 | 2362 |
2341 Handle<JSObject> o = | 2363 Handle<JSObject> o = |
2342 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2364 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2343 | 2365 |
2344 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2366 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2345 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); | 2367 CHECK(CcTest::heap()->InOldDataSpace(o->properties())); |
2346 } | 2368 } |
2347 | 2369 |
2348 | 2370 |
2349 TEST(OptimizedPretenuringdoubleArrayLiterals) { | 2371 TEST(OptimizedPretenuringdoubleArrayLiterals) { |
2350 i::FLAG_allow_natives_syntax = true; | 2372 i::FLAG_allow_natives_syntax = true; |
2351 i::FLAG_allocation_site_pretenuring = false; | |
2352 CcTest::InitializeVM(); | 2373 CcTest::InitializeVM(); |
2353 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2374 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2354 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2375 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2355 v8::HandleScope scope(CcTest::isolate()); | 2376 v8::HandleScope scope(CcTest::isolate()); |
2356 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2357 | 2377 |
2358 v8::Local<v8::Value> res = CompileRun( | 2378 v8::Local<v8::Value> res = CompileRun( |
| 2379 "var number_elements = 100000;" |
| 2380 "var current_counter = 0;" |
| 2381 "var elements = new Array(number_elements * 4);" |
2359 "function f() {" | 2382 "function f() {" |
2360 " var numbers = [1.1, 2.2, 3.3];" | 2383 " for (var i = 0; i < number_elements; i++) {" |
2361 " return numbers;" | 2384 " elements[current_counter] = [1.1, 2.2, 3.3];" |
| 2385 " current_counter++;" |
| 2386 " }" |
| 2387 " return elements[current_counter - 1];" |
2362 "};" | 2388 "};" |
2363 "f(); f(); f();" | 2389 "f(); f(); f();" |
2364 "%OptimizeFunctionOnNextCall(f);" | 2390 "%OptimizeFunctionOnNextCall(f);" |
2365 "f();"); | 2391 "f();"); |
2366 | 2392 |
2367 Handle<JSObject> o = | 2393 Handle<JSObject> o = |
2368 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2394 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2369 | 2395 |
2370 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); | 2396 CHECK(CcTest::heap()->InOldDataSpace(o->elements())); |
2371 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2397 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2372 } | 2398 } |
2373 | 2399 |
2374 | 2400 |
2375 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { | 2401 TEST(OptimizedPretenuringNestedMixedArrayLiterals) { |
2376 i::FLAG_allow_natives_syntax = true; | 2402 i::FLAG_allow_natives_syntax = true; |
2377 i::FLAG_allocation_site_pretenuring = false; | |
2378 CcTest::InitializeVM(); | 2403 CcTest::InitializeVM(); |
2379 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2404 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2380 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2405 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2381 v8::HandleScope scope(CcTest::isolate()); | 2406 v8::HandleScope scope(CcTest::isolate()); |
2382 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2383 | 2407 |
2384 v8::Local<v8::Value> res = CompileRun( | 2408 v8::Local<v8::Value> res = CompileRun( |
| 2409 "var number_elements = 100000;" |
| 2410 "var current_counter = 0;" |
| 2411 "var elements = new Array(number_elements * 4);" |
2385 "function f() {" | 2412 "function f() {" |
2386 " var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];" | 2413 " for (var i = 0; i < number_elements; i++) {" |
2387 " return numbers;" | 2414 " elements[current_counter] = [[{}, {}, {}], [1.1, 2.2, 3.3]];" |
| 2415 " current_counter++;" |
| 2416 " }" |
| 2417 " return elements[current_counter - 1];" |
2388 "};" | 2418 "};" |
2389 "f(); f(); f();" | 2419 "f(); f(); f();" |
2390 "%OptimizeFunctionOnNextCall(f);" | 2420 "%OptimizeFunctionOnNextCall(f);" |
2391 "f();"); | 2421 "f();"); |
2392 | 2422 |
2393 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); | 2423 v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0")); |
2394 Handle<JSObject> int_array_handle = | 2424 Handle<JSObject> int_array_handle = |
2395 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array)); | 2425 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")); | 2426 v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1")); |
2397 Handle<JSObject> double_array_handle = | 2427 Handle<JSObject> double_array_handle = |
2398 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); | 2428 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array)); |
2399 | 2429 |
2400 Handle<JSObject> o = | 2430 Handle<JSObject> o = |
2401 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2431 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2402 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2432 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2403 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); | 2433 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); |
2404 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); | 2434 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); |
2405 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); | 2435 CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); |
2406 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); | 2436 CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); |
2407 } | 2437 } |
2408 | 2438 |
2409 | 2439 |
2410 TEST(OptimizedPretenuringNestedObjectLiterals) { | 2440 TEST(OptimizedPretenuringNestedObjectLiterals) { |
2411 i::FLAG_allow_natives_syntax = true; | 2441 i::FLAG_allow_natives_syntax = true; |
2412 i::FLAG_allocation_site_pretenuring = false; | |
2413 CcTest::InitializeVM(); | 2442 CcTest::InitializeVM(); |
2414 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2443 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2415 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2444 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2416 v8::HandleScope scope(CcTest::isolate()); | 2445 v8::HandleScope scope(CcTest::isolate()); |
2417 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2418 | 2446 |
2419 v8::Local<v8::Value> res = CompileRun( | 2447 v8::Local<v8::Value> res = CompileRun( |
| 2448 "var number_elements = 100000;" |
| 2449 "var current_counter = 0;" |
| 2450 "var elements = new Array(number_elements * 4);" |
2420 "function f() {" | 2451 "function f() {" |
2421 " var numbers = [[{}, {}, {}],[{}, {}, {}]];" | 2452 " for (var i = 0; i < number_elements; i++) {" |
2422 " return numbers;" | 2453 " elements[current_counter] = [[{}, {}, {}],[{}, {}, {}]];" |
| 2454 " current_counter++;" |
| 2455 " }" |
| 2456 " return elements[current_counter - 1];" |
2423 "};" | 2457 "};" |
2424 "f(); f(); f();" | 2458 "f(); f(); f();" |
2425 "%OptimizeFunctionOnNextCall(f);" | 2459 "%OptimizeFunctionOnNextCall(f);" |
2426 "f();"); | 2460 "f();"); |
2427 | 2461 |
2428 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); | 2462 v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0")); |
2429 Handle<JSObject> int_array_handle_1 = | 2463 Handle<JSObject> int_array_handle_1 = |
2430 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1)); | 2464 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")); | 2465 v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1")); |
2432 Handle<JSObject> int_array_handle_2 = | 2466 Handle<JSObject> int_array_handle_2 = |
2433 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); | 2467 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2)); |
2434 | 2468 |
2435 Handle<JSObject> o = | 2469 Handle<JSObject> o = |
2436 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); | 2470 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); |
2437 CHECK(CcTest::heap()->InOldPointerSpace(*o)); | 2471 CHECK(CcTest::heap()->InOldPointerSpace(*o)); |
2438 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); | 2472 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); |
2439 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); | 2473 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); |
2440 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); | 2474 CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); |
2441 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); | 2475 CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); |
2442 } | 2476 } |
2443 | 2477 |
2444 | 2478 |
2445 TEST(OptimizedPretenuringNestedDoubleLiterals) { | 2479 TEST(OptimizedPretenuringNestedDoubleLiterals) { |
2446 i::FLAG_allow_natives_syntax = true; | 2480 i::FLAG_allow_natives_syntax = true; |
2447 i::FLAG_allocation_site_pretenuring = false; | |
2448 CcTest::InitializeVM(); | 2481 CcTest::InitializeVM(); |
2449 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2482 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2450 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2483 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2451 v8::HandleScope scope(CcTest::isolate()); | 2484 v8::HandleScope scope(CcTest::isolate()); |
2452 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2453 | 2485 |
2454 v8::Local<v8::Value> res = CompileRun( | 2486 v8::Local<v8::Value> res = CompileRun( |
| 2487 "var number_elements = 100000;" |
| 2488 "var current_counter = 0;" |
| 2489 "var elements = new Array(number_elements * 4);" |
2455 "function f() {" | 2490 "function f() {" |
2456 " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" | 2491 " for (var i = 0; i < number_elements; i++) {" |
2457 " return numbers;" | 2492 " elements[current_counter] = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];" |
| 2493 " current_counter++;" |
| 2494 " }" |
| 2495 " return elements[current_counter - 1];" |
2458 "};" | 2496 "};" |
2459 "f(); f(); f();" | 2497 "f(); f(); f();" |
2460 "%OptimizeFunctionOnNextCall(f);" | 2498 "%OptimizeFunctionOnNextCall(f);" |
2461 "f();"); | 2499 "f();"); |
2462 | 2500 |
2463 v8::Local<v8::Value> double_array_1 = | 2501 v8::Local<v8::Value> double_array_1 = |
2464 v8::Object::Cast(*res)->Get(v8_str("0")); | 2502 v8::Object::Cast(*res)->Get(v8_str("0")); |
2465 Handle<JSObject> double_array_handle_1 = | 2503 Handle<JSObject> double_array_handle_1 = |
2466 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); | 2504 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1)); |
2467 v8::Local<v8::Value> double_array_2 = | 2505 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++) { | 3664 for (int i = 0; i < 4; i++) { |
3627 heap->CollectAllGarbage(false); | 3665 heap->CollectAllGarbage(false); |
3628 } | 3666 } |
3629 | 3667 |
3630 // The site still exists because of our global handle, but the code is no | 3668 // The site still exists because of our global handle, but the code is no |
3631 // longer referred to by dependent_code(). | 3669 // longer referred to by dependent_code(). |
3632 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3670 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3633 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3671 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3634 CHECK(!(site->dependent_code()->is_code_at(index))); | 3672 CHECK(!(site->dependent_code()->is_code_at(index))); |
3635 } | 3673 } |
OLD | NEW |