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