2122N/A * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// This file defines the IndexSet class, a set of sparse integer indices. 0N/A// This data structure is used by the compiler in its liveness analysis and 0N/A// during register allocation. It also defines an iterator for this class. 0N/A//-------------------------------- Initializations ------------------------------ 0N/A// Initialize statistics counters 0N/A// Per set, or all sets operation tracing 0N/A// What is the first set bit in a 5 bit integer? 0N/A// What is the second set bit in a 5 bit integer? 0N/A// I tried implementing the IndexSetIterator with a window_size of 8 and 0N/A// didn't seem to get a noticeable speedup. I am leaving in the tables 0N/A// in case we want to switch back. 0N/A/*const byte IndexSetIterator::_first_bit[256] = { 0N/A 8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0N/A 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0N/A 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0N/A 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0N/A 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 0N/A 4, 0, 1, 0, 2, 0, 1, 0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 7, 2, 2, 1, 7, 3, 3, 1, 3, 2, 2, 1, 0N/A 7, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 0N/A 7, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, 0N/A 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 0N/A 7, 6, 6, 1, 6, 2, 2, 1, 6, 3, 3, 1, 3, 2, 2, 1, 0N/A 6, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1, 0N/A 6, 5, 5, 1, 5, 2, 2, 1, 5, 3, 3, 1, 3, 2, 2, 1, 0N/A 5, 4, 4, 1, 4, 2, 2, 1, 4, 3, 3, 1, 3, 2, 2, 1 0N/A//---------------------------- IndexSet::populate_free_list() ----------------------------- 0N/A// Populate the free BitBlock list with a batch of BitBlocks. The BitBlocks 0N/A// are 32 bit aligned. 0N/A // Align the pointer to a 32 bit boundary. 0N/A // Add the new blocks to the free list. 0N/A//---------------------------- IndexSet::alloc_block() ------------------------ 0N/A// Allocate a BitBlock from the free list. If the free list is empty, 0N/A//---------------------------- IndexSet::alloc_block_containing() ------------- 0N/A// Allocate a new BitBlock and put it into the position in the _blocks array 0N/A// corresponding to element. 0N/A//---------------------------- IndexSet::free_block() ------------------------- 0N/A// Add a BitBlock to the free list. 0N/A//------------------------------lrg_union-------------------------------------- 0N/A// Compute the union of all elements of one and two which interfere with 0N/A// the RegMask mask. If the degree of the union becomes exceeds 0N/A// fail_degree, the union bails out. The underlying set is cleared before 0N/A// the union is performed. 0N/A // Compute the degree of the combined live-range. The combined 0N/A // live-range has the union of the original live-ranges' neighbors set as 0N/A // well as the neighbors of all intermediate copies, minus those neighbors 0N/A // that can not use the intersected allowed-register-set. 0N/A // Copy the larger set. Insert the smaller set into the larger. 0N/A // Used to compute degree of register-only interferences. Infinite-stack 0N/A // neighbors do not alter colorability, as they can always color to some 0N/A // other color. (A variant of the Briggs assertion) 0N/A // Load up the combined interference set with the neighbors of one 0N/A // !!!!! Danger! No update to reg_degree despite having a neighbor. 0N/A // A variant of the Briggs assertion. 0N/A // Add neighbors of two as well 0N/A // !!!!! Danger! No update to reg_degree despite having a neighbor. 0N/A // A variant of the Briggs assertion. 0N/A//---------------------------- IndexSet() ----------------------------- 0N/A// A deep copy constructor. This is used when you need a scratch copy of this set. 0N/A//---------------------------- IndexSet::initialize() ----------------------------- 0N/A// Prepare an IndexSet for use. 0N/A//---------------------------- IndexSet::initialize()------------------------------ 0N/A// Prepare an IndexSet for use. If it needs to allocate its _blocks array, it does 0N/A// so from the Arena passed as a parameter. BitBlock allocation is still done from 0N/A// the static Arena which was set with reset_memory(). 0N/A//---------------------------- IndexSet::swap() ----------------------------- 0N/A// Exchange two IndexSets. 0N/A//---------------------------- IndexSet::dump() ----------------------------- 0N/A// Print this set. Used for debugging. 0N/A//---------------------------- IndexSet::tally_iteration_statistics() ----------------------------- 0N/A// Update block/bit counts to reflect that this set has been iterated over. 0N/A//---------------------------- IndexSet::print_statistics() ----------------------------- 0N/A// Print statistics about IndexSet usage. 0N/A//---------------------------- IndexSet::verify() ----------------------------- 0N/A// Expensive test of IndexSet sanity. Ensure that the count agrees with the 0N/A// number of bits in the blocks. Make sure the iterator is seeing all elements 0N/A// of the set. Meant for use during development. 0N/A//---------------------------- IndexSetIterator() ----------------------------- 0N/A// Create an iterator for a set. If empty blocks are detected when iterating 0N/A// over the set, these blocks are replaced. 0N/A // We don't need the following values when we iterate over an empty set. 0N/A // The commented out code is left here to document that the omission 0N/A//---------------------------- IndexSetIterator(const) ----------------------------- 0N/A// Iterate over a constant IndexSet. 0N/A // We don't call check_watch from here to avoid bad recursion. 0N/A // set->check_watch("traversed const", set->count()); 0N/A // We don't need the following values when we iterate over an empty set. 0N/A // The commented out code is left here to document that the omission 0N/A//---------------------------- List16Iterator::advance_and_next() ----------------------------- 0N/A// Advance to the next non-empty word in the set being iterated over. Return the next element 0N/A// if there is one. If we are done, return 0. This method is called from the next() method 0N/A// when it gets done with a word. 0N/A // See if there is another non-empty word in the current block. 0N/A // Found a non-empty word. 0N/A // We ran out of words in the current block. Advance to next non-empty block. 0N/A // Found a non-empty block. 0N/A // Found a non-empty word. 0N/A // All of the words in the block were empty. Replace 0N/A // the block with the empty block. 0N/A // These assignments make redundant calls to next on a finished iterator 0N/A // faster. Probably not necessary.