Mercurial > hg > graal-compiler
changeset 20731:42c091d63c72
8048949: Requeue queue implementation
Summary: devirtualize flush and move calls
Reviewed-by: brutisso, tschatzl, mschoene
Contributed-by: kim.barrett@oracle.com
author | tschatzl |
---|---|
date | Mon, 04 Aug 2014 10:49:40 -0400 |
parents | 8210e5f2e21b |
children | 6709b033c725 |
files | src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp src/share/vm/gc_implementation/g1/ptrQueue.cpp src/share/vm/gc_implementation/g1/ptrQueue.hpp src/share/vm/gc_implementation/g1/satbQueue.cpp src/share/vm/gc_implementation/g1/satbQueue.hpp |
diffstat | 5 files changed, 27 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp Tue Aug 12 17:46:16 2014 -0400 +++ b/src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp Mon Aug 04 10:49:40 2014 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,13 @@ // active field set to true. PtrQueue(qset_, perm, true /* active */) { } + // Flush before destroying; queue may be used to capture pending work while + // doing something else, with auto-flush on completion. + ~DirtyCardQueue() { if (!is_permanent()) flush(); } + + // Process queue entries and release resources. + void flush() { flush_impl(); } + // Apply the closure to all elements, and reset the index to make the // buffer empty. If a closure application returns "false", return // "false" immediately, halting the iteration. If "consume" is true,
--- a/src/share/vm/gc_implementation/g1/ptrQueue.cpp Tue Aug 12 17:46:16 2014 -0400 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.cpp Mon Aug 04 10:49:40 2014 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,11 +31,15 @@ #include "runtime/thread.inline.hpp" PtrQueue::PtrQueue(PtrQueueSet* qset, bool perm, bool active) : - _qset(qset), _buf(NULL), _index(0), _active(active), + _qset(qset), _buf(NULL), _index(0), _sz(0), _active(active), _perm(perm), _lock(NULL) {} -void PtrQueue::flush() { +PtrQueue::~PtrQueue() { + assert(_perm || (_buf == NULL), "queue must be flushed before delete"); +} + +void PtrQueue::flush_impl() { if (!_perm && _buf != NULL) { if (_index == _sz) { // No work to do.
--- a/src/share/vm/gc_implementation/g1/ptrQueue.hpp Tue Aug 12 17:46:16 2014 -0400 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.hpp Mon Aug 04 10:49:40 2014 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,15 +65,18 @@ Mutex* _lock; PtrQueueSet* qset() { return _qset; } + bool is_permanent() const { return _perm; } + + // Process queue entries and release resources, if not permanent. + void flush_impl(); public: // Initialize this queue to contain a null buffer, and be part of the // given PtrQueueSet. PtrQueue(PtrQueueSet* qset, bool perm = false, bool active = false); - // Release any contained resources. - virtual void flush(); - // Calls flush() when destroyed. - ~PtrQueue() { flush(); } + + // Requires queue flushed or permanent. + ~PtrQueue(); // Associate a lock with a ptr queue. void set_lock(Mutex* lock) { _lock = lock; }
--- a/src/share/vm/gc_implementation/g1/satbQueue.cpp Tue Aug 12 17:46:16 2014 -0400 +++ b/src/share/vm/gc_implementation/g1/satbQueue.cpp Mon Aug 04 10:49:40 2014 -0400 @@ -39,7 +39,7 @@ // first before we flush it, otherwise we might end up with an // enqueued buffer with refs into the CSet which breaks our invariants. filter(); - PtrQueue::flush(); + flush_impl(); } // This method removes entries from an SATB buffer that will not be
--- a/src/share/vm/gc_implementation/g1/satbQueue.hpp Tue Aug 12 17:46:16 2014 -0400 +++ b/src/share/vm/gc_implementation/g1/satbQueue.hpp Mon Aug 04 10:49:40 2014 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,9 +58,8 @@ // field to true. This is done in JavaThread::initialize_queues(). PtrQueue(qset, perm, false /* active */) { } - // Overrides PtrQueue::flush() so that it can filter the buffer - // before it is flushed. - virtual void flush(); + // Process queue entries and free resources. + void flush(); // Overrides PtrQueue::should_enqueue_buffer(). See the method's // definition for more information.