1 /*
   2  * Copyright (c) 2015, 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  */
  23 package org.graalvm.compiler.nodes;
  24 
  25 import java.util.List;
  26 
  27 import org.graalvm.compiler.graph.NodeClass;
  28 
  29 import jdk.vm.ci.meta.Assumptions;
  30 import jdk.vm.ci.meta.ResolvedJavaMethod;
  31 
  32 /**
  33  * A {@link StructuredGraph} encoded in a compact binary representation as a byte[] array. See
  34  * {@link GraphEncoder} for a description of the encoding format. Use {@link GraphDecoder} for
  35  * decoding.
  36  */
  37 public class EncodedGraph {
  38 
  39     private final byte[] encoding;
  40     private final long startOffset;
  41     private final Object[] objects;
  42     private final NodeClass<?>[] types;
  43     private final Assumptions assumptions;
  44     private final List<ResolvedJavaMethod> inlinedMethods;
  45 
  46     /**
  47      * The "table of contents" of the encoded graph, i.e., the mapping from orderId numbers to the
  48      * offset in the encoded byte[] array. Used as a cache during decoding.
  49      */
  50     protected long[] nodeStartOffsets;
  51 
  52     public EncodedGraph(byte[] encoding, long startOffset, Object[] objects, NodeClass<?>[] types, Assumptions assumptions, List<ResolvedJavaMethod> inlinedMethods) {
  53         this.encoding = encoding;
  54         this.startOffset = startOffset;
  55         this.objects = objects;
  56         this.types = types;
  57         this.assumptions = assumptions;
  58         this.inlinedMethods = inlinedMethods;
  59     }
  60 
  61     public byte[] getEncoding() {
  62         return encoding;
  63     }
  64 
  65     public long getStartOffset() {
  66         return startOffset;
  67     }
  68 
  69     public Object[] getObjects() {
  70         return objects;
  71     }
  72 
  73     public NodeClass<?>[] getNodeClasses() {
  74         return types;
  75     }
  76 
  77     public Assumptions getAssumptions() {
  78         return assumptions;
  79     }
  80 
  81     public List<ResolvedJavaMethod> getInlinedMethods() {
  82         return inlinedMethods;
  83     }
  84 }