< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core/src/org/graalvm/compiler/core/gen/DebugInfoBuilder.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 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  */


 115                 } else {
 116                     values = new JavaValue[entryCount];
 117                     slotKinds = new JavaKind[entryCount];
 118                 }
 119                 if (values.length > 0) {
 120                     VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobjNode);
 121                     assert currentField != null;
 122                     int pos = 0;
 123                     for (int i = 0; i < entryCount; i++) {
 124                         ValueNode value = currentField.values().get(i);
 125                         if (value == null) {
 126                             JavaKind entryKind = vobjNode.entryKind(i);
 127                             values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
 128                             slotKinds[pos] = entryKind.getStackKind();
 129                             pos++;
 130                         } else if (!value.isConstant() || value.asJavaConstant().getJavaKind() != JavaKind.Illegal) {
 131                             values[pos] = toJavaValue(value);
 132                             slotKinds[pos] = toSlotKind(value);
 133                             pos++;
 134                         } else {
 135                             assert currentField.values().get(i - 1).getStackKind() == JavaKind.Double || currentField.values().get(i - 1).getStackKind() == JavaKind.Long : vobjNode + " " + i + " " +
 136                                             currentField.values().get(i - 1);









 137                         }
 138                     }
 139                     if (pos != entryCount) {
 140                         values = Arrays.copyOf(values, pos);
 141                         slotKinds = Arrays.copyOf(slotKinds, pos);
 142                     }
 143                 }
 144                 assert checkValues(vobjValue.getType(), values, slotKinds);
 145                 vobjValue.setValues(values, slotKinds);
 146             }
 147 
 148             virtualObjectsArray = new VirtualObject[virtualObjects.size()];
 149             int index = 0;
 150             for (VirtualObject value : virtualObjects.getValues()) {
 151                 virtualObjectsArray[index++] = value;
 152             }
 153             virtualObjects.clear();
 154         }
 155         objectStates.clear();
 156 
 157         return newLIRFrameState(exceptionEdge, frame, virtualObjectsArray);
 158     }
 159 
 160     private boolean checkValues(ResolvedJavaType type, JavaValue[] values, JavaKind[] slotKinds) {
 161         assert (values == null) == (slotKinds == null);
 162         if (values != null) {
 163             assert values.length == slotKinds.length;
 164             if (!type.isArray()) {
 165                 ResolvedJavaField[] fields = type.getInstanceFields(true);
 166                 int fieldIndex = 0;
 167                 for (int i = 0; i < values.length; i++) {
 168                     ResolvedJavaField field = fields[fieldIndex++];
 169                     JavaKind valKind = slotKinds[i].getStackKind();
 170                     JavaKind fieldKind = storageKind(field.getType());
 171                     if (fieldKind == JavaKind.Object) {
 172                         assert valKind.isObject() : field + ": " + valKind + " != " + fieldKind;
 173                     } else {
 174                         if ((valKind == JavaKind.Double || valKind == JavaKind.Long) && fieldKind == JavaKind.Int) {
 175                             assert storageKind(fields[fieldIndex].getType()) == JavaKind.Int;




 176                             fieldIndex++;
 177                         } else {
 178                             assert valKind == fieldKind.getStackKind() : field + ": " + valKind + " != " + fieldKind;
 179                         }
 180                     }
 181                 }
 182                 assert fields.length == fieldIndex : type + ": fields=" + Arrays.toString(fields) + ", field values=" + Arrays.toString(values);
 183             } else {
 184                 JavaKind componentKind = storageKind(type.getComponentType()).getStackKind();
 185                 if (componentKind == JavaKind.Object) {
 186                     for (int i = 0; i < values.length; i++) {
 187                         assert slotKinds[i].isObject() : slotKinds[i] + " != " + componentKind;
 188                     }
 189                 } else {
 190                     for (int i = 0; i < values.length; i++) {
 191                         assert slotKinds[i] == componentKind || componentKind.getBitCount() >= slotKinds[i].getBitCount() ||
 192                                         (componentKind == JavaKind.Int && slotKinds[i].getBitCount() >= JavaKind.Int.getBitCount()) : slotKinds[i] + " != " + componentKind;
 193                     }
 194                 }
 195             }
 196         }
 197         return true;
 198     }
 199 


   1 /*
   2  * Copyright (c) 2017, 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  */


 115                 } else {
 116                     values = new JavaValue[entryCount];
 117                     slotKinds = new JavaKind[entryCount];
 118                 }
 119                 if (values.length > 0) {
 120                     VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobjNode);
 121                     assert currentField != null;
 122                     int pos = 0;
 123                     for (int i = 0; i < entryCount; i++) {
 124                         ValueNode value = currentField.values().get(i);
 125                         if (value == null) {
 126                             JavaKind entryKind = vobjNode.entryKind(i);
 127                             values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
 128                             slotKinds[pos] = entryKind.getStackKind();
 129                             pos++;
 130                         } else if (!value.isConstant() || value.asJavaConstant().getJavaKind() != JavaKind.Illegal) {
 131                             values[pos] = toJavaValue(value);
 132                             slotKinds[pos] = toSlotKind(value);
 133                             pos++;
 134                         } else {
 135                             assert value.getStackKind() == JavaKind.Illegal;
 136                             ValueNode previousValue = currentField.values().get(i - 1);
 137                             assert (previousValue != null && previousValue.getStackKind().needsTwoSlots()) : vobjNode + " " + i +
 138                                             " " + previousValue + " " + currentField.values().snapshot();
 139                             if (previousValue == null || !previousValue.getStackKind().needsTwoSlots()) {
 140                                 // Don't allow the IllegalConstant to leak into the debug info
 141                                 JavaKind entryKind = vobjNode.entryKind(i);
 142                                 values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
 143                                 slotKinds[pos] = entryKind.getStackKind();
 144                                 pos++;
 145                             }
 146                         }
 147                     }
 148                     if (pos != entryCount) {
 149                         values = Arrays.copyOf(values, pos);
 150                         slotKinds = Arrays.copyOf(slotKinds, pos);
 151                     }
 152                 }
 153                 assert checkValues(vobjValue.getType(), values, slotKinds);
 154                 vobjValue.setValues(values, slotKinds);
 155             }
 156 
 157             virtualObjectsArray = new VirtualObject[virtualObjects.size()];
 158             int index = 0;
 159             for (VirtualObject value : virtualObjects.getValues()) {
 160                 virtualObjectsArray[index++] = value;
 161             }
 162             virtualObjects.clear();
 163         }
 164         objectStates.clear();
 165 
 166         return newLIRFrameState(exceptionEdge, frame, virtualObjectsArray);
 167     }
 168 
 169     private boolean checkValues(ResolvedJavaType type, JavaValue[] values, JavaKind[] slotKinds) {
 170         assert (values == null) == (slotKinds == null);
 171         if (values != null) {
 172             assert values.length == slotKinds.length;
 173             if (!type.isArray()) {
 174                 ResolvedJavaField[] fields = type.getInstanceFields(true);
 175                 int fieldIndex = 0;
 176                 for (int valueIndex = 0; valueIndex < values.length; valueIndex++, fieldIndex++) {
 177                     ResolvedJavaField field = fields[fieldIndex];
 178                     JavaKind valKind = slotKinds[valueIndex].getStackKind();
 179                     JavaKind fieldKind = storageKind(field.getType());



 180                     if ((valKind == JavaKind.Double || valKind == JavaKind.Long) && fieldKind == JavaKind.Int) {
 181                         assert fieldIndex + 1 < fields.length : String.format("Not enough fields for fieldIndex = %d valueIndex = %d %s %s", fieldIndex, valueIndex, Arrays.toString(fields),
 182                                         Arrays.toString(values));
 183                         assert storageKind(fields[fieldIndex + 1].getType()) == JavaKind.Int : String.format("fieldIndex = %d valueIndex = %d %s %s %s", fieldIndex, valueIndex,
 184                                         storageKind(fields[fieldIndex + 1].getType()), Arrays.toString(fields),
 185                                         Arrays.toString(values));
 186                         fieldIndex++;
 187                     } else {
 188                         assert valKind == fieldKind.getStackKind() : field + ": " + valKind + " != " + fieldKind;

 189                     }
 190                 }
 191                 assert fields.length == fieldIndex : type + ": fields=" + Arrays.toString(fields) + ", field values=" + Arrays.toString(values);
 192             } else {
 193                 JavaKind componentKind = storageKind(type.getComponentType()).getStackKind();
 194                 if (componentKind == JavaKind.Object) {
 195                     for (int i = 0; i < values.length; i++) {
 196                         assert slotKinds[i].isObject() : slotKinds[i] + " != " + componentKind;
 197                     }
 198                 } else {
 199                     for (int i = 0; i < values.length; i++) {
 200                         assert slotKinds[i] == componentKind || componentKind.getBitCount() >= slotKinds[i].getBitCount() ||
 201                                         (componentKind == JavaKind.Int && slotKinds[i].getBitCount() >= JavaKind.Int.getBitCount()) : slotKinds[i] + " != " + componentKind;
 202                     }
 203                 }
 204             }
 205         }
 206         return true;
 207     }
 208 


< prev index next >