src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52910 583fd71c47d6
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    23 
    23 
    24 
    24 
    25 
    25 
    26 package jdk.tools.jaotc;
    26 package jdk.tools.jaotc;
    27 
    27 
       
    28 import static jdk.tools.jaotc.AOTCompiledClass.getType;
       
    29 import static jdk.tools.jaotc.AOTCompiledClass.metadataName;
       
    30 
    28 import java.util.ArrayList;
    31 import java.util.ArrayList;
    29 import java.util.List;
    32 import java.util.List;
       
    33 
       
    34 import org.graalvm.compiler.code.CompilationResult;
       
    35 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
       
    36 import org.graalvm.compiler.hotspot.HotSpotGraalServices;
    30 
    37 
    31 import jdk.tools.jaotc.binformat.BinaryContainer;
    38 import jdk.tools.jaotc.binformat.BinaryContainer;
    32 import jdk.tools.jaotc.binformat.ByteContainer;
    39 import jdk.tools.jaotc.binformat.ByteContainer;
    33 import jdk.tools.jaotc.binformat.GotSymbol;
    40 import jdk.tools.jaotc.binformat.GotSymbol;
    34 import jdk.tools.jaotc.utils.NativeOrderOutputStream;
    41 import jdk.tools.jaotc.utils.NativeOrderOutputStream;
    35 import org.graalvm.compiler.code.CompilationResult;
       
    36 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
       
    37 
       
    38 import jdk.vm.ci.code.StackSlot;
    42 import jdk.vm.ci.code.StackSlot;
    39 import jdk.vm.ci.code.site.DataPatch;
    43 import jdk.vm.ci.code.site.DataPatch;
    40 import jdk.vm.ci.code.site.Infopoint;
    44 import jdk.vm.ci.code.site.Infopoint;
    41 import jdk.vm.ci.code.site.Mark;
    45 import jdk.vm.ci.code.site.Mark;
    42 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
    46 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
    43 import jdk.vm.ci.hotspot.HotSpotMetaData;
    47 import jdk.vm.ci.hotspot.HotSpotMetaData;
    44 
       
    45 import static jdk.tools.jaotc.AOTCompiledClass.getType;
       
    46 import static jdk.tools.jaotc.AOTCompiledClass.metadataName;
       
    47 
    48 
    48 final class MetadataBuilder {
    49 final class MetadataBuilder {
    49 
    50 
    50     private final DataBuilder dataBuilder;
    51     private final DataBuilder dataBuilder;
    51 
    52 
    95 
    96 
    96             byte[] pcDesc = metaData.pcDescBytes();
    97             byte[] pcDesc = metaData.pcDescBytes();
    97             byte[] scopeDesc = metaData.scopesDescBytes();
    98             byte[] scopeDesc = metaData.scopesDescBytes();
    98             byte[] relocationInfo = metaData.relocBytes();
    99             byte[] relocationInfo = metaData.relocBytes();
    99             byte[] oopMapInfo = metaData.oopMaps();
   100             byte[] oopMapInfo = metaData.oopMaps();
       
   101             byte[] implicitExceptionBytes = HotSpotGraalServices.getImplicitExceptionBytes(metaData);
   100 
   102 
   101             // create a global symbol at this position for this method
   103             // create a global symbol at this position for this method
   102             NativeOrderOutputStream metadataStream = new NativeOrderOutputStream();
   104             NativeOrderOutputStream metadataStream = new NativeOrderOutputStream();
   103 
   105 
   104             // get the code size
   106             // get the code size
   139 
   141 
   140                 NativeOrderOutputStream.PatchableInt pcDescOffset = metadataStream.patchableInt();
   142                 NativeOrderOutputStream.PatchableInt pcDescOffset = metadataStream.patchableInt();
   141                 NativeOrderOutputStream.PatchableInt scopeOffset = metadataStream.patchableInt();
   143                 NativeOrderOutputStream.PatchableInt scopeOffset = metadataStream.patchableInt();
   142                 NativeOrderOutputStream.PatchableInt relocationOffset = metadataStream.patchableInt();
   144                 NativeOrderOutputStream.PatchableInt relocationOffset = metadataStream.patchableInt();
   143                 NativeOrderOutputStream.PatchableInt exceptionOffset = metadataStream.patchableInt();
   145                 NativeOrderOutputStream.PatchableInt exceptionOffset = metadataStream.patchableInt();
       
   146                 NativeOrderOutputStream.PatchableInt implictTableOffset = null;
       
   147                 if (implicitExceptionBytes != null) {
       
   148                     implictTableOffset = metadataStream.patchableInt();
       
   149                 }
   144                 NativeOrderOutputStream.PatchableInt oopMapOffset = metadataStream.patchableInt();
   150                 NativeOrderOutputStream.PatchableInt oopMapOffset = metadataStream.patchableInt();
   145                 metadataStream.align(8);
   151                 metadataStream.align(8);
   146 
   152 
   147                 pcDescOffset.set(metadataStream.position());
   153                 pcDescOffset.set(metadataStream.position());
   148                 metadataStream.put(pcDesc).align(8);
   154                 metadataStream.put(pcDesc).align(8);
   153                 relocationOffset.set(metadataStream.position());
   159                 relocationOffset.set(metadataStream.position());
   154                 metadataStream.put(relocationInfo).align(8);
   160                 metadataStream.put(relocationInfo).align(8);
   155 
   161 
   156                 exceptionOffset.set(metadataStream.position());
   162                 exceptionOffset.set(metadataStream.position());
   157                 metadataStream.put(metaData.exceptionBytes()).align(8);
   163                 metadataStream.put(metaData.exceptionBytes()).align(8);
       
   164 
       
   165                 if (implicitExceptionBytes != null) {
       
   166                     implictTableOffset.set(metadataStream.position());
       
   167                     metadataStream.put(implicitExceptionBytes).align(8);
       
   168                 }
   158 
   169 
   159                 // oopmaps should be last
   170                 // oopmaps should be last
   160                 oopMapOffset.set(metadataStream.position());
   171                 oopMapOffset.set(metadataStream.position());
   161                 metadataStream.put(oopMapInfo).align(8);
   172                 metadataStream.put(oopMapInfo).align(8);
   162 
   173