1 /*
2 * Copyright (c) 1997, 2013, 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 *
968 {
969 #ifndef PRODUCT
970 _counter = NULL;
971 #endif
972 }
973 virtual int Opcode() const = 0;
974 Node * obj_node() const {return in(TypeFunc::Parms + 0); }
975 Node * box_node() const {return in(TypeFunc::Parms + 1); }
976 Node * fastlock_node() const {return in(TypeFunc::Parms + 2); }
977 void set_box_node(Node* box) { set_req(TypeFunc::Parms + 1, box); }
978
979 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
980
981 virtual uint size_of() const { return sizeof(*this); }
982
983 bool is_eliminated() const { return (_kind != Regular); }
984 bool is_non_esc_obj() const { return (_kind == NonEscObj); }
985 bool is_coarsened() const { return (_kind == Coarsened); }
986 bool is_nested() const { return (_kind == Nested); }
987
988 void set_non_esc_obj() { _kind = NonEscObj; set_eliminated_lock_counter(); }
989 void set_coarsened() { _kind = Coarsened; set_eliminated_lock_counter(); }
990 void set_nested() { _kind = Nested; set_eliminated_lock_counter(); }
991
992 // locking does not modify its arguments
993 virtual bool may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase){ return false;}
994
995 #ifndef PRODUCT
996 void create_lock_counter(JVMState* s);
997 NamedCounter* counter() const { return _counter; }
998 #endif
999 };
1000
1001 //------------------------------Lock---------------------------------------
1002 // High-level lock operation
1003 //
1004 // This is a subclass of CallNode because it is a macro node which gets expanded
1005 // into a code sequence containing a call. This node takes 3 "parameters":
1006 // 0 - object to lock
1007 // 1 - a BoxLockNode
1028
1029 virtual int Opcode() const;
1030 virtual uint size_of() const; // Size is bigger
1031 LockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) {
1032 init_class_id(Class_Lock);
1033 init_flags(Flag_is_macro);
1034 C->add_macro_node(this);
1035 }
1036 virtual bool guaranteed_safepoint() { return false; }
1037
1038 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
1039 // Expansion modifies the JVMState, so we need to clone it
1040 virtual void clone_jvms(Compile* C) {
1041 if (jvms() != NULL) {
1042 set_jvms(jvms()->clone_deep(C));
1043 jvms()->set_map_deep(this);
1044 }
1045 }
1046
1047 bool is_nested_lock_region(); // Is this Lock nested?
1048 };
1049
1050 //------------------------------Unlock---------------------------------------
1051 // High-level unlock operation
1052 class UnlockNode : public AbstractLockNode {
1053 public:
1054 virtual int Opcode() const;
1055 virtual uint size_of() const; // Size is bigger
1056 UnlockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) {
1057 init_class_id(Class_Unlock);
1058 init_flags(Flag_is_macro);
1059 C->add_macro_node(this);
1060 }
1061 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
1062 // unlock is never a safepoint
1063 virtual bool guaranteed_safepoint() { return false; }
1064 };
1065
1066 class GraphKit;
1067
1068 class ArrayCopyNode : public CallNode {
1069 private:
1070
1071 // What kind of arraycopy variant is this?
1072 enum {
1073 None, // not set yet
1074 ArrayCopy, // System.arraycopy()
1075 CloneBasic, // A clone that can be copied by 64 bit chunks
1076 CloneOop, // An oop array clone
1077 CopyOf, // Arrays.copyOf()
1078 CopyOfRange // Arrays.copyOfRange()
1079 } _kind;
1080
1081 #ifndef PRODUCT
1082 static const char* _kind_names[CopyOfRange+1];
1083 #endif
|
1 /*
2 * Copyright (c) 1997, 2015, 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 *
968 {
969 #ifndef PRODUCT
970 _counter = NULL;
971 #endif
972 }
973 virtual int Opcode() const = 0;
974 Node * obj_node() const {return in(TypeFunc::Parms + 0); }
975 Node * box_node() const {return in(TypeFunc::Parms + 1); }
976 Node * fastlock_node() const {return in(TypeFunc::Parms + 2); }
977 void set_box_node(Node* box) { set_req(TypeFunc::Parms + 1, box); }
978
979 const Type *sub(const Type *t1, const Type *t2) const { return TypeInt::CC;}
980
981 virtual uint size_of() const { return sizeof(*this); }
982
983 bool is_eliminated() const { return (_kind != Regular); }
984 bool is_non_esc_obj() const { return (_kind == NonEscObj); }
985 bool is_coarsened() const { return (_kind == Coarsened); }
986 bool is_nested() const { return (_kind == Nested); }
987
988 const char * kind_as_string() const;
989 void log_lock_optimization(Phase* phase, const char * tag) const;
990
991 void set_non_esc_obj() { _kind = NonEscObj; set_eliminated_lock_counter(); }
992 void set_coarsened() { _kind = Coarsened; set_eliminated_lock_counter(); }
993 void set_nested() { _kind = Nested; set_eliminated_lock_counter(); }
994
995 // locking does not modify its arguments
996 virtual bool may_modify(const TypeOopPtr *t_oop, PhaseTransform *phase){ return false;}
997
998 #ifndef PRODUCT
999 void create_lock_counter(JVMState* s);
1000 NamedCounter* counter() const { return _counter; }
1001 #endif
1002 };
1003
1004 //------------------------------Lock---------------------------------------
1005 // High-level lock operation
1006 //
1007 // This is a subclass of CallNode because it is a macro node which gets expanded
1008 // into a code sequence containing a call. This node takes 3 "parameters":
1009 // 0 - object to lock
1010 // 1 - a BoxLockNode
1031
1032 virtual int Opcode() const;
1033 virtual uint size_of() const; // Size is bigger
1034 LockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf ) {
1035 init_class_id(Class_Lock);
1036 init_flags(Flag_is_macro);
1037 C->add_macro_node(this);
1038 }
1039 virtual bool guaranteed_safepoint() { return false; }
1040
1041 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
1042 // Expansion modifies the JVMState, so we need to clone it
1043 virtual void clone_jvms(Compile* C) {
1044 if (jvms() != NULL) {
1045 set_jvms(jvms()->clone_deep(C));
1046 jvms()->set_map_deep(this);
1047 }
1048 }
1049
1050 bool is_nested_lock_region(); // Is this Lock nested?
1051 bool is_nested_lock_region(Phase * p); // Why isn't this Lock nested?
1052 };
1053
1054 //------------------------------Unlock---------------------------------------
1055 // High-level unlock operation
1056 class UnlockNode : public AbstractLockNode {
1057 private:
1058 #ifdef ASSERT
1059 JVMState* const _dbg_jvms; // Pointer to list of JVM State objects
1060 #endif
1061 public:
1062 virtual int Opcode() const;
1063 virtual uint size_of() const; // Size is bigger
1064 UnlockNode(Compile* C, const TypeFunc *tf) : AbstractLockNode( tf )
1065 #ifdef ASSERT
1066 , _dbg_jvms(NULL)
1067 #endif
1068 {
1069 init_class_id(Class_Unlock);
1070 init_flags(Flag_is_macro);
1071 C->add_macro_node(this);
1072 }
1073 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
1074 // unlock is never a safepoint
1075 virtual bool guaranteed_safepoint() { return false; }
1076 #ifdef ASSERT
1077 void set_dbg_jvms(JVMState* s) {
1078 *(JVMState**)&_dbg_jvms = s; // override const attribute in the accessor
1079 }
1080 JVMState* dbg_jvms() const { return _dbg_jvms; }
1081 #else
1082 JVMState* dbg_jvms() const { return NULL; }
1083 #endif
1084 };
1085
1086 class GraphKit;
1087
1088 class ArrayCopyNode : public CallNode {
1089 private:
1090
1091 // What kind of arraycopy variant is this?
1092 enum {
1093 None, // not set yet
1094 ArrayCopy, // System.arraycopy()
1095 CloneBasic, // A clone that can be copied by 64 bit chunks
1096 CloneOop, // An oop array clone
1097 CopyOf, // Arrays.copyOf()
1098 CopyOfRange // Arrays.copyOfRange()
1099 } _kind;
1100
1101 #ifndef PRODUCT
1102 static const char* _kind_names[CopyOfRange+1];
1103 #endif
|