001/* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013package org.mmtk.utility.deque; 014 015import org.mmtk.vm.VM; 016import org.vmmagic.pragma.Uninterruptible; 017import org.vmmagic.unboxed.Address; 018 019 020/** 021 * This supports <i>unsynchronized</i> enqueuing and dequeuing of 022 * address triples 023 */ 024@Uninterruptible public class AddressTripleDeque extends LocalDeque { 025 026 /**************************************************************************** 027 * 028 * Public instance methods 029 */ 030 031 /** 032 * Constructor 033 * 034 * @param queue The shared queue to which this queue will append its 035 * buffers (when full or flushed) and from which it will acquire new 036 * buffers when it has exhausted its own. 037 */ 038 AddressTripleDeque(SharedDeque queue) { 039 super(queue); 040 } 041 042 /** 043 * Insert an address triple into the address queue. 044 * 045 * @param addr1 the first address to be inserted into the address queue 046 * @param addr2 the second address to be inserted into the address queue 047 * @param addr3 the third address to be inserted into the address queue 048 */ 049 public final void insert(Address addr1, Address addr2, 050 Address addr3) { 051 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr1.isZero()); 052 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr2.isZero()); 053 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr3.isZero()); 054 checkTailInsert(3); 055 uncheckedTailInsert(addr1); 056 uncheckedTailInsert(addr2); 057 uncheckedTailInsert(addr3); 058 } 059 /** 060 * Push an address pair onto the address queue. 061 * 062 * @param addr1 the first value to be pushed onto the address queue 063 * @param addr2 the second value to be pushed onto the address queue 064 * @param addr3 the third address to be pushed onto the address queue 065 */ 066 public final void push(Address addr1, Address addr2, Address addr3) { 067 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr1.isZero()); 068 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr2.isZero()); 069 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!addr3.isZero()); 070 checkHeadInsert(3); 071 uncheckedHeadInsert(addr3); 072 uncheckedHeadInsert(addr2); 073 uncheckedHeadInsert(addr1); 074 } 075 076 /** 077 * Pop the first address in a triple from the address queue, return 078 * zero if the queue is empty. 079 * 080 * @return The next address in the address queue, or zero if the 081 * queue is empty 082 */ 083 public final Address pop1() { 084 if (checkDequeue(3)) 085 return uncheckedDequeue(); 086 else 087 return Address.zero(); 088 } 089 090 /** 091 * Pop the second address in a triple from the address queue. 092 * 093 * @return The next address in the address queue 094 */ 095 public final Address pop2() { 096 return uncheckedDequeue(); 097 } 098 099 100 /** 101 * Pop the third address in a triple from the address queue. 102 * 103 * @return The next address in the address queue 104 */ 105 public final Address pop3() { 106 return uncheckedDequeue(); 107 } 108}