comparison src/share/vm/gc_implementation/parallelScavenge/gcTaskManager.cpp @ 4132:6d7d0790074d

7119584: UseParallelGC barrier task can be overwritten. Summary: Provoke a GC for a metadata allocation failure. Reviewed-by: johnc, iveresov
author jmasa
date Fri, 09 Dec 2011 19:28:34 -0800
parents bca17e38de00
children d2a62e0f25eb
comparison
equal deleted inserted replaced
4131:e9b91fd07263 4132:6d7d0790074d
1 /* 1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
50 case barrier_task: 50 case barrier_task:
51 result = "barrier task"; 51 result = "barrier task";
52 break; 52 break;
53 case noop_task: 53 case noop_task:
54 result = "noop task"; 54 result = "noop task";
55 break;
56 case idle_task:
57 result = "idle task";
55 break; 58 break;
56 } 59 }
57 return result; 60 return result;
58 }; 61 };
59 62
780 // tasks are added last to the list. 783 // tasks are added last to the list.
781 784
782 void GCTaskManager::execute_and_wait(GCTaskQueue* list) { 785 void GCTaskManager::execute_and_wait(GCTaskQueue* list) {
783 WaitForBarrierGCTask* fin = WaitForBarrierGCTask::create(); 786 WaitForBarrierGCTask* fin = WaitForBarrierGCTask::create();
784 list->enqueue(fin); 787 list->enqueue(fin);
788 // The barrier task will be read by one of the GC
789 // workers once it is added to the list of tasks.
790 // Be sure that is globally visible before the
791 // GC worker reads it (which is after the task is added
792 // to the list of tasks below).
793 OrderAccess::storestore();
785 add_list(list); 794 add_list(list);
786 fin->wait_for(true /* reset */); 795 fin->wait_for(true /* reset */);
787 // We have to release the barrier tasks! 796 // We have to release the barrier tasks!
788 WaitForBarrierGCTask::destroy(fin); 797 WaitForBarrierGCTask::destroy(fin);
789 } 798 }
831 // IdleGCTask 840 // IdleGCTask
832 // 841 //
833 842
834 IdleGCTask* IdleGCTask::create() { 843 IdleGCTask* IdleGCTask::create() {
835 IdleGCTask* result = new IdleGCTask(false); 844 IdleGCTask* result = new IdleGCTask(false);
845 assert(UseDynamicNumberOfGCThreads,
846 "Should only be used with dynamic GC thread");
836 return result; 847 return result;
837 } 848 }
838 849
839 IdleGCTask* IdleGCTask::create_on_c_heap() { 850 IdleGCTask* IdleGCTask::create_on_c_heap() {
840 IdleGCTask* result = new(ResourceObj::C_HEAP) IdleGCTask(true); 851 IdleGCTask* result = new(ResourceObj::C_HEAP) IdleGCTask(true);
852 assert(UseDynamicNumberOfGCThreads,
853 "Should only be used with dynamic GC thread");
841 return result; 854 return result;
842 } 855 }
843 856
844 void IdleGCTask::do_it(GCTaskManager* manager, uint which) { 857 void IdleGCTask::do_it(GCTaskManager* manager, uint which) {
845 WaitForBarrierGCTask* wait_for_task = manager->idle_inactive_task(); 858 WaitForBarrierGCTask* wait_for_task = manager->idle_inactive_task();