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 3679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3690 code = scope.CloseAndEscape(Handle<Code>(bar->code())); | 3690 code = scope.CloseAndEscape(Handle<Code>(bar->code())); |
3691 } | 3691 } |
3692 | 3692 |
3693 // Now make sure that a gc should get rid of the function | 3693 // Now make sure that a gc should get rid of the function |
3694 for (int i = 0; i < 4; i++) { | 3694 for (int i = 0; i < 4; i++) { |
3695 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3695 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3696 } | 3696 } |
3697 | 3697 |
3698 ASSERT(code->marked_for_deoptimization()); | 3698 ASSERT(code->marked_for_deoptimization()); |
3699 } | 3699 } |
| 3700 |
| 3701 |
| 3702 TEST(AddInstructionChangesNewSpacePromotion) { |
| 3703 i::FLAG_allow_natives_syntax = true; |
| 3704 i::FLAG_expose_gc = true; |
| 3705 i::FLAG_stress_compaction = true; |
| 3706 i::FLAG_gc_interval = 1000; |
| 3707 CcTest::InitializeVM(); |
| 3708 if (!i::FLAG_allocation_site_pretenuring) return; |
| 3709 v8::HandleScope scope(CcTest::isolate()); |
| 3710 Isolate* isolate = CcTest::i_isolate(); |
| 3711 Heap* heap = isolate->heap(); |
| 3712 |
| 3713 CompileRun( |
| 3714 "function add(a, b) {" |
| 3715 " return a + b;" |
| 3716 "}" |
| 3717 "add(1, 2);" |
| 3718 "add(\"a\", \"b\");" |
| 3719 "var oldSpaceObject;" |
| 3720 "gc();" |
| 3721 "function crash(x) {" |
| 3722 " var object = {a: null, b: null};" |
| 3723 " var result = add(1.5, x | 0);" |
| 3724 " object.a = result;" |
| 3725 " oldSpaceObject = object;" |
| 3726 " return object;" |
| 3727 "}" |
| 3728 "crash(1);" |
| 3729 "crash(1);" |
| 3730 "%OptimizeFunctionOnNextCall(crash);" |
| 3731 "crash(1);"); |
| 3732 |
| 3733 v8::Handle<v8::Object> global = CcTest::global(); |
| 3734 v8::Handle<v8::Function> g = |
| 3735 v8::Handle<v8::Function>::Cast(global->Get(v8_str("crash"))); |
| 3736 v8::Handle<v8::Value> args1[] = { v8_num(1) }; |
| 3737 heap->DisableInlineAllocation(); |
| 3738 heap->set_allocation_timeout(1); |
| 3739 g->Call(global, 1, args1); |
| 3740 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 3741 } |
OLD | NEW |