Mercurial > hg > truffle
comparison graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java @ 9958:8efb5a58a799
more checks for ArrayCopyNode virtualization
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 10 Jun 2013 10:49:24 +0200 |
parents | 2c82f780bff5 |
children | ee1e283ea967 |
comparison
equal
deleted
inserted
replaced
9948:b4325bc087c4 | 9958:8efb5a58a799 |
---|---|
114 | 114 |
115 private static boolean checkBounds(int position, int length, VirtualObjectNode virtualObject) { | 115 private static boolean checkBounds(int position, int length, VirtualObjectNode virtualObject) { |
116 return position >= 0 && position + length <= virtualObject.entryCount(); | 116 return position >= 0 && position + length <= virtualObject.entryCount(); |
117 } | 117 } |
118 | 118 |
119 private static boolean checkEntryTypes(int srcPos, int length, State srcState, ResolvedJavaType destComponentType) { | 119 private static boolean checkEntryTypes(int srcPos, int length, State srcState, ResolvedJavaType destComponentType, VirtualizerTool tool) { |
120 if (destComponentType.getKind() == Kind.Object) { | 120 if (destComponentType.getKind() == Kind.Object) { |
121 for (int i = 0; i < length; i++) { | 121 for (int i = 0; i < length; i++) { |
122 if (!destComponentType.isAssignableFrom(srcState.getEntry(srcPos + i).objectStamp().type())) { | 122 ValueNode entry = srcState.getEntry(srcPos + i); |
123 State state = tool.getObjectState(entry); | |
124 ResolvedJavaType type; | |
125 if (state != null) { | |
126 if (state.getState() == EscapeState.Virtual) { | |
127 type = state.getVirtualObject().type(); | |
128 } else { | |
129 type = state.getMaterializedValue().objectStamp().type(); | |
130 } | |
131 } else { | |
132 type = entry.objectStamp().type(); | |
133 } | |
134 if (type == null || !destComponentType.isAssignableFrom(type)) { | |
123 return false; | 135 return false; |
124 } | 136 } |
125 } | 137 } |
126 } | 138 } |
127 return true; | 139 return true; |
137 State destState = tool.getObjectState(getDestination()); | 149 State destState = tool.getObjectState(getDestination()); |
138 | 150 |
139 if (srcState != null && srcState.getState() == EscapeState.Virtual && destState != null && destState.getState() == EscapeState.Virtual) { | 151 if (srcState != null && srcState.getState() == EscapeState.Virtual && destState != null && destState.getState() == EscapeState.Virtual) { |
140 VirtualObjectNode srcVirtual = srcState.getVirtualObject(); | 152 VirtualObjectNode srcVirtual = srcState.getVirtualObject(); |
141 VirtualObjectNode destVirtual = destState.getVirtualObject(); | 153 VirtualObjectNode destVirtual = destState.getVirtualObject(); |
154 if (!(srcVirtual instanceof VirtualArrayNode) || !(destVirtual instanceof VirtualArrayNode)) { | |
155 return; | |
156 } | |
157 if (((VirtualArrayNode) srcVirtual).componentType().getKind() != Kind.Object || ((VirtualArrayNode) destVirtual).componentType().getKind() != Kind.Object) { | |
158 return; | |
159 } | |
142 if (length < 0 || !checkBounds(srcPos, length, srcVirtual) || !checkBounds(destPos, length, destVirtual)) { | 160 if (length < 0 || !checkBounds(srcPos, length, srcVirtual) || !checkBounds(destPos, length, destVirtual)) { |
143 return; | 161 return; |
144 } | 162 } |
145 if (!checkEntryTypes(srcPos, length, srcState, destVirtual.type().getComponentType())) { | 163 if (!checkEntryTypes(srcPos, length, srcState, destVirtual.type().getComponentType(), tool)) { |
146 return; | 164 return; |
147 } | 165 } |
148 for (int i = 0; i < length; i++) { | 166 for (int i = 0; i < length; i++) { |
149 tool.setVirtualEntry(destState, destPos + i, srcState.getEntry(srcPos + i)); | 167 tool.setVirtualEntry(destState, destPos + i, srcState.getEntry(srcPos + i)); |
150 } | 168 } |