< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotDataBuilder.java

Print this page


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


  31 import org.graalvm.compiler.code.DataSection.Data;
  32 import org.graalvm.compiler.code.DataSection.Patches;
  33 import org.graalvm.compiler.code.DataSection.SerializableData;
  34 import org.graalvm.compiler.code.DataSection.ZeroData;
  35 import org.graalvm.compiler.debug.GraalError;
  36 import org.graalvm.compiler.lir.asm.DataBuilder;
  37 
  38 import jdk.vm.ci.code.TargetDescription;
  39 import jdk.vm.ci.hotspot.HotSpotConstant;
  40 import jdk.vm.ci.meta.Constant;
  41 import jdk.vm.ci.meta.JavaConstant;
  42 import jdk.vm.ci.meta.SerializableConstant;
  43 import jdk.vm.ci.meta.VMConstant;
  44 
  45 public class HotSpotDataBuilder extends DataBuilder {
  46 
  47     private final TargetDescription target;
  48 
  49     public HotSpotDataBuilder(TargetDescription target) {
  50         this.target = target;
  51     }
  52 
  53     @Override
  54     public boolean needDetailedPatchingInformation() {
  55         /* The HotSpot VM finds operands that need patching by decoding the instruction. */
  56         return false;
  57     }
  58 
  59     @Override
  60     public Data createDataItem(Constant constant) {
  61         if (JavaConstant.isNull(constant)) {
  62             boolean compressed = COMPRESSED_NULL.equals(constant);
  63             int size = compressed ? 4 : target.wordSize;
  64             return ZeroData.create(size, size);
  65         } else if (constant instanceof VMConstant) {
  66             VMConstant vmConstant = (VMConstant) constant;
  67             if (!(constant instanceof HotSpotConstant)) {
  68                 throw new GraalError(String.valueOf(constant));
  69             }
  70 
  71             HotSpotConstant c = (HotSpotConstant) vmConstant;
  72             int size = c.isCompressed() ? 4 : target.wordSize;
  73             return new Data(size, size) {
  74                 @Override
  75                 protected void emit(ByteBuffer buffer, Patches patches) {
  76                     int position = buffer.position();
   1 /*
   2  * Copyright (c) 2015, 2019, 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  */


  31 import org.graalvm.compiler.code.DataSection.Data;
  32 import org.graalvm.compiler.code.DataSection.Patches;
  33 import org.graalvm.compiler.code.DataSection.SerializableData;
  34 import org.graalvm.compiler.code.DataSection.ZeroData;
  35 import org.graalvm.compiler.debug.GraalError;
  36 import org.graalvm.compiler.lir.asm.DataBuilder;
  37 
  38 import jdk.vm.ci.code.TargetDescription;
  39 import jdk.vm.ci.hotspot.HotSpotConstant;
  40 import jdk.vm.ci.meta.Constant;
  41 import jdk.vm.ci.meta.JavaConstant;
  42 import jdk.vm.ci.meta.SerializableConstant;
  43 import jdk.vm.ci.meta.VMConstant;
  44 
  45 public class HotSpotDataBuilder extends DataBuilder {
  46 
  47     private final TargetDescription target;
  48 
  49     public HotSpotDataBuilder(TargetDescription target) {
  50         this.target = target;






  51     }
  52 
  53     @Override
  54     public Data createDataItem(Constant constant) {
  55         if (JavaConstant.isNull(constant)) {
  56             boolean compressed = COMPRESSED_NULL.equals(constant);
  57             int size = compressed ? 4 : target.wordSize;
  58             return ZeroData.create(size, size);
  59         } else if (constant instanceof VMConstant) {
  60             VMConstant vmConstant = (VMConstant) constant;
  61             if (!(constant instanceof HotSpotConstant)) {
  62                 throw new GraalError(String.valueOf(constant));
  63             }
  64 
  65             HotSpotConstant c = (HotSpotConstant) vmConstant;
  66             int size = c.isCompressed() ? 4 : target.wordSize;
  67             return new Data(size, size) {
  68                 @Override
  69                 protected void emit(ByteBuffer buffer, Patches patches) {
  70                     int position = buffer.position();
< prev index next >