never@1515: /* kvn@3760: * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. never@1515: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. never@1515: * never@1515: * This code is free software; you can redistribute it and/or modify it never@1515: * under the terms of the GNU General Public License version 2 only, as never@1515: * published by the Free Software Foundation. never@1515: * never@1515: * This code is distributed in the hope that it will be useful, but WITHOUT never@1515: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or never@1515: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License never@1515: * version 2 for more details (a copy is included in the LICENSE file that never@1515: * accompanied this code). never@1515: * never@1515: * You should have received a copy of the GNU General Public License version never@1515: * 2 along with this work; if not, write to the Free Software Foundation, never@1515: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. never@1515: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. never@1515: * never@1515: */ never@1515: stefank@2314: #ifndef SHARE_VM_OPTO_STRINGOPTS_HPP stefank@2314: #define SHARE_VM_OPTO_STRINGOPTS_HPP stefank@2314: stefank@2314: #include "opto/node.hpp" stefank@2314: #include "opto/phaseX.hpp" stefank@2314: never@1515: class StringConcat; never@1515: never@1515: class PhaseStringOpts : public Phase { never@1515: friend class StringConcat; never@1515: never@1515: private: never@1515: PhaseGVN* _gvn; never@1515: never@1515: // List of dead nodes to clean up aggressively at the end never@1515: Unique_Node_List dead_worklist; never@1515: never@1515: // Memory slices needed for code gen never@1515: int char_adr_idx; never@1515: never@1515: // Integer.sizeTable - used for int to String conversion never@1515: ciField* size_table_field; never@1515: never@1515: // A set for use by various stages never@1515: VectorSet _visited; never@1515: never@1515: // Collect a list of all SB.toString calls never@1515: Node_List collect_toString_calls(); never@1515: never@1515: // Examine the use of the SB alloc to see if it can be replace with never@1515: // a single string construction. never@1515: StringConcat* build_candidate(CallStaticJavaNode* call); never@1515: never@1515: // Replace all the SB calls in concat with an optimization String allocation never@1515: void replace_string_concat(StringConcat* concat); never@1515: never@1515: // Load the value of a static field, performing any constant folding. never@1515: Node* fetch_static_field(GraphKit& kit, ciField* field); never@1515: never@1515: // Compute the number of characters required to represent the int value never@1515: Node* int_stringSize(GraphKit& kit, Node* value); never@1515: never@1515: // Copy the characters representing value into char_array starting at start never@1515: void int_getChars(GraphKit& kit, Node* value, Node* char_array, Node* start, Node* end); never@1515: never@1515: // Copy of the contents of the String str into char_array starting at index start. never@1515: Node* copy_string(GraphKit& kit, Node* str, Node* char_array, Node* start); never@1515: never@1515: // Clean up any leftover nodes never@1515: void record_dead_node(Node* node); never@1515: void remove_dead_nodes(); never@1515: never@1515: PhaseGVN* gvn() { return _gvn; } never@1515: never@1515: enum { never@1515: // max length of constant string copy unrolling in copy_string never@1515: unroll_string_copy_length = 6 never@1515: }; never@1515: never@1515: public: never@1515: PhaseStringOpts(PhaseGVN* gvn, Unique_Node_List* worklist); never@1515: }; stefank@2314: stefank@2314: #endif // SHARE_VM_OPTO_STRINGOPTS_HPP