hotspot/src/share/vm/opto/stringopts.hpp
author iveresov
Thu, 22 Jan 2015 11:25:23 -0800
changeset 28723 0a36120cb225
parent 12623 09fcb0dc71ad
child 33628 09241459a8b8
permissions -rw-r--r--
8071302: assert(!_reg_node[reg_lo] || edge_from_to(_reg_node[reg_lo], def)) failed: after block local Summary: Add merge nodes to node to block mapping Reviewed-by: kvn, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4450
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     1
/*
12623
09fcb0dc71ad 6924259: Remove String.count/String.offset
kvn
parents: 7397
diff changeset
     2
 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
4450
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     4
 *
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     8
 *
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    13
 * accompanied this code).
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    14
 *
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4450
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4450
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4450
diff changeset
    21
 * questions.
4450
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    22
 *
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    23
 */
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_OPTO_STRINGOPTS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OPTO_STRINGOPTS_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/node.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
4450
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    31
class StringConcat;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    32
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    33
class PhaseStringOpts : public Phase {
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    34
  friend class StringConcat;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    35
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    36
 private:
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    37
  PhaseGVN* _gvn;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    38
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    39
  // List of dead nodes to clean up aggressively at the end
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    40
  Unique_Node_List dead_worklist;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    41
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    42
  // Memory slices needed for code gen
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    43
  int char_adr_idx;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    44
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    45
  // Integer.sizeTable - used for int to String conversion
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    46
  ciField* size_table_field;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    47
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    48
  // A set for use by various stages
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    49
  VectorSet _visited;
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    50
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    51
  // Collect a list of all SB.toString calls
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    52
  Node_List collect_toString_calls();
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    53
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    54
  // Examine the use of the SB alloc to see if it can be replace with
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    55
  // a single string construction.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    56
  StringConcat* build_candidate(CallStaticJavaNode* call);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    57
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    58
  // Replace all the SB calls in concat with an optimization String allocation
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    59
  void replace_string_concat(StringConcat* concat);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    60
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    61
  // Load the value of a static field, performing any constant folding.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    62
  Node* fetch_static_field(GraphKit& kit, ciField* field);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    63
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    64
  // Compute the number of characters required to represent the int value
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    65
  Node* int_stringSize(GraphKit& kit, Node* value);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    66
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    67
  // Copy the characters representing value into char_array starting at start
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    68
  void int_getChars(GraphKit& kit, Node* value, Node* char_array, Node* start, Node* end);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    69
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    70
  // Copy of the contents of the String str into char_array starting at index start.
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    71
  Node* copy_string(GraphKit& kit, Node* str, Node* char_array, Node* start);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    72
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    73
  // Clean up any leftover nodes
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    74
  void record_dead_node(Node* node);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    75
  void remove_dead_nodes();
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    76
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    77
  PhaseGVN* gvn() { return _gvn; }
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    78
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    79
  enum {
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    80
    // max length of constant string copy unrolling in copy_string
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    81
    unroll_string_copy_length = 6
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    82
  };
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    83
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    84
 public:
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    85
  PhaseStringOpts(PhaseGVN* gvn, Unique_Node_List* worklist);
6d700b859b3e 6892658: C2 should optimize some stringbuilder patterns
never
parents:
diff changeset
    86
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    87
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    88
#endif // SHARE_VM_OPTO_STRINGOPTS_HPP