author | vlivanov |
Thu, 29 Jan 2015 10:25:59 -0800 | |
changeset 28912 | 27fac2f8fdbe |
parent 23528 | 8f1a7f5e8066 |
child 35551 | 36ef3841fb34 |
permissions | -rw-r--r-- |
23528 | 1 |
/* |
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_OPTO_OPAQUENODE_HPP |
|
26 |
#define SHARE_VM_OPTO_OPAQUENODE_HPP |
|
27 |
||
28 |
#include "opto/node.hpp" |
|
29 |
#include "opto/opcodes.hpp" |
|
30 |
||
31 |
//------------------------------Opaque1Node------------------------------------ |
|
32 |
// A node to prevent unwanted optimizations. Allows constant folding. |
|
33 |
// Stops value-numbering, Ideal calls or Identity functions. |
|
34 |
class Opaque1Node : public Node { |
|
35 |
virtual uint hash() const ; // { return NO_HASH; } |
|
36 |
virtual uint cmp( const Node &n ) const; |
|
37 |
public: |
|
38 |
Opaque1Node( Compile* C, Node *n ) : Node(0,n) { |
|
39 |
// Put it on the Macro nodes list to removed during macro nodes expansion. |
|
40 |
init_flags(Flag_is_macro); |
|
41 |
C->add_macro_node(this); |
|
42 |
} |
|
43 |
// Special version for the pre-loop to hold the original loop limit |
|
44 |
// which is consumed by range check elimination. |
|
45 |
Opaque1Node( Compile* C, Node *n, Node* orig_limit ) : Node(0,n,orig_limit) { |
|
46 |
// Put it on the Macro nodes list to removed during macro nodes expansion. |
|
47 |
init_flags(Flag_is_macro); |
|
48 |
C->add_macro_node(this); |
|
49 |
} |
|
50 |
Node* original_loop_limit() { return req()==3 ? in(2) : NULL; } |
|
51 |
virtual int Opcode() const; |
|
52 |
virtual const Type *bottom_type() const { return TypeInt::INT; } |
|
53 |
virtual Node *Identity( PhaseTransform *phase ); |
|
54 |
}; |
|
55 |
||
56 |
//------------------------------Opaque2Node------------------------------------ |
|
57 |
// A node to prevent unwanted optimizations. Allows constant folding. Stops |
|
58 |
// value-numbering, most Ideal calls or Identity functions. This Node is |
|
59 |
// specifically designed to prevent the pre-increment value of a loop trip |
|
60 |
// counter from being live out of the bottom of the loop (hence causing the |
|
61 |
// pre- and post-increment values both being live and thus requiring an extra |
|
62 |
// temp register and an extra move). If we "accidentally" optimize through |
|
63 |
// this kind of a Node, we'll get slightly pessimal, but correct, code. Thus |
|
64 |
// it's OK to be slightly sloppy on optimizations here. |
|
65 |
class Opaque2Node : public Node { |
|
66 |
virtual uint hash() const ; // { return NO_HASH; } |
|
67 |
virtual uint cmp( const Node &n ) const; |
|
68 |
public: |
|
69 |
Opaque2Node( Compile* C, Node *n ) : Node(0,n) { |
|
70 |
// Put it on the Macro nodes list to removed during macro nodes expansion. |
|
71 |
init_flags(Flag_is_macro); |
|
72 |
C->add_macro_node(this); |
|
73 |
} |
|
74 |
virtual int Opcode() const; |
|
75 |
virtual const Type *bottom_type() const { return TypeInt::INT; } |
|
76 |
}; |
|
77 |
||
78 |
//------------------------------Opaque3Node------------------------------------ |
|
79 |
// A node to prevent unwanted optimizations. Will be optimized only during |
|
80 |
// macro nodes expansion. |
|
81 |
class Opaque3Node : public Opaque2Node { |
|
82 |
int _opt; // what optimization it was used for |
|
83 |
public: |
|
84 |
enum { RTM_OPT }; |
|
85 |
Opaque3Node(Compile* C, Node *n, int opt) : Opaque2Node(C, n), _opt(opt) {} |
|
86 |
virtual int Opcode() const; |
|
87 |
bool rtm_opt() const { return (_opt == RTM_OPT); } |
|
88 |
}; |
|
89 |
||
28912
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
90 |
//------------------------------ProfileBooleanNode------------------------------- |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
91 |
// A node represents value profile for a boolean during parsing. |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
92 |
// Once parsing is over, the node goes away (during IGVN). |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
93 |
// It is used to override branch frequencies from MDO (see has_injected_profile in parse2.cpp). |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
94 |
class ProfileBooleanNode : public Node { |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
95 |
uint _false_cnt; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
96 |
uint _true_cnt; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
97 |
bool _consumed; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
98 |
bool _delay_removal; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
99 |
virtual uint hash() const ; // { return NO_HASH; } |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
100 |
virtual uint cmp( const Node &n ) const; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
101 |
public: |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
102 |
ProfileBooleanNode(Node *n, uint false_cnt, uint true_cnt) : Node(0, n), |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
103 |
_false_cnt(false_cnt), _true_cnt(true_cnt), _delay_removal(true), _consumed(false) {} |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
104 |
|
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
105 |
uint false_count() const { return _false_cnt; } |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
106 |
uint true_count() const { return _true_cnt; } |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
107 |
|
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
108 |
void consume() { _consumed = true; } |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
109 |
|
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
110 |
virtual int Opcode() const; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
111 |
virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
112 |
virtual Node *Identity(PhaseTransform *phase); |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
113 |
virtual const Type *bottom_type() const { return TypeInt::BOOL; } |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
114 |
}; |
27fac2f8fdbe
8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
vlivanov
parents:
23528
diff
changeset
|
115 |
|
23528 | 116 |
#endif // SHARE_VM_OPTO_OPAQUENODE_HPP |
117 |