stubs.cpp revision 1410
2887N/A * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. 2016N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2016N/A * This code is free software; you can redistribute it and/or modify it 2016N/A * under the terms of the GNU General Public License version 2 only, as 2016N/A * published by the Free Software Foundation. 2016N/A * This code is distributed in the hope that it will be useful, but WITHOUT 5826N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2016N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5826N/A * version 2 for more details (a copy is included in the LICENSE file that 2016N/A * You should have received a copy of the GNU General Public License version 5826N/A * 2 along with this work; if not, write to the Free Software Foundation, 2016N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5826N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2016N/A * CA 95054 USA or visit www.sun.com if you need additional information or 2016N/A#
include "incls/_precompiled.incl" 2016N/A// Implementation of StubQueue 2016N/A// Standard wrap-around queue implementation; the queue dimensions 5826N/A// are specified by the _queue_begin & _queue_end indices. The queue 5826N/A// can be in two states (transparent to the outside): 6215N/A// a) contiguous state: all queue entries in one block (or empty) 6215N/A// Queue: |...|XXXXXXX|...............| 5826N/A// ^0 ^begin ^end ^size = limit 5826N/A// b) non-contiguous state: queue entries in two blocks 5826N/A// Queue: |XXX|.......|XXXXXXX|.......| 5826N/A// ^0 ^end ^begin ^limit ^size 5826N/A// In the non-contiguous state, the wrap-around point is 5826N/A// indicated via the _buffer_limit index since the last 5826N/A// queue entry may not fill up the queue completely in 5826N/A// which case we need to know where the 2nd block's end 5826N/A// is to do the proper wrap-around. When removing the 5826N/A// last entry of the 2nd block, _buffer_limit is reset 5826N/A// CAUTION: DO NOT MESS WITH THIS CODE IF YOU CANNOT PROVE 5826N/A// ITS CORRECTNESS! THIS CODE IS MORE SUBTLE THAN IT LOOKS! 5826N/A // Note: Currently StubQueues are never destroyed so nothing needs to be done here. 5826N/A // If we want to implement the destructor, we need to release the BufferBlob 5826N/A // allocated in the constructor (i.e., we need to keep it around or look it 5826N/A // up via CodeCache::find_blob(...). 2399N/A // Queue: |...|XXXXXXX|.............| 5826N/A // ^0 ^begin ^end ^size = limit 5826N/A // code fits in at the end => nothing to do 5826N/A // stub doesn't fit in at the queue end 5826N/A // => reduce buffer limit & wrap around 5826N/A // Queue: |XXX|.......|XXXXXXX|.......| 5826N/A // ^0 ^end ^begin ^limit ^size // => reset queue indices // => reset buffer limit & wrap around // verify only if initialized // verify index boundaries