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 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2193 | 2193 |
2194 | 2194 |
2195 TEST(OptimizedPretenuringAllocationFolding) { | 2195 TEST(OptimizedPretenuringAllocationFolding) { |
2196 i::FLAG_allow_natives_syntax = true; | 2196 i::FLAG_allow_natives_syntax = true; |
2197 i::FLAG_max_semi_space_size = 1; | 2197 i::FLAG_max_semi_space_size = 1; |
2198 i::FLAG_allocation_site_pretenuring = false; | 2198 i::FLAG_allocation_site_pretenuring = false; |
2199 CcTest::InitializeVM(); | 2199 CcTest::InitializeVM(); |
2200 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2200 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2201 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2201 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2202 v8::HandleScope scope(CcTest::isolate()); | 2202 v8::HandleScope scope(CcTest::isolate()); |
2203 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2204 | 2203 |
2205 v8::Local<v8::Value> res = CompileRun( | 2204 v8::Local<v8::Value> res = CompileRun( |
2206 "function DataObject() {" | 2205 "function DataObject() {" |
2207 " this.a = 1.1;" | 2206 " this.a = 1.1;" |
2208 " this.b = [{}];" | 2207 " this.b = [{}];" |
2209 " this.c = 1.2;" | 2208 " this.c = 1.2;" |
2210 " this.d = [{}];" | 2209 " this.d = [{}];" |
2211 " this.e = 1.3;" | 2210 " this.e = 1.3;" |
2212 " this.f = [{}];" | 2211 " this.f = [{}];" |
2213 "}" | 2212 "}" |
(...skipping 22 matching lines...) Expand all Loading... |
2236 | 2235 |
2237 | 2236 |
2238 TEST(OptimizedPretenuringAllocationFoldingBlocks) { | 2237 TEST(OptimizedPretenuringAllocationFoldingBlocks) { |
2239 i::FLAG_allow_natives_syntax = true; | 2238 i::FLAG_allow_natives_syntax = true; |
2240 i::FLAG_max_semi_space_size = 1; | 2239 i::FLAG_max_semi_space_size = 1; |
2241 i::FLAG_allocation_site_pretenuring = false; | 2240 i::FLAG_allocation_site_pretenuring = false; |
2242 CcTest::InitializeVM(); | 2241 CcTest::InitializeVM(); |
2243 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2242 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2244 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2243 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2245 v8::HandleScope scope(CcTest::isolate()); | 2244 v8::HandleScope scope(CcTest::isolate()); |
2246 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2247 | 2245 |
2248 v8::Local<v8::Value> res = CompileRun( | 2246 v8::Local<v8::Value> res = CompileRun( |
2249 "var number_elements = 30000;" | 2247 "var number_elements = 30000;" |
2250 "var elements = new Array(number_elements);" | 2248 "var elements = new Array(number_elements);" |
2251 "function DataObject() {" | 2249 "function DataObject() {" |
2252 " this.a = [{}];" | 2250 " this.a = [{}];" |
2253 " this.b = [{}];" | 2251 " this.b = [{}];" |
2254 " this.c = 1.1;" | 2252 " this.c = 1.1;" |
2255 " this.d = 1.2;" | 2253 " this.d = 1.2;" |
2256 " this.e = [{}];" | 2254 " this.e = [{}];" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2583 | 2581 |
2584 // Test global pretenuring call new. | 2582 // Test global pretenuring call new. |
2585 TEST(OptimizedPretenuringCallNew) { | 2583 TEST(OptimizedPretenuringCallNew) { |
2586 i::FLAG_allow_natives_syntax = true; | 2584 i::FLAG_allow_natives_syntax = true; |
2587 i::FLAG_allocation_site_pretenuring = false; | 2585 i::FLAG_allocation_site_pretenuring = false; |
2588 i::FLAG_pretenuring_call_new = true; | 2586 i::FLAG_pretenuring_call_new = true; |
2589 CcTest::InitializeVM(); | 2587 CcTest::InitializeVM(); |
2590 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 2588 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
2591 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; | 2589 if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; |
2592 v8::HandleScope scope(CcTest::isolate()); | 2590 v8::HandleScope scope(CcTest::isolate()); |
2593 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
2594 | 2591 |
2595 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 2592 AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |
2596 v8::Local<v8::Value> res = CompileRun( | 2593 v8::Local<v8::Value> res = CompileRun( |
2597 "function g() { this.a = 0; }" | 2594 "function g() { this.a = 0; }" |
2598 "function f() {" | 2595 "function f() {" |
2599 " return new g();" | 2596 " return new g();" |
2600 "};" | 2597 "};" |
2601 "f(); f(); f();" | 2598 "f(); f(); f();" |
2602 "%OptimizeFunctionOnNextCall(f);" | 2599 "%OptimizeFunctionOnNextCall(f);" |
2603 "f();"); | 2600 "f();"); |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3716 " %DeoptimizeFunction(test);" | 3713 " %DeoptimizeFunction(test);" |
3717 "}"); | 3714 "}"); |
3718 | 3715 |
3719 // Warm-up with inline allocation enabled. | 3716 // Warm-up with inline allocation enabled. |
3720 CompileRun("test(); test(); run();"); | 3717 CompileRun("test(); test(); run();"); |
3721 | 3718 |
3722 // Run test with inline allocation disabled. | 3719 // Run test with inline allocation disabled. |
3723 CcTest::heap()->DisableInlineAllocation(); | 3720 CcTest::heap()->DisableInlineAllocation(); |
3724 CompileRun("run()"); | 3721 CompileRun("run()"); |
3725 | 3722 |
3726 // Run test with inline allocation disabled and pretenuring. | |
3727 CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); | |
3728 CompileRun("run()"); | |
3729 | |
3730 // Run test with inline allocation re-enabled. | 3723 // Run test with inline allocation re-enabled. |
3731 CcTest::heap()->EnableInlineAllocation(); | 3724 CcTest::heap()->EnableInlineAllocation(); |
3732 CompileRun("run()"); | 3725 CompileRun("run()"); |
3733 } | 3726 } |
3734 | 3727 |
3735 | 3728 |
3736 static int AllocationSitesCount(Heap* heap) { | 3729 static int AllocationSitesCount(Heap* heap) { |
3737 int count = 0; | 3730 int count = 0; |
3738 for (Object* site = heap->allocation_sites_list(); | 3731 for (Object* site = heap->allocation_sites_list(); |
3739 !(site->IsUndefined()); | 3732 !(site->IsUndefined()); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4242 "array;"); | 4235 "array;"); |
4243 | 4236 |
4244 Handle<JSObject> o = | 4237 Handle<JSObject> o = |
4245 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4238 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
4246 CHECK(heap->InOldPointerSpace(o->elements())); | 4239 CHECK(heap->InOldPointerSpace(o->elements())); |
4247 CHECK(heap->InOldPointerSpace(*o)); | 4240 CHECK(heap->InOldPointerSpace(*o)); |
4248 Page* page = Page::FromAddress(o->elements()->address()); | 4241 Page* page = Page::FromAddress(o->elements()->address()); |
4249 CHECK(page->WasSwept() || | 4242 CHECK(page->WasSwept() || |
4250 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4243 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
4251 } | 4244 } |
OLD | NEW |