diff --git a/.hgtags-top-repo b/.hgtags-top-repo index bfa2e564382..69e09487ac2 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -307,3 +307,4 @@ ea38728b4f4bdd8fd0d7a89b18069f521cf05013 jdk9-b61 105d045a69174d870b69bfe471b3f2d05a9f8ecc jdk9-b62 0b32ed628fa60e4ab99fb0b5866d648e16231f17 jdk9-b63 82cf9aab9a83e41c8194ba01af9666afdb856cbe jdk9-b64 +7c31f9d7b932f7924f1258d52885b1c7c3e078c2 jdk9-b65 diff --git a/common/bin/compare_exceptions.sh.incl b/common/bin/compare_exceptions.sh.incl index 90e110c8978..b015b7d0d8b 100644 --- a/common/bin/compare_exceptions.sh.incl +++ b/common/bin/compare_exceptions.sh.incl @@ -83,7 +83,6 @@ ACCEPTED_BIN_DIFF=" ./bin/jcmd ./bin/jconsole ./bin/jdb -./bin/jhat ./bin/jimage ./bin/jinfo ./bin/jjs @@ -163,7 +162,6 @@ ACCEPTED_BIN_DIFF=" ./bin/jcmd ./bin/jconsole ./bin/jdb -./bin/jhat ./bin/jimage ./bin/jinfo ./bin/jjs @@ -284,7 +282,6 @@ ACCEPTED_SMALL_SIZE_DIFF=" ./bin/jcmd ./bin/jconsole ./bin/jdb -./bin/jhat ./bin/jimage ./bin/jinfo ./bin/jjs @@ -420,7 +417,6 @@ ACCEPTED_SMALL_SIZE_DIFF=" ./bin/jcmd ./bin/jconsole ./bin/jdb -./bin/jhat ./bin/jimage ./bin/jinfo ./bin/jjs @@ -499,7 +495,6 @@ ACCEPTED_SMALL_SIZE_DIFF=" ./bin/jcmd.exe ./bin/jconsole.exe ./bin/jdb.exe -./bin/jhat.exe ./bin/jimage.exe ./bin/jinfo.exe ./bin/jjs.exe @@ -579,7 +574,6 @@ ACCEPTED_BIN_DIFF=" ./bin/jcmd ./bin/jconsole ./bin/jdb -./bin/jhat ./bin/jimage ./bin/jinfo ./bin/jjs diff --git a/corba/.hgtags b/corba/.hgtags index 8acbf91c3b9..182e23ba265 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -307,3 +307,4 @@ d690f489ca0bb95a6157d996da2fa72bcbcf02ea jdk9-b61 d27f7e0a7aca129969de23e9934408a31b4abf4c jdk9-b62 0acac6937de7a0868f8c6f88b7d036d780abeee6 jdk9-b63 0a5e5a7c3539e8bde73d9fe55750e49a49cb8dac jdk9-b64 +afc1e295c4bf83f9a5dd539c29914edd4a754a3f jdk9-b65 diff --git a/hotspot/.hgignore b/hotspot/.hgignore index e9ce602582b..45f920748bb 100644 --- a/hotspot/.hgignore +++ b/hotspot/.hgignore @@ -6,5 +6,7 @@ ^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/ ^src/share/tools/IdealGraphVisualizer/build/ ^src/share/tools/IdealGraphVisualizer/dist/ +^src/share/tools/IdealGraphVisualizer/nbplatform/ +.igv.log ^.hgtip .DS_Store diff --git a/hotspot/.hgtags b/hotspot/.hgtags index def3dbf7702..36118304912 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -467,3 +467,4 @@ ee878f3d6732856f7725c590312bfbe2ffa52cc7 jdk9-b58 1eab877142cce6ca06e556e2ad0af688f993f00b jdk9-b62 2ac9b6b36689b50d1562627067c92d51781b5684 jdk9-b63 bf92b8db249cdfa5651ef954b6c0743a7e0ea4cd jdk9-b64 +e7ae94c4f35e940ea423fc1dd260435df34a77c0 jdk9-b65 diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java index 9ae362baa48..c43c5b1b88e 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HSDB.java @@ -27,9 +27,7 @@ package sun.jvm.hotspot; import java.io.*; import java.awt.*; import java.awt.event.*; -import java.math.*; import javax.swing.*; -import javax.swing.tree.*; import java.util.*; import sun.jvm.hotspot.code.*; @@ -928,7 +926,7 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener { boolean shouldSkipOopMaps = false; if (curVFrame.isCompiledFrame()) { CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC()); - OopMapSet maps = cb.getOopMaps(); + ImmutableOopMapSet maps = cb.getOopMaps(); if ((maps == null) || (maps.getSize() == 0)) { shouldSkipOopMaps = true; } @@ -977,7 +975,7 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener { } while (nextVFrame != null && nextFrame.equals(curFrame)); if (shouldSkipOopMaps) { - anno = anno + "\nNOTE: null or empty OopMapSet found for this CodeBlob"; + anno = anno + "\nNOTE: null or empty ImmutableOopMapSet found for this CodeBlob"; } if (curFrame.getFP() != null) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java index e1be42422be..a018ab83014 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java @@ -171,17 +171,17 @@ public class CodeBlob extends VMObject { public boolean isLockedByVM() { return false; } /** OopMap for frame; can return null if none available */ - public OopMapSet getOopMaps() { + public ImmutableOopMapSet getOopMaps() { Address oopMapsAddr = oopMapsField.getValue(addr); if (oopMapsAddr == null) { return null; } - return new OopMapSet(oopMapsAddr); + return new ImmutableOopMapSet(oopMapsAddr); } // FIXME: not yet implementable - // void set_oop_maps(OopMapSet* p); + // void set_oop_maps(ImmutableOopMapSet* p); - public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { + public ImmutableOopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { Address pc = returnAddress; if (Assert.ASSERTS_ENABLED) { Assert.that(getOopMaps() != null, "nope"); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMap.java similarity index 50% rename from hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMap.java rename to hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMap.java index 2643d2ccaa1..72ee812bd8d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMap.java @@ -31,15 +31,9 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; -public class OopMap extends VMObject { - private static CIntegerField pcOffsetField; - private static CIntegerField omvCountField; - private static CIntegerField omvDataSizeField; - private static AddressField omvDataField; - private static AddressField compressedWriteStreamField; - - // This is actually a field inside class CompressedStream - private static AddressField compressedStreamBufferField; +public class ImmutableOopMap extends VMObject { + private static CIntegerField countField; + private static long classSize; static { VM.registerVMInitializedObserver(new Observer() { @@ -50,52 +44,24 @@ public class OopMap extends VMObject { } private static void initialize(TypeDataBase db) { - Type type = db.lookupType("OopMap"); - - pcOffsetField = type.getCIntegerField("_pc_offset"); - omvCountField = type.getCIntegerField("_omv_count"); - omvDataSizeField = type.getCIntegerField("_omv_data_size"); - omvDataField = type.getAddressField("_omv_data"); - compressedWriteStreamField = type.getAddressField("_write_stream"); - - type = db.lookupType("CompressedStream"); - compressedStreamBufferField = type.getAddressField("_buffer"); + Type type = db.lookupType("ImmutableOopMap"); + countField = type.getCIntegerField("_count"); + classSize = type.getSize(); } - public OopMap(Address addr) { + public ImmutableOopMap(Address addr) { super(addr); } - public long getOffset() { - return pcOffsetField.getValue(addr); - } - //-------------------------------------------------------------------------------- // Internals only below this point // - // Accessors -- package private for now - Address getOMVData() { - return omvDataField.getValue(addr); + long getCount() { + return countField.getValue(addr); } - long getOMVDataSize() { - return omvDataSizeField.getValue(addr); - } - - long getOMVCount() { - return omvCountField.getValue(addr); - } - - CompressedWriteStream getWriteStream() { - Address wsAddr = compressedWriteStreamField.getValue(addr); - if (wsAddr == null) { - return null; - } - Address bufferAddr = compressedStreamBufferField.getValue(wsAddr); - if (bufferAddr == null) { - return null; - } - return new CompressedWriteStream(bufferAddr); + public Address getData() { + return addr.addOffsetTo(classSize); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapPair.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapPair.java new file mode 100644 index 00000000000..5c975fc5298 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapPair.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.compiler; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.types.CIntegerField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; + +import java.util.Observable; +import java.util.Observer; + +public class ImmutableOopMapPair { + private static CIntegerField pcField; + private static CIntegerField offsetField; + private static long classSize; + + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private final Address address; + + public ImmutableOopMapPair(Address address) { + this.address = address; + } + + public static long classSize() { + return classSize; + } + + public int getPC() { + return (int) pcField.getValue(address); + } + + public int getOffset() { + return (int) offsetField.getValue(address); + } + + private static void initialize(TypeDataBase db) { + Type type = db.lookupType("ImmutableOopMapPair"); + + pcField = type.getCIntegerField("_pc_offset"); + offsetField = type.getCIntegerField("_oopmap_offset"); + classSize = type.getSize(); + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapSet.java similarity index 69% rename from hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java rename to hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapSet.java index 9433cf6864d..b2ece64f639 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapSet.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/ImmutableOopMapSet.java @@ -32,15 +32,17 @@ import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; -public class OopMapSet extends VMObject { - private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.compiler.OopMapSet.DEBUG") != null; +public class ImmutableOopMapSet extends VMObject { + private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.compiler.ImmutableOopMapSet.DEBUG") != null; - private static CIntegerField omCountField; - private static CIntegerField omSizeField; - private static AddressField omDataField; + private static CIntegerField countField; + private static CIntegerField sizeField; + private static AddressField omDataField; private static int REG_COUNT; private static int SAVED_ON_ENTRY_REG_COUNT; private static int C_SAVED_ON_ENTRY_REG_COUNT; + private static long classSize; + private static class MyVisitor implements OopMapVisitor { private AddressVisitor addressVisitor; @@ -60,7 +62,7 @@ public class OopMapSet extends VMObject { if (VM.getVM().isClientCompiler()) { Assert.that(false, "should not reach here"); } else if (VM.getVM().isServerCompiler() && - VM.getVM().useDerivedPointerTable()) { + VM.getVM().useDerivedPointerTable()) { Assert.that(false, "FIXME: add derived pointer table"); } } @@ -75,18 +77,18 @@ public class OopMapSet extends VMObject { static { VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); } private static void initialize(TypeDataBase db) { - Type type = db.lookupType("OopMapSet"); + Type type = db.lookupType("ImmutableOopMapSet"); - omCountField = type.getCIntegerField("_om_count"); - omSizeField = type.getCIntegerField("_om_size"); - omDataField = type.getAddressField("_om_data"); + countField = type.getCIntegerField("_count"); + sizeField = type.getCIntegerField("_size"); + classSize = type.getSize(); if (!VM.getVM().isCore()) { REG_COUNT = db.lookupIntConstant("REG_COUNT").intValue(); @@ -97,29 +99,41 @@ public class OopMapSet extends VMObject { } } - public OopMapSet(Address addr) { + public ImmutableOopMapSet(Address addr) { super(addr); } - /** Returns the number of OopMaps in this OopMapSet */ + /** + * Returns the number of OopMaps in this ImmutableOopMapSet + */ public long getSize() { - return omCountField.getValue(addr); + return countField.getValue(addr); } - /** returns the OopMap at a given index */ - public OopMap getMapAt(int index) { + public int getCount() { return (int) countField.getValue(addr); } + + private Address dataStart() { + return (addr.addOffsetTo(ImmutableOopMapSet.classSize * getCount())); + } + + public ImmutableOopMapPair pairAt(int index) { + Assert.that((index >= 0) && (index < getCount()), "bad index"); + return new ImmutableOopMapPair(addr.addOffsetTo(index * ImmutableOopMapPair.classSize())); + } + + /** + * returns the OopMap at a given index + */ + public ImmutableOopMap getMapAt(int index) { if (Assert.ASSERTS_ENABLED) { - Assert.that((index >= 0) && (index <= getSize()),"bad index"); + Assert.that((index >= 0) && (index <= getSize()), "bad index"); } - Address omDataAddr = omDataField.getValue(addr); - Address oopMapAddr = omDataAddr.getAddressAt(index * VM.getVM().getAddressSize()); - if (oopMapAddr == null) { - return null; - } - return new OopMap(oopMapAddr); + + ImmutableOopMapPair immutableOopMapPair = pairAt(index); + return getMap(immutableOopMapPair); } - public OopMap findMapAtOffset(long pcOffset, boolean debugging) { + public ImmutableOopMap findMapAtOffset(long pcOffset, boolean debugging) { int i; int len = (int) getSize(); if (Assert.ASSERTS_ENABLED) { @@ -129,7 +143,7 @@ public class OopMapSet extends VMObject { // Scan through oopmaps. Stop when current offset is either equal or greater // than the one we are looking for. for (i = 0; i < len; i++) { - if (getMapAt(i).getOffset() >= pcOffset) { + if (pairAt(i).getPC() >= pcOffset) { break; } } @@ -137,7 +151,7 @@ public class OopMapSet extends VMObject { if (!debugging) { if (Assert.ASSERTS_ENABLED) { Assert.that(i < len, "oopmap not found for pcOffset = " + pcOffset + "; len = " + len); - Assert.that(getMapAt(i).getOffset() == pcOffset, "oopmap not found"); + Assert.that(pairAt(i).getPC() == pcOffset, "oopmap not found"); } } else { if (i == len) { @@ -145,7 +159,7 @@ public class OopMapSet extends VMObject { System.out.println("can't find oopmap at " + pcOffset); System.out.print("Oopmap offsets are [ "); for (i = 0; i < len; i++) { - System.out.print(getMapAt(i).getOffset()); + System.out.print(pairAt(i).getPC()); } System.out.println("]"); } @@ -154,28 +168,32 @@ public class OopMapSet extends VMObject { } } - OopMap m = getMapAt(i); + ImmutableOopMap m = getMapAt(i); return m; } - /** Visitation -- iterates through the frame for a compiled method. - This is a very generic mechanism that requires the Address to be - dereferenced by the callee. Other, more specialized, visitation - mechanisms are given below. */ + /** + * Visitation -- iterates through the frame for a compiled method. + * This is a very generic mechanism that requires the Address to be + * dereferenced by the callee. Other, more specialized, visitation + * mechanisms are given below. + */ public static void oopsDo(Frame fr, CodeBlob cb, RegisterMap regMap, AddressVisitor oopVisitor, boolean debugging) { allDo(fr, cb, regMap, new MyVisitor(oopVisitor), debugging); } - /** Note that there are 4 required AddressVisitors: one for oops, - one for derived oops, one for values, and one for dead values */ + /** + * Note that there are 4 required AddressVisitors: one for oops, + * one for derived oops, one for values, and one for dead values + */ public static void allDo(Frame fr, CodeBlob cb, RegisterMap regMap, OopMapVisitor visitor, boolean debugging) { if (Assert.ASSERTS_ENABLED) { CodeBlob tmpCB = VM.getVM().getCodeCache().findBlob(fr.getPC()); Assert.that(tmpCB != null && cb.equals(tmpCB), "wrong codeblob passed in"); } - OopMapSet maps = cb.getOopMaps(); - OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging); + ImmutableOopMapSet maps = cb.getOopMaps(); + ImmutableOopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging); if (Assert.ASSERTS_ENABLED) { Assert.that(map != null, "no ptr map found"); } @@ -191,7 +209,7 @@ public class OopMapSet extends VMObject { omv = oms.getCurrent(); Address loc = fr.oopMapRegToLocation(omv.getReg(), regMap); if (loc != null) { - Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap); + Address baseLoc = fr.oopMapRegToLocation(omv.getContentReg(), regMap); Address derivedLoc = loc; visitor.visitDerivedOopLocation(baseLoc, derivedLoc); } @@ -199,8 +217,8 @@ public class OopMapSet extends VMObject { } // We want narow oop, value and oop oop_types - OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[] { - OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.NARROWOOP_VALUE + OopMapValue.OopTypes[] values = new OopMapValue.OopTypes[]{ + OopMapValue.OopTypes.OOP_VALUE, OopMapValue.OopTypes.VALUE_VALUE, OopMapValue.OopTypes.NARROWOOP_VALUE }; { @@ -223,8 +241,10 @@ public class OopMapSet extends VMObject { } } - /** Update callee-saved register info for the following frame. - Should only be called in non-core builds. */ + /** + * Update callee-saved register info for the following frame. + * Should only be called in non-core builds. + */ public static void updateRegisterMap(Frame fr, CodeBlob cb, RegisterMap regMap, boolean debugging) { if (Assert.ASSERTS_ENABLED) { Assert.that(!VM.getVM().isCore(), "non-core builds only"); @@ -232,14 +252,14 @@ public class OopMapSet extends VMObject { if (!VM.getVM().isDebugging()) { if (Assert.ASSERTS_ENABLED) { - OopMapSet maps = cb.getOopMaps(); - Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty OopMapSet for CodeBlob"); + ImmutableOopMapSet maps = cb.getOopMaps(); + Assert.that((maps != null) && (maps.getSize() > 0), "found null or empty ImmutableOopMapSet for CodeBlob"); } } else { // Hack for some topmost frames that have been found with empty // OopMapSets. (Actually have not seen the null case, but don't // want to take any chances.) See HSDB.showThreadStackMemory(). - OopMapSet maps = cb.getOopMaps(); + ImmutableOopMapSet maps = cb.getOopMaps(); if ((maps == null) || (maps.getSize() == 0)) { return; } @@ -250,18 +270,18 @@ public class OopMapSet extends VMObject { int nofCallee = 0; Address[] locs = new Address[2 * REG_COUNT + 1]; - VMReg [] regs = new VMReg [2 * REG_COUNT + 1]; + VMReg[] regs = new VMReg[2 * REG_COUNT + 1]; // ("+1" because REG_COUNT might be zero) // Scan through oopmap and find location of all callee-saved registers // (we do not do update in place, since info could be overwritten) - OopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging); + ImmutableOopMap map = cb.getOopMapForReturnAddress(fr.getPC(), debugging); if (Assert.ASSERTS_ENABLED) { Assert.that(map != null, "no ptr map found"); } OopMapValue omv = null; - for(OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE); !oms.isDone(); oms.next()) { + for (OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE); !oms.isDone(); oms.next()) { omv = oms.getCurrent(); if (Assert.ASSERTS_ENABLED) { Assert.that(nofCallee < 2 * REG_COUNT, "overflow"); @@ -276,8 +296,8 @@ public class OopMapSet extends VMObject { if (Assert.ASSERTS_ENABLED) { if (VM.getVM().isServerCompiler()) { Assert.that(!cb.isRuntimeStub() || - (nofCallee >= SAVED_ON_ENTRY_REG_COUNT || nofCallee >= C_SAVED_ON_ENTRY_REG_COUNT), - "must save all"); + (nofCallee >= SAVED_ON_ENTRY_REG_COUNT || nofCallee >= C_SAVED_ON_ENTRY_REG_COUNT), + "must save all"); } } @@ -286,4 +306,13 @@ public class OopMapSet extends VMObject { regMap.setLocation(regs[i], locs[i]); } } + + public ImmutableOopMapPair getPairAt(int index) { + return pairAt(index); + } + + public ImmutableOopMap getMap(ImmutableOopMapPair pair) { + Assert.that(pair.getOffset() < (int) sizeField.getValue(), "boundary check"); + return new ImmutableOopMap(dataStart().addOffsetTo(pair.getOffset())); + } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapStream.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapStream.java index 3056ee924a6..3dc1556a53e 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapStream.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/compiler/OopMapStream.java @@ -28,30 +28,26 @@ import sun.jvm.hotspot.code.*; public class OopMapStream { private CompressedReadStream stream; - private OopMap oopMap; + private ImmutableOopMap oopMap; private int mask; private int size; private int position; private OopMapValue omv; private boolean omvValid; - public OopMapStream(OopMap oopMap) { + public OopMapStream(ImmutableOopMap oopMap) { this(oopMap, (OopMapValue.OopTypes[]) null); } - public OopMapStream(OopMap oopMap, OopMapValue.OopTypes type) { + public OopMapStream(ImmutableOopMap oopMap, OopMapValue.OopTypes type) { this(oopMap, (OopMapValue.OopTypes[]) null); mask = type.getValue(); } - public OopMapStream(OopMap oopMap, OopMapValue.OopTypes[] types) { - if (oopMap.getOMVData() == null) { - stream = new CompressedReadStream(oopMap.getWriteStream().getBuffer()); - } else { - stream = new CompressedReadStream(oopMap.getOMVData()); - } + public OopMapStream(ImmutableOopMap oopMap, OopMapValue.OopTypes[] types) { + stream = new CompressedReadStream(oopMap.getData()); mask = computeMask(types); - size = (int) oopMap.getOMVCount(); + size = (int) oopMap.getCount(); position = 0; omv = new OopMapValue(); omvValid = false; diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java index daa2574d136..b7b27b98135 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java @@ -26,14 +26,12 @@ package sun.jvm.hotspot.runtime; import java.io.*; import java.util.*; -import sun.jvm.hotspot.*; + import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; -import sun.jvm.hotspot.c1.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.interpreter.*; import sun.jvm.hotspot.oops.*; -import sun.jvm.hotspot.runtime.sparc.SPARCFrame; import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; @@ -626,7 +624,7 @@ public abstract class Frame implements Cloneable { Assert.that(cb != null, "sanity check"); } if (cb.getOopMaps() != null) { - OopMapSet.oopsDo(this, cb, regMap, oopVisitor, VM.getVM().isDebugging()); + ImmutableOopMapSet.oopsDo(this, cb, regMap, oopVisitor, VM.getVM().isDebugging()); // FIXME: add in traversal of argument oops (skipping this for // now until we have the other stuff tested) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java index 619a3fd8b53..5937f7f19a2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java @@ -358,7 +358,7 @@ public class PPC64Frame extends Frame { map.setIncludeArgumentOops(cb.callerMustGCArguments()); if (cb.getOopMaps() != null) { - OopMapSet.updateRegisterMap(this, cb, map, true); + ImmutableOopMapSet.updateRegisterMap(this, cb, map, true); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java index 20f44ce2376..bbb1dfa7e44 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java @@ -24,8 +24,6 @@ package sun.jvm.hotspot.runtime.sparc; -import java.util.*; - import sun.jvm.hotspot.asm.sparc.*; import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; @@ -34,7 +32,6 @@ import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.runtime.posix.*; -import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; /** Specialization of and implementation of abstract methods of the @@ -592,7 +589,7 @@ public class SPARCFrame extends Frame { map.setIncludeArgumentOops(true); } if (cb.getOopMaps() != null) { - OopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging()); + ImmutableOopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging()); } } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java index 558aa4a8dbd..51e2b6e8089 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java @@ -385,7 +385,7 @@ public class X86Frame extends Frame { map.setIncludeArgumentOops(cb.callerMustGCArguments()); if (cb.getOopMaps() != null) { - OopMapSet.updateRegisterMap(this, cb, map, true); + ImmutableOopMapSet.updateRegisterMap(this, cb, map, true); } // Since the prolog does the save and restore of EBP there is no oopmap diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java index 91993feea8c..eba84fd6496 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @@ -31,11 +31,9 @@ import sun.jvm.hotspot.code.*; import sun.jvm.hotspot.compiler.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.interpreter.*; -import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.tools.jcore.*; -import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; public class HTMLGenerator implements /* imports */ ClassConstants { @@ -887,7 +885,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { private Formatter buf; private SymbolFinder symFinder = createSymbolFinder(); private long pc; - private OopMapSet oms; + private ImmutableOopMapSet oms; private CodeBlob blob; private NMethod nmethod; @@ -954,13 +952,13 @@ public class HTMLGenerator implements /* imports */ ClassConstants { if (oms != null) { long base = addressToLong(blob.codeBegin()); - for (int i = 0, imax = (int)oms.getSize(); i < imax; i++) { - OopMap om = oms.getMapAt(i); - long omspc = base + om.getOffset(); + for (int i = 0, imax = oms.getCount(); i < imax; i++) { + ImmutableOopMapPair pair = oms.getPairAt(i); + long omspc = base + pair.getPC(); if (omspc > pc) { if (omspc <= endPc) { buf.br(); - buf.append(genOopMapInfo(om)); + buf.append(genOopMapInfo(oms.getMap(pair))); // st.move_to(column); // visitor.print("; "); // om.print_on(st); @@ -1167,7 +1165,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { } } - protected String genHTMLForOopMap(OopMap map) { + protected String genHTMLForOopMap(ImmutableOopMap map) { final int stack0 = VMRegImpl.getStack0().getValue(); Formatter buf = new Formatter(genHTML); @@ -1237,11 +1235,11 @@ public class HTMLGenerator implements /* imports */ ClassConstants { protected String genOopMapInfo(NMethod nmethod, PCDesc pcDesc) { - OopMapSet mapSet = nmethod.getOopMaps(); + ImmutableOopMapSet mapSet = nmethod.getOopMaps(); if (mapSet == null || (mapSet.getSize() <= 0)) return ""; int pcOffset = pcDesc.getPCOffset(); - OopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging()); + ImmutableOopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging()); if (map == null) { throw new IllegalArgumentException("no oopmap at safepoint!"); } @@ -1249,7 +1247,7 @@ public class HTMLGenerator implements /* imports */ ClassConstants { return genOopMapInfo(map); } - protected String genOopMapInfo(OopMap map) { + protected String genOopMapInfo(ImmutableOopMap map) { Formatter buf = new Formatter(genHTML); buf.beginTag("pre"); buf.append("OopMap: "); diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 6e41838c786..357b0167029 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -421,7 +421,40 @@ reg_class any_reg( ); // Class for all non-special integer registers -reg_class no_special_reg32( +reg_class no_special_reg32_no_fp( + R0, + R1, + R2, + R3, + R4, + R5, + R6, + R7, + R10, + R11, + R12, // rmethod + R13, + R14, + R15, + R16, + R17, + R18, + R19, + R20, + R21, + R22, + R23, + R24, + R25, + R26 + /* R27, */ // heapbase + /* R28, */ // thread + /* R29, */ // fp + /* R30, */ // lr + /* R31 */ // sp +); + +reg_class no_special_reg32_with_fp( R0, R1, R2, @@ -454,8 +487,43 @@ reg_class no_special_reg32( /* R31 */ // sp ); +reg_class_dynamic no_special_reg32(no_special_reg32_no_fp, no_special_reg32_with_fp, %{ PreserveFramePointer %}); + // Class for all non-special long integer registers -reg_class no_special_reg( +reg_class no_special_reg_no_fp( + R0, R0_H, + R1, R1_H, + R2, R2_H, + R3, R3_H, + R4, R4_H, + R5, R5_H, + R6, R6_H, + R7, R7_H, + R10, R10_H, + R11, R11_H, + R12, R12_H, // rmethod + R13, R13_H, + R14, R14_H, + R15, R15_H, + R16, R16_H, + R17, R17_H, + R18, R18_H, + R19, R19_H, + R20, R20_H, + R21, R21_H, + R22, R22_H, + R23, R23_H, + R24, R24_H, + R25, R25_H, + R26, R26_H, + /* R27, R27_H, */ // heapbase + /* R28, R28_H, */ // thread + /* R29, R29_H, */ // fp + /* R30, R30_H, */ // lr + /* R31, R31_H */ // sp +); + +reg_class no_special_reg_with_fp( R0, R0_H, R1, R1_H, R2, R2_H, @@ -488,6 +556,8 @@ reg_class no_special_reg( /* R31, R31_H */ // sp ); +reg_class_dynamic no_special_reg(no_special_reg_no_fp, no_special_reg_with_fp, %{ PreserveFramePointer %}); + // Class for 64 bit register r0 reg_class r0_reg( R0, R0_H @@ -1637,12 +1707,7 @@ bool needs_releasing_store(const Node *n) int MachCallStaticJavaNode::ret_addr_offset() { // call should be a simple bl - // unless this is a method handle invoke in which case it is - // mov(rfp, sp), bl, mov(sp, rfp) int off = 4; - if (_method_handle_invoke) { - off += 4; - } return off; } @@ -1753,14 +1818,13 @@ void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const { if (C->need_stack_bang(framesize)) st->print("# stack bang size=%d\n\t", framesize); - if (framesize == 0) { - // Is this even possible? - st->print("stp lr, rfp, [sp, #%d]!", -(2 * wordSize)); - } else if (framesize < ((1 << 9) + 2 * wordSize)) { + if (framesize < ((1 << 9) + 2 * wordSize)) { st->print("sub sp, sp, #%d\n\t", framesize); st->print("stp rfp, lr, [sp, #%d]", framesize - 2 * wordSize); + if (PreserveFramePointer) st->print("\n\tadd rfp, sp, #%d", framesize - 2 * wordSize); } else { st->print("stp lr, rfp, [sp, #%d]!\n\t", -(2 * wordSize)); + if (PreserveFramePointer) st->print("mov rfp, sp\n\t"); st->print("mov rscratch1, #%d\n\t", framesize - 2 * wordSize); st->print("sub sp, sp, rscratch1"); } @@ -3517,34 +3581,6 @@ encode %{ } %} - enc_class aarch64_enc_java_handle_call(method meth) %{ - MacroAssembler _masm(&cbuf); - relocInfo::relocType reloc; - - // RFP is preserved across all calls, even compiled calls. - // Use it to preserve SP. - __ mov(rfp, sp); - - const int start_offset = __ offset(); - address addr = (address)$meth$$method; - if (!_method) { - // A call to a runtime wrapper, e.g. new, new_typeArray_Java, uncommon_trap. - __ trampoline_call(Address(addr, relocInfo::runtime_call_type), &cbuf); - } else if (_optimized_virtual) { - __ trampoline_call(Address(addr, relocInfo::opt_virtual_call_type), &cbuf); - } else { - __ trampoline_call(Address(addr, relocInfo::static_call_type), &cbuf); - } - - if (_method) { - // Emit stub for static call - CompiledStaticCall::emit_to_interp_stub(cbuf); - } - - // now restore sp - __ mov(sp, rfp); - %} - enc_class aarch64_enc_java_dynamic_call(method meth) %{ MacroAssembler _masm(&cbuf); __ ic_call((address)$meth$$method); @@ -12561,8 +12597,6 @@ instruct CallStaticJavaDirect(method meth) effect(USE meth); - predicate(!((CallStaticJavaNode*)n)->is_method_handle_invoke()); - ins_cost(CALL_COST); format %{ "call,static $meth \t// ==> " %} @@ -12575,26 +12609,6 @@ instruct CallStaticJavaDirect(method meth) // TO HERE -// Call Java Static Instruction (method handle version) - -instruct CallStaticJavaDirectHandle(method meth, iRegP_FP reg_mh_save) -%{ - match(CallStaticJava); - - effect(USE meth); - - predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke()); - - ins_cost(CALL_COST); - - format %{ "call,static $meth \t// (methodhandle) ==> " %} - - ins_encode( aarch64_enc_java_handle_call(meth), - aarch64_enc_call_epilog ); - - ins_pipe(pipe_class_call); -%} - // Call Java Dynamic Instruction instruct CallDynamicJavaDirect(method meth) %{ diff --git a/hotspot/src/cpu/aarch64/vm/c1_FrameMap_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_FrameMap_aarch64.cpp index 9a1339d337d..abb57ff8db6 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_FrameMap_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_FrameMap_aarch64.cpp @@ -346,8 +346,7 @@ LIR_Opr FrameMap::stack_pointer() { // JSR 292 LIR_Opr FrameMap::method_handle_invoke_SP_save_opr() { - // assert(rfp == rbp_mh_SP_save, "must be same register"); - return rfp_opr; + return LIR_OprFact::illegalOpr; // Not needed on aarch64 } diff --git a/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp index a290591ad56..5b31905fdef 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_Runtime1_aarch64.cpp @@ -443,18 +443,8 @@ OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler *sasm) { restore_live_registers(sasm, id != handle_exception_nofpu_id); break; case handle_exception_from_callee_id: - // Pop the return address since we are possibly changing SP (restoring from BP). + // Pop the return address. __ leave(); - - // Restore SP from FP if the exception PC is a method handle call site. - { - Label nope; - __ ldrw(rscratch1, Address(rthread, JavaThread::is_method_handle_return_offset())); - __ cbzw(rscratch1, nope); - __ mov(sp, rfp); - __ bind(nope); - } - __ ret(lr); // jump to exception handler break; default: ShouldNotReachHere(); @@ -514,14 +504,6 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) { __ verify_not_null_oop(exception_oop); - { - Label foo; - __ ldrw(rscratch1, Address(rthread, JavaThread::is_method_handle_return_offset())); - __ cbzw(rscratch1, foo); - __ mov(sp, rfp); - __ bind(foo); - } - // continue at exception handler (return address removed) // note: do *not* remove arguments when unwinding the // activation since the caller assumes having diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp index 56f47bd2a8e..96f9c1ef0ce 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp @@ -223,7 +223,8 @@ bool frame::safe_for_sender(JavaThread *thread) { if (sender_blob->is_nmethod()) { nmethod* nm = sender_blob->as_nmethod_or_null(); if (nm != NULL) { - if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc)) { + if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || + nm->method()->is_method_handle_intrinsic()) { return false; } } @@ -389,10 +390,9 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const { // frame::verify_deopt_original_pc // // Verifies the calculated original PC of a deoptimization PC for the -// given unextended SP. The unextended SP might also be the saved SP -// for MethodHandle call sites. +// given unextended SP. #ifdef ASSERT -void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return) { +void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) { frame fr; // This is ugly but it's better than to change {get,set}_original_pc @@ -402,33 +402,23 @@ void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp, bool address original_pc = nm->get_original_pc(&fr); assert(nm->insts_contains(original_pc), "original PC must be in nmethod"); - assert(nm->is_method_handle_return(original_pc) == is_method_handle_return, "must be"); } #endif //------------------------------------------------------------------------------ // frame::adjust_unextended_sp void frame::adjust_unextended_sp() { - // If we are returning to a compiled MethodHandle call site, the - // saved_fp will in fact be a saved value of the unextended SP. The - // simplest way to tell whether we are returning to such a call site - // is as follows: + // On aarch64, sites calling method handle intrinsics and lambda forms are treated + // as any other call site. Therefore, no special action is needed when we are + // returning to any of these call sites. nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null(); if (sender_nm != NULL) { - // If the sender PC is a deoptimization point, get the original - // PC. For MethodHandle call site the unextended_sp is stored in - // saved_fp. - if (sender_nm->is_deopt_mh_entry(_pc)) { - DEBUG_ONLY(verify_deopt_mh_original_pc(sender_nm, _fp)); - _unextended_sp = _fp; - } - else if (sender_nm->is_deopt_entry(_pc)) { + // If the sender PC is a deoptimization point, get the original PC. + if (sender_nm->is_deopt_entry(_pc) || + sender_nm->is_deopt_mh_entry(_pc)) { DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp)); } - else if (sender_nm->is_method_handle_return(_pc)) { - _unextended_sp = _fp; - } } } diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp index 38f202dc986..496bb0ed7af 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp @@ -167,10 +167,7 @@ #ifdef ASSERT // Used in frame::sender_for_{interpreter,compiled}_frame - static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp, bool is_method_handle_return = false); - static void verify_deopt_mh_original_pc(nmethod* nm, intptr_t* unextended_sp) { - verify_deopt_original_pc(nm, unextended_sp, true); - } + static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp); #endif public: diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp index 5a9ae786638..3288eef3dac 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp @@ -47,12 +47,6 @@ static int spin; inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { intptr_t a = intptr_t(sp); intptr_t b = intptr_t(fp); -#ifndef PRODUCT - if (fp) - if (sp > fp || (fp - sp > 0x100000)) - for(;;) - asm("nop"); -#endif _sp = sp; _unextended_sp = sp; _fp = fp; diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index cdd5de4d23a..7d180013406 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -3788,14 +3788,14 @@ void MacroAssembler::adrp(Register reg1, const Address &dest, unsigned long &byt } void MacroAssembler::build_frame(int framesize) { - if (framesize == 0) { - // Is this even possible? - stp(rfp, lr, Address(pre(sp, -2 * wordSize))); - } else if (framesize < ((1 << 9) + 2 * wordSize)) { + assert(framesize > 0, "framesize must be > 0"); + if (framesize < ((1 << 9) + 2 * wordSize)) { sub(sp, sp, framesize); stp(rfp, lr, Address(sp, framesize - 2 * wordSize)); + if (PreserveFramePointer) add(rfp, sp, framesize - 2 * wordSize); } else { stp(rfp, lr, Address(pre(sp, -2 * wordSize))); + if (PreserveFramePointer) mov(rfp, sp); if (framesize < ((1 << 12) + 2 * wordSize)) sub(sp, sp, framesize - 2 * wordSize); else { @@ -3806,9 +3806,8 @@ void MacroAssembler::build_frame(int framesize) { } void MacroAssembler::remove_frame(int framesize) { - if (framesize == 0) { - ldp(rfp, lr, Address(post(sp, 2 * wordSize))); - } else if (framesize < ((1 << 9) + 2 * wordSize)) { + assert(framesize > 0, "framesize must be > 0"); + if (framesize < ((1 << 9) + 2 * wordSize)) { ldp(rfp, lr, Address(sp, framesize - 2 * wordSize)); add(sp, sp, framesize); } else { diff --git a/hotspot/src/cpu/aarch64/vm/register_definitions_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/register_definitions_aarch64.cpp index eb782d9dfb1..2c67be11d64 100644 --- a/hotspot/src/cpu/aarch64/vm/register_definitions_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/register_definitions_aarch64.cpp @@ -149,7 +149,3 @@ REGISTER_DEFINITION(Register, rthread); REGISTER_DEFINITION(Register, rheapbase); REGISTER_DEFINITION(Register, r31_sp); - -// TODO : x86 uses rbp to save SP in method handle code -// we may need to do the same with fp -// REGISTER_DEFINITION(Register, rbp_mh_SP_save) diff --git a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp index dfbbffae495..fe9a26ee502 100644 --- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp @@ -2995,21 +2995,6 @@ void OptoRuntime::generate_exception_blob() { // r0: exception handler - // Restore SP from BP if the exception PC is a MethodHandle call site. - __ ldrw(rscratch1, Address(rthread, JavaThread::is_method_handle_return_offset())); - // n.b. Intel uses special register rbp_mh_SP_save here but we will - // just hard wire rfp - __ cmpw(rscratch1, zr); - // the obvious way to conditionally copy rfp to sp if NE - // Label skip; - // __ br(Assembler::EQ, skip); - // __ mov(sp, rfp); - // __ bind(skip); - // same but branchless - __ mov(rscratch1, sp); - __ csel(rscratch1, rfp, rscratch1, Assembler::NE); - __ mov(sp, rscratch1); - // We have a handler in r0 (could be deopt blob). __ mov(r8, r0); diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index 5cf5bd77700..af461db8b61 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -1891,7 +1891,7 @@ class StubGenerator: public StubCodeGenerator { address start = __ pc(); __ enter(); - __ mov(rscratch1, len_reg); + __ mov(rscratch2, len_reg); __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ ld1(v0, __ T16B, rvec); diff --git a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp index 357b3d359bd..2cf4257891a 100644 --- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp @@ -629,7 +629,7 @@ void VM_Version::config_dscr() { // Print the detection code. if (PrintAssembly) { ttyLocker ttyl; - tty->print_cr("Decoding dscr configuration stub at " INTPTR_FORMAT " before execution:", code); + tty->print_cr("Decoding dscr configuration stub at " INTPTR_FORMAT " before execution:", p2i(code)); Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 2d06abb0086..613c1cb0145 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -54,6 +54,36 @@ #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") // Implementation of AddressLiteral +// A 2-D table for managing compressed displacement(disp8) on EVEX enabled platforms. +unsigned char tuple_table[Assembler::EVEX_ETUP + 1][Assembler::AVX_512bit + 1] = { + // -----------------Table 4.5 -------------------- // + 16, 32, 64, // EVEX_FV(0) + 4, 4, 4, // EVEX_FV(1) - with Evex.b + 16, 32, 64, // EVEX_FV(2) - with Evex.w + 8, 8, 8, // EVEX_FV(3) - with Evex.w and Evex.b + 8, 16, 32, // EVEX_HV(0) + 4, 4, 4, // EVEX_HV(1) - with Evex.b + // -----------------Table 4.6 -------------------- // + 16, 32, 64, // EVEX_FVM(0) + 1, 1, 1, // EVEX_T1S(0) + 2, 2, 2, // EVEX_T1S(1) + 4, 4, 4, // EVEX_T1S(2) + 8, 8, 8, // EVEX_T1S(3) + 4, 4, 4, // EVEX_T1F(0) + 8, 8, 8, // EVEX_T1F(1) + 8, 8, 8, // EVEX_T2(0) + 0, 16, 16, // EVEX_T2(1) + 0, 16, 16, // EVEX_T4(0) + 0, 0, 32, // EVEX_T4(1) + 0, 0, 32, // EVEX_T8(0) + 8, 16, 32, // EVEX_HVM(0) + 4, 8, 16, // EVEX_QVM(0) + 2, 4, 8, // EVEX_OVM(0) + 16, 16, 16, // EVEX_M128(0) + 8, 32, 64, // EVEX_DUP(0) + 0, 0, 0 // EVEX_NTUP +}; + AddressLiteral::AddressLiteral(address target, relocInfo::relocType rtype) { _is_lval = false; _target = target; @@ -183,8 +213,9 @@ int AbstractAssembler::code_fill_byte() { // make this go away someday void Assembler::emit_data(jint data, relocInfo::relocType rtype, int format) { if (rtype == relocInfo::none) - emit_int32(data); - else emit_data(data, Relocation::spec_simple(rtype), format); + emit_int32(data); + else + emit_data(data, Relocation::spec_simple(rtype), format); } void Assembler::emit_data(jint data, RelocationHolder const& rspec, int format) { @@ -273,6 +304,177 @@ void Assembler::emit_arith(int op1, int op2, Register dst, Register src) { } +bool Assembler::query_compressed_disp_byte(int disp, bool is_evex_inst, int vector_len, + int cur_tuple_type, int in_size_in_bits, int cur_encoding) { + int mod_idx = 0; + // We will test if the displacement fits the compressed format and if so + // apply the compression to the displacment iff the result is8bit. + if (VM_Version::supports_evex() && is_evex_inst) { + switch (cur_tuple_type) { + case EVEX_FV: + if ((cur_encoding & VEX_W) == VEX_W) { + mod_idx += 2 + ((cur_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + } else { + mod_idx = ((cur_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + } + break; + + case EVEX_HV: + mod_idx = ((cur_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + break; + + case EVEX_FVM: + break; + + case EVEX_T1S: + switch (in_size_in_bits) { + case EVEX_8bit: + break; + + case EVEX_16bit: + mod_idx = 1; + break; + + case EVEX_32bit: + mod_idx = 2; + break; + + case EVEX_64bit: + mod_idx = 3; + break; + } + break; + + case EVEX_T1F: + case EVEX_T2: + case EVEX_T4: + mod_idx = (in_size_in_bits == EVEX_64bit) ? 1 : 0; + break; + + case EVEX_T8: + break; + + case EVEX_HVM: + break; + + case EVEX_QVM: + break; + + case EVEX_OVM: + break; + + case EVEX_M128: + break; + + case EVEX_DUP: + break; + + default: + assert(0, "no valid evex tuple_table entry"); + break; + } + + if (vector_len >= AVX_128bit && vector_len <= AVX_512bit) { + int disp_factor = tuple_table[cur_tuple_type + mod_idx][vector_len]; + if ((disp % disp_factor) == 0) { + int new_disp = disp / disp_factor; + if ((-0x80 <= new_disp && new_disp < 0x80)) { + disp = new_disp; + } + } else { + return false; + } + } + } + return (-0x80 <= disp && disp < 0x80); +} + + +bool Assembler::emit_compressed_disp_byte(int &disp) { + int mod_idx = 0; + // We will test if the displacement fits the compressed format and if so + // apply the compression to the displacment iff the result is8bit. + if (VM_Version::supports_evex() && is_evex_instruction) { + switch (tuple_type) { + case EVEX_FV: + if ((evex_encoding & VEX_W) == VEX_W) { + mod_idx += 2 + ((evex_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + } else { + mod_idx = ((evex_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + } + break; + + case EVEX_HV: + mod_idx = ((evex_encoding & EVEX_Rb) == EVEX_Rb) ? 1 : 0; + break; + + case EVEX_FVM: + break; + + case EVEX_T1S: + switch (input_size_in_bits) { + case EVEX_8bit: + break; + + case EVEX_16bit: + mod_idx = 1; + break; + + case EVEX_32bit: + mod_idx = 2; + break; + + case EVEX_64bit: + mod_idx = 3; + break; + } + break; + + case EVEX_T1F: + case EVEX_T2: + case EVEX_T4: + mod_idx = (input_size_in_bits == EVEX_64bit) ? 1 : 0; + break; + + case EVEX_T8: + break; + + case EVEX_HVM: + break; + + case EVEX_QVM: + break; + + case EVEX_OVM: + break; + + case EVEX_M128: + break; + + case EVEX_DUP: + break; + + default: + assert(0, "no valid evex tuple_table entry"); + break; + } + + if (avx_vector_len >= AVX_128bit && avx_vector_len <= AVX_512bit) { + int disp_factor = tuple_table[tuple_type + mod_idx][avx_vector_len]; + if ((disp % disp_factor) == 0) { + int new_disp = disp / disp_factor; + if (is8bit(new_disp)) { + disp = new_disp; + } + } else { + return false; + } + } + } + return is8bit(disp); +} + + void Assembler::emit_operand(Register reg, Register base, Register index, Address::ScaleFactor scale, int disp, RelocationHolder const& rspec, @@ -296,7 +498,7 @@ void Assembler::emit_operand(Register reg, Register base, Register index, assert(index != rsp, "illegal addressing mode"); emit_int8(0x04 | regenc); emit_int8(scale << 6 | indexenc | baseenc); - } else if (is8bit(disp) && rtype == relocInfo::none) { + } else if (emit_compressed_disp_byte(disp) && rtype == relocInfo::none) { // [base + index*scale + imm8] // [01 reg 100][ss index base] imm8 assert(index != rsp, "illegal addressing mode"); @@ -318,7 +520,7 @@ void Assembler::emit_operand(Register reg, Register base, Register index, // [00 reg 100][00 100 100] emit_int8(0x04 | regenc); emit_int8(0x24); - } else if (is8bit(disp) && rtype == relocInfo::none) { + } else if (emit_compressed_disp_byte(disp) && rtype == relocInfo::none) { // [rsp + imm8] // [01 reg 100][00 100 100] disp8 emit_int8(0x44 | regenc); @@ -339,7 +541,7 @@ void Assembler::emit_operand(Register reg, Register base, Register index, // [base] // [00 reg base] emit_int8(0x00 | regenc | baseenc); - } else if (is8bit(disp) && rtype == relocInfo::none) { + } else if (emit_compressed_disp_byte(disp) && rtype == relocInfo::none) { // [base + disp8] // [01 reg base] disp8 emit_int8(0x40 | regenc | baseenc); @@ -389,11 +591,20 @@ void Assembler::emit_operand(Register reg, Register base, Register index, emit_data(disp, rspec, disp32_operand); } } + is_evex_instruction = false; } void Assembler::emit_operand(XMMRegister reg, Register base, Register index, Address::ScaleFactor scale, int disp, RelocationHolder const& rspec) { + if (UseAVX > 2) { + int xreg_enc = reg->encoding(); + if (xreg_enc > 15) { + XMMRegister new_reg = as_XMMRegister(xreg_enc & 0xf); + emit_operand((Register)new_reg, base, index, scale, disp, rspec); + return; + } + } emit_operand((Register)reg, base, index, scale, disp, rspec); } @@ -686,6 +897,29 @@ address Assembler::locate_operand(address inst, WhichOperand which) { debug_only(has_disp32 = true); // has both kinds of operands! break; + case 0x62: // EVEX_4bytes + assert((UseAVX > 0), "shouldn't have EVEX prefix"); + assert(ip == inst+1, "no prefixes allowed"); + // no EVEX collisions, all instructions that have 0x62 opcodes + // have EVEX versions and are subopcodes of 0x66 + ip++; // skip P0 and exmaine W in P1 + is_64bit = ((VEX_W & *ip) == VEX_W); + ip++; // move to P2 + ip++; // skip P2, move to opcode + // To find the end of instruction (which == end_pc_operand). + switch (0xFF & *ip) { + case 0x61: // pcmpestri r, r/a, #8 + case 0x70: // pshufd r, r/a, #8 + case 0x73: // psrldq r, #8 + tail_size = 1; // the imm8 + break; + default: + break; + } + ip++; // skip opcode + debug_only(has_disp32 = true); // has both kinds of operands! + break; + case 0xD1: // sal a, 1; sar a, 1; shl a, 1; shr a, 1 case 0xD3: // sal a, %cl; sar a, %cl; shl a, %cl; shr a, %cl case 0xD9: // fld_s a; fst_s a; fstp_s a; fldcw a @@ -985,12 +1219,22 @@ void Assembler::addr_nop_8() { void Assembler::addsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x58, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x58, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x58, dst, src, VEX_SIMD_F2); + } } void Assembler::addsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x58, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x58, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x58, dst, src, VEX_SIMD_F2); + } } void Assembler::addss(XMMRegister dst, XMMRegister src) { @@ -1000,20 +1244,26 @@ void Assembler::addss(XMMRegister dst, XMMRegister src) { void Assembler::addss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } emit_simd_arith(0x58, dst, src, VEX_SIMD_F3); } void Assembler::aesdec(XMMRegister dst, Address src) { assert(VM_Version::supports_aes(), ""); InstructionMark im(this); - simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDE); emit_operand(dst, src); } void Assembler::aesdec(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_aes(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDE); emit_int8(0xC0 | encode); } @@ -1021,14 +1271,16 @@ void Assembler::aesdec(XMMRegister dst, XMMRegister src) { void Assembler::aesdeclast(XMMRegister dst, Address src) { assert(VM_Version::supports_aes(), ""); InstructionMark im(this); - simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDF); emit_operand(dst, src); } void Assembler::aesdeclast(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_aes(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDF); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1036,14 +1288,16 @@ void Assembler::aesdeclast(XMMRegister dst, XMMRegister src) { void Assembler::aesenc(XMMRegister dst, Address src) { assert(VM_Version::supports_aes(), ""); InstructionMark im(this); - simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDC); emit_operand(dst, src); } void Assembler::aesenc(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_aes(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDC); emit_int8(0xC0 | encode); } @@ -1051,14 +1305,16 @@ void Assembler::aesenc(XMMRegister dst, XMMRegister src) { void Assembler::aesenclast(XMMRegister dst, Address src) { assert(VM_Version::supports_aes(), ""); InstructionMark im(this); - simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDD); emit_operand(dst, src); } void Assembler::aesenclast(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_aes(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8((unsigned char)0xDD); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1091,7 +1347,7 @@ void Assembler::andl(Register dst, Register src) { void Assembler::andnl(Register dst, Register src1, Register src2) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - int encode = vex_prefix_0F38_and_encode(dst, src1, src2); + int encode = vex_prefix_0F38_and_encode(dst, src1, src2, false); emit_int8((unsigned char)0xF2); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1099,7 +1355,7 @@ void Assembler::andnl(Register dst, Register src1, Register src2) { void Assembler::andnl(Register dst, Register src1, Address src2) { InstructionMark im(this); assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - vex_prefix_0F38(dst, src1, src2); + vex_prefix_0F38(dst, src1, src2, false); emit_int8((unsigned char)0xF2); emit_operand(dst, src2); } @@ -1126,7 +1382,7 @@ void Assembler::bswapl(Register reg) { // bswap void Assembler::blsil(Register dst, Register src) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - int encode = vex_prefix_0F38_and_encode(rbx, dst, src); + int encode = vex_prefix_0F38_and_encode(rbx, dst, src, false); emit_int8((unsigned char)0xF3); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1134,14 +1390,14 @@ void Assembler::blsil(Register dst, Register src) { void Assembler::blsil(Register dst, Address src) { InstructionMark im(this); assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - vex_prefix_0F38(rbx, dst, src); + vex_prefix_0F38(rbx, dst, src, false); emit_int8((unsigned char)0xF3); emit_operand(rbx, src); } void Assembler::blsmskl(Register dst, Register src) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - int encode = vex_prefix_0F38_and_encode(rdx, dst, src); + int encode = vex_prefix_0F38_and_encode(rdx, dst, src, false); emit_int8((unsigned char)0xF3); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1149,14 +1405,14 @@ void Assembler::blsmskl(Register dst, Register src) { void Assembler::blsmskl(Register dst, Address src) { InstructionMark im(this); assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - vex_prefix_0F38(rdx, dst, src); + vex_prefix_0F38(rdx, dst, src, false); emit_int8((unsigned char)0xF3); emit_operand(rdx, src); } void Assembler::blsrl(Register dst, Register src) { assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - int encode = vex_prefix_0F38_and_encode(rcx, dst, src); + int encode = vex_prefix_0F38_and_encode(rcx, dst, src, false); emit_int8((unsigned char)0xF3); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1164,7 +1420,7 @@ void Assembler::blsrl(Register dst, Register src) { void Assembler::blsrl(Register dst, Address src) { InstructionMark im(this); assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); - vex_prefix_0F38(rcx, dst, src); + vex_prefix_0F38(rcx, dst, src, false); emit_int8((unsigned char)0xF3); emit_operand(rcx, src); } @@ -1312,22 +1568,36 @@ void Assembler::comisd(XMMRegister dst, Address src) { // NOTE: dbx seems to decode this as comiss even though the // 0x66 is there. Strangly ucomisd comes out correct NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_nonds_q(0x2F, dst, src, VEX_SIMD_66, true); + } else { + emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_66); + } } void Assembler::comisd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_nonds_q(0x2F, dst, src, VEX_SIMD_66, true); + } else { + emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_66); + } } void Assembler::comiss(XMMRegister dst, Address src) { + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_NONE); + emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_NONE, true); } void Assembler::comiss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_NONE); + emit_simd_arith_nonds(0x2F, dst, src, VEX_SIMD_NONE, true); } void Assembler::cpuid() { @@ -1347,36 +1617,61 @@ void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) { void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5A, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x5A, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x5A, dst, src, VEX_SIMD_F2); + } } void Assembler::cvtsd2ss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5A, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1F; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x5A, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x5A, dst, src, VEX_SIMD_F2); + } } void Assembler::cvtsi2sdl(XMMRegister dst, Register src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2); + int encode = 0; + if (VM_Version::supports_evex()) { + encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F2, true); + } else { + encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, false); + } emit_int8(0x2A); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvtsi2sdl(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x2A, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + emit_simd_arith_q(0x2A, dst, src, VEX_SIMD_F2, true); + } else { + emit_simd_arith(0x2A, dst, src, VEX_SIMD_F2); + } } void Assembler::cvtsi2ssl(XMMRegister dst, Register src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F3, true); emit_int8(0x2A); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvtsi2ssl(XMMRegister dst, Address src) { + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x2A, dst, src, VEX_SIMD_F3); + emit_simd_arith(0x2A, dst, src, VEX_SIMD_F3, true); } void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { @@ -1385,6 +1680,10 @@ void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { } void Assembler::cvtss2sd(XMMRegister dst, Address src) { + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } NOT_LP64(assert(VM_Version::supports_sse2(), "")); emit_simd_arith(0x5A, dst, src, VEX_SIMD_F3); } @@ -1392,14 +1691,14 @@ void Assembler::cvtss2sd(XMMRegister dst, Address src) { void Assembler::cvttsd2sil(Register dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F2); + int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, true); emit_int8(0x2C); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvttss2sil(Register dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F3); + int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_F3, VEX_OPCODE_0F, true); emit_int8(0x2C); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1414,15 +1713,29 @@ void Assembler::decl(Address dst) { void Assembler::divsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5E, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x5E, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x5E, dst, src, VEX_SIMD_F2); + } } void Assembler::divsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5E, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x5E, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x5E, dst, src, VEX_SIMD_F2); + } } void Assembler::divss(XMMRegister dst, Address src) { + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } NOT_LP64(assert(VM_Version::supports_sse(), "")); emit_simd_arith(0x5E, dst, src, VEX_SIMD_F3); } @@ -1675,7 +1988,11 @@ void Assembler::mov(Register dst, Register src) { void Assembler::movapd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x28, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_nonds_q(0x28, dst, src, VEX_SIMD_66, true); + } else { + emit_simd_arith_nonds(0x28, dst, src, VEX_SIMD_66); + } } void Assembler::movaps(XMMRegister dst, XMMRegister src) { @@ -1685,7 +2002,8 @@ void Assembler::movaps(XMMRegister dst, XMMRegister src) { void Assembler::movlhps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - int encode = simd_prefix_and_encode(dst, src, src, VEX_SIMD_NONE); + int encode = simd_prefix_and_encode(dst, src, src, VEX_SIMD_NONE, true, VEX_OPCODE_0F, + false, AVX_128bit); emit_int8(0x16); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1698,6 +2016,51 @@ void Assembler::movb(Register dst, Address src) { emit_operand(dst, src); } +void Assembler::kmovq(KRegister dst, KRegister src) { + NOT_LP64(assert(VM_Version::supports_evex(), "")); + int encode = kreg_prefix_and_encode(dst, knoreg, src, VEX_SIMD_NONE, + true, VEX_OPCODE_0F, true); + emit_int8((unsigned char)0x90); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::kmovq(KRegister dst, Address src) { + NOT_LP64(assert(VM_Version::supports_evex(), "")); + int dst_enc = dst->encoding(); + int nds_enc = 0; + vex_prefix(src, nds_enc, dst_enc, VEX_SIMD_NONE, + VEX_OPCODE_0F, true, AVX_128bit, true, true); + emit_int8((unsigned char)0x90); + emit_operand((Register)dst, src); +} + +void Assembler::kmovq(Address dst, KRegister src) { + NOT_LP64(assert(VM_Version::supports_evex(), "")); + int src_enc = src->encoding(); + int nds_enc = 0; + vex_prefix(dst, nds_enc, src_enc, VEX_SIMD_NONE, + VEX_OPCODE_0F, true, AVX_128bit, true, true); + emit_int8((unsigned char)0x90); + emit_operand((Register)src, dst); +} + +void Assembler::kmovql(KRegister dst, Register src) { + NOT_LP64(assert(VM_Version::supports_evex(), "")); + bool supports_bw = VM_Version::supports_avx512bw(); + VexSimdPrefix pre = supports_bw ? VEX_SIMD_F2 : VEX_SIMD_NONE; + int encode = kreg_prefix_and_encode(dst, knoreg, src, pre, true, + VEX_OPCODE_0F, supports_bw); + emit_int8((unsigned char)0x92); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::kmovdl(KRegister dst, Register src) { + NOT_LP64(assert(VM_Version::supports_evex(), "")); + VexSimdPrefix pre = VM_Version::supports_avx512bw() ? VEX_SIMD_F2 : VEX_SIMD_NONE; + int encode = kreg_prefix_and_encode(dst, knoreg, src, pre, true, VEX_OPCODE_0F, false); + emit_int8((unsigned char)0x92); + emit_int8((unsigned char)(0xC0 | encode)); +} void Assembler::movb(Address dst, int imm8) { InstructionMark im(this); @@ -1718,7 +2081,7 @@ void Assembler::movb(Address dst, Register src) { void Assembler::movdl(XMMRegister dst, Register src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66); + int encode = simd_prefix_and_encode(dst, src, VEX_SIMD_66, true); emit_int8(0x6E); emit_int8((unsigned char)(0xC0 | encode)); } @@ -1726,23 +2089,31 @@ void Assembler::movdl(XMMRegister dst, Register src) { void Assembler::movdl(Register dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // swap src/dst to get correct prefix - int encode = simd_prefix_and_encode(src, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(src, dst, VEX_SIMD_66, true); emit_int8(0x7E); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::movdl(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66); + simd_prefix(dst, src, VEX_SIMD_66, true, VEX_OPCODE_0F); emit_int8(0x6E); emit_operand(dst, src); } void Assembler::movdl(Address dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66); + simd_prefix(dst, src, VEX_SIMD_66, true); emit_int8(0x7E); emit_operand(src, dst); } @@ -1754,11 +2125,17 @@ void Assembler::movdqa(XMMRegister dst, XMMRegister src) { void Assembler::movdqa(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } emit_simd_arith_nonds(0x6F, dst, src, VEX_SIMD_66); } void Assembler::movdqu(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } emit_simd_arith_nonds(0x6F, dst, src, VEX_SIMD_F3); } @@ -1769,8 +2146,11 @@ void Assembler::movdqu(XMMRegister dst, XMMRegister src) { void Assembler::movdqu(Address dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_F3); + simd_prefix(dst, src, VEX_SIMD_F3, false); emit_int8(0x7F); emit_operand(src, dst); } @@ -1778,28 +2158,77 @@ void Assembler::movdqu(Address dst, XMMRegister src) { // Move Unaligned 256bit Vector void Assembler::vmovdqu(XMMRegister dst, XMMRegister src) { assert(UseAVX > 0, ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F3, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F3, vector_len); emit_int8(0x6F); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::vmovdqu(XMMRegister dst, Address src) { assert(UseAVX > 0, ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } InstructionMark im(this); - bool vector256 = true; - vex_prefix(dst, xnoreg, src, VEX_SIMD_F3, vector256); + int vector_len = AVX_256bit; + vex_prefix(dst, xnoreg, src, VEX_SIMD_F3, vector_len, false); emit_int8(0x6F); emit_operand(dst, src); } void Assembler::vmovdqu(Address dst, XMMRegister src) { assert(UseAVX > 0, ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_256bit; // swap src<->dst for encoding assert(src != xnoreg, "sanity"); - vex_prefix(src, xnoreg, dst, VEX_SIMD_F3, vector256); + vex_prefix(src, xnoreg, dst, VEX_SIMD_F3, vector_len, false); + emit_int8(0x7F); + emit_operand(src, dst); +} + +// Move Unaligned EVEX enabled Vector (programmable : 8,16,32,64) +void Assembler::evmovdqu(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 0, ""); + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(dst_enc, 0, src_enc, VEX_SIMD_F3, VEX_OPCODE_0F, + true, vector_len, false, false); + emit_int8(0x6F); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evmovdqu(XMMRegister dst, Address src, int vector_len) { + assert(UseAVX > 0, ""); + InstructionMark im(this); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + vex_prefix_q(dst, xnoreg, src, VEX_SIMD_F3, vector_len, false); + } else { + vex_prefix(dst, xnoreg, src, VEX_SIMD_F3, vector_len, false); + } + emit_int8(0x6F); + emit_operand(dst, src); +} + +void Assembler::evmovdqu(Address dst, XMMRegister src, int vector_len) { + assert(UseAVX > 0, ""); + InstructionMark im(this); + assert(src != xnoreg, "sanity"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + // swap src<->dst for encoding + vex_prefix_q(src, xnoreg, dst, VEX_SIMD_F3, vector_len, false); + } else { + // swap src<->dst for encoding + vex_prefix(src, xnoreg, dst, VEX_SIMD_F3, vector_len, false); + } emit_int8(0x7F); emit_operand(src, dst); } @@ -1845,7 +2274,11 @@ void Assembler::movl(Address dst, Register src) { // The selection is done in MacroAssembler::movdbl() and movflt(). void Assembler::movlpd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x12, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith(0x12, dst, src, VEX_SIMD_66, true); } void Assembler::movq( MMXRegister dst, Address src ) { @@ -1871,7 +2304,13 @@ void Assembler::movq( Address dst, MMXRegister src ) { void Assembler::movq(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_F3); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + simd_prefix_q(dst, xnoreg, src, VEX_SIMD_F3, true); + } else { + simd_prefix(dst, src, VEX_SIMD_F3, true, VEX_OPCODE_0F); + } emit_int8(0x7E); emit_operand(dst, src); } @@ -1879,7 +2318,14 @@ void Assembler::movq(XMMRegister dst, Address src) { void Assembler::movq(Address dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + simd_prefix(src, xnoreg, dst, VEX_SIMD_66, true, + VEX_OPCODE_0F, true, AVX_128bit); + } else { + simd_prefix(dst, src, VEX_SIMD_66, true); + } emit_int8((unsigned char)0xD6); emit_operand(src, dst); } @@ -1902,36 +2348,60 @@ void Assembler::movsbl(Register dst, Register src) { // movsxb void Assembler::movsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x10, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x10, dst, src, VEX_SIMD_F2, true); + } else { + emit_simd_arith(0x10, dst, src, VEX_SIMD_F2); + } } void Assembler::movsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x10, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_nonds_q(0x10, dst, src, VEX_SIMD_F2, true); + } else { + emit_simd_arith_nonds(0x10, dst, src, VEX_SIMD_F2); + } } void Assembler::movsd(Address dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + simd_prefix_q(src, xnoreg, dst, VEX_SIMD_F2); + } else { + simd_prefix(src, xnoreg, dst, VEX_SIMD_F2, false); + } emit_int8(0x11); emit_operand(src, dst); } void Assembler::movss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x10, dst, src, VEX_SIMD_F3); + emit_simd_arith(0x10, dst, src, VEX_SIMD_F3, true); } void Assembler::movss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith_nonds(0x10, dst, src, VEX_SIMD_F3); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith_nonds(0x10, dst, src, VEX_SIMD_F3, true); } void Assembler::movss(Address dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_F3); + simd_prefix(dst, src, VEX_SIMD_F3, false); emit_int8(0x11); emit_operand(src, dst); } @@ -2023,16 +2493,30 @@ void Assembler::mull(Register src) { void Assembler::mulsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x59, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x59, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x59, dst, src, VEX_SIMD_F2); + } } void Assembler::mulsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x59, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x59, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x59, dst, src, VEX_SIMD_F2); + } } void Assembler::mulss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } emit_simd_arith(0x59, dst, src, VEX_SIMD_F3); } @@ -2332,22 +2816,30 @@ void Assembler::orl(Register dst, Register src) { void Assembler::packuswb(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); - emit_simd_arith(0x67, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith(0x67, dst, src, VEX_SIMD_66, + false, (VM_Version::supports_avx512dq() == false)); } void Assembler::packuswb(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x67, dst, src, VEX_SIMD_66); + emit_simd_arith(0x67, dst, src, VEX_SIMD_66, + false, (VM_Version::supports_avx512dq() == false)); } -void Assembler::vpackuswb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0x67, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpackuswb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "some form of AVX must be enabled"); + emit_vex_arith(0x67, dst, nds, src, VEX_SIMD_66, vector_len, + false, (VM_Version::supports_avx512dq() == false)); } -void Assembler::vpermq(XMMRegister dst, XMMRegister src, int imm8, bool vector256) { +void Assembler::vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_len) { assert(VM_Version::supports_avx2(), ""); - int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, true, vector256); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_3A, true, vector_len); emit_int8(0x00); emit_int8(0xC0 | encode); emit_int8(imm8); @@ -2361,7 +2853,8 @@ void Assembler::pause() { void Assembler::pcmpestri(XMMRegister dst, Address src, int imm8) { assert(VM_Version::supports_sse4_2(), ""); InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A); + simd_prefix(dst, xnoreg, src, VEX_SIMD_66, false, VEX_OPCODE_0F_3A, + false, AVX_128bit, true); emit_int8(0x61); emit_operand(dst, src); emit_int8(imm8); @@ -2369,7 +2862,8 @@ void Assembler::pcmpestri(XMMRegister dst, Address src, int imm8) { void Assembler::pcmpestri(XMMRegister dst, XMMRegister src, int imm8) { assert(VM_Version::supports_sse4_2(), ""); - int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_3A); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_3A, false, AVX_128bit, true); emit_int8(0x61); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); @@ -2377,7 +2871,8 @@ void Assembler::pcmpestri(XMMRegister dst, XMMRegister src, int imm8) { void Assembler::pextrd(Register dst, XMMRegister src, int imm8) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, false); + int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, true, VEX_OPCODE_0F_3A, + false, AVX_128bit, (VM_Version::supports_avx512dq() == false)); emit_int8(0x16); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); @@ -2385,7 +2880,8 @@ void Assembler::pextrd(Register dst, XMMRegister src, int imm8) { void Assembler::pextrq(Register dst, XMMRegister src, int imm8) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, true); + int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, true, VEX_OPCODE_0F_3A, + false, AVX_128bit, (VM_Version::supports_avx512dq() == false)); emit_int8(0x16); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); @@ -2393,7 +2889,8 @@ void Assembler::pextrq(Register dst, XMMRegister src, int imm8) { void Assembler::pinsrd(XMMRegister dst, Register src, int imm8) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(dst, dst, as_XMMRegister(src->encoding()), VEX_SIMD_66, VEX_OPCODE_0F_3A, false); + int encode = simd_prefix_and_encode(dst, dst, as_XMMRegister(src->encoding()), VEX_SIMD_66, true, VEX_OPCODE_0F_3A, + false, AVX_128bit, (VM_Version::supports_avx512dq() == false)); emit_int8(0x22); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); @@ -2401,7 +2898,8 @@ void Assembler::pinsrd(XMMRegister dst, Register src, int imm8) { void Assembler::pinsrq(XMMRegister dst, Register src, int imm8) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(dst, dst, as_XMMRegister(src->encoding()), VEX_SIMD_66, VEX_OPCODE_0F_3A, true); + int encode = simd_prefix_and_encode(dst, dst, as_XMMRegister(src->encoding()), VEX_SIMD_66, true, VEX_OPCODE_0F_3A, + false, AVX_128bit, (VM_Version::supports_avx512dq() == false)); emit_int8(0x22); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); @@ -2409,15 +2907,18 @@ void Assembler::pinsrq(XMMRegister dst, Register src, int imm8) { void Assembler::pmovzxbw(XMMRegister dst, Address src) { assert(VM_Version::supports_sse4_1(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_HVM; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, src, VEX_SIMD_66, false, VEX_OPCODE_0F_38); emit_int8(0x30); emit_operand(dst, src); } void Assembler::pmovzxbw(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, false, VEX_OPCODE_0F_38); emit_int8(0x30); emit_int8((unsigned char)(0xC0 | encode)); } @@ -2520,15 +3021,20 @@ void Assembler::prefix(Prefix p) { void Assembler::pshufb(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_ssse3(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, VEX_OPCODE_0F_38, + false, AVX_128bit, (VM_Version::supports_avx512bw() == false)); emit_int8(0x00); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::pshufb(XMMRegister dst, Address src) { assert(VM_Version::supports_ssse3(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } InstructionMark im(this); - simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, dst, src, VEX_SIMD_66, false, VEX_OPCODE_0F_38, + false, AVX_128bit, (VM_Version::supports_avx512bw() == false)); emit_int8(0x00); emit_operand(dst, src); } @@ -2545,8 +3051,12 @@ void Assembler::pshufd(XMMRegister dst, Address src, int mode) { assert(isByte(mode), "invalid value"); NOT_LP64(assert(VM_Version::supports_sse2(), "")); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66); + simd_prefix(dst, src, VEX_SIMD_66, false); emit_int8(0x70); emit_operand(dst, src); emit_int8(mode & 0xFF); @@ -2555,7 +3065,8 @@ void Assembler::pshufd(XMMRegister dst, Address src, int mode) { void Assembler::pshuflw(XMMRegister dst, XMMRegister src, int mode) { assert(isByte(mode), "invalid value"); NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x70, dst, src, VEX_SIMD_F2); + emit_simd_arith_nonds(0x70, dst, src, VEX_SIMD_F2, false, + (VM_Version::supports_avx512bw() == false)); emit_int8(mode & 0xFF); } @@ -2563,8 +3074,12 @@ void Assembler::pshuflw(XMMRegister dst, Address src, int mode) { assert(isByte(mode), "invalid value"); NOT_LP64(assert(VM_Version::supports_sse2(), "")); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_F2); + simd_prefix(dst, xnoreg, src, VEX_SIMD_F2, false, VEX_OPCODE_0F, + false, AVX_128bit, (VM_Version::supports_avx512bw() == false)); emit_int8(0x70); emit_operand(dst, src); emit_int8(mode & 0xFF); @@ -2573,7 +3088,8 @@ void Assembler::pshuflw(XMMRegister dst, Address src, int mode) { void Assembler::psrldq(XMMRegister dst, int shift) { // Shift 128 bit value in xmm register by number of bytes. NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode(xmm3, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm3, dst, dst, VEX_SIMD_66, true, VEX_OPCODE_0F, + false, AVX_128bit, (VM_Version::supports_avx512bw() == false)); emit_int8(0x73); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift); @@ -2583,14 +3099,15 @@ void Assembler::ptest(XMMRegister dst, Address src) { assert(VM_Version::supports_sse4_1(), ""); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); InstructionMark im(this); - simd_prefix(dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + simd_prefix(dst, src, VEX_SIMD_66, false, VEX_OPCODE_0F_38); emit_int8(0x17); emit_operand(dst, src); } void Assembler::ptest(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, + false, VEX_OPCODE_0F_38); emit_int8(0x17); emit_int8((unsigned char)(0xC0 | encode)); } @@ -2598,19 +3115,20 @@ void Assembler::ptest(XMMRegister dst, XMMRegister src) { void Assembler::vptest(XMMRegister dst, Address src) { assert(VM_Version::supports_avx(), ""); InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_256bit; assert(dst != xnoreg, "sanity"); int dst_enc = dst->encoding(); // swap src<->dst for encoding - vex_prefix(src, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_38, false, vector256); + vex_prefix(src, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_38, false, vector_len); emit_int8(0x17); emit_operand(dst, src); } void Assembler::vptest(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_38); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, + vector_len, VEX_OPCODE_0F_38); emit_int8(0x17); emit_int8((unsigned char)(0xC0 | encode)); } @@ -2618,6 +3136,9 @@ void Assembler::vptest(XMMRegister dst, XMMRegister src) { void Assembler::punpcklbw(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } emit_simd_arith(0x60, dst, src, VEX_SIMD_66); } @@ -2629,6 +3150,10 @@ void Assembler::punpcklbw(XMMRegister dst, XMMRegister src) { void Assembler::punpckldq(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } emit_simd_arith(0x62, dst, src, VEX_SIMD_66); } @@ -2838,12 +3363,22 @@ void Assembler::smovl() { void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x51, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x51, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x51, dst, src, VEX_SIMD_F2); + } } void Assembler::sqrtsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x51, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x51, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x51, dst, src, VEX_SIMD_F2); + } } void Assembler::sqrtss(XMMRegister dst, XMMRegister src) { @@ -2857,6 +3392,10 @@ void Assembler::std() { void Assembler::sqrtss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } emit_simd_arith(0x51, dst, src, VEX_SIMD_F3); } @@ -2907,12 +3446,20 @@ void Assembler::subl(Register dst, Register src) { void Assembler::subsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5C, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x5C, dst, src, VEX_SIMD_F2); + } else { + emit_simd_arith(0x5C, dst, src, VEX_SIMD_F2); + } } void Assembler::subsd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5C, dst, src, VEX_SIMD_F2); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + } + emit_simd_arith_q(0x5C, dst, src, VEX_SIMD_F2); } void Assembler::subss(XMMRegister dst, XMMRegister src) { @@ -2922,6 +3469,10 @@ void Assembler::subss(XMMRegister dst, XMMRegister src) { void Assembler::subss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } emit_simd_arith(0x5C, dst, src, VEX_SIMD_F3); } @@ -2978,22 +3529,36 @@ void Assembler::tzcntq(Register dst, Register src) { void Assembler::ucomisd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_nonds_q(0x2E, dst, src, VEX_SIMD_66, true); + } else { + emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_66); + } } void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_nonds_q(0x2E, dst, src, VEX_SIMD_66, true); + } else { + emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_66); + } } void Assembler::ucomiss(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_NONE); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_NONE, true); } void Assembler::ucomiss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_NONE); + emit_simd_arith_nonds(0x2E, dst, src, VEX_SIMD_NONE, true); } void Assembler::xabort(int8_t imm8) { @@ -3075,82 +3640,138 @@ void Assembler::xorl(Register dst, Register src) { void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x58, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x58, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vaddss(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vaddss(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x5E, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x5E, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vdivss(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vdivss(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x59, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x59, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vmulss(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vmulss(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x5C, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F2, /* vector256 */ false); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x5C, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } else { + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F2, AVX_128bit); + } } void Assembler::vsubss(XMMRegister dst, XMMRegister nds, Address src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } void Assembler::vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F3, /* vector256 */ false); + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_F3, AVX_128bit); } //====================VECTOR ARITHMETIC===================================== @@ -3159,7 +3780,11 @@ void Assembler::vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src) { void Assembler::addpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x58, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x58, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x58, dst, src, VEX_SIMD_66); + } } void Assembler::addps(XMMRegister dst, XMMRegister src) { @@ -3167,29 +3792,47 @@ void Assembler::addps(XMMRegister dst, XMMRegister src) { emit_simd_arith(0x58, dst, src, VEX_SIMD_NONE); } -void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x58, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vaddps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vaddps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_NONE, vector256); + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_NONE, vector_len); } -void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x58, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vaddps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vaddps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x58, dst, nds, src, VEX_SIMD_NONE, vector_len); } void Assembler::subpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5C, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x5C, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x5C, dst, src, VEX_SIMD_66); + } } void Assembler::subps(XMMRegister dst, XMMRegister src) { @@ -3197,29 +3840,47 @@ void Assembler::subps(XMMRegister dst, XMMRegister src) { emit_simd_arith(0x5C, dst, src, VEX_SIMD_NONE); } -void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x5C, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vsubps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vsubps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_NONE, vector256); + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_NONE, vector_len); } -void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x5C, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vsubps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vsubps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x5C, dst, nds, src, VEX_SIMD_NONE, vector_len); } void Assembler::mulpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x59, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x59, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x59, dst, src, VEX_SIMD_66); + } } void Assembler::mulps(XMMRegister dst, XMMRegister src) { @@ -3227,29 +3888,47 @@ void Assembler::mulps(XMMRegister dst, XMMRegister src) { emit_simd_arith(0x59, dst, src, VEX_SIMD_NONE); } -void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x59, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vmulps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vmulps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_NONE, vector256); + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_NONE, vector_len); } -void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x59, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vmulps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vmulps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x59, dst, nds, src, VEX_SIMD_NONE, vector_len); } void Assembler::divpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x5E, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0x5E, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x5E, dst, src, VEX_SIMD_66); + } } void Assembler::divps(XMMRegister dst, XMMRegister src) { @@ -3257,118 +3936,199 @@ void Assembler::divps(XMMRegister dst, XMMRegister src) { emit_simd_arith(0x5E, dst, src, VEX_SIMD_NONE); } -void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x5E, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vdivps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vdivps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_NONE, vector256); + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_NONE, vector_len); } -void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x5E, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vdivps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vdivps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x5E, dst, nds, src, VEX_SIMD_NONE, vector_len); } void Assembler::andpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x54, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + emit_simd_arith_q(0x54, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x54, dst, src, VEX_SIMD_66, false, true); + } } void Assembler::andps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x54, dst, src, VEX_SIMD_NONE); + emit_simd_arith(0x54, dst, src, VEX_SIMD_NONE, false, + (VM_Version::supports_avx512dq() == false)); } void Assembler::andps(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x54, dst, src, VEX_SIMD_NONE); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith(0x54, dst, src, VEX_SIMD_NONE, + false, (VM_Version::supports_avx512dq() == false)); } void Assembler::andpd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x54, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x54, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x54, dst, src, VEX_SIMD_66, false, true); + } } -void Assembler::vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + emit_vex_arith_q(0x54, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_66, vector_len, true); + } } -void Assembler::vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_NONE, vector256); + bool legacy_mode = (VM_Version::supports_avx512dq() == false); + emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_NONE, vector_len, legacy_mode); } -void Assembler::vandpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vandpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x54, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_66, vector_len, true); + } } -void Assembler::vandps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vandps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x54, dst, nds, src, VEX_SIMD_NONE, vector_len, + (VM_Version::supports_avx512dq() == false)); } void Assembler::xorpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x57, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + emit_simd_arith_q(0x57, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x57, dst, src, VEX_SIMD_66, false, true); + } } void Assembler::xorps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x57, dst, src, VEX_SIMD_NONE); + emit_simd_arith(0x57, dst, src, VEX_SIMD_NONE, + false, (VM_Version::supports_avx512dq() == false)); } void Assembler::xorpd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0x57, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_simd_arith_q(0x57, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0x57, dst, src, VEX_SIMD_66, false, true); + } } void Assembler::xorps(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - emit_simd_arith(0x57, dst, src, VEX_SIMD_NONE); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_simd_arith(0x57, dst, src, VEX_SIMD_NONE, false, + (VM_Version::supports_avx512dq() == false)); } -void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + emit_vex_arith_q(0x57, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_66, vector_len, true); + } } -void Assembler::vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { +void Assembler::vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_NONE, vector256); + emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_NONE, vector_len, + (VM_Version::supports_avx512dq() == false)); } -void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex() && VM_Version::supports_avx512dq()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0x57, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_66, vector_len, true); + } } -void Assembler::vxorps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { +void Assembler::vxorps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx(), ""); - emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_NONE, vector256); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0x57, dst, nds, src, VEX_SIMD_NONE, vector_len, + (VM_Version::supports_avx512dq() == false)); } - // Integer vector arithmetic -void Assembler::vphaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_38); +void Assembler::vphaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(VM_Version::supports_avx() && (vector_len == 0) || + VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector_len, + VEX_OPCODE_0F_38, true, false); emit_int8(0x01); emit_int8((unsigned char)(0xC0 | encode)); } -void Assembler::vphaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_38); +void Assembler::vphaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(VM_Version::supports_avx() && (vector_len == 0) || + VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector_len, + VEX_OPCODE_0F_38, true, false); emit_int8(0x02); emit_int8((unsigned char)(0xC0 | encode)); } @@ -3390,61 +4150,89 @@ void Assembler::paddd(XMMRegister dst, XMMRegister src) { void Assembler::paddq(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xD4, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0xD4, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0xD4, dst, src, VEX_SIMD_66); + } } void Assembler::phaddw(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse3(), "")); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8(0x01); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::phaddd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse3(), "")); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_38, false, AVX_128bit, true); emit_int8(0x02); emit_int8((unsigned char)(0xC0 | encode)); } -void Assembler::vpaddb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFC, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xFC, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFD, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xFD, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFE, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xFE, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD4, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0xD4, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xD4, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vpaddb(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFC, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + emit_vex_arith(0xFC, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpaddw(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFD, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + emit_vex_arith(0xFD, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpaddd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFE, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0xFE, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD4, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0xD4, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xD4, dst, nds, src, VEX_SIMD_66, vector_len); + } } void Assembler::psubb(XMMRegister dst, XMMRegister src) { @@ -3464,84 +4252,149 @@ void Assembler::psubd(XMMRegister dst, XMMRegister src) { void Assembler::psubq(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xFB, dst, src, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0xFB, dst, src, VEX_SIMD_66); + } else { + emit_simd_arith(0xFB, dst, src, VEX_SIMD_66); + } } -void Assembler::vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF8, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xF8, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsubw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF9, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xF9, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFA, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xFA, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0xFB, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xFB, dst, nds, src, VEX_SIMD_66, vector_len); + } } -void Assembler::vpsubb(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF8, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + emit_vex_arith(0xF8, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsubw(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF9, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + emit_vex_arith(0xF9, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsubd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFA, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0xFA, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xFB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + emit_vex_arith_q(0xFB, dst, nds, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xFB, dst, nds, src, VEX_SIMD_66, vector_len); + } } void Assembler::pmullw(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xD5, dst, src, VEX_SIMD_66); + emit_simd_arith(0xD5, dst, src, VEX_SIMD_66, + (VM_Version::supports_avx512bw() == false)); } void Assembler::pmulld(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_sse4_1(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, + false, VEX_OPCODE_0F_38); emit_int8(0x40); emit_int8((unsigned char)(0xC0 | encode)); } -void Assembler::vpmullw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD5, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpmullw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xD5, dst, nds, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_38); +void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, + vector_len, VEX_OPCODE_0F_38); emit_int8(0x40); emit_int8((unsigned char)(0xC0 | encode)); } -void Assembler::vpmullw(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD5, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 2, "requires some form of AVX"); + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + int encode = vex_prefix_and_encode(dst_enc, nds_enc, src_enc, VEX_SIMD_66, + VEX_OPCODE_0F_38, true, vector_len, false, false); + emit_int8(0x40); + emit_int8((unsigned char)(0xC0 | encode)); } -void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpmullw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FVM; + } + emit_vex_arith(0xD5, dst, nds, src, VEX_SIMD_66, vector_len); +} + +void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); int dst_enc = dst->encoding(); int nds_enc = nds->is_valid() ? nds->encoding() : 0; - vex_prefix(src, nds_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_38, false, vector256); + vex_prefix(src, nds_enc, dst_enc, VEX_SIMD_66, + VEX_OPCODE_0F_38, false, vector_len); + emit_int8(0x40); + emit_operand(dst, src); +} + +void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_64bit; + } + InstructionMark im(this); + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + vex_prefix(src, nds_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_38, true, vector_len); emit_int8(0x40); emit_operand(dst, src); } @@ -3550,7 +4403,8 @@ void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, Address src, bool vect void Assembler::psllw(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM6 is for /6 encoding: 66 0F 71 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, false, VEX_OPCODE_0F, + false, AVX_128bit, (VM_Version::supports_avx512bw() == false)); emit_int8(0x71); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3559,7 +4413,7 @@ void Assembler::psllw(XMMRegister dst, int shift) { void Assembler::pslld(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM6 is for /6 encoding: 66 0F 72 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, false); emit_int8(0x72); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3568,7 +4422,7 @@ void Assembler::pslld(XMMRegister dst, int shift) { void Assembler::psllq(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM6 is for /6 encoding: 66 0F 73 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, false, VEX_OPCODE_0F, true); emit_int8(0x73); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3576,7 +4430,8 @@ void Assembler::psllq(XMMRegister dst, int shift) { void Assembler::psllw(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xF1, dst, shift, VEX_SIMD_66); + emit_simd_arith(0xF1, dst, shift, VEX_SIMD_66, false, + (VM_Version::supports_avx512bw() == false)); } void Assembler::pslld(XMMRegister dst, XMMRegister shift) { @@ -3586,50 +4441,65 @@ void Assembler::pslld(XMMRegister dst, XMMRegister shift) { void Assembler::psllq(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xF3, dst, shift, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0xF3, dst, shift, VEX_SIMD_66); + } else { + emit_simd_arith(0xF3, dst, shift, VEX_SIMD_66); + } } -void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM6 is for /6 encoding: 66 0F 71 /6 ib - emit_vex_arith(0x71, xmm6, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x71, xmm6, dst, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); emit_int8(shift & 0xFF); } -void Assembler::vpslld(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpslld(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM6 is for /6 encoding: 66 0F 72 /6 ib - emit_vex_arith(0x72, xmm6, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x72, xmm6, dst, src, VEX_SIMD_66, vector_len); emit_int8(shift & 0xFF); } -void Assembler::vpsllq(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsllq(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM6 is for /6 encoding: 66 0F 73 /6 ib - emit_vex_arith(0x73, xmm6, dst, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x73, xmm6, dst, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x73, xmm6, dst, src, VEX_SIMD_66, vector_len); + } emit_int8(shift & 0xFF); } -void Assembler::vpsllw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF1, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsllw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xF1, dst, src, shift, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF2, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xF2, dst, src, shift, VEX_SIMD_66, vector_len); } -void Assembler::vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xF3, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0xF3, dst, src, shift, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xF3, dst, src, shift, VEX_SIMD_66, vector_len); + } } // Shift packed integers logically right by specified number of bits. void Assembler::psrlw(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM2 is for /2 encoding: 66 0F 71 /2 ib - int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, false, VEX_OPCODE_0F, + (VM_Version::supports_avx512bw() == false)); emit_int8(0x71); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3638,7 +4508,7 @@ void Assembler::psrlw(XMMRegister dst, int shift) { void Assembler::psrld(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM2 is for /2 encoding: 66 0F 72 /2 ib - int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, false); emit_int8(0x72); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3649,7 +4519,12 @@ void Assembler::psrlq(XMMRegister dst, int shift) { // shifts 128 bit value in xmm register by number of bytes. NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM2 is for /2 encoding: 66 0F 73 /2 ib - int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66); + int encode = 0; + if (VM_Version::supports_evex() && VM_Version::supports_avx512bw()) { + encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, true, VEX_OPCODE_0F, false); + } else { + encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, false, VEX_OPCODE_0F, true); + } emit_int8(0x73); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3657,7 +4532,8 @@ void Assembler::psrlq(XMMRegister dst, int shift) { void Assembler::psrlw(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xD1, dst, shift, VEX_SIMD_66); + emit_simd_arith(0xD1, dst, shift, VEX_SIMD_66, false, + (VM_Version::supports_avx512bw() == false)); } void Assembler::psrld(XMMRegister dst, XMMRegister shift) { @@ -3667,50 +4543,65 @@ void Assembler::psrld(XMMRegister dst, XMMRegister shift) { void Assembler::psrlq(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xD3, dst, shift, VEX_SIMD_66); + if (VM_Version::supports_evex()) { + emit_simd_arith_q(0xD3, dst, shift, VEX_SIMD_66); + } else { + emit_simd_arith(0xD3, dst, shift, VEX_SIMD_66); + } } -void Assembler::vpsrlw(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsrlw(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM2 is for /2 encoding: 66 0F 73 /2 ib - emit_vex_arith(0x71, xmm2, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x71, xmm2, dst, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); emit_int8(shift & 0xFF); } -void Assembler::vpsrld(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsrld(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM2 is for /2 encoding: 66 0F 73 /2 ib - emit_vex_arith(0x72, xmm2, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x72, xmm2, dst, src, VEX_SIMD_66, vector_len); emit_int8(shift & 0xFF); } -void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM2 is for /2 encoding: 66 0F 73 /2 ib - emit_vex_arith(0x73, xmm2, dst, src, VEX_SIMD_66, vector256); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0x73, xmm2, dst, src, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0x73, xmm2, dst, src, VEX_SIMD_66, vector_len); + } emit_int8(shift & 0xFF); } -void Assembler::vpsrlw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD1, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsrlw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xD1, dst, src, shift, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD2, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xD2, dst, src, shift, VEX_SIMD_66, vector_len); } -void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xD3, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + emit_vex_arith_q(0xD3, dst, src, shift, VEX_SIMD_66, vector_len); + } else { + emit_vex_arith(0xD3, dst, src, shift, VEX_SIMD_66, vector_len); + } } // Shift packed integers arithmetically right by specified number of bits. void Assembler::psraw(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM4 is for /4 encoding: 66 0F 71 /4 ib - int encode = simd_prefix_and_encode(xmm4, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm4, dst, dst, VEX_SIMD_66, false, VEX_OPCODE_0F, + (VM_Version::supports_avx512bw() == false)); emit_int8(0x71); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3719,7 +4610,7 @@ void Assembler::psraw(XMMRegister dst, int shift) { void Assembler::psrad(XMMRegister dst, int shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); // XMM4 is for /4 encoding: 66 0F 72 /4 ib - int encode = simd_prefix_and_encode(xmm4, dst, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode(xmm4, dst, dst, VEX_SIMD_66, false); emit_int8(0x72); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(shift & 0xFF); @@ -3727,7 +4618,8 @@ void Assembler::psrad(XMMRegister dst, int shift) { void Assembler::psraw(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - emit_simd_arith(0xE1, dst, shift, VEX_SIMD_66); + emit_simd_arith(0xE1, dst, shift, VEX_SIMD_66, + (VM_Version::supports_avx512bw() == false)); } void Assembler::psrad(XMMRegister dst, XMMRegister shift) { @@ -3735,28 +4627,30 @@ void Assembler::psrad(XMMRegister dst, XMMRegister shift) { emit_simd_arith(0xE2, dst, shift, VEX_SIMD_66); } -void Assembler::vpsraw(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsraw(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM4 is for /4 encoding: 66 0F 71 /4 ib - emit_vex_arith(0x71, xmm4, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x71, xmm4, dst, src, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); emit_int8(shift & 0xFF); } -void Assembler::vpsrad(XMMRegister dst, XMMRegister src, int shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); +void Assembler::vpsrad(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); // XMM4 is for /4 encoding: 66 0F 71 /4 ib - emit_vex_arith(0x72, xmm4, dst, src, VEX_SIMD_66, vector256); + emit_vex_arith(0x72, xmm4, dst, src, VEX_SIMD_66, vector_len); emit_int8(shift & 0xFF); } -void Assembler::vpsraw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xE1, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsraw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xE1, dst, src, shift, VEX_SIMD_66, vector_len, + (VM_Version::supports_avx512bw() == false)); } -void Assembler::vpsrad(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xE2, dst, src, shift, VEX_SIMD_66, vector256); +void Assembler::vpsrad(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xE2, dst, src, shift, VEX_SIMD_66, vector_len); } @@ -3766,14 +4660,18 @@ void Assembler::pand(XMMRegister dst, XMMRegister src) { emit_simd_arith(0xDB, dst, src, VEX_SIMD_66); } -void Assembler::vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xDB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xDB, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpand(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xDB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0xDB, dst, nds, src, VEX_SIMD_66, vector_len); } void Assembler::por(XMMRegister dst, XMMRegister src) { @@ -3781,14 +4679,18 @@ void Assembler::por(XMMRegister dst, XMMRegister src) { emit_simd_arith(0xEB, dst, src, VEX_SIMD_66); } -void Assembler::vpor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xEB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xEB, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpor(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xEB, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpor(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0xEB, dst, nds, src, VEX_SIMD_66, vector_len); } void Assembler::pxor(XMMRegister dst, XMMRegister src) { @@ -3796,21 +4698,25 @@ void Assembler::pxor(XMMRegister dst, XMMRegister src) { emit_simd_arith(0xEF, dst, src, VEX_SIMD_66); } -void Assembler::vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xEF, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + emit_vex_arith(0xEF, dst, nds, src, VEX_SIMD_66, vector_len); } -void Assembler::vpxor(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - assert(VM_Version::supports_avx() && !vector256 || VM_Version::supports_avx2(), "256 bit integer vectors requires AVX2"); - emit_vex_arith(0xEF, dst, nds, src, VEX_SIMD_66, vector256); +void Assembler::vpxor(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_FV; + input_size_in_bits = EVEX_32bit; + } + emit_vex_arith(0xEF, dst, nds, src, VEX_SIMD_66, vector_len); } void Assembler::vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector_len, VEX_OPCODE_0F_3A); emit_int8(0x18); emit_int8((unsigned char)(0xC0 | encode)); // 0x00 - insert into lower 128 bits @@ -3818,14 +4724,51 @@ void Assembler::vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src) emit_int8(0x01); } -void Assembler::vinsertf128h(XMMRegister dst, Address src) { +void Assembler::vinsertf64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + int encode = vex_prefix_and_encode(dst_enc, nds_enc, src_enc, VEX_SIMD_66, + VEX_OPCODE_0F_3A, true, vector_len, false, false); + emit_int8(0x1A); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x00 - insert into lower 256 bits + // 0x01 - insert into upper 256 bits + emit_int8(0x01); +} + +void Assembler::vinsertf64x4h(XMMRegister dst, Address src) { assert(VM_Version::supports_avx(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_64bit; + } InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_512bit; assert(dst != xnoreg, "sanity"); int dst_enc = dst->encoding(); // swap src<->dst for encoding - vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256); + vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, true, vector_len); + emit_int8(0x1A); + emit_operand(dst, src); + // 0x01 - insert into upper 128 bits + emit_int8(0x01); +} + +void Assembler::vinsertf128h(XMMRegister dst, Address src) { + assert(VM_Version::supports_avx(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_32bit; + } + InstructionMark im(this); + int vector_len = AVX_256bit; + assert(dst != xnoreg, "sanity"); + int dst_enc = dst->encoding(); + // swap src<->dst for encoding + vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector_len); emit_int8(0x18); emit_operand(dst, src); // 0x01 - insert into upper 128 bits @@ -3834,8 +4777,8 @@ void Assembler::vinsertf128h(XMMRegister dst, Address src) { void Assembler::vextractf128h(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_avx(), ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(src, xnoreg, dst, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(src, xnoreg, dst, VEX_SIMD_66, vector_len, VEX_OPCODE_0F_3A); emit_int8(0x19); emit_int8((unsigned char)(0xC0 | encode)); // 0x00 - insert into lower 128 bits @@ -3845,11 +4788,15 @@ void Assembler::vextractf128h(XMMRegister dst, XMMRegister src) { void Assembler::vextractf128h(Address dst, XMMRegister src) { assert(VM_Version::supports_avx(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_256bit; assert(src != xnoreg, "sanity"); int src_enc = src->encoding(); - vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256); + vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector_len); emit_int8(0x19); emit_operand(src, dst); // 0x01 - extract from upper 128 bits @@ -3858,8 +4805,8 @@ void Assembler::vextractf128h(Address dst, XMMRegister src) { void Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx2(), ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector_len, VEX_OPCODE_0F_3A); emit_int8(0x38); emit_int8((unsigned char)(0xC0 | encode)); // 0x00 - insert into lower 128 bits @@ -3867,38 +4814,169 @@ void Assembler::vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src) emit_int8(0x01); } +void Assembler::vinserti64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + int encode = vex_prefix_and_encode(dst_enc, nds_enc, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + VM_Version::supports_avx512dq(), vector_len, false, false); + emit_int8(0x38); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x00 - insert into lower 256 bits + // 0x01 - insert into upper 256 bits + emit_int8(0x01); +} + void Assembler::vinserti128h(XMMRegister dst, Address src) { assert(VM_Version::supports_avx2(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_256bit; assert(dst != xnoreg, "sanity"); int dst_enc = dst->encoding(); // swap src<->dst for encoding - vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256); + vex_prefix(src, dst_enc, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector_len); emit_int8(0x38); emit_operand(dst, src); // 0x01 - insert into upper 128 bits emit_int8(0x01); } +void Assembler::vextracti128h(XMMRegister dst, XMMRegister src) { + assert(VM_Version::supports_avx(), ""); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(src, xnoreg, dst, VEX_SIMD_66, vector_len, VEX_OPCODE_0F_3A); + emit_int8(0x39); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x00 - insert into lower 128 bits + // 0x01 - insert into upper 128 bits + emit_int8(0x01); +} + void Assembler::vextracti128h(Address dst, XMMRegister src) { assert(VM_Version::supports_avx2(), ""); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - bool vector256 = true; + int vector_len = AVX_256bit; assert(src != xnoreg, "sanity"); int src_enc = src->encoding(); - vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector256); + vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, false, vector_len); emit_int8(0x39); emit_operand(src, dst); // 0x01 - extract from upper 128 bits emit_int8(0x01); } +void Assembler::vextracti64x4h(XMMRegister dst, XMMRegister src) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(src_enc, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + true, vector_len, false, false); + emit_int8(0x3B); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x01 - extract from upper 256 bits + emit_int8(0x01); +} + +void Assembler::vextracti64x2h(XMMRegister dst, XMMRegister src, int value) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(src_enc, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + VM_Version::supports_avx512dq(), vector_len, false, false); + emit_int8(0x39); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x01 - extract from bits 255:128 + // 0x02 - extract from bits 383:256 + // 0x03 - extract from bits 511:384 + emit_int8(value & 0x3); +} + +void Assembler::vextractf64x4h(XMMRegister dst, XMMRegister src) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(src_enc, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + VM_Version::supports_avx512dq(), vector_len, false, false); + emit_int8(0x1B); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x01 - extract from upper 256 bits + emit_int8(0x01); +} + +void Assembler::vextractf64x4h(Address dst, XMMRegister src) { + assert(VM_Version::supports_avx2(), ""); + tuple_type = EVEX_T4; + input_size_in_bits = EVEX_64bit; + InstructionMark im(this); + int vector_len = AVX_512bit; + assert(src != xnoreg, "sanity"); + int src_enc = src->encoding(); + vex_prefix(dst, 0, src_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + VM_Version::supports_avx512dq(), vector_len); + emit_int8(0x1B); + emit_operand(src, dst); + // 0x01 - extract from upper 128 bits + emit_int8(0x01); +} + +void Assembler::vextractf32x4h(XMMRegister dst, XMMRegister src, int value) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(src_enc, 0, dst_enc, VEX_SIMD_66, + VEX_OPCODE_0F_3A, false, vector_len, false, false); + emit_int8(0x19); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x01 - extract from bits 255:128 + // 0x02 - extract from bits 383:256 + // 0x03 - extract from bits 511:384 + emit_int8(value & 0x3); +} + +void Assembler::vextractf64x2h(XMMRegister dst, XMMRegister src, int value) { + assert(VM_Version::supports_evex(), ""); + int vector_len = AVX_512bit; + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int encode = vex_prefix_and_encode(src_enc, 0, dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, + VM_Version::supports_avx512dq(), vector_len, false, false); + emit_int8(0x19); + emit_int8((unsigned char)(0xC0 | encode)); + // 0x01 - extract from bits 255:128 + // 0x02 - extract from bits 383:256 + // 0x03 - extract from bits 511:384 + emit_int8(value & 0x3); +} + // duplicate 4-bytes integer data from src into 8 locations in dest void Assembler::vpbroadcastd(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_avx2(), ""); - bool vector256 = true; - int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_38); + int vector_len = AVX_256bit; + int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, + vector_len, VEX_OPCODE_0F_38, false); + emit_int8(0x58); + emit_int8((unsigned char)(0xC0 | encode)); +} + +// duplicate 4-bytes integer data from src into 8 locations in dest +void Assembler::evpbroadcastd(XMMRegister dst, XMMRegister src, int vector_len) { + assert(VM_Version::supports_evex(), ""); + int encode = vex_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, + vector_len, VEX_OPCODE_0F_38, false); emit_int8(0x58); emit_int8((unsigned char)(0xC0 | encode)); } @@ -3906,7 +4984,8 @@ void Assembler::vpbroadcastd(XMMRegister dst, XMMRegister src) { // Carry-Less Multiplication Quadword void Assembler::pclmulqdq(XMMRegister dst, XMMRegister src, int mask) { assert(VM_Version::supports_clmul(), ""); - int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A); + int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, false, + VEX_OPCODE_0F_3A, false, AVX_128bit, true); emit_int8(0x44); emit_int8((unsigned char)(0xC0 | encode)); emit_int8((unsigned char)mask); @@ -3915,8 +4994,9 @@ void Assembler::pclmulqdq(XMMRegister dst, XMMRegister src, int mask) { // Carry-Less Multiplication Quadword void Assembler::vpclmulqdq(XMMRegister dst, XMMRegister nds, XMMRegister src, int mask) { assert(VM_Version::supports_avx() && VM_Version::supports_clmul(), ""); - bool vector256 = false; - int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, vector256, VEX_OPCODE_0F_3A); + int vector_len = AVX_128bit; + int encode = vex_prefix_and_encode(dst, nds, src, VEX_SIMD_66, + vector_len, VEX_OPCODE_0F_3A, true); emit_int8(0x44); emit_int8((unsigned char)(0xC0 | encode)); emit_int8((unsigned char)mask); @@ -3924,8 +5004,11 @@ void Assembler::vpclmulqdq(XMMRegister dst, XMMRegister nds, XMMRegister src, in void Assembler::vzeroupper() { assert(VM_Version::supports_avx(), ""); - (void)vex_prefix_and_encode(xmm0, xmm0, xmm0, VEX_SIMD_NONE); - emit_int8(0x77); + if (UseAVX < 3) + { + (void)vex_prefix_and_encode(xmm0, xmm0, xmm0, VEX_SIMD_NONE); + emit_int8(0x77); + } } @@ -4442,7 +5525,7 @@ int Assembler::rex_prefix_and_encode(int dst_enc, int src_enc, VexSimdPrefix pre } -void Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int nds_enc, VexSimdPrefix pre, VexOpcode opc, bool vector256) { +void Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int nds_enc, VexSimdPrefix pre, VexOpcode opc, int vector_len) { if (vex_b || vex_x || vex_w || (opc == VEX_OPCODE_0F_38) || (opc == VEX_OPCODE_0F_3A)) { prefix(VEX_3bytes); @@ -4452,7 +5535,7 @@ void Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int n emit_int8(byte1); int byte2 = ((~nds_enc) & 0xf) << 3; - byte2 |= (vex_w ? VEX_W : 0) | (vector256 ? 4 : 0) | pre; + byte2 |= (vex_w ? VEX_W : 0) | ((vector_len > 0) ? 4 : 0) | pre; emit_int8(byte2); } else { prefix(VEX_2bytes); @@ -4460,89 +5543,237 @@ void Assembler::vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int n int byte1 = vex_r ? VEX_R : 0; byte1 = (~byte1) & 0x80; byte1 |= ((~nds_enc) & 0xf) << 3; - byte1 |= (vector256 ? 4 : 0) | pre; + byte1 |= ((vector_len > 0 ) ? 4 : 0) | pre; emit_int8(byte1); } } -void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, bool vex_w, bool vector256){ +// This is a 4 byte encoding +void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, bool evex_r, bool evex_v, + int nds_enc, VexSimdPrefix pre, VexOpcode opc, + bool is_extended_context, bool is_merge_context, + int vector_len, bool no_mask_reg ){ + // EVEX 0x62 prefix + prefix(EVEX_4bytes); + evex_encoding = (vex_w ? VEX_W : 0) | (evex_r ? EVEX_Rb : 0); + + // P0: byte 2, initialized to RXBR`00mm + // instead of not'd + int byte2 = (vex_r ? VEX_R : 0) | (vex_x ? VEX_X : 0) | (vex_b ? VEX_B : 0) | (evex_r ? EVEX_Rb : 0); + byte2 = (~byte2) & 0xF0; + // confine opc opcode extensions in mm bits to lower two bits + // of form {0F, 0F_38, 0F_3A} + byte2 |= opc; + emit_int8(byte2); + + // P1: byte 3 as Wvvvv1pp + int byte3 = ((~nds_enc) & 0xf) << 3; + // p[10] is always 1 + byte3 |= EVEX_F; + byte3 |= (vex_w & 1) << 7; + // confine pre opcode extensions in pp bits to lower two bits + // of form {66, F3, F2} + byte3 |= pre; + emit_int8(byte3); + + // P2: byte 4 as zL'Lbv'aaa + int byte4 = (no_mask_reg) ? 0 : 1; // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now) + // EVEX.v` for extending EVEX.vvvv or VIDX + byte4 |= (evex_v ? 0: EVEX_V); + // third EXEC.b for broadcast actions + byte4 |= (is_extended_context ? EVEX_Rb : 0); + // fourth EVEX.L'L for vector length : 0 is 128, 1 is 256, 2 is 512, currently we do not support 1024 + byte4 |= ((vector_len) & 0x3) << 5; + // last is EVEX.z for zero/merge actions + byte4 |= (is_merge_context ? EVEX_Z : 0); + emit_int8(byte4); +} + +void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, + VexOpcode opc, bool vex_w, int vector_len, bool legacy_mode, bool no_mask_reg) { bool vex_r = (xreg_enc >= 8); bool vex_b = adr.base_needs_rex(); bool vex_x = adr.index_needs_rex(); - vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector256); + avx_vector_len = vector_len; + + // if vector length is turned off, revert to AVX for vectors smaller than AVX_512bit + if (VM_Version::supports_avx512vl() == false) { + switch (vector_len) { + case AVX_128bit: + case AVX_256bit: + legacy_mode = true; + break; + } + } + + if ((UseAVX > 2) && (legacy_mode == false)) + { + bool evex_r = (xreg_enc >= 16); + bool evex_v = (nds_enc >= 16); + is_evex_instruction = true; + evex_prefix(vex_r, vex_b, vex_x, vex_w, evex_r, evex_v, nds_enc, pre, opc, false, false, vector_len, no_mask_reg); + } else { + vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector_len); + } } -int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, bool vex_w, bool vector256) { +int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, + bool vex_w, int vector_len, bool legacy_mode, bool no_mask_reg ) { bool vex_r = (dst_enc >= 8); bool vex_b = (src_enc >= 8); bool vex_x = false; - vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector256); + avx_vector_len = vector_len; + + // if vector length is turned off, revert to AVX for vectors smaller than AVX_512bit + if (VM_Version::supports_avx512vl() == false) { + switch (vector_len) { + case AVX_128bit: + case AVX_256bit: + legacy_mode = true; + break; + } + } + + if ((UseAVX > 2) && (legacy_mode == false)) + { + bool evex_r = (dst_enc >= 16); + bool evex_v = (nds_enc >= 16); + // can use vex_x as bank extender on rm encoding + vex_x = (src_enc >= 16); + evex_prefix(vex_r, vex_b, vex_x, vex_w, evex_r, evex_v, nds_enc, pre, opc, false, false, vector_len, no_mask_reg); + } else { + vex_prefix(vex_r, vex_b, vex_x, vex_w, nds_enc, pre, opc, vector_len); + } + + // return modrm byte components for operands return (((dst_enc & 7) << 3) | (src_enc & 7)); } -void Assembler::simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, VexSimdPrefix pre, VexOpcode opc, bool rex_w, bool vector256) { +void Assembler::simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, VexSimdPrefix pre, + bool no_mask_reg, VexOpcode opc, bool rex_w, int vector_len, bool legacy_mode) { if (UseAVX > 0) { int xreg_enc = xreg->encoding(); int nds_enc = nds->is_valid() ? nds->encoding() : 0; - vex_prefix(adr, nds_enc, xreg_enc, pre, opc, rex_w, vector256); + vex_prefix(adr, nds_enc, xreg_enc, pre, opc, rex_w, vector_len, legacy_mode, no_mask_reg); } else { assert((nds == xreg) || (nds == xnoreg), "wrong sse encoding"); rex_prefix(adr, xreg, pre, opc, rex_w); } } -int Assembler::simd_prefix_and_encode(XMMRegister dst, XMMRegister nds, XMMRegister src, VexSimdPrefix pre, VexOpcode opc, bool rex_w, bool vector256) { +int Assembler::simd_prefix_and_encode(XMMRegister dst, XMMRegister nds, XMMRegister src, VexSimdPrefix pre, + bool no_mask_reg, VexOpcode opc, bool rex_w, int vector_len, bool legacy_mode) { int dst_enc = dst->encoding(); int src_enc = src->encoding(); if (UseAVX > 0) { int nds_enc = nds->is_valid() ? nds->encoding() : 0; - return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, rex_w, vector256); + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, rex_w, vector_len, legacy_mode, no_mask_reg); } else { assert((nds == dst) || (nds == src) || (nds == xnoreg), "wrong sse encoding"); return rex_prefix_and_encode(dst_enc, src_enc, pre, opc, rex_w); } } -void Assembler::emit_simd_arith(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre) { +int Assembler::kreg_prefix_and_encode(KRegister dst, KRegister nds, KRegister src, VexSimdPrefix pre, + bool no_mask_reg, VexOpcode opc, bool rex_w, int vector_len) { + int dst_enc = dst->encoding(); + int src_enc = src->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, rex_w, vector_len, true, no_mask_reg); +} + +int Assembler::kreg_prefix_and_encode(KRegister dst, KRegister nds, Register src, VexSimdPrefix pre, + bool no_mask_reg, VexOpcode opc, bool rex_w, int vector_len) { + int dst_enc = dst->encoding(); + int src_enc = src->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, rex_w, vector_len, true, no_mask_reg); +} + +void Assembler::emit_simd_arith(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg, bool legacy_mode) { InstructionMark im(this); - simd_prefix(dst, dst, src, pre); + simd_prefix(dst, dst, src, pre, no_mask_reg, VEX_OPCODE_0F, false, AVX_128bit, legacy_mode); emit_int8(opcode); emit_operand(dst, src); } -void Assembler::emit_simd_arith(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre) { - int encode = simd_prefix_and_encode(dst, dst, src, pre); +void Assembler::emit_simd_arith_q(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg) { + InstructionMark im(this); + simd_prefix_q(dst, dst, src, pre, no_mask_reg); + emit_int8(opcode); + emit_operand(dst, src); +} + +void Assembler::emit_simd_arith(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg, bool legacy_mode) { + int encode = simd_prefix_and_encode(dst, dst, src, pre, no_mask_reg, VEX_OPCODE_0F, false, AVX_128bit, legacy_mode); + emit_int8(opcode); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::emit_simd_arith_q(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg) { + int encode = simd_prefix_and_encode(dst, dst, src, pre, no_mask_reg, VEX_OPCODE_0F, true, AVX_128bit); emit_int8(opcode); emit_int8((unsigned char)(0xC0 | encode)); } // Versions with no second source register (non-destructive source). -void Assembler::emit_simd_arith_nonds(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre) { +void Assembler::emit_simd_arith_nonds(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool opNoRegMask) { InstructionMark im(this); - simd_prefix(dst, xnoreg, src, pre); + simd_prefix(dst, xnoreg, src, pre, opNoRegMask); emit_int8(opcode); emit_operand(dst, src); } -void Assembler::emit_simd_arith_nonds(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre) { - int encode = simd_prefix_and_encode(dst, xnoreg, src, pre); +void Assembler::emit_simd_arith_nonds_q(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool opNoRegMask) { + InstructionMark im(this); + simd_prefix_q(dst, xnoreg, src, pre, opNoRegMask); + emit_int8(opcode); + emit_operand(dst, src); +} + +void Assembler::emit_simd_arith_nonds(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg, bool legacy_mode) { + int encode = simd_prefix_and_encode(dst, xnoreg, src, pre, no_mask_reg, VEX_OPCODE_0F, legacy_mode, AVX_128bit); + emit_int8(opcode); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::emit_simd_arith_nonds_q(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg) { + int encode = simd_prefix_and_encode(dst, xnoreg, src, pre, no_mask_reg, VEX_OPCODE_0F, true, AVX_128bit); emit_int8(opcode); emit_int8((unsigned char)(0xC0 | encode)); } // 3-operands AVX instructions -void Assembler::emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, - Address src, VexSimdPrefix pre, bool vector256) { +void Assembler::emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, Address src, + VexSimdPrefix pre, int vector_len, bool no_mask_reg, bool legacy_mode) { InstructionMark im(this); - vex_prefix(dst, nds, src, pre, vector256); + vex_prefix(dst, nds, src, pre, vector_len, no_mask_reg, legacy_mode); emit_int8(opcode); emit_operand(dst, src); } -void Assembler::emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, - XMMRegister src, VexSimdPrefix pre, bool vector256) { - int encode = vex_prefix_and_encode(dst, nds, src, pre, vector256); +void Assembler::emit_vex_arith_q(int opcode, XMMRegister dst, XMMRegister nds, + Address src, VexSimdPrefix pre, int vector_len, bool no_mask_reg) { + InstructionMark im(this); + vex_prefix_q(dst, nds, src, pre, vector_len, no_mask_reg); + emit_int8(opcode); + emit_operand(dst, src); +} + +void Assembler::emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, XMMRegister src, + VexSimdPrefix pre, int vector_len, bool no_mask_reg, bool legacy_mode) { + int encode = vex_prefix_and_encode(dst, nds, src, pre, vector_len, VEX_OPCODE_0F, false, no_mask_reg); + emit_int8(opcode); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::emit_vex_arith_q(int opcode, XMMRegister dst, XMMRegister nds, XMMRegister src, + VexSimdPrefix pre, int vector_len, bool no_mask_reg) { + int src_enc = src->encoding(); + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + int encode = vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, VEX_OPCODE_0F, true, vector_len, false, no_mask_reg); emit_int8(opcode); emit_int8((unsigned char)(0xC0 | encode)); } @@ -5040,6 +6271,10 @@ void Assembler::andnq(Register dst, Register src1, Register src2) { } void Assembler::andnq(Register dst, Register src1, Address src2) { + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_64bit; + } InstructionMark im(this); assert(VM_Version::supports_bmi1(), "bit manipulation instructions not supported"); vex_prefix_0F38_q(dst, src1, src2); @@ -5181,44 +6416,52 @@ void Assembler::cmpxchgq(Register reg, Address adr) { void Assembler::cvtsi2sdq(XMMRegister dst, Register src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F2); + int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F2, true); emit_int8(0x2A); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvtsi2sdq(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix_q(dst, dst, src, VEX_SIMD_F2); + simd_prefix_q(dst, dst, src, VEX_SIMD_F2, true); emit_int8(0x2A); emit_operand(dst, src); } void Assembler::cvtsi2ssq(XMMRegister dst, Register src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F3); + int encode = simd_prefix_and_encode_q(dst, dst, src, VEX_SIMD_F3, true); emit_int8(0x2A); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvtsi2ssq(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); + if (VM_Version::supports_evex()) { + tuple_type = EVEX_T1S; + input_size_in_bits = EVEX_32bit; + } InstructionMark im(this); - simd_prefix_q(dst, dst, src, VEX_SIMD_F3); + simd_prefix_q(dst, dst, src, VEX_SIMD_F3, true); emit_int8(0x2A); emit_operand(dst, src); } void Assembler::cvttsd2siq(Register dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F2); + int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, true); emit_int8(0x2C); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::cvttss2siq(Register dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse(), "")); - int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F3); + int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_F3, VEX_OPCODE_0F, true); emit_int8(0x2C); emit_int8((unsigned char)(0xC0 | encode)); } @@ -5387,7 +6630,7 @@ void Assembler::lzcntq(Register dst, Register src) { void Assembler::movdq(XMMRegister dst, Register src) { // table D-1 says MMX/SSE2 NOT_LP64(assert(VM_Version::supports_sse2(), "")); - int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_66); + int encode = simd_prefix_and_encode_q(dst, src, VEX_SIMD_66, true); emit_int8(0x6E); emit_int8((unsigned char)(0xC0 | encode)); } @@ -5396,7 +6639,7 @@ void Assembler::movdq(Register dst, XMMRegister src) { // table D-1 says MMX/SSE2 NOT_LP64(assert(VM_Version::supports_sse2(), "")); // swap src/dst to get correct prefix - int encode = simd_prefix_and_encode_q(src, dst, VEX_SIMD_66); + int encode = simd_prefix_and_encode_q(src, dst, VEX_SIMD_66, true); emit_int8(0x7E); emit_int8((unsigned char)(0xC0 | encode)); } @@ -5529,7 +6772,8 @@ void Assembler::mulq(Register src) { void Assembler::mulxq(Register dst1, Register dst2, Register src) { assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported"); - int encode = vex_prefix_and_encode(dst1->encoding(), dst2->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F_38, true, false); + int encode = vex_prefix_and_encode(dst1->encoding(), dst2->encoding(), src->encoding(), + VEX_SIMD_F2, VEX_OPCODE_0F_38, true, AVX_128bit, true, false); emit_int8((unsigned char)0xF6); emit_int8((unsigned char)(0xC0 | encode)); } @@ -5678,7 +6922,8 @@ void Assembler::rorq(Register dst, int imm8) { void Assembler::rorxq(Register dst, Register src, int imm8) { assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported"); - int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F_3A, true, false); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F2, + VEX_OPCODE_0F_3A, true, AVX_128bit, true, false); emit_int8((unsigned char)0xF0); emit_int8((unsigned char)(0xC0 | encode)); emit_int8(imm8); diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 742d6c5eed9..32619735400 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -438,7 +438,7 @@ class ArrayAddress VALUE_OBJ_CLASS_SPEC { }; -const int FPUStateSizeInWords = NOT_LP64(27) LP64_ONLY( 512 / wordSize); +const int FPUStateSizeInWords = NOT_LP64(27) LP64_ONLY( 512*2 / wordSize); // The Intel x86/Amd64 Assembler: Pure assembler doing NO optimizations on the instruction // level (e.g. mov rax, 0 is not translated into xor rax, rax!); i.e., what you write @@ -503,7 +503,8 @@ class Assembler : public AbstractAssembler { REX_WRXB = 0x4F, VEX_3bytes = 0xC4, - VEX_2bytes = 0xC5 + VEX_2bytes = 0xC5, + EVEX_4bytes = 0x62 }; enum VexPrefix { @@ -513,6 +514,14 @@ class Assembler : public AbstractAssembler { VEX_W = 0x80 }; + enum ExexPrefix { + EVEX_F = 0x04, + EVEX_V = 0x08, + EVEX_Rb = 0x10, + EVEX_X = 0x40, + EVEX_Z = 0x80 + }; + enum VexSimdPrefix { VEX_SIMD_NONE = 0x0, VEX_SIMD_66 = 0x1, @@ -527,6 +536,37 @@ class Assembler : public AbstractAssembler { VEX_OPCODE_0F_3A = 0x3 }; + enum AvxVectorLen { + AVX_128bit = 0x0, + AVX_256bit = 0x1, + AVX_512bit = 0x2, + AVX_NoVec = 0x4 + }; + + enum EvexTupleType { + EVEX_FV = 0, + EVEX_HV = 4, + EVEX_FVM = 6, + EVEX_T1S = 7, + EVEX_T1F = 11, + EVEX_T2 = 13, + EVEX_T4 = 15, + EVEX_T8 = 17, + EVEX_HVM = 18, + EVEX_QVM = 19, + EVEX_OVM = 20, + EVEX_M128 = 21, + EVEX_DUP = 22, + EVEX_ETUP = 23 + }; + + enum EvexInputSizeInBits { + EVEX_8bit = 0, + EVEX_16bit = 1, + EVEX_32bit = 2, + EVEX_64bit = 3 + }; + enum WhichOperand { // input to locate_operand, and format code for relocations imm_operand = 0, // embedded 32-bit|64-bit immediate operand @@ -554,6 +594,11 @@ class Assembler : public AbstractAssembler { private: + int evex_encoding; + int input_size_in_bits; + int avx_vector_len; + int tuple_type; + bool is_evex_instruction; // 64bit prefixes int prefix_and_encode(int reg_enc, bool byteinst = false); @@ -580,108 +625,143 @@ private: void vex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, int nds_enc, VexSimdPrefix pre, VexOpcode opc, - bool vector256); + int vector_len); + + void evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool vex_w, bool evex_r, bool evex_v, + int nds_enc, VexSimdPrefix pre, VexOpcode opc, + bool is_extended_context, bool is_merge_context, + int vector_len, bool no_mask_reg ); void vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix pre, VexOpcode opc, - bool vex_w, bool vector256); + bool vex_w, int vector_len, + bool legacy_mode = false, bool no_mask_reg = false); void vex_prefix(XMMRegister dst, XMMRegister nds, Address src, - VexSimdPrefix pre, bool vector256 = false) { + VexSimdPrefix pre, int vector_len = AVX_128bit, + bool no_mask_reg = false, bool legacy_mode = false) { int dst_enc = dst->encoding(); int nds_enc = nds->is_valid() ? nds->encoding() : 0; - vex_prefix(src, nds_enc, dst_enc, pre, VEX_OPCODE_0F, false, vector256); + vex_prefix(src, nds_enc, dst_enc, pre, VEX_OPCODE_0F, false, vector_len, legacy_mode, no_mask_reg); } - void vex_prefix_0F38(Register dst, Register nds, Address src) { + void vex_prefix_q(XMMRegister dst, XMMRegister nds, Address src, + VexSimdPrefix pre, int vector_len = AVX_128bit, + bool no_mask_reg = false) { + int dst_enc = dst->encoding(); + int nds_enc = nds->is_valid() ? nds->encoding() : 0; + vex_prefix(src, nds_enc, dst_enc, pre, VEX_OPCODE_0F, true, vector_len, false, no_mask_reg); + } + + void vex_prefix_0F38(Register dst, Register nds, Address src, bool no_mask_reg = false) { bool vex_w = false; - bool vector256 = false; + int vector_len = AVX_128bit; vex_prefix(src, nds->encoding(), dst->encoding(), - VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector256); + VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, + vector_len, no_mask_reg); } - void vex_prefix_0F38_q(Register dst, Register nds, Address src) { + void vex_prefix_0F38_q(Register dst, Register nds, Address src, bool no_mask_reg = false) { bool vex_w = true; - bool vector256 = false; + int vector_len = AVX_128bit; vex_prefix(src, nds->encoding(), dst->encoding(), - VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector256); + VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, + vector_len, no_mask_reg); } int vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexSimdPrefix pre, VexOpcode opc, - bool vex_w, bool vector256); + bool vex_w, int vector_len, + bool legacy_mode, bool no_mask_reg); - int vex_prefix_0F38_and_encode(Register dst, Register nds, Register src) { + int vex_prefix_0F38_and_encode(Register dst, Register nds, Register src, bool no_mask_reg = false) { bool vex_w = false; - bool vector256 = false; + int vector_len = AVX_128bit; return vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), - VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector256); + VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector_len, + false, no_mask_reg); } - int vex_prefix_0F38_and_encode_q(Register dst, Register nds, Register src) { + int vex_prefix_0F38_and_encode_q(Register dst, Register nds, Register src, bool no_mask_reg = false) { bool vex_w = true; - bool vector256 = false; + int vector_len = AVX_128bit; return vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), - VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector256); + VEX_SIMD_NONE, VEX_OPCODE_0F_38, vex_w, vector_len, + false, no_mask_reg); } int vex_prefix_and_encode(XMMRegister dst, XMMRegister nds, XMMRegister src, - VexSimdPrefix pre, bool vector256 = false, - VexOpcode opc = VEX_OPCODE_0F) { + VexSimdPrefix pre, int vector_len = AVX_128bit, + VexOpcode opc = VEX_OPCODE_0F, bool legacy_mode = false, + bool no_mask_reg = false) { int src_enc = src->encoding(); int dst_enc = dst->encoding(); int nds_enc = nds->is_valid() ? nds->encoding() : 0; - return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, false, vector256); + return vex_prefix_and_encode(dst_enc, nds_enc, src_enc, pre, opc, false, vector_len, legacy_mode, no_mask_reg); } void simd_prefix(XMMRegister xreg, XMMRegister nds, Address adr, - VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F, - bool rex_w = false, bool vector256 = false); + VexSimdPrefix pre, bool no_mask_reg, VexOpcode opc = VEX_OPCODE_0F, + bool rex_w = false, int vector_len = AVX_128bit, bool legacy_mode = false); - void simd_prefix(XMMRegister dst, Address src, - VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F) { - simd_prefix(dst, xnoreg, src, pre, opc); + void simd_prefix(XMMRegister dst, Address src, VexSimdPrefix pre, + bool no_mask_reg, VexOpcode opc = VEX_OPCODE_0F) { + simd_prefix(dst, xnoreg, src, pre, no_mask_reg, opc); } - void simd_prefix(Address dst, XMMRegister src, VexSimdPrefix pre) { - simd_prefix(src, dst, pre); + void simd_prefix(Address dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg) { + simd_prefix(src, dst, pre, no_mask_reg); } void simd_prefix_q(XMMRegister dst, XMMRegister nds, Address src, - VexSimdPrefix pre) { + VexSimdPrefix pre, bool no_mask_reg = false) { bool rex_w = true; - simd_prefix(dst, nds, src, pre, VEX_OPCODE_0F, rex_w); + simd_prefix(dst, nds, src, pre, no_mask_reg, VEX_OPCODE_0F, rex_w); } int simd_prefix_and_encode(XMMRegister dst, XMMRegister nds, XMMRegister src, - VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F, - bool rex_w = false, bool vector256 = false); + VexSimdPrefix pre, bool no_mask_reg, + VexOpcode opc = VEX_OPCODE_0F, + bool rex_w = false, int vector_len = AVX_128bit, + bool legacy_mode = false); + + int kreg_prefix_and_encode(KRegister dst, KRegister nds, KRegister src, + VexSimdPrefix pre, bool no_mask_reg, + VexOpcode opc = VEX_OPCODE_0F, + bool rex_w = false, int vector_len = AVX_128bit); + + int kreg_prefix_and_encode(KRegister dst, KRegister nds, Register src, + VexSimdPrefix pre, bool no_mask_reg, + VexOpcode opc = VEX_OPCODE_0F, + bool rex_w = false, int vector_len = AVX_128bit); // Move/convert 32-bit integer value. int simd_prefix_and_encode(XMMRegister dst, XMMRegister nds, Register src, - VexSimdPrefix pre) { + VexSimdPrefix pre, bool no_mask_reg) { // It is OK to cast from Register to XMMRegister to pass argument here // since only encoding is used in simd_prefix_and_encode() and number of // Gen and Xmm registers are the same. - return simd_prefix_and_encode(dst, nds, as_XMMRegister(src->encoding()), pre); + return simd_prefix_and_encode(dst, nds, as_XMMRegister(src->encoding()), pre, no_mask_reg, VEX_OPCODE_0F); } - int simd_prefix_and_encode(XMMRegister dst, Register src, VexSimdPrefix pre) { - return simd_prefix_and_encode(dst, xnoreg, src, pre); + int simd_prefix_and_encode(XMMRegister dst, Register src, VexSimdPrefix pre, bool no_mask_reg) { + return simd_prefix_and_encode(dst, xnoreg, src, pre, no_mask_reg); } int simd_prefix_and_encode(Register dst, XMMRegister src, - VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F) { - return simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, pre, opc); + VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F, + bool no_mask_reg = false) { + return simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, pre, no_mask_reg, opc); } // Move/convert 64-bit integer value. int simd_prefix_and_encode_q(XMMRegister dst, XMMRegister nds, Register src, - VexSimdPrefix pre) { + VexSimdPrefix pre, bool no_mask_reg = false) { bool rex_w = true; - return simd_prefix_and_encode(dst, nds, as_XMMRegister(src->encoding()), pre, VEX_OPCODE_0F, rex_w); + return simd_prefix_and_encode(dst, nds, as_XMMRegister(src->encoding()), pre, no_mask_reg, VEX_OPCODE_0F, rex_w); } - int simd_prefix_and_encode_q(XMMRegister dst, Register src, VexSimdPrefix pre) { - return simd_prefix_and_encode_q(dst, xnoreg, src, pre); + int simd_prefix_and_encode_q(XMMRegister dst, Register src, VexSimdPrefix pre, bool no_mask_reg) { + return simd_prefix_and_encode_q(dst, xnoreg, src, pre, no_mask_reg); } int simd_prefix_and_encode_q(Register dst, XMMRegister src, - VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F) { + VexSimdPrefix pre, VexOpcode opc = VEX_OPCODE_0F, + bool no_mask_reg = false) { bool rex_w = true; - return simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, pre, opc, rex_w); + return simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, pre, no_mask_reg, opc, rex_w); } // Helper functions for groups of instructions @@ -692,14 +772,28 @@ private: void emit_arith_imm32(int op1, int op2, Register dst, int32_t imm32); void emit_arith(int op1, int op2, Register dst, Register src); - void emit_simd_arith(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre); - void emit_simd_arith(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre); - void emit_simd_arith_nonds(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre); - void emit_simd_arith_nonds(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre); + void emit_simd_arith(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg = false, bool legacy_mode = false); + void emit_simd_arith_q(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg = false); + void emit_simd_arith(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg = false, bool legacy_mode = false); + void emit_simd_arith_q(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg = false); + void emit_simd_arith_nonds(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg = false); + void emit_simd_arith_nonds_q(int opcode, XMMRegister dst, Address src, VexSimdPrefix pre, bool no_mask_reg = false); + void emit_simd_arith_nonds(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg = false, bool legacy_mode = false); + void emit_simd_arith_nonds_q(int opcode, XMMRegister dst, XMMRegister src, VexSimdPrefix pre, bool no_mask_reg = false); void emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, - Address src, VexSimdPrefix pre, bool vector256); + Address src, VexSimdPrefix pre, int vector_len, + bool no_mask_reg = false, bool legacy_mode = false); + void emit_vex_arith_q(int opcode, XMMRegister dst, XMMRegister nds, + Address src, VexSimdPrefix pre, int vector_len, + bool no_mask_reg = false); void emit_vex_arith(int opcode, XMMRegister dst, XMMRegister nds, - XMMRegister src, VexSimdPrefix pre, bool vector256); + XMMRegister src, VexSimdPrefix pre, int vector_len, + bool no_mask_reg = false, bool legacy_mode = false); + void emit_vex_arith_q(int opcode, XMMRegister dst, XMMRegister nds, + XMMRegister src, VexSimdPrefix pre, int vector_len, + bool no_mask_reg = false); + + bool emit_compressed_disp_byte(int &disp); void emit_operand(Register reg, Register base, Register index, Address::ScaleFactor scale, @@ -825,7 +919,9 @@ private: public: // Creation - Assembler(CodeBuffer* code) : AbstractAssembler(code) {} + Assembler(CodeBuffer* code) : AbstractAssembler(code) { + init_attributes(); + } // Decoding static address locate_operand(address inst, WhichOperand which); @@ -833,11 +929,21 @@ private: // Utilities static bool is_polling_page_far() NOT_LP64({ return false;}); + static bool query_compressed_disp_byte(int disp, bool is_evex_inst, int vector_len, + int cur_tuple_type, int in_size_in_bits, int cur_encoding); // Generic instructions // Does 32bit or 64bit as needed for the platform. In some sense these // belong in macro assembler but there is no need for both varieties to exist + void init_attributes(void) { + evex_encoding = 0; + input_size_in_bits = 0; + avx_vector_len = AVX_NoVec; + tuple_type = EVEX_ETUP; + is_evex_instruction = false; + } + void lea(Register dst, Address src); void mov(Register dst, Register src); @@ -1338,6 +1444,12 @@ private: void movb(Address dst, int imm8); void movb(Register dst, Address src); + void kmovq(KRegister dst, KRegister src); + void kmovql(KRegister dst, Register src); + void kmovdl(KRegister dst, Register src); + void kmovq(Address dst, KRegister src); + void kmovq(KRegister dst, Address src); + void movdl(XMMRegister dst, Register src); void movdl(Register dst, XMMRegister src); void movdl(XMMRegister dst, Address src); @@ -1361,6 +1473,11 @@ private: void vmovdqu(XMMRegister dst, Address src); void vmovdqu(XMMRegister dst, XMMRegister src); + // Move Unaligned 512bit Vector + void evmovdqu(Address dst, XMMRegister src, int vector_len); + void evmovdqu(XMMRegister dst, Address src, int vector_len); + void evmovdqu(XMMRegister dst, XMMRegister src, int vector_len); + // Move lower 64bit to high 64bit in 128bit register void movlhps(XMMRegister dst, XMMRegister src); @@ -1486,10 +1603,10 @@ private: // Pack with unsigned saturation void packuswb(XMMRegister dst, XMMRegister src); void packuswb(XMMRegister dst, Address src); - void vpackuswb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); + void vpackuswb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); // Pemutation of 64bit words - void vpermq(XMMRegister dst, XMMRegister src, int imm8, bool vector256); + void vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_len); void pause(); @@ -1734,54 +1851,54 @@ private: // Add Packed Floating-Point Values void addpd(XMMRegister dst, XMMRegister src); void addps(XMMRegister dst, XMMRegister src); - void vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vaddps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vaddpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vaddps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vaddps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vaddpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vaddps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Subtract Packed Floating-Point Values void subpd(XMMRegister dst, XMMRegister src); void subps(XMMRegister dst, XMMRegister src); - void vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vsubps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vsubpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vsubps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vsubps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vsubpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vsubps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Multiply Packed Floating-Point Values void mulpd(XMMRegister dst, XMMRegister src); void mulps(XMMRegister dst, XMMRegister src); - void vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vmulps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vmulpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vmulps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vmulps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vmulpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vmulps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Divide Packed Floating-Point Values void divpd(XMMRegister dst, XMMRegister src); void divps(XMMRegister dst, XMMRegister src); - void vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vdivps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vdivpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vdivps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vdivps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vdivpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vdivps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Bitwise Logical AND of Packed Floating-Point Values void andpd(XMMRegister dst, XMMRegister src); void andps(XMMRegister dst, XMMRegister src); - void vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vandpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vandps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vandpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vandps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Bitwise Logical XOR of Packed Floating-Point Values void xorpd(XMMRegister dst, XMMRegister src); void xorps(XMMRegister dst, XMMRegister src); - void vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vxorpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vxorps(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vxorpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vxorps(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Add horizontal packed integers - void vphaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vphaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); + void vphaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vphaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void phaddw(XMMRegister dst, XMMRegister src); void phaddd(XMMRegister dst, XMMRegister src); @@ -1790,36 +1907,38 @@ private: void paddw(XMMRegister dst, XMMRegister src); void paddd(XMMRegister dst, XMMRegister src); void paddq(XMMRegister dst, XMMRegister src); - void vpaddb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpaddb(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpaddw(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpaddd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpaddq(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpaddb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddq(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Sub packed integers void psubb(XMMRegister dst, XMMRegister src); void psubw(XMMRegister dst, XMMRegister src); void psubd(XMMRegister dst, XMMRegister src); void psubq(XMMRegister dst, XMMRegister src); - void vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpsubw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpsubb(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpsubw(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpsubd(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpsubq(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubq(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Multiply packed integers (only shorts and ints) void pmullw(XMMRegister dst, XMMRegister src); void pmulld(XMMRegister dst, XMMRegister src); - void vpmullw(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpmullw(XMMRegister dst, XMMRegister nds, Address src, bool vector256); - void vpmulld(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpmullw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpmullq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpmullw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpmulld(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpmullq(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Shift left packed integers void psllw(XMMRegister dst, int shift); @@ -1828,12 +1947,12 @@ private: void psllw(XMMRegister dst, XMMRegister shift); void pslld(XMMRegister dst, XMMRegister shift); void psllq(XMMRegister dst, XMMRegister shift); - void vpsllw(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpslld(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsllq(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsllw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); - void vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); - void vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); + void vpsllw(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpslld(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsllq(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsllw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); + void vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); + void vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); // Logical shift right packed integers void psrlw(XMMRegister dst, int shift); @@ -1842,42 +1961,43 @@ private: void psrlw(XMMRegister dst, XMMRegister shift); void psrld(XMMRegister dst, XMMRegister shift); void psrlq(XMMRegister dst, XMMRegister shift); - void vpsrlw(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsrld(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsrlq(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsrlw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); - void vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); - void vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); + void vpsrlw(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsrld(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsrlq(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsrlw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); + void vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); + void vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); // Arithmetic shift right packed integers (only shorts and ints, no instructions for longs) void psraw(XMMRegister dst, int shift); void psrad(XMMRegister dst, int shift); void psraw(XMMRegister dst, XMMRegister shift); void psrad(XMMRegister dst, XMMRegister shift); - void vpsraw(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsrad(XMMRegister dst, XMMRegister src, int shift, bool vector256); - void vpsraw(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); - void vpsrad(XMMRegister dst, XMMRegister src, XMMRegister shift, bool vector256); + void vpsraw(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsrad(XMMRegister dst, XMMRegister src, int shift, int vector_len); + void vpsraw(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); + void vpsrad(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len); // And packed integers void pand(XMMRegister dst, XMMRegister src); - void vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpand(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Or packed integers void por(XMMRegister dst, XMMRegister src); - void vpor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpor(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpor(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Xor packed integers void pxor(XMMRegister dst, XMMRegister src); - void vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256); - void vpxor(XMMRegister dst, XMMRegister nds, Address src, bool vector256); + void vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpxor(XMMRegister dst, XMMRegister nds, Address src, int vector_len); // Copy low 128bit into high 128bit of YMM registers. void vinsertf128h(XMMRegister dst, XMMRegister nds, XMMRegister src); void vinserti128h(XMMRegister dst, XMMRegister nds, XMMRegister src); void vextractf128h(XMMRegister dst, XMMRegister src); + void vextracti128h(XMMRegister dst, XMMRegister src); // Load/store high 128bit of YMM registers which does not destroy other half. void vinsertf128h(XMMRegister dst, Address src); @@ -1885,9 +2005,25 @@ private: void vextractf128h(Address dst, XMMRegister src); void vextracti128h(Address dst, XMMRegister src); + // Copy low 256bit into high 256bit of ZMM registers. + void vinserti64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src); + void vinsertf64x4h(XMMRegister dst, XMMRegister nds, XMMRegister src); + void vextracti64x4h(XMMRegister dst, XMMRegister src); + void vextractf64x4h(XMMRegister dst, XMMRegister src); + void vextractf64x4h(Address dst, XMMRegister src); + void vinsertf64x4h(XMMRegister dst, Address src); + + // Copy targeted 128bit segments of the ZMM registers + void vextracti64x2h(XMMRegister dst, XMMRegister src, int value); + void vextractf64x2h(XMMRegister dst, XMMRegister src, int value); + void vextractf32x4h(XMMRegister dst, XMMRegister src, int value); + // duplicate 4-bytes integer data from src into 8 locations in dest void vpbroadcastd(XMMRegister dst, XMMRegister src); + // duplicate 4-bytes integer data from src into vector_len locations in dest + void evpbroadcastd(XMMRegister dst, XMMRegister src, int vector_len); + // Carry-Less Multiplication Quadword void pclmulqdq(XMMRegister dst, XMMRegister src, int mask); void vpclmulqdq(XMMRegister dst, XMMRegister nds, XMMRegister src, int mask); diff --git a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp index bec7eed65e9..13eefe509bb 100644 --- a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp @@ -233,13 +233,30 @@ void FrameMap::initialize() { _xmm_regs[13] = xmm13; _xmm_regs[14] = xmm14; _xmm_regs[15] = xmm15; + _xmm_regs[16] = xmm16; + _xmm_regs[17] = xmm17; + _xmm_regs[18] = xmm18; + _xmm_regs[19] = xmm19; + _xmm_regs[20] = xmm20; + _xmm_regs[21] = xmm21; + _xmm_regs[22] = xmm22; + _xmm_regs[23] = xmm23; + _xmm_regs[24] = xmm24; + _xmm_regs[25] = xmm25; + _xmm_regs[26] = xmm26; + _xmm_regs[27] = xmm27; + _xmm_regs[28] = xmm28; + _xmm_regs[29] = xmm29; + _xmm_regs[30] = xmm30; + _xmm_regs[31] = xmm31; #endif // _LP64 for (int i = 0; i < 8; i++) { _caller_save_fpu_regs[i] = LIR_OprFact::single_fpu(i); } - for (int i = 0; i < nof_caller_save_xmm_regs ; i++) { + int num_caller_save_xmm_regs = get_num_caller_save_xmms(); + for (int i = 0; i < num_caller_save_xmm_regs; i++) { _caller_save_xmm_regs[i] = LIR_OprFact::single_xmm(i); } diff --git a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp index ddd358cc5d9..0b3bafb2e15 100644 --- a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp +++ b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.hpp @@ -152,6 +152,16 @@ return range; } + static int get_num_caller_save_xmms(void) { + int num_caller_save_xmm_regs = nof_caller_save_xmm_regs; +#ifdef _LP64 + if (UseAVX < 3) { + num_caller_save_xmm_regs = num_caller_save_xmm_regs / 2; + } +#endif + return num_caller_save_xmm_regs; + } + static int nof_caller_save_cpu_regs() { return adjust_reg_range(pd_nof_caller_save_cpu_regs_frame_map); } static int last_cpu_reg() { return adjust_reg_range(pd_last_cpu_reg); } static int last_byte_reg() { return adjust_reg_range(pd_last_byte_reg); } diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp index efb2002fd65..3902d974bc0 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.hpp @@ -85,8 +85,9 @@ inline void LinearScan::pd_add_temps(LIR_Op* op) { tty->print_cr("killing XMMs for trig"); } #endif + int num_caller_save_xmm_regs = FrameMap::get_num_caller_save_xmms(); int op_id = op->id(); - for (int xmm = 0; xmm < FrameMap::nof_caller_save_xmm_regs; xmm++) { + for (int xmm = 0; xmm < num_caller_save_xmm_regs; xmm++) { LIR_Opr opr = FrameMap::caller_save_xmm_reg_at(xmm); add_temp(reg_num(opr), op_id, noUse, T_ILLEGAL); } @@ -100,6 +101,10 @@ inline void LinearScan::pd_add_temps(LIR_Op* op) { // Implementation of LinearScanWalker inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) { + int last_xmm_reg = pd_last_xmm_reg; + if (UseAVX < 3) { + last_xmm_reg = pd_first_xmm_reg + (pd_nof_xmm_regs_frame_map / 2) - 1; + } if (allocator()->gen()->is_vreg_flag_set(cur->reg_num(), LIRGenerator::byte_reg)) { assert(cur->type() != T_FLOAT && cur->type() != T_DOUBLE, "cpu regs only"); _first_reg = pd_first_byte_reg; @@ -107,7 +112,7 @@ inline bool LinearScanWalker::pd_init_regs_for_alloc(Interval* cur) { return true; } else if ((UseSSE >= 1 && cur->type() == T_FLOAT) || (UseSSE >= 2 && cur->type() == T_DOUBLE)) { _first_reg = pd_first_xmm_reg; - _last_reg = pd_last_xmm_reg; + _last_reg = last_xmm_reg; return true; } diff --git a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp index 152ad2e0189..6746704cabf 100644 --- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp @@ -323,7 +323,7 @@ static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args, LP64_ONLY(num_rt_args = 0); LP64_ONLY(assert((reg_save_frame_size * VMRegImpl::stack_slot_size) % 16 == 0, "must be 16 byte aligned");) int frame_size_in_slots = reg_save_frame_size + num_rt_args; // args + thread - sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word ); + sasm->set_frame_size(frame_size_in_slots / VMRegImpl::slots_per_word); // record saved value locations in an OopMap // locations are offsets from sp after runtime call; num_rt_args is number of arguments in call, including thread @@ -362,6 +362,13 @@ static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args, map->set_callee_saved(VMRegImpl::stack2reg(r15H_off + num_rt_args), r15->as_VMReg()->next()); #endif // _LP64 + int xmm_bypass_limit = FrameMap::nof_xmm_regs; +#ifdef _LP64 + if (UseAVX < 3) { + xmm_bypass_limit = xmm_bypass_limit / 2; + } +#endif + if (save_fpu_registers) { if (UseSSE < 2) { int fpu_off = float_regs_as_doubles_off; @@ -380,11 +387,13 @@ static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args, if (UseSSE >= 2) { int xmm_off = xmm_regs_as_doubles_off; for (int n = 0; n < FrameMap::nof_xmm_regs; n++) { - VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg(); - map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + num_rt_args), xmm_name_0); - // %%% This is really a waste but we'll keep things as they were for now - if (true) { - map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + 1 + num_rt_args), xmm_name_0->next()); + if (n < xmm_bypass_limit) { + VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg(); + map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + num_rt_args), xmm_name_0); + // %%% This is really a waste but we'll keep things as they were for now + if (true) { + map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + 1 + num_rt_args), xmm_name_0->next()); + } } xmm_off += 2; } @@ -393,8 +402,10 @@ static OopMap* generate_oop_map(StubAssembler* sasm, int num_rt_args, } else if (UseSSE == 1) { int xmm_off = xmm_regs_as_doubles_off; for (int n = 0; n < FrameMap::nof_xmm_regs; n++) { - VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg(); - map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + num_rt_args), xmm_name_0); + if (n < xmm_bypass_limit) { + VMReg xmm_name_0 = as_XMMRegister(n)->as_VMReg(); + map->set_callee_saved(VMRegImpl::stack2reg(xmm_off + num_rt_args), xmm_name_0); + } xmm_off += 2; } assert(xmm_off == float_regs_as_doubles_off, "incorrect number of xmm registers"); @@ -474,6 +485,24 @@ static OopMap* save_live_registers(StubAssembler* sasm, int num_rt_args, __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 104), xmm13); __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 112), xmm14); __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 120), xmm15); + if (UseAVX > 2) { + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 128), xmm16); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 136), xmm17); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 144), xmm18); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 152), xmm19); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 160), xmm20); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 168), xmm21); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 176), xmm22); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 184), xmm23); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 192), xmm24); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 200), xmm25); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 208), xmm26); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 216), xmm27); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 224), xmm28); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 232), xmm29); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 240), xmm30); + __ movdbl(Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 248), xmm31); + } #endif // _LP64 } else if (UseSSE == 1) { // save XMM registers as float because double not supported without SSE2 @@ -516,6 +545,24 @@ static void restore_fpu(StubAssembler* sasm, bool restore_fpu_registers = true) __ movdbl(xmm13, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 104)); __ movdbl(xmm14, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 112)); __ movdbl(xmm15, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 120)); + if (UseAVX > 2) { + __ movdbl(xmm16, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 128)); + __ movdbl(xmm17, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 136)); + __ movdbl(xmm18, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 144)); + __ movdbl(xmm19, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 152)); + __ movdbl(xmm20, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 160)); + __ movdbl(xmm21, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 168)); + __ movdbl(xmm22, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 176)); + __ movdbl(xmm23, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 184)); + __ movdbl(xmm24, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 192)); + __ movdbl(xmm25, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 200)); + __ movdbl(xmm26, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 208)); + __ movdbl(xmm27, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 216)); + __ movdbl(xmm28, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 224)); + __ movdbl(xmm29, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 232)); + __ movdbl(xmm30, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 240)); + __ movdbl(xmm31, Address(rsp, xmm_regs_as_doubles_off * VMRegImpl::stack_slot_size + 248)); + } #endif // _LP64 } else if (UseSSE == 1) { // restore XMM registers @@ -1631,36 +1678,22 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { NOT_LP64(__ get_thread(thread);) - Address in_progress(thread, in_bytes(JavaThread::satb_mark_queue_offset() + - PtrQueue::byte_offset_of_active())); - Address queue_index(thread, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_index())); Address buffer(thread, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_buf())); - Label done; Label runtime; // Can we store original value in the thread's buffer? -#ifdef _LP64 - __ movslq(tmp, queue_index); - __ cmpq(tmp, 0); -#else - __ cmpl(queue_index, 0); -#endif - __ jcc(Assembler::equal, runtime); -#ifdef _LP64 - __ subq(tmp, wordSize); - __ movl(queue_index, tmp); - __ addq(tmp, buffer); -#else - __ subl(queue_index, wordSize); - __ movl(tmp, buffer); - __ addl(tmp, queue_index); -#endif + __ movptr(tmp, queue_index); + __ testptr(tmp, tmp); + __ jcc(Assembler::zero, runtime); + __ subptr(tmp, wordSize); + __ movptr(queue_index, tmp); + __ addptr(tmp, buffer); // prev_val (rax) f.load_argument(0, pre_val); @@ -1713,6 +1746,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); Label done; + Label enqueued; Label runtime; // At this point we know new_value is non-NULL and the new_value crosses regions. @@ -1752,28 +1786,19 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ movb(Address(card_addr, 0), (int)CardTableModRefBS::dirty_card_val()); - __ cmpl(queue_index, 0); - __ jcc(Assembler::equal, runtime); - __ subl(queue_index, wordSize); + const Register tmp = rdx; + __ push(rdx); - const Register buffer_addr = rbx; - __ push(rbx); - - __ movptr(buffer_addr, buffer); - -#ifdef _LP64 - __ movslq(rscratch1, queue_index); - __ addptr(buffer_addr, rscratch1); -#else - __ addptr(buffer_addr, queue_index); -#endif - __ movptr(Address(buffer_addr, 0), card_addr); - - __ pop(rbx); - __ jmp(done); + __ movptr(tmp, queue_index); + __ testptr(tmp, tmp); + __ jcc(Assembler::zero, runtime); + __ subptr(tmp, wordSize); + __ movptr(queue_index, tmp); + __ addptr(tmp, buffer); + __ movptr(Address(tmp, 0), card_addr); + __ jmp(enqueued); __ bind(runtime); - __ push(rdx); #ifdef _LP64 __ push(r8); __ push(r9); @@ -1795,12 +1820,12 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { __ pop(r9); __ pop(r8); #endif + __ bind(enqueued); __ pop(rdx); - __ bind(done); + __ bind(done); __ pop(rcx); __ pop(rax); - } break; #endif // INCLUDE_ALL_GCS diff --git a/hotspot/src/cpu/x86/vm/c2_init_x86.cpp b/hotspot/src/cpu/x86/vm/c2_init_x86.cpp index 286fec21376..522af0038ae 100644 --- a/hotspot/src/cpu/x86/vm/c2_init_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c2_init_x86.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "opto/compile.hpp" #include "opto/node.hpp" +#include "opto/optoreg.hpp" // processor dependent initialization for i486 @@ -37,4 +38,24 @@ void Compile::pd_compiler2_init() { ConditionalMoveLimit = 0; } #endif // AMD64 + + if (UseAVX < 3) { + int delta = XMMRegisterImpl::max_slots_per_register * XMMRegisterImpl::number_of_registers; + int bottom = ConcreteRegisterImpl::max_fpr; + int top = bottom + delta; + int middle = bottom + (delta / 2); + int xmm_slots = XMMRegisterImpl::max_slots_per_register; + int lower = xmm_slots / 2; + // mark bad every register that we cannot get to if AVX less than 3, we have all slots in the array + // Note: vm2opto is allocated to ConcreteRegisterImpl::number_of_registers + for (int i = bottom; i < middle; i += xmm_slots) { + for (OptoReg::Name j = OptoReg::Name(i + lower); j= 2) { + if (UseAVX > 2) { + movl(rbx, 0xffff); +#ifdef _LP64 + kmovql(k1, rbx); +#else + kmovdl(k1, rbx); +#endif + } #ifdef COMPILER2 if (MaxVectorSize > 16) { assert(UseAVX > 0, "256bit vectors are supported only with AVX"); @@ -7063,8 +7071,39 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, { assert( UseSSE >= 2, "supported cpu only" ); Label L_fill_32_bytes_loop, L_check_fill_8_bytes, L_fill_8_bytes_loop, L_fill_8_bytes; + if (UseAVX > 2) { + movl(rtmp, 0xffff); +#ifdef _LP64 + kmovql(k1, rtmp); +#else + kmovdl(k1, rtmp); +#endif + } movdl(xtmp, value); - if (UseAVX >= 2 && UseUnalignedLoadStores) { + if (UseAVX > 2 && UseUnalignedLoadStores) { + // Fill 64-byte chunks + Label L_fill_64_bytes_loop, L_check_fill_32_bytes; + evpbroadcastd(xtmp, xtmp, Assembler::AVX_512bit); + + subl(count, 16 << shift); + jcc(Assembler::less, L_check_fill_32_bytes); + align(16); + + BIND(L_fill_64_bytes_loop); + evmovdqu(Address(to, 0), xtmp, Assembler::AVX_512bit); + addptr(to, 64); + subl(count, 16 << shift); + jcc(Assembler::greaterEqual, L_fill_64_bytes_loop); + + BIND(L_check_fill_32_bytes); + addl(count, 8 << shift); + jccb(Assembler::less, L_check_fill_8_bytes); + evmovdqu(Address(to, 0), xtmp, Assembler::AVX_256bit); + addptr(to, 32); + subl(count, 8 << shift); + + BIND(L_check_fill_8_bytes); + } else if (UseAVX == 2 && UseUnalignedLoadStores) { // Fill 64-byte chunks Label L_fill_64_bytes_loop, L_check_fill_32_bytes; vpbroadcastd(xtmp, xtmp); @@ -7200,11 +7239,11 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, bind(L_copy_32_chars); vmovdqu(tmp3Reg, Address(src, len, Address::times_2, -64)); vmovdqu(tmp4Reg, Address(src, len, Address::times_2, -32)); - vpor(tmp2Reg, tmp3Reg, tmp4Reg, /* vector256 */ true); + vpor(tmp2Reg, tmp3Reg, tmp4Reg, /* vector_len */ 1); vptest(tmp2Reg, tmp1Reg); // check for Unicode chars in vector jccb(Assembler::notZero, L_copy_32_chars_exit); - vpackuswb(tmp3Reg, tmp3Reg, tmp4Reg, /* vector256 */ true); - vpermq(tmp4Reg, tmp3Reg, 0xD8, /* vector256 */ true); + vpackuswb(tmp3Reg, tmp3Reg, tmp4Reg, /* vector_len */ 1); + vpermq(tmp4Reg, tmp3Reg, 0xD8, /* vector_len */ 1); vmovdqu(Address(dst, len, Address::times_1, -32), tmp4Reg); bind(L_chars_32_check); @@ -7227,13 +7266,13 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, vmovdqu(tmp2Reg, Address(src, len, Address::times_2, -32)); vptest(tmp2Reg, tmp1Reg); jccb(Assembler::notZero, L_copy_16_chars_exit); - vpackuswb(tmp2Reg, tmp2Reg, tmp1Reg, /* vector256 */ true); - vpermq(tmp3Reg, tmp2Reg, 0xD8, /* vector256 */ true); + vpackuswb(tmp2Reg, tmp2Reg, tmp1Reg, /* vector_len */ 1); + vpermq(tmp3Reg, tmp2Reg, 0xD8, /* vector_len */ 1); } else { if (UseAVX > 0) { movdqu(tmp3Reg, Address(src, len, Address::times_2, -32)); movdqu(tmp4Reg, Address(src, len, Address::times_2, -16)); - vpor(tmp2Reg, tmp3Reg, tmp4Reg, /* vector256 */ false); + vpor(tmp2Reg, tmp3Reg, tmp4Reg, /* vector_len */ 0); } else { movdqu(tmp3Reg, Address(src, len, Address::times_2, -32)); por(tmp2Reg, tmp3Reg); @@ -7776,7 +7815,7 @@ void MacroAssembler::fold_128bit_crc32(XMMRegister xcrc, XMMRegister xK, XMMRegi if (UseAVX > 0) { vpclmulhdq(xtmp, xK, xcrc); // [123:64] vpclmulldq(xcrc, xK, xcrc); // [63:0] - vpxor(xcrc, xcrc, Address(buf, offset), false /* vector256 */); + vpxor(xcrc, xcrc, Address(buf, offset), 0 /* vector_len */); pxor(xcrc, xtmp); } else { movdqa(xtmp, xcrc); @@ -7920,7 +7959,7 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Regi movdqu(xmm0, ExternalAddress(StubRoutines::x86::crc_by128_masks_addr())); if (UseAVX > 0) { vpclmulqdq(xmm2, xmm0, xmm1, 0x1); - vpand(xmm3, xmm0, xmm2, false /* vector256 */); + vpand(xmm3, xmm0, xmm2, 0 /* vector_len */); vpclmulqdq(xmm0, xmm0, xmm3, 0x1); } else { movdqa(xmm2, xmm0); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 69c9e8aa360..ad75e27ddd9 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -1024,13 +1024,13 @@ public: void vaddss(XMMRegister dst, XMMRegister nds, Address src) { Assembler::vaddss(dst, nds, src); } void vaddss(XMMRegister dst, XMMRegister nds, AddressLiteral src); - void vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { Assembler::vandpd(dst, nds, src, vector256); } - void vandpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { Assembler::vandpd(dst, nds, src, vector256); } - void vandpd(XMMRegister dst, XMMRegister nds, AddressLiteral src, bool vector256); + void vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vandpd(dst, nds, src, vector_len); } + void vandpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vandpd(dst, nds, src, vector_len); } + void vandpd(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len); - void vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { Assembler::vandps(dst, nds, src, vector256); } - void vandps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { Assembler::vandps(dst, nds, src, vector256); } - void vandps(XMMRegister dst, XMMRegister nds, AddressLiteral src, bool vector256); + void vandps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vandps(dst, nds, src, vector_len); } + void vandps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vandps(dst, nds, src, vector_len); } + void vandps(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len); void vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { Assembler::vdivsd(dst, nds, src); } void vdivsd(XMMRegister dst, XMMRegister nds, Address src) { Assembler::vdivsd(dst, nds, src); } @@ -1058,25 +1058,25 @@ public: // AVX Vector instructions - void vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { Assembler::vxorpd(dst, nds, src, vector256); } - void vxorpd(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { Assembler::vxorpd(dst, nds, src, vector256); } - void vxorpd(XMMRegister dst, XMMRegister nds, AddressLiteral src, bool vector256); + void vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vxorpd(dst, nds, src, vector_len); } + void vxorpd(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vxorpd(dst, nds, src, vector_len); } + void vxorpd(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len); - void vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { Assembler::vxorps(dst, nds, src, vector256); } - void vxorps(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { Assembler::vxorps(dst, nds, src, vector256); } - void vxorps(XMMRegister dst, XMMRegister nds, AddressLiteral src, bool vector256); + void vxorps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vxorps(dst, nds, src, vector_len); } + void vxorps(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vxorps(dst, nds, src, vector_len); } + void vxorps(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len); - void vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, bool vector256) { - if (UseAVX > 1 || !vector256) // vpxor 256 bit is available only in AVX2 - Assembler::vpxor(dst, nds, src, vector256); + void vpxor(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + if (UseAVX > 1 || (vector_len < 1)) // vpxor 256 bit is available only in AVX2 + Assembler::vpxor(dst, nds, src, vector_len); else - Assembler::vxorpd(dst, nds, src, vector256); + Assembler::vxorpd(dst, nds, src, vector_len); } - void vpxor(XMMRegister dst, XMMRegister nds, Address src, bool vector256) { - if (UseAVX > 1 || !vector256) // vpxor 256 bit is available only in AVX2 - Assembler::vpxor(dst, nds, src, vector256); + void vpxor(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + if (UseAVX > 1 || (vector_len < 1)) // vpxor 256 bit is available only in AVX2 + Assembler::vpxor(dst, nds, src, vector_len); else - Assembler::vxorpd(dst, nds, src, vector256); + Assembler::vxorpd(dst, nds, src, vector_len); } // Simple version for AVX2 256bit vectors diff --git a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp index 8ed435dc3eb..6c0ca8e9b48 100644 --- a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp +++ b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp @@ -68,6 +68,22 @@ REGISTER_DEFINITION(XMMRegister, xmm12); REGISTER_DEFINITION(XMMRegister, xmm13); REGISTER_DEFINITION(XMMRegister, xmm14); REGISTER_DEFINITION(XMMRegister, xmm15); +REGISTER_DEFINITION(XMMRegister, xmm16); +REGISTER_DEFINITION(XMMRegister, xmm17); +REGISTER_DEFINITION(XMMRegister, xmm18); +REGISTER_DEFINITION(XMMRegister, xmm19); +REGISTER_DEFINITION(XMMRegister, xmm20); +REGISTER_DEFINITION(XMMRegister, xmm21); +REGISTER_DEFINITION(XMMRegister, xmm22); +REGISTER_DEFINITION(XMMRegister, xmm23); +REGISTER_DEFINITION(XMMRegister, xmm24); +REGISTER_DEFINITION(XMMRegister, xmm25); +REGISTER_DEFINITION(XMMRegister, xmm26); +REGISTER_DEFINITION(XMMRegister, xmm27); +REGISTER_DEFINITION(XMMRegister, xmm28); +REGISTER_DEFINITION(XMMRegister, xmm29); +REGISTER_DEFINITION(XMMRegister, xmm30); +REGISTER_DEFINITION(XMMRegister, xmm31); REGISTER_DEFINITION(Register, c_rarg0); REGISTER_DEFINITION(Register, c_rarg1); @@ -123,5 +139,15 @@ REGISTER_DEFINITION(MMXRegister, mmx5 ); REGISTER_DEFINITION(MMXRegister, mmx6 ); REGISTER_DEFINITION(MMXRegister, mmx7 ); +REGISTER_DEFINITION(KRegister, knoreg); +REGISTER_DEFINITION(KRegister, k0); +REGISTER_DEFINITION(KRegister, k1); +REGISTER_DEFINITION(KRegister, k2); +REGISTER_DEFINITION(KRegister, k3); +REGISTER_DEFINITION(KRegister, k4); +REGISTER_DEFINITION(KRegister, k5); +REGISTER_DEFINITION(KRegister, k6); +REGISTER_DEFINITION(KRegister, k7); + // JSR 292 REGISTER_DEFINITION(Register, rbp_mh_SP_save); diff --git a/hotspot/src/cpu/x86/vm/register_x86.cpp b/hotspot/src/cpu/x86/vm/register_x86.cpp index a3763a3498f..00cba4c9461 100644 --- a/hotspot/src/cpu/x86/vm/register_x86.cpp +++ b/hotspot/src/cpu/x86/vm/register_x86.cpp @@ -31,11 +31,13 @@ const int ConcreteRegisterImpl::max_gpr = RegisterImpl::number_of_registers; const int ConcreteRegisterImpl::max_gpr = RegisterImpl::number_of_registers << 1; #endif // AMD64 - const int ConcreteRegisterImpl::max_fpr = ConcreteRegisterImpl::max_gpr + - 2 * FloatRegisterImpl::number_of_registers; + 2 * FloatRegisterImpl::number_of_registers; const int ConcreteRegisterImpl::max_xmm = ConcreteRegisterImpl::max_fpr + - 8 * XMMRegisterImpl::number_of_registers; + XMMRegisterImpl::max_slots_per_register * XMMRegisterImpl::number_of_registers; +const int ConcreteRegisterImpl::max_kpr = ConcreteRegisterImpl::max_xmm + + KRegisterImpl::max_slots_per_register * KRegisterImpl::number_of_registers; + const char* RegisterImpl::name() const { const char* names[number_of_registers] = { #ifndef AMD64 @@ -59,8 +61,17 @@ const char* XMMRegisterImpl::name() const { const char* names[number_of_registers] = { "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7" #ifdef AMD64 - ,"xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" + ,"xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" + ,"xmm16", "xmm17", "xmm18", "xmm19", "xmm20", "xmm21", "xmm22", "xmm23" + ,"xmm24", "xmm25", "xmm26", "xmm27", "xmm28", "xmm29", "xmm30", "xmm31" #endif // AMD64 }; return is_valid() ? names[encoding()] : "xnoreg"; } + +const char* KRegisterImpl::name() const { + const char* names[number_of_registers] = { + "k0", "k1", "k2", "k3", "k4", "k5", "k6", "k7" + }; + return is_valid() ? names[encoding()] : "knoreg"; +} diff --git a/hotspot/src/cpu/x86/vm/register_x86.hpp b/hotspot/src/cpu/x86/vm/register_x86.hpp index b5e6989d5d9..ccce3850261 100644 --- a/hotspot/src/cpu/x86/vm/register_x86.hpp +++ b/hotspot/src/cpu/x86/vm/register_x86.hpp @@ -45,10 +45,12 @@ class RegisterImpl: public AbstractRegisterImpl { enum { #ifndef AMD64 number_of_registers = 8, - number_of_byte_registers = 4 + number_of_byte_registers = 4, + max_slots_per_register = 1 #else number_of_registers = 16, - number_of_byte_registers = 16 + number_of_byte_registers = 16, + max_slots_per_register = 1 #endif // AMD64 }; @@ -143,9 +145,11 @@ class XMMRegisterImpl: public AbstractRegisterImpl { public: enum { #ifndef AMD64 - number_of_registers = 8 + number_of_registers = 8, + max_slots_per_register = 16 // 512-bit #else - number_of_registers = 16 + number_of_registers = 32, + max_slots_per_register = 16 // 512-bit #endif // AMD64 }; @@ -183,6 +187,22 @@ CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm12, (12)); CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm13, (13)); CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm14, (14)); CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm15, (15)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm16, (16)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm17, (17)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm18, (18)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm19, (19)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm20, (20)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm21, (21)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm22, (22)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm23, (23)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm24, (24)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm25, (25)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm26, (26)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm27, (27)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm28, (28)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm29, (29)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm30, (30)); +CONSTANT_REGISTER_DECLARATION(XMMRegister, xmm31, (31)); #endif // AMD64 // Only used by the 32bit stubGenerator. These can't be described by vmreg and hence @@ -200,6 +220,46 @@ CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx5 , ( 5)); CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx6 , ( 6)); CONSTANT_REGISTER_DECLARATION(MMXRegister, mmx7 , ( 7)); +// Use XMMRegister as shortcut +class KRegisterImpl; +typedef KRegisterImpl* KRegister; + +inline KRegister as_KRegister(int encoding) { + return (KRegister)(intptr_t)encoding; +} + +// The implementation of XMM registers for the IA32 architecture +class KRegisterImpl : public AbstractRegisterImpl { +public: + enum { + number_of_registers = 8, + max_slots_per_register = 1 + }; + + // construction + friend KRegister as_KRegister(int encoding); + + inline VMReg as_VMReg(); + + // derived registers, offsets, and addresses + KRegister successor() const { return as_KRegister(encoding() + 1); } + + // accessors + int encoding() const { assert(is_valid(), err_msg("invalid register (%d)", (int)(intptr_t)this)); return (intptr_t)this; } + bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; } + const char* name() const; +}; + +// The Mask registers, for AVX3 enabled and up chips +CONSTANT_REGISTER_DECLARATION(KRegister, knoreg, (-1)); +CONSTANT_REGISTER_DECLARATION(KRegister, k0, (0)); +CONSTANT_REGISTER_DECLARATION(KRegister, k1, (1)); +CONSTANT_REGISTER_DECLARATION(KRegister, k2, (2)); +CONSTANT_REGISTER_DECLARATION(KRegister, k3, (3)); +CONSTANT_REGISTER_DECLARATION(KRegister, k4, (4)); +CONSTANT_REGISTER_DECLARATION(KRegister, k5, (5)); +CONSTANT_REGISTER_DECLARATION(KRegister, k6, (6)); +CONSTANT_REGISTER_DECLARATION(KRegister, k7, (7)); // Need to know the total number of registers of all sorts for SharedInfo. // Define a class that exports it. @@ -211,18 +271,20 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl { // There is no requirement that any ordering here matches any ordering c2 gives // it's optoregs. - number_of_registers = RegisterImpl::number_of_registers + + number_of_registers = RegisterImpl::number_of_registers + #ifdef AMD64 - RegisterImpl::number_of_registers + // "H" half of a 64bit register + RegisterImpl::number_of_registers + // "H" half of a 64bit register #endif // AMD64 - 2 * FloatRegisterImpl::number_of_registers + - 8 * XMMRegisterImpl::number_of_registers + - 1 // eflags + 2 * FloatRegisterImpl::number_of_registers + + XMMRegisterImpl::max_slots_per_register * XMMRegisterImpl::number_of_registers + + KRegisterImpl::number_of_registers + // mask registers + 1 // eflags }; static const int max_gpr; static const int max_fpr; static const int max_xmm; + static const int max_kpr; }; diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index a0c39dd4dca..baafe57d97d 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -117,9 +117,9 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ int vect_words = 0; #ifdef COMPILER2 if (save_vectors) { - assert(UseAVX > 0, "256bit vectors are supported only with AVX"); - assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); - // Save upper half of YMM registes + assert(UseAVX > 0, "512bit vectors are supported only with EVEX"); + assert(MaxVectorSize == 64, "only 512bit vectors are supported now"); + // Save upper half of ZMM/YMM registers : vect_words = 8 * 16 / wordSize; additional_frame_words += vect_words; } @@ -216,6 +216,17 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ __ vextractf128h(Address(rsp, 80),xmm5); __ vextractf128h(Address(rsp, 96),xmm6); __ vextractf128h(Address(rsp,112),xmm7); + if (UseAVX > 2) { + __ subptr(rsp, 256); // Save upper half of ZMM registes + __ vextractf64x4h(Address(rsp, 0), xmm0); + __ vextractf64x4h(Address(rsp, 32), xmm1); + __ vextractf64x4h(Address(rsp, 64), xmm2); + __ vextractf64x4h(Address(rsp, 96), xmm3); + __ vextractf64x4h(Address(rsp, 128), xmm4); + __ vextractf64x4h(Address(rsp, 160), xmm5); + __ vextractf64x4h(Address(rsp, 192), xmm6); + __ vextractf64x4h(Address(rsp, 224), xmm7); + } } // Set an oopmap for the call site. This oopmap will map all @@ -283,8 +294,8 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_ve int additional_frame_bytes = 0; #ifdef COMPILER2 if (restore_vectors) { - assert(UseAVX > 0, "256bit vectors are supported only with AVX"); - assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); + assert(UseAVX > 0, "512bit vectors are supported only with EVEX"); + assert(MaxVectorSize == 64, "only 512bit vectors are supported now"); additional_frame_bytes = 128; } #else @@ -324,6 +335,18 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_ve __ vinsertf128h(xmm6, Address(rsp, 96)); __ vinsertf128h(xmm7, Address(rsp,112)); __ addptr(rsp, additional_frame_bytes); + if (UseAVX > 2) { + additional_frame_bytes = 256; + __ vinsertf64x4h(xmm0, Address(rsp, 0)); + __ vinsertf64x4h(xmm1, Address(rsp, 32)); + __ vinsertf64x4h(xmm2, Address(rsp, 64)); + __ vinsertf64x4h(xmm3, Address(rsp, 96)); + __ vinsertf64x4h(xmm4, Address(rsp, 128)); + __ vinsertf64x4h(xmm5, Address(rsp, 160)); + __ vinsertf64x4h(xmm6, Address(rsp, 192)); + __ vinsertf64x4h(xmm7, Address(rsp, 224)); + __ addptr(rsp, additional_frame_bytes); + } } __ pop_FPU_state(); __ addptr(rsp, FPU_regs_live*wordSize); // Pop FPU registers diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 0d27447c49e..a5e78ba19d8 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -86,7 +86,23 @@ class RegisterSaver { DEF_XMM_OFFS(13), DEF_XMM_OFFS(14), DEF_XMM_OFFS(15), - fpu_state_end = fpu_state_off + ((FPUStateSizeInWords-1)*wordSize / BytesPerInt), + DEF_XMM_OFFS(16), + DEF_XMM_OFFS(17), + DEF_XMM_OFFS(18), + DEF_XMM_OFFS(19), + DEF_XMM_OFFS(20), + DEF_XMM_OFFS(21), + DEF_XMM_OFFS(22), + DEF_XMM_OFFS(23), + DEF_XMM_OFFS(24), + DEF_XMM_OFFS(25), + DEF_XMM_OFFS(26), + DEF_XMM_OFFS(27), + DEF_XMM_OFFS(28), + DEF_XMM_OFFS(29), + DEF_XMM_OFFS(30), + DEF_XMM_OFFS(31), + fpu_state_end = fpu_state_off + ((FPUStateSizeInWords - 1)*wordSize / BytesPerInt), fpu_stateH_end, r15_off, r15H_off, r14_off, r14H_off, @@ -136,13 +152,21 @@ class RegisterSaver { OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_vectors) { int vect_words = 0; + int num_xmm_regs = 16; + if (UseAVX > 2) { + num_xmm_regs = 32; + } #ifdef COMPILER2 if (save_vectors) { - assert(UseAVX > 0, "256bit vectors are supported only with AVX"); - assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); - // Save upper half of YMM registes - vect_words = 16 * 16 / wordSize; + assert(UseAVX > 0, "512bit vectors are supported only with EVEX"); + assert(MaxVectorSize == 64, "only 512bit vectors are supported now"); + // Save upper half of YMM registers + vect_words = 16 * num_xmm_regs / wordSize; additional_frame_words += vect_words; + if (UseAVX > 2) { + // Save upper half of ZMM registers as well + additional_frame_words += vect_words; + } } #else assert(!save_vectors, "vectors are generated only by C2"); @@ -150,7 +174,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ // Always make the frame size 16-byte aligned int frame_size_in_bytes = round_to(additional_frame_words*wordSize + - reg_save_size*BytesPerInt, 16); + reg_save_size*BytesPerInt, num_xmm_regs); // OopMap frame size is in compiler stack slots (jint's) not bytes or words int frame_size_in_slots = frame_size_in_bytes / BytesPerInt; // The caller will allocate additional_frame_words @@ -169,24 +193,77 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ __ push_CPU_state(); // Push a multiple of 16 bytes if (vect_words > 0) { - assert(vect_words*wordSize == 256, ""); - __ subptr(rsp, 256); // Save upper half of YMM registes - __ vextractf128h(Address(rsp, 0),xmm0); - __ vextractf128h(Address(rsp, 16),xmm1); - __ vextractf128h(Address(rsp, 32),xmm2); - __ vextractf128h(Address(rsp, 48),xmm3); - __ vextractf128h(Address(rsp, 64),xmm4); - __ vextractf128h(Address(rsp, 80),xmm5); - __ vextractf128h(Address(rsp, 96),xmm6); - __ vextractf128h(Address(rsp,112),xmm7); - __ vextractf128h(Address(rsp,128),xmm8); - __ vextractf128h(Address(rsp,144),xmm9); - __ vextractf128h(Address(rsp,160),xmm10); - __ vextractf128h(Address(rsp,176),xmm11); - __ vextractf128h(Address(rsp,192),xmm12); - __ vextractf128h(Address(rsp,208),xmm13); - __ vextractf128h(Address(rsp,224),xmm14); - __ vextractf128h(Address(rsp,240),xmm15); + assert(vect_words*wordSize >= 256, ""); + __ subptr(rsp, 256); // Save upper half of YMM registes(0..15) + __ vextractf128h(Address(rsp, 0), xmm0); + __ vextractf128h(Address(rsp, 16), xmm1); + __ vextractf128h(Address(rsp, 32), xmm2); + __ vextractf128h(Address(rsp, 48), xmm3); + __ vextractf128h(Address(rsp, 64), xmm4); + __ vextractf128h(Address(rsp, 80), xmm5); + __ vextractf128h(Address(rsp, 96), xmm6); + __ vextractf128h(Address(rsp, 112), xmm7); + __ vextractf128h(Address(rsp, 128), xmm8); + __ vextractf128h(Address(rsp, 144), xmm9); + __ vextractf128h(Address(rsp, 160), xmm10); + __ vextractf128h(Address(rsp, 176), xmm11); + __ vextractf128h(Address(rsp, 192), xmm12); + __ vextractf128h(Address(rsp, 208), xmm13); + __ vextractf128h(Address(rsp, 224), xmm14); + __ vextractf128h(Address(rsp, 240), xmm15); + if (UseAVX > 2) { + __ subptr(rsp, 256); // Save upper half of YMM registes(16..31) + __ vextractf128h(Address(rsp, 0), xmm16); + __ vextractf128h(Address(rsp, 16), xmm17); + __ vextractf128h(Address(rsp, 32), xmm18); + __ vextractf128h(Address(rsp, 48), xmm19); + __ vextractf128h(Address(rsp, 64), xmm20); + __ vextractf128h(Address(rsp, 80), xmm21); + __ vextractf128h(Address(rsp, 96), xmm22); + __ vextractf128h(Address(rsp, 112), xmm23); + __ vextractf128h(Address(rsp, 128), xmm24); + __ vextractf128h(Address(rsp, 144), xmm25); + __ vextractf128h(Address(rsp, 160), xmm26); + __ vextractf128h(Address(rsp, 176), xmm27); + __ vextractf128h(Address(rsp, 192), xmm28); + __ vextractf128h(Address(rsp, 208), xmm29); + __ vextractf128h(Address(rsp, 224), xmm30); + __ vextractf128h(Address(rsp, 240), xmm31); + // Now handle the ZMM registers (0..31) + __ subptr(rsp, 1024); // Save upper half of ZMM registes + __ vextractf64x4h(Address(rsp, 0), xmm0); + __ vextractf64x4h(Address(rsp, 32), xmm1); + __ vextractf64x4h(Address(rsp, 64), xmm2); + __ vextractf64x4h(Address(rsp, 96), xmm3); + __ vextractf64x4h(Address(rsp, 128), xmm4); + __ vextractf64x4h(Address(rsp, 160), xmm5); + __ vextractf64x4h(Address(rsp, 192), xmm6); + __ vextractf64x4h(Address(rsp, 224), xmm7); + __ vextractf64x4h(Address(rsp, 256), xmm8); + __ vextractf64x4h(Address(rsp, 288), xmm9); + __ vextractf64x4h(Address(rsp, 320), xmm10); + __ vextractf64x4h(Address(rsp, 352), xmm11); + __ vextractf64x4h(Address(rsp, 384), xmm12); + __ vextractf64x4h(Address(rsp, 416), xmm13); + __ vextractf64x4h(Address(rsp, 448), xmm14); + __ vextractf64x4h(Address(rsp, 480), xmm15); + __ vextractf64x4h(Address(rsp, 512), xmm16); + __ vextractf64x4h(Address(rsp, 544), xmm17); + __ vextractf64x4h(Address(rsp, 576), xmm18); + __ vextractf64x4h(Address(rsp, 608), xmm19); + __ vextractf64x4h(Address(rsp, 640), xmm20); + __ vextractf64x4h(Address(rsp, 672), xmm21); + __ vextractf64x4h(Address(rsp, 704), xmm22); + __ vextractf64x4h(Address(rsp, 736), xmm23); + __ vextractf64x4h(Address(rsp, 768), xmm24); + __ vextractf64x4h(Address(rsp, 800), xmm25); + __ vextractf64x4h(Address(rsp, 832), xmm26); + __ vextractf64x4h(Address(rsp, 864), xmm27); + __ vextractf64x4h(Address(rsp, 896), xmm28); + __ vextractf64x4h(Address(rsp, 928), xmm29); + __ vextractf64x4h(Address(rsp, 960), xmm30); + __ vextractf64x4h(Address(rsp, 992), xmm31); + } } if (frame::arg_reg_save_area_bytes != 0) { // Allocate argument register save area @@ -235,6 +312,24 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ map->set_callee_saved(STACK_OFFSET(xmm13_off), xmm13->as_VMReg()); map->set_callee_saved(STACK_OFFSET(xmm14_off), xmm14->as_VMReg()); map->set_callee_saved(STACK_OFFSET(xmm15_off), xmm15->as_VMReg()); + if (UseAVX > 2) { + map->set_callee_saved(STACK_OFFSET(xmm16_off), xmm16->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm17_off), xmm17->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm18_off), xmm18->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm19_off), xmm19->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm20_off), xmm20->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm21_off), xmm21->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm22_off), xmm22->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm23_off), xmm23->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm24_off), xmm24->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm25_off), xmm25->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm26_off), xmm26->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm27_off), xmm27->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm28_off), xmm28->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm29_off), xmm29->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm30_off), xmm30->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm31_off), xmm31->as_VMReg()); + } // %%% These should all be a waste but we'll keep things as they were for now if (true) { @@ -269,6 +364,24 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ map->set_callee_saved(STACK_OFFSET(xmm13H_off), xmm13->as_VMReg()->next()); map->set_callee_saved(STACK_OFFSET(xmm14H_off), xmm14->as_VMReg()->next()); map->set_callee_saved(STACK_OFFSET(xmm15H_off), xmm15->as_VMReg()->next()); + if (UseAVX > 2) { + map->set_callee_saved(STACK_OFFSET(xmm16H_off), xmm16->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm17H_off), xmm17->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm18H_off), xmm18->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm19H_off), xmm19->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm20H_off), xmm20->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm21H_off), xmm21->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm22H_off), xmm22->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm23H_off), xmm23->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm24H_off), xmm24->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm25H_off), xmm25->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm26H_off), xmm26->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm27H_off), xmm27->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm28H_off), xmm28->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm29H_off), xmm29->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm30H_off), xmm30->as_VMReg()); + map->set_callee_saved(STACK_OFFSET(xmm31H_off), xmm31->as_VMReg()); + } } return map; @@ -281,9 +394,9 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_ve } #ifdef COMPILER2 if (restore_vectors) { - // Restore upper half of YMM registes. - assert(UseAVX > 0, "256bit vectors are supported only with AVX"); - assert(MaxVectorSize == 32, "only 256bit vectors are supported now"); + // Restore upper half of YMM registes (0..15) + assert(UseAVX > 0, "512bit vectors are supported only with AVX"); + assert(MaxVectorSize == 64, "only 512bit vectors are supported now"); __ vinsertf128h(xmm0, Address(rsp, 0)); __ vinsertf128h(xmm1, Address(rsp, 16)); __ vinsertf128h(xmm2, Address(rsp, 32)); @@ -301,6 +414,60 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_ve __ vinsertf128h(xmm14, Address(rsp,224)); __ vinsertf128h(xmm15, Address(rsp,240)); __ addptr(rsp, 256); + if (UseAVX > 2) { + // Restore upper half of YMM registes (16..31) + __ vinsertf128h(xmm16, Address(rsp, 0)); + __ vinsertf128h(xmm17, Address(rsp, 16)); + __ vinsertf128h(xmm18, Address(rsp, 32)); + __ vinsertf128h(xmm19, Address(rsp, 48)); + __ vinsertf128h(xmm20, Address(rsp, 64)); + __ vinsertf128h(xmm21, Address(rsp, 80)); + __ vinsertf128h(xmm22, Address(rsp, 96)); + __ vinsertf128h(xmm23, Address(rsp,112)); + __ vinsertf128h(xmm24, Address(rsp,128)); + __ vinsertf128h(xmm25, Address(rsp,144)); + __ vinsertf128h(xmm26, Address(rsp,160)); + __ vinsertf128h(xmm27, Address(rsp,176)); + __ vinsertf128h(xmm28, Address(rsp,192)); + __ vinsertf128h(xmm29, Address(rsp,208)); + __ vinsertf128h(xmm30, Address(rsp,224)); + __ vinsertf128h(xmm31, Address(rsp,240)); + __ addptr(rsp, 256); + // Restore upper half of ZMM registes. + __ vinsertf64x4h(xmm0, Address(rsp, 0)); + __ vinsertf64x4h(xmm1, Address(rsp, 32)); + __ vinsertf64x4h(xmm2, Address(rsp, 64)); + __ vinsertf64x4h(xmm3, Address(rsp, 96)); + __ vinsertf64x4h(xmm4, Address(rsp, 128)); + __ vinsertf64x4h(xmm5, Address(rsp, 160)); + __ vinsertf64x4h(xmm6, Address(rsp, 192)); + __ vinsertf64x4h(xmm7, Address(rsp, 224)); + __ vinsertf64x4h(xmm8, Address(rsp, 256)); + __ vinsertf64x4h(xmm9, Address(rsp, 288)); + __ vinsertf64x4h(xmm10, Address(rsp, 320)); + __ vinsertf64x4h(xmm11, Address(rsp, 352)); + __ vinsertf64x4h(xmm12, Address(rsp, 384)); + __ vinsertf64x4h(xmm13, Address(rsp, 416)); + __ vinsertf64x4h(xmm14, Address(rsp, 448)); + __ vinsertf64x4h(xmm15, Address(rsp, 480)); + __ vinsertf64x4h(xmm16, Address(rsp, 512)); + __ vinsertf64x4h(xmm17, Address(rsp, 544)); + __ vinsertf64x4h(xmm18, Address(rsp, 576)); + __ vinsertf64x4h(xmm19, Address(rsp, 608)); + __ vinsertf64x4h(xmm20, Address(rsp, 640)); + __ vinsertf64x4h(xmm21, Address(rsp, 672)); + __ vinsertf64x4h(xmm22, Address(rsp, 704)); + __ vinsertf64x4h(xmm23, Address(rsp, 736)); + __ vinsertf64x4h(xmm24, Address(rsp, 768)); + __ vinsertf64x4h(xmm25, Address(rsp, 800)); + __ vinsertf64x4h(xmm26, Address(rsp, 832)); + __ vinsertf64x4h(xmm27, Address(rsp, 864)); + __ vinsertf64x4h(xmm28, Address(rsp, 896)); + __ vinsertf64x4h(xmm29, Address(rsp, 928)); + __ vinsertf64x4h(xmm30, Address(rsp, 960)); + __ vinsertf64x4h(xmm31, Address(rsp, 992)); + __ subptr(rsp, 1024); + } } #else assert(!restore_vectors, "vectors are generated only by C2"); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index 9cbffb37176..92ff5ca7af2 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -166,6 +166,13 @@ class StubGenerator: public StubCodeGenerator { __ movptr(saved_rdi, rdi); __ movptr(saved_rsi, rsi); __ movptr(saved_rbx, rbx); + + // provide initial value for required masks + if (UseAVX > 2) { + __ movl(rbx, 0xffff); + __ kmovdl(k1, rbx); + } + // save and initialize %mxcsr if (sse_save) { Label skip_ldmx; @@ -794,7 +801,10 @@ class StubGenerator: public StubCodeGenerator { __ BIND(L_copy_64_bytes_loop); if (UseUnalignedLoadStores) { - if (UseAVX >= 2) { + if (UseAVX > 2) { + __ evmovdqu(xmm0, Address(from, 0), Assembler::AVX_512bit); + __ evmovdqu(Address(from, to_from, Address::times_1, 0), xmm0, Assembler::AVX_512bit); + } else if (UseAVX == 2) { __ vmovdqu(xmm0, Address(from, 0)); __ vmovdqu(Address(from, to_from, Address::times_1, 0), xmm0); __ vmovdqu(xmm1, Address(from, 32)); @@ -833,7 +843,7 @@ class StubGenerator: public StubCodeGenerator { __ subl(qword_count, 8); __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); - if (UseUnalignedLoadStores && (UseAVX >= 2)) { + if (UseUnalignedLoadStores && (UseAVX == 2)) { // clean upper bits of YMM registers __ vpxor(xmm0, xmm0); __ vpxor(xmm1, xmm1); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 5ac6727dce0..e52da3ec6b6 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -137,8 +137,10 @@ class StubGenerator: public StubCodeGenerator { // [ return_from_Java ] <--- rsp // [ argument word n ] // ... - // -28 [ argument word 1 ] - // -27 [ saved xmm15 ] <--- rsp_after_call + // -60 [ argument word 1 ] + // -59 [ saved xmm31 ] <--- rsp after_call + // [ saved xmm16-xmm30 ] (EVEX enabled, else the space is blank) + // -27 [ saved xmm15 ] // [ saved xmm7-xmm14 ] // -9 [ saved xmm6 ] (each xmm register takes 2 slots) // -7 [ saved r15 ] @@ -166,7 +168,7 @@ class StubGenerator: public StubCodeGenerator { enum call_stub_layout { #ifdef _WIN64 xmm_save_first = 6, // save from xmm6 - xmm_save_last = 15, // to xmm15 + xmm_save_last = 31, // to xmm31 xmm_save_base = -9, rsp_after_call_off = xmm_save_base - 2 * (xmm_save_last - xmm_save_first), // -27 r15_off = -7, @@ -262,9 +264,19 @@ class StubGenerator: public StubCodeGenerator { __ movptr(r13_save, r13); __ movptr(r14_save, r14); __ movptr(r15_save, r15); + if (UseAVX > 2) { + __ movl(rbx, 0xffff); + __ kmovql(k1, rbx); + } #ifdef _WIN64 - for (int i = 6; i <= 15; i++) { - __ movdqu(xmm_save(i), as_XMMRegister(i)); + if (UseAVX > 2) { + for (int i = 6; i <= 31; i++) { + __ movdqu(xmm_save(i), as_XMMRegister(i)); + } + } else { + for (int i = 6; i <= 15; i++) { + __ movdqu(xmm_save(i), as_XMMRegister(i)); + } } const Address rdi_save(rbp, rdi_off * wordSize); @@ -1318,7 +1330,10 @@ class StubGenerator: public StubCodeGenerator { Label L_end; // Copy 64-bytes per iteration __ BIND(L_loop); - if (UseAVX >= 2) { + if (UseAVX > 2) { + __ evmovdqu(xmm0, Address(end_from, qword_count, Address::times_8, -56), Assembler::AVX_512bit); + __ evmovdqu(Address(end_to, qword_count, Address::times_8, -56), xmm0, Assembler::AVX_512bit); + } else if (UseAVX == 2) { __ vmovdqu(xmm0, Address(end_from, qword_count, Address::times_8, -56)); __ vmovdqu(Address(end_to, qword_count, Address::times_8, -56), xmm0); __ vmovdqu(xmm1, Address(end_from, qword_count, Address::times_8, -24)); @@ -1395,7 +1410,10 @@ class StubGenerator: public StubCodeGenerator { Label L_end; // Copy 64-bytes per iteration __ BIND(L_loop); - if (UseAVX >= 2) { + if (UseAVX > 2) { + __ evmovdqu(xmm0, Address(from, qword_count, Address::times_8, 32), Assembler::AVX_512bit); + __ evmovdqu(Address(dest, qword_count, Address::times_8, 32), xmm0, Assembler::AVX_512bit); + } else if (UseAVX == 2) { __ vmovdqu(xmm0, Address(from, qword_count, Address::times_8, 32)); __ vmovdqu(Address(dest, qword_count, Address::times_8, 32), xmm0); __ vmovdqu(xmm1, Address(from, qword_count, Address::times_8, 0)); diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp index 61267632209..e09a13af3b7 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp @@ -35,7 +35,7 @@ int VM_Version::_cpu; int VM_Version::_model; int VM_Version::_stepping; -int VM_Version::_cpuFeatures; +uint64_t VM_Version::_cpuFeatures; const char* VM_Version::_features_str = ""; VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; @@ -45,7 +45,7 @@ address VM_Version::_cpuinfo_segv_addr = 0; address VM_Version::_cpuinfo_cont_addr = 0; static BufferBlob* stub_blob; -static const int stub_size = 600; +static const int stub_size = 1000; extern "C" { typedef void (*get_cpu_info_stub_t)(void*); @@ -60,15 +60,16 @@ class VM_Version_StubGenerator: public StubCodeGenerator { address generate_get_cpu_info() { // Flags to test CPU type. - const uint32_t HS_EFL_AC = 0x40000; - const uint32_t HS_EFL_ID = 0x200000; + const uint32_t HS_EFL_AC = 0x40000; + const uint32_t HS_EFL_ID = 0x200000; // Values for when we don't have a CPUID instruction. const int CPU_FAMILY_SHIFT = 8; - const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); - const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); + const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT); + const uint32_t CPU_FAMILY_486 = (4 << CPU_FAMILY_SHIFT); Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4; - Label sef_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7, done; + Label sef_cpuid, ext_cpuid, ext_cpuid1, ext_cpuid5, ext_cpuid7, done, wrapup; + Label legacy_setup, save_restore_except, legacy_save_restore, start_simd_check; StubCodeMark mark(this, "VM_Version", "get_cpu_info_stub"); # define __ _masm-> @@ -241,53 +242,6 @@ class VM_Version_StubGenerator: public StubCodeGenerator { __ movl(Address(rsi, 0), rax); __ movl(Address(rsi, 4), rdx); - __ andl(rax, 0x6); // xcr0 bits sse | ymm - __ cmpl(rax, 0x6); - __ jccb(Assembler::notEqual, sef_cpuid); // jump if AVX is not supported - - // - // Some OSs have a bug when upper 128bits of YMM - // registers are not restored after a signal processing. - // Generate SEGV here (reference through NULL) - // and check upper YMM bits after it. - // - VM_Version::set_avx_cpuFeatures(); // Enable temporary to pass asserts - intx saved_useavx = UseAVX; - intx saved_usesse = UseSSE; - UseAVX = 1; - UseSSE = 2; - - // load value into all 32 bytes of ymm7 register - __ movl(rcx, VM_Version::ymm_test_value()); - - __ movdl(xmm0, rcx); - __ pshufd(xmm0, xmm0, 0x00); - __ vinsertf128h(xmm0, xmm0, xmm0); - __ vmovdqu(xmm7, xmm0); -#ifdef _LP64 - __ vmovdqu(xmm8, xmm0); - __ vmovdqu(xmm15, xmm0); -#endif - - __ xorl(rsi, rsi); - VM_Version::set_cpuinfo_segv_addr( __ pc() ); - // Generate SEGV - __ movl(rax, Address(rsi, 0)); - - VM_Version::set_cpuinfo_cont_addr( __ pc() ); - // Returns here after signal. Save xmm0 to check it later. - __ lea(rsi, Address(rbp, in_bytes(VM_Version::ymm_save_offset()))); - __ vmovdqu(Address(rsi, 0), xmm0); - __ vmovdqu(Address(rsi, 32), xmm7); -#ifdef _LP64 - __ vmovdqu(Address(rsi, 64), xmm8); - __ vmovdqu(Address(rsi, 96), xmm15); -#endif - - VM_Version::clean_cpuFeatures(); - UseAVX = saved_useavx; - UseSSE = saved_usesse; - // // cpuid(0x7) Structured Extended Features // @@ -364,9 +318,143 @@ class VM_Version_StubGenerator: public StubCodeGenerator { __ movl(Address(rsi,12), rdx); // - // return + // Check if OS has enabled XGETBV instruction to access XCR0 + // (OSXSAVE feature flag) and CPU supports AVX // + __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset()))); + __ movl(rcx, 0x18000000); // cpuid1 bits osxsave | avx + __ andl(rcx, Address(rsi, 8)); // cpuid1 bits osxsave | avx + __ cmpl(rcx, 0x18000000); + __ jccb(Assembler::notEqual, done); // jump if AVX is not supported + + __ movl(rax, 0x6); + __ andl(rax, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); // xcr0 bits sse | ymm + __ cmpl(rax, 0x6); + __ jccb(Assembler::equal, start_simd_check); // return if AVX is not supported + + // we need to bridge farther than imm8, so we use this island as a thunk __ bind(done); + __ jmp(wrapup); + + __ bind(start_simd_check); + // + // Some OSs have a bug when upper 128/256bits of YMM/ZMM + // registers are not restored after a signal processing. + // Generate SEGV here (reference through NULL) + // and check upper YMM/ZMM bits after it. + // + intx saved_useavx = UseAVX; + intx saved_usesse = UseSSE; + // check _cpuid_info.sef_cpuid7_ebx.bits.avx512f + __ lea(rsi, Address(rbp, in_bytes(VM_Version::sef_cpuid7_offset()))); + __ movl(rax, 0x10000); + __ andl(rax, Address(rsi, 4)); // xcr0 bits sse | ymm + __ cmpl(rax, 0x10000); + __ jccb(Assembler::notEqual, legacy_setup); // jump if EVEX is not supported + // check _cpuid_info.xem_xcr0_eax.bits.opmask + // check _cpuid_info.xem_xcr0_eax.bits.zmm512 + // check _cpuid_info.xem_xcr0_eax.bits.zmm32 + __ movl(rax, 0xE0); + __ andl(rax, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); // xcr0 bits sse | ymm + __ cmpl(rax, 0xE0); + __ jccb(Assembler::notEqual, legacy_setup); // jump if EVEX is not supported + + // EVEX setup: run in lowest evex mode + VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts + UseAVX = 3; + UseSSE = 2; + // load value into all 64 bytes of zmm7 register + __ movl(rcx, VM_Version::ymm_test_value()); + __ movdl(xmm0, rcx); + __ movl(rcx, 0xffff); +#ifdef _LP64 + __ kmovql(k1, rcx); +#else + __ kmovdl(k1, rcx); +#endif + __ evpbroadcastd(xmm0, xmm0, Assembler::AVX_512bit); + __ evmovdqu(xmm7, xmm0, Assembler::AVX_512bit); +#ifdef _LP64 + __ evmovdqu(xmm8, xmm0, Assembler::AVX_512bit); + __ evmovdqu(xmm31, xmm0, Assembler::AVX_512bit); +#endif + VM_Version::clean_cpuFeatures(); + __ jmp(save_restore_except); + + __ bind(legacy_setup); + // AVX setup + VM_Version::set_avx_cpuFeatures(); // Enable temporary to pass asserts + UseAVX = 1; + UseSSE = 2; + // load value into all 32 bytes of ymm7 register + __ movl(rcx, VM_Version::ymm_test_value()); + + __ movdl(xmm0, rcx); + __ pshufd(xmm0, xmm0, 0x00); + __ vinsertf128h(xmm0, xmm0, xmm0); + __ vmovdqu(xmm7, xmm0); +#ifdef _LP64 + __ vmovdqu(xmm8, xmm0); + __ vmovdqu(xmm15, xmm0); +#endif + VM_Version::clean_cpuFeatures(); + + __ bind(save_restore_except); + __ xorl(rsi, rsi); + VM_Version::set_cpuinfo_segv_addr(__ pc()); + // Generate SEGV + __ movl(rax, Address(rsi, 0)); + + VM_Version::set_cpuinfo_cont_addr(__ pc()); + // Returns here after signal. Save xmm0 to check it later. + + // check _cpuid_info.sef_cpuid7_ebx.bits.avx512f + __ lea(rsi, Address(rbp, in_bytes(VM_Version::sef_cpuid7_offset()))); + __ movl(rax, 0x10000); + __ andl(rax, Address(rsi, 4)); + __ cmpl(rax, 0x10000); + __ jccb(Assembler::notEqual, legacy_save_restore); + // check _cpuid_info.xem_xcr0_eax.bits.opmask + // check _cpuid_info.xem_xcr0_eax.bits.zmm512 + // check _cpuid_info.xem_xcr0_eax.bits.zmm32 + __ movl(rax, 0xE0); + __ andl(rax, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); // xcr0 bits sse | ymm + __ cmpl(rax, 0xE0); + __ jccb(Assembler::notEqual, legacy_save_restore); + + // EVEX check: run in lowest evex mode + VM_Version::set_evex_cpuFeatures(); // Enable temporary to pass asserts + UseAVX = 3; + UseSSE = 2; + __ lea(rsi, Address(rbp, in_bytes(VM_Version::zmm_save_offset()))); + __ evmovdqu(Address(rsi, 0), xmm0, Assembler::AVX_512bit); + __ evmovdqu(Address(rsi, 64), xmm7, Assembler::AVX_512bit); +#ifdef _LP64 + __ evmovdqu(Address(rsi, 128), xmm8, Assembler::AVX_512bit); + __ evmovdqu(Address(rsi, 192), xmm31, Assembler::AVX_512bit); +#endif + VM_Version::clean_cpuFeatures(); + UseAVX = saved_useavx; + UseSSE = saved_usesse; + __ jmp(wrapup); + + __ bind(legacy_save_restore); + // AVX check + VM_Version::set_avx_cpuFeatures(); // Enable temporary to pass asserts + UseAVX = 1; + UseSSE = 2; + __ lea(rsi, Address(rbp, in_bytes(VM_Version::ymm_save_offset()))); + __ vmovdqu(Address(rsi, 0), xmm0); + __ vmovdqu(Address(rsi, 32), xmm7); +#ifdef _LP64 + __ vmovdqu(Address(rsi, 64), xmm8); + __ vmovdqu(Address(rsi, 96), xmm15); +#endif + VM_Version::clean_cpuFeatures(); + UseAVX = saved_useavx; + UseSSE = saved_usesse; + + __ bind(wrapup); __ popf(); __ pop(rsi); __ pop(rbx); @@ -459,6 +547,29 @@ void VM_Version::get_processor_features() { if (UseSSE < 1) _cpuFeatures &= ~CPU_SSE; + // first try initial setting and detect what we can support + if (UseAVX > 0) { + if (UseAVX > 2 && supports_evex()) { + UseAVX = 3; + } else if (UseAVX > 1 && supports_avx2()) { + UseAVX = 2; + } else if (UseAVX > 0 && supports_avx()) { + UseAVX = 1; + } else { + UseAVX = 0; + } + } else if (UseAVX < 0) { + UseAVX = 0; + } + + if (UseAVX < 3) { + _cpuFeatures &= ~CPU_AVX512F; + _cpuFeatures &= ~CPU_AVX512DQ; + _cpuFeatures &= ~CPU_AVX512CD; + _cpuFeatures &= ~CPU_AVX512BW; + _cpuFeatures &= ~CPU_AVX512VL; + } + if (UseAVX < 2) _cpuFeatures &= ~CPU_AVX2; @@ -474,7 +585,7 @@ void VM_Version::get_processor_features() { } char buf[256]; - jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", cores_per_cpu(), threads_per_core(), cpu_family(), _model, _stepping, (supports_cmov() ? ", cmov" : ""), @@ -504,7 +615,8 @@ void VM_Version::get_processor_features() { (supports_tscinv() ? ", tscinv": ""), (supports_bmi1() ? ", bmi1" : ""), (supports_bmi2() ? ", bmi2" : ""), - (supports_adx() ? ", adx" : "")); + (supports_adx() ? ", adx" : ""), + (supports_evex() ? ", evex" : "")); _features_str = os::strdup(buf); // UseSSE is set to the smaller of what hardware supports and what @@ -521,13 +633,6 @@ void VM_Version::get_processor_features() { if (!supports_sse ()) // Drop to 0 if no SSE support UseSSE = 0; - if (UseAVX > 2) UseAVX=2; - if (UseAVX < 0) UseAVX=0; - if (!supports_avx2()) // Drop to 1 if no AVX2 support - UseAVX = MIN2((intx)1,UseAVX); - if (!supports_avx ()) // Drop to 0 if no AVX support - UseAVX = 0; - // Use AES instructions if available. if (supports_aes()) { if (FLAG_IS_DEFAULT(UseAES)) { @@ -598,7 +703,8 @@ void VM_Version::get_processor_features() { if ((_model == CPU_MODEL_HASWELL_E3) || (_model == CPU_MODEL_HASWELL_E7 && _stepping < 3) || (_model == CPU_MODEL_BROADWELL && _stepping < 4)) { - if (!UnlockExperimentalVMOptions) { + // currently a collision between SKL and HSW_E3 + if (!UnlockExperimentalVMOptions && UseAVX < 3) { vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this platform. It must be enabled via -XX:+UnlockExperimentalVMOptions flag."); } else { warning("UseRTMLocking is only available as experimental option on this platform."); @@ -651,10 +757,10 @@ void VM_Version::get_processor_features() { if (MaxVectorSize > 0) { if (!is_power_of_2(MaxVectorSize)) { warning("MaxVectorSize must be a power of 2"); - FLAG_SET_DEFAULT(MaxVectorSize, 32); + FLAG_SET_DEFAULT(MaxVectorSize, 64); } - if (MaxVectorSize > 32) { - FLAG_SET_DEFAULT(MaxVectorSize, 32); + if (MaxVectorSize > 64) { + FLAG_SET_DEFAULT(MaxVectorSize, 64); } if (MaxVectorSize > 16 && (UseAVX == 0 || !os_supports_avx_vectors())) { // 32 bytes vectors (in YMM) are only supported with AVX+ diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp index be27e3908b2..8da46bf729c 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp @@ -208,20 +208,33 @@ public: bmi2 : 1, erms : 1, : 1, - rtm : 1, - : 7, - adx : 1, - : 12; + rtm : 1, + : 4, + avx512f : 1, + avx512dq : 1, + : 1, + adx : 1, + : 6, + avx512pf : 1, + avx512er : 1, + avx512cd : 1, + : 1, + avx512bw : 1, + avx512vl : 1; } bits; }; union XemXcr0Eax { uint32_t value; struct { - uint32_t x87 : 1, - sse : 1, - ymm : 1, - : 29; + uint32_t x87 : 1, + sse : 1, + ymm : 1, + : 2, + opmask : 1, + zmm512 : 1, + zmm32 : 1, + : 24; } bits; }; @@ -229,43 +242,51 @@ protected: static int _cpu; static int _model; static int _stepping; - static int _cpuFeatures; // features returned by the "cpuid" instruction - // 0 if this instruction is not available + static uint64_t _cpuFeatures; // features returned by the "cpuid" instruction + // 0 if this instruction is not available static const char* _features_str; static address _cpuinfo_segv_addr; // address of instruction which causes SEGV static address _cpuinfo_cont_addr; // address of instruction after the one which causes SEGV enum { - CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX) - CPU_CMOV = (1 << 1), - CPU_FXSR = (1 << 2), - CPU_HT = (1 << 3), - CPU_MMX = (1 << 4), - CPU_3DNOW_PREFETCH = (1 << 5), // Processor supports 3dnow prefetch and prefetchw instructions - // may not necessarily support other 3dnow instructions - CPU_SSE = (1 << 6), - CPU_SSE2 = (1 << 7), - CPU_SSE3 = (1 << 8), // SSE3 comes from cpuid 1 (ECX) - CPU_SSSE3 = (1 << 9), - CPU_SSE4A = (1 << 10), - CPU_SSE4_1 = (1 << 11), - CPU_SSE4_2 = (1 << 12), - CPU_POPCNT = (1 << 13), - CPU_LZCNT = (1 << 14), - CPU_TSC = (1 << 15), - CPU_TSCINV = (1 << 16), - CPU_AVX = (1 << 17), - CPU_AVX2 = (1 << 18), - CPU_AES = (1 << 19), - CPU_ERMS = (1 << 20), // enhanced 'rep movsb/stosb' instructions - CPU_CLMUL = (1 << 21), // carryless multiply for CRC - CPU_BMI1 = (1 << 22), - CPU_BMI2 = (1 << 23), - CPU_RTM = (1 << 24), // Restricted Transactional Memory instructions - CPU_ADX = (1 << 25) + CPU_CX8 = (1 << 0), // next bits are from cpuid 1 (EDX) + CPU_CMOV = (1 << 1), + CPU_FXSR = (1 << 2), + CPU_HT = (1 << 3), + CPU_MMX = (1 << 4), + CPU_3DNOW_PREFETCH = (1 << 5), // Processor supports 3dnow prefetch and prefetchw instructions + // may not necessarily support other 3dnow instructions + CPU_SSE = (1 << 6), + CPU_SSE2 = (1 << 7), + CPU_SSE3 = (1 << 8), // SSE3 comes from cpuid 1 (ECX) + CPU_SSSE3 = (1 << 9), + CPU_SSE4A = (1 << 10), + CPU_SSE4_1 = (1 << 11), + CPU_SSE4_2 = (1 << 12), + CPU_POPCNT = (1 << 13), + CPU_LZCNT = (1 << 14), + CPU_TSC = (1 << 15), + CPU_TSCINV = (1 << 16), + CPU_AVX = (1 << 17), + CPU_AVX2 = (1 << 18), + CPU_AES = (1 << 19), + CPU_ERMS = (1 << 20), // enhanced 'rep movsb/stosb' instructions + CPU_CLMUL = (1 << 21), // carryless multiply for CRC + CPU_BMI1 = (1 << 22), + CPU_BMI2 = (1 << 23), + CPU_RTM = (1 << 24), // Restricted Transactional Memory instructions + CPU_ADX = (1 << 25), + CPU_AVX512F = (1 << 26), // AVX 512bit foundation instructions + CPU_AVX512DQ = (1 << 27), + CPU_AVX512PF = (1 << 28), + CPU_AVX512ER = (1 << 29), + CPU_AVX512CD = (1 << 30), + CPU_AVX512BW = (1 << 31) } cpuFeatureFlags; +#define CPU_AVX512VL 0x100000000 // EVEX instructions with smaller vector length : enums are limited to 32bit + enum { // AMD CPU_FAMILY_AMD_11H = 0x11, @@ -282,7 +303,8 @@ protected: CPU_MODEL_IVYBRIDGE_EP = 0x3a, CPU_MODEL_HASWELL_E3 = 0x3c, CPU_MODEL_HASWELL_E7 = 0x3f, - CPU_MODEL_BROADWELL = 0x3d + CPU_MODEL_BROADWELL = 0x3d, + CPU_MODEL_SKYLAKE = CPU_MODEL_HASWELL_E3 } cpuExtendedFamily; // cpuid information block. All info derived from executing cpuid with @@ -376,6 +398,9 @@ protected: // Space to save ymm registers after signal handle int ymm_save[8*4]; // Save ymm0, ymm7, ymm8, ymm15 + + // Space to save zmm registers after signal handle + int zmm_save[16*4]; // Save zmm0, zmm7, zmm8, zmm31 }; // The actual cpuid info block @@ -404,8 +429,8 @@ protected: return result; } - static uint32_t feature_flags() { - uint32_t result = 0; + static uint64_t feature_flags() { + uint64_t result = 0; if (_cpuid_info.std_cpuid1_edx.bits.cmpxchg8 != 0) result |= CPU_CX8; if (_cpuid_info.std_cpuid1_edx.bits.cmov != 0) @@ -440,6 +465,24 @@ protected: result |= CPU_AVX; if (_cpuid_info.sef_cpuid7_ebx.bits.avx2 != 0) result |= CPU_AVX2; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512f != 0 && + _cpuid_info.xem_xcr0_eax.bits.opmask != 0 && + _cpuid_info.xem_xcr0_eax.bits.zmm512 != 0 && + _cpuid_info.xem_xcr0_eax.bits.zmm32 != 0) { + result |= CPU_AVX512F; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512cd != 0) + result |= CPU_AVX512CD; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512dq != 0) + result |= CPU_AVX512DQ; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512pf != 0) + result |= CPU_AVX512PF; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512er != 0) + result |= CPU_AVX512ER; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512bw != 0) + result |= CPU_AVX512BW; + if (_cpuid_info.sef_cpuid7_ebx.bits.avx512vl != 0) + result |= CPU_AVX512VL; + } } if(_cpuid_info.sef_cpuid7_ebx.bits.bmi1 != 0) result |= CPU_BMI1; @@ -484,18 +527,31 @@ protected: } static bool os_supports_avx_vectors() { - if (!supports_avx()) { - return false; - } - // Verify that OS save/restore all bits of AVX registers - // during signal processing. - int nreg = 2 LP64_ONLY(+2); - for (int i = 0; i < 8 * nreg; i++) { // 32 bytes per ymm register - if (_cpuid_info.ymm_save[i] != ymm_test_value()) { - return false; + bool retVal = false; + if (supports_evex()) { + // Verify that OS save/restore all bits of EVEX registers + // during signal processing. + int nreg = 2 LP64_ONLY(+2); + retVal = true; + for (int i = 0; i < 16 * nreg; i++) { // 64 bytes per zmm register + if (_cpuid_info.zmm_save[i] != ymm_test_value()) { + retVal = false; + break; + } + } + } else if (supports_avx()) { + // Verify that OS save/restore all bits of AVX registers + // during signal processing. + int nreg = 2 LP64_ONLY(+2); + retVal = true; + for (int i = 0; i < 8 * nreg; i++) { // 32 bytes per ymm register + if (_cpuid_info.ymm_save[i] != ymm_test_value()) { + retVal = false; + break; + } } } - return true; + return retVal; } static void get_processor_features(); @@ -515,6 +571,7 @@ public: static ByteSize tpl_cpuidB2_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB2_eax); } static ByteSize xem_xcr0_offset() { return byte_offset_of(CpuidInfo, xem_xcr0_eax); } static ByteSize ymm_save_offset() { return byte_offset_of(CpuidInfo, ymm_save); } + static ByteSize zmm_save_offset() { return byte_offset_of(CpuidInfo, zmm_save); } // The value used to check ymm register after signal handle static int ymm_test_value() { return 0xCAFEBABE; } @@ -527,6 +584,7 @@ public: static void clean_cpuFeatures() { _cpuFeatures = 0; } static void set_avx_cpuFeatures() { _cpuFeatures = (CPU_SSE | CPU_SSE2 | CPU_AVX); } + static void set_evex_cpuFeatures() { _cpuFeatures = (CPU_AVX512F | CPU_SSE | CPU_SSE2 ); } // Initialization @@ -636,7 +694,14 @@ public: static bool supports_rtm() { return (_cpuFeatures & CPU_RTM) != 0; } static bool supports_bmi1() { return (_cpuFeatures & CPU_BMI1) != 0; } static bool supports_bmi2() { return (_cpuFeatures & CPU_BMI2) != 0; } - static bool supports_adx() { return (_cpuFeatures & CPU_ADX) != 0; } + static bool supports_adx() { return (_cpuFeatures & CPU_ADX) != 0; } + static bool supports_evex() { return (_cpuFeatures & CPU_AVX512F) != 0; } + static bool supports_avx512dq() { return (_cpuFeatures & CPU_AVX512DQ) != 0; } + static bool supports_avx512pf() { return (_cpuFeatures & CPU_AVX512PF) != 0; } + static bool supports_avx512er() { return (_cpuFeatures & CPU_AVX512ER) != 0; } + static bool supports_avx512cd() { return (_cpuFeatures & CPU_AVX512CD) != 0; } + static bool supports_avx512bw() { return (_cpuFeatures & CPU_AVX512BW) != 0; } + static bool supports_avx512vl() { return (_cpuFeatures & CPU_AVX512VL) != 0; } // Intel features static bool is_intel_family_core() { return is_intel() && extended_cpu_family() == CPU_FAMILY_INTEL_CORE; } diff --git a/hotspot/src/cpu/x86/vm/vmreg_x86.cpp b/hotspot/src/cpu/x86/vm/vmreg_x86.cpp index 89959771ea2..202230a0528 100644 --- a/hotspot/src/cpu/x86/vm/vmreg_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vmreg_x86.cpp @@ -47,13 +47,22 @@ void VMRegImpl::set_regName() { } XMMRegister xreg = ::as_XMMRegister(0); - for ( ; i < ConcreteRegisterImpl::max_xmm ; ) { - for (int j = 0 ; j < 8 ; j++) { + for (; i < ConcreteRegisterImpl::max_xmm;) { + for (int j = 0 ; j < XMMRegisterImpl::max_slots_per_register ; j++) { regName[i++] = xreg->name(); } xreg = xreg->successor(); } + + KRegister kreg = ::as_KRegister(0); + for (; i < ConcreteRegisterImpl::max_kpr;) { + for (int j = 0; j < KRegisterImpl::max_slots_per_register; j++) { + regName[i++] = kreg->name(); + } + kreg = kreg->successor(); + } + for ( ; i < ConcreteRegisterImpl::number_of_registers ; i ++ ) { - regName[i] = "NON-GPR-FPR-XMM"; + regName[i] = "NON-GPR-FPR-XMM-KREG"; } } diff --git a/hotspot/src/cpu/x86/vm/vmreg_x86.hpp b/hotspot/src/cpu/x86/vm/vmreg_x86.hpp index f31e1c5c9fd..b382110d2a5 100644 --- a/hotspot/src/cpu/x86/vm/vmreg_x86.hpp +++ b/hotspot/src/cpu/x86/vm/vmreg_x86.hpp @@ -36,7 +36,24 @@ inline bool is_FloatRegister() { } inline bool is_XMMRegister() { - return value() >= ConcreteRegisterImpl::max_fpr && value() < ConcreteRegisterImpl::max_xmm; + int uarch_max_xmm = ConcreteRegisterImpl::max_xmm; + +#ifdef _LP64 + if (UseAVX < 3) { + int half_xmm = (XMMRegisterImpl::max_slots_per_register * XMMRegisterImpl::number_of_registers) / 2; + uarch_max_xmm -= half_xmm; + } +#endif + + return (value() >= ConcreteRegisterImpl::max_fpr && value() < uarch_max_xmm); +} + +inline bool is_KRegister() { + if (UseAVX > 2) { + return value() >= ConcreteRegisterImpl::max_xmm && value() < ConcreteRegisterImpl::max_kpr; + } else { + return false; + } } inline Register as_Register() { @@ -59,7 +76,13 @@ inline FloatRegister as_FloatRegister() { inline XMMRegister as_XMMRegister() { assert( is_XMMRegister() && is_even(value()), "must be" ); // Yuk - return ::as_XMMRegister((value() - ConcreteRegisterImpl::max_fpr) >> 3); + return ::as_XMMRegister((value() - ConcreteRegisterImpl::max_fpr) >> 4); +} + +inline KRegister as_KRegister() { + assert(is_KRegister(), "must be"); + // Yuk + return ::as_KRegister((value() - ConcreteRegisterImpl::max_xmm)); } inline bool is_concrete() { diff --git a/hotspot/src/cpu/x86/vm/vmreg_x86.inline.hpp b/hotspot/src/cpu/x86/vm/vmreg_x86.inline.hpp index bc94e4839af..bad5235c35d 100644 --- a/hotspot/src/cpu/x86/vm/vmreg_x86.inline.hpp +++ b/hotspot/src/cpu/x86/vm/vmreg_x86.inline.hpp @@ -39,7 +39,11 @@ inline VMReg FloatRegisterImpl::as_VMReg() { } inline VMReg XMMRegisterImpl::as_VMReg() { - return VMRegImpl::as_VMReg((encoding() << 3) + ConcreteRegisterImpl::max_fpr); + return VMRegImpl::as_VMReg((encoding() << 4) + ConcreteRegisterImpl::max_fpr); +} + +inline VMReg KRegisterImpl::as_VMReg() { + return VMRegImpl::as_VMReg(encoding() + ConcreteRegisterImpl::max_xmm); } #endif // CPU_X86_VM_VMREG_X86_INLINE_HPP diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index 5c99066206e..790187ca637 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -59,15 +59,19 @@ register %{ // // The encoding number is the actual bit-pattern placed into the opcodes. -// XMM registers. 256-bit registers or 8 words each, labeled (a)-h. +// XMM registers. 512-bit registers or 8 words each, labeled (a)-p. // Word a in each register holds a Float, words ab hold a Double. // The whole registers are used in SSE4.2 version intrinsics, // array copy stubs and superword operations (see UseSSE42Intrinsics, // UseXMMForArrayCopy and UseSuperword flags). -// XMM8-XMM15 must be encoded with REX (VEX for UseAVX). +// For pre EVEX enabled architectures: +// XMM8-XMM15 must be encoded with REX (VEX for UseAVX) +// For EVEX enabled architectures: +// XMM8-XMM31 must be encoded with REX (EVEX for UseAVX). +// // Linux ABI: No register preserved across function calls // XMM0-XMM7 might hold parameters -// Windows ABI: XMM6-XMM15 preserved across function calls +// Windows ABI: XMM6-XMM31 preserved across function calls // XMM0-XMM3 might hold parameters reg_def XMM0 ( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()); @@ -78,6 +82,14 @@ reg_def XMM0e( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(4)); reg_def XMM0f( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(5)); reg_def XMM0g( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(6)); reg_def XMM0h( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(7)); +reg_def XMM0i( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(8)); +reg_def XMM0j( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(9)); +reg_def XMM0k( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(10)); +reg_def XMM0l( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(11)); +reg_def XMM0m( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(12)); +reg_def XMM0n( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(13)); +reg_def XMM0o( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(14)); +reg_def XMM0p( SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next(15)); reg_def XMM1 ( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()); reg_def XMM1b( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(1)); @@ -87,6 +99,14 @@ reg_def XMM1e( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(4)); reg_def XMM1f( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(5)); reg_def XMM1g( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(6)); reg_def XMM1h( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(7)); +reg_def XMM1i( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(8)); +reg_def XMM1j( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(9)); +reg_def XMM1k( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(10)); +reg_def XMM1l( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(11)); +reg_def XMM1m( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(12)); +reg_def XMM1n( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(13)); +reg_def XMM1o( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(14)); +reg_def XMM1p( SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next(15)); reg_def XMM2 ( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()); reg_def XMM2b( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(1)); @@ -96,6 +116,14 @@ reg_def XMM2e( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(4)); reg_def XMM2f( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(5)); reg_def XMM2g( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(6)); reg_def XMM2h( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(7)); +reg_def XMM2i( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(8)); +reg_def XMM2j( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(9)); +reg_def XMM2k( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(10)); +reg_def XMM2l( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(11)); +reg_def XMM2m( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(12)); +reg_def XMM2n( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(13)); +reg_def XMM2o( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(14)); +reg_def XMM2p( SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next(15)); reg_def XMM3 ( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()); reg_def XMM3b( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(1)); @@ -105,6 +133,14 @@ reg_def XMM3e( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(4)); reg_def XMM3f( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(5)); reg_def XMM3g( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(6)); reg_def XMM3h( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(7)); +reg_def XMM3i( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(8)); +reg_def XMM3j( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(9)); +reg_def XMM3k( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(10)); +reg_def XMM3l( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(11)); +reg_def XMM3m( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(12)); +reg_def XMM3n( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(13)); +reg_def XMM3o( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(14)); +reg_def XMM3p( SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next(15)); reg_def XMM4 ( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()); reg_def XMM4b( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(1)); @@ -114,6 +150,14 @@ reg_def XMM4e( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(4)); reg_def XMM4f( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(5)); reg_def XMM4g( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(6)); reg_def XMM4h( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(7)); +reg_def XMM4i( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(8)); +reg_def XMM4j( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(9)); +reg_def XMM4k( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(10)); +reg_def XMM4l( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(11)); +reg_def XMM4m( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(12)); +reg_def XMM4n( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(13)); +reg_def XMM4o( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(14)); +reg_def XMM4p( SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next(15)); reg_def XMM5 ( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()); reg_def XMM5b( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(1)); @@ -123,6 +167,14 @@ reg_def XMM5e( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(4)); reg_def XMM5f( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(5)); reg_def XMM5g( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(6)); reg_def XMM5h( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(7)); +reg_def XMM5i( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(8)); +reg_def XMM5j( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(9)); +reg_def XMM5k( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(10)); +reg_def XMM5l( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(11)); +reg_def XMM5m( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(12)); +reg_def XMM5n( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(13)); +reg_def XMM5o( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(14)); +reg_def XMM5p( SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next(15)); #ifdef _WIN64 @@ -134,6 +186,14 @@ reg_def XMM6e( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(4)); reg_def XMM6f( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(5)); reg_def XMM6g( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(6)); reg_def XMM6h( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(7)); +reg_def XMM6i( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(8)); +reg_def XMM6j( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(9)); +reg_def XMM6k( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(10)); +reg_def XMM6l( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(11)); +reg_def XMM6m( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(12)); +reg_def XMM6n( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(13)); +reg_def XMM6o( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(14)); +reg_def XMM6p( SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next(15)); reg_def XMM7 ( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()); reg_def XMM7b( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(1)); @@ -143,6 +203,14 @@ reg_def XMM7e( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(4)); reg_def XMM7f( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(5)); reg_def XMM7g( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(6)); reg_def XMM7h( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(7)); +reg_def XMM7i( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(8)); +reg_def XMM7j( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(9)); +reg_def XMM7k( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(10)); +reg_def XMM7l( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(11)); +reg_def XMM7m( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(12)); +reg_def XMM7n( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(13)); +reg_def XMM7o( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(14)); +reg_def XMM7p( SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next(15)); reg_def XMM8 ( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()); reg_def XMM8b( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(1)); @@ -152,6 +220,14 @@ reg_def XMM8e( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(4)); reg_def XMM8f( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(5)); reg_def XMM8g( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(6)); reg_def XMM8h( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(7)); +reg_def XMM8i( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(8)); +reg_def XMM8j( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(9)); +reg_def XMM8k( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(10)); +reg_def XMM8l( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(11)); +reg_def XMM8m( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(12)); +reg_def XMM8n( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(13)); +reg_def XMM8o( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(14)); +reg_def XMM8p( SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next(15)); reg_def XMM9 ( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()); reg_def XMM9b( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(1)); @@ -161,6 +237,14 @@ reg_def XMM9e( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(4)); reg_def XMM9f( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(5)); reg_def XMM9g( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(6)); reg_def XMM9h( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(7)); +reg_def XMM9i( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(8)); +reg_def XMM9j( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(9)); +reg_def XMM9k( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(10)); +reg_def XMM9l( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(11)); +reg_def XMM9m( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(12)); +reg_def XMM9n( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(13)); +reg_def XMM9o( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(14)); +reg_def XMM9p( SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next(15)); reg_def XMM10 ( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()); reg_def XMM10b( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(1)); @@ -170,6 +254,14 @@ reg_def XMM10e( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(4)); reg_def XMM10f( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(5)); reg_def XMM10g( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(6)); reg_def XMM10h( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(7)); +reg_def XMM10i( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(8)); +reg_def XMM10j( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(9)); +reg_def XMM10k( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(10)); +reg_def XMM10l( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(11)); +reg_def XMM10m( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(12)); +reg_def XMM10n( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(13)); +reg_def XMM10o( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(14)); +reg_def XMM10p( SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next(15)); reg_def XMM11 ( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()); reg_def XMM11b( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(1)); @@ -179,6 +271,14 @@ reg_def XMM11e( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(4)); reg_def XMM11f( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(5)); reg_def XMM11g( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(6)); reg_def XMM11h( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(7)); +reg_def XMM11i( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(8)); +reg_def XMM11j( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(9)); +reg_def XMM11k( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(10)); +reg_def XMM11l( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(11)); +reg_def XMM11m( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(12)); +reg_def XMM11n( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(13)); +reg_def XMM11o( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(14)); +reg_def XMM11p( SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next(15)); reg_def XMM12 ( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()); reg_def XMM12b( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(1)); @@ -188,6 +288,14 @@ reg_def XMM12e( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(4)); reg_def XMM12f( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(5)); reg_def XMM12g( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(6)); reg_def XMM12h( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(7)); +reg_def XMM12i( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(8)); +reg_def XMM12j( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(9)); +reg_def XMM12k( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(10)); +reg_def XMM12l( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(11)); +reg_def XMM12m( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(12)); +reg_def XMM12n( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(13)); +reg_def XMM12o( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(14)); +reg_def XMM12p( SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next(15)); reg_def XMM13 ( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()); reg_def XMM13b( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(1)); @@ -197,6 +305,14 @@ reg_def XMM13e( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(4)); reg_def XMM13f( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(5)); reg_def XMM13g( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(6)); reg_def XMM13h( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(7)); +reg_def XMM13i( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(8)); +reg_def XMM13j( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(9)); +reg_def XMM13k( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(10)); +reg_def XMM13l( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(11)); +reg_def XMM13m( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(12)); +reg_def XMM13n( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(13)); +reg_def XMM13o( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(14)); +reg_def XMM13p( SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next(15)); reg_def XMM14 ( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()); reg_def XMM14b( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(1)); @@ -206,6 +322,14 @@ reg_def XMM14e( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(4)); reg_def XMM14f( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(5)); reg_def XMM14g( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(6)); reg_def XMM14h( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(7)); +reg_def XMM14i( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(8)); +reg_def XMM14j( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(9)); +reg_def XMM14k( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(10)); +reg_def XMM14l( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(11)); +reg_def XMM14m( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(12)); +reg_def XMM14n( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(13)); +reg_def XMM14o( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(14)); +reg_def XMM14p( SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next(15)); reg_def XMM15 ( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()); reg_def XMM15b( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(1)); @@ -215,6 +339,285 @@ reg_def XMM15e( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(4)); reg_def XMM15f( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(5)); reg_def XMM15g( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(6)); reg_def XMM15h( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(7)); +reg_def XMM15i( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(8)); +reg_def XMM15j( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(9)); +reg_def XMM15k( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(10)); +reg_def XMM15l( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(11)); +reg_def XMM15m( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(12)); +reg_def XMM15n( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(13)); +reg_def XMM15o( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(14)); +reg_def XMM15p( SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next(15)); + +reg_def XMM16 ( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()); +reg_def XMM16b( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(1)); +reg_def XMM16c( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(2)); +reg_def XMM16d( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(3)); +reg_def XMM16e( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(4)); +reg_def XMM16f( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(5)); +reg_def XMM16g( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(6)); +reg_def XMM16h( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(7)); +reg_def XMM16i( SOC, SOE, Op_RegF, 16, xmm15->as_VMReg()->next(8)); +reg_def XMM16j( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(9)); +reg_def XMM16k( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(10)); +reg_def XMM16l( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(11)); +reg_def XMM16m( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(12)); +reg_def XMM16n( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(13)); +reg_def XMM16o( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(14)); +reg_def XMM16p( SOC, SOE, Op_RegF, 16, xmm16->as_VMReg()->next(15)); + +reg_def XMM17 ( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()); +reg_def XMM17b( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(1)); +reg_def XMM17c( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(2)); +reg_def XMM17d( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(3)); +reg_def XMM17e( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(4)); +reg_def XMM17f( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(5)); +reg_def XMM17g( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(6)); +reg_def XMM17h( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(7)); +reg_def XMM17i( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(8)); +reg_def XMM17j( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(9)); +reg_def XMM17k( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(10)); +reg_def XMM17l( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(11)); +reg_def XMM17m( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(12)); +reg_def XMM17n( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(13)); +reg_def XMM17o( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(14)); +reg_def XMM17p( SOC, SOE, Op_RegF, 17, xmm17->as_VMReg()->next(15)); + +reg_def XMM18 ( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()); +reg_def XMM18b( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(1)); +reg_def XMM18c( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(2)); +reg_def XMM18d( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(3)); +reg_def XMM18e( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(4)); +reg_def XMM18f( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(5)); +reg_def XMM18g( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(6)); +reg_def XMM18h( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(7)); +reg_def XMM18i( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(8)); +reg_def XMM18j( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(9)); +reg_def XMM18k( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(10)); +reg_def XMM18l( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(11)); +reg_def XMM18m( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(12)); +reg_def XMM18n( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(13)); +reg_def XMM18o( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(14)); +reg_def XMM18p( SOC, SOE, Op_RegF, 18, xmm18->as_VMReg()->next(15)); + +reg_def XMM19 ( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()); +reg_def XMM19b( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(1)); +reg_def XMM19c( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(2)); +reg_def XMM19d( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(3)); +reg_def XMM19e( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(4)); +reg_def XMM19f( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(5)); +reg_def XMM19g( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(6)); +reg_def XMM19h( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(7)); +reg_def XMM19i( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(8)); +reg_def XMM19j( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(9)); +reg_def XMM19k( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(10)); +reg_def XMM19l( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(11)); +reg_def XMM19m( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(12)); +reg_def XMM19n( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(13)); +reg_def XMM19o( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(14)); +reg_def XMM19p( SOC, SOE, Op_RegF, 19, xmm19->as_VMReg()->next(15)); + +reg_def XMM20 ( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()); +reg_def XMM20b( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(1)); +reg_def XMM20c( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(2)); +reg_def XMM20d( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(3)); +reg_def XMM20e( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(4)); +reg_def XMM20f( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(5)); +reg_def XMM20g( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(6)); +reg_def XMM20h( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(7)); +reg_def XMM20i( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(8)); +reg_def XMM20j( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(9)); +reg_def XMM20k( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(10)); +reg_def XMM20l( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(11)); +reg_def XMM20m( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(12)); +reg_def XMM20n( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(13)); +reg_def XMM20o( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(14)); +reg_def XMM20p( SOC, SOE, Op_RegF, 20, xmm20->as_VMReg()->next(15)); + +reg_def XMM21 ( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()); +reg_def XMM21b( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(1)); +reg_def XMM21c( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(2)); +reg_def XMM21d( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(3)); +reg_def XMM21e( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(4)); +reg_def XMM21f( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(5)); +reg_def XMM21g( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(6)); +reg_def XMM21h( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(7)); +reg_def XMM21i( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(8)); +reg_def XMM21j( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(9)); +reg_def XMM21k( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(10)); +reg_def XMM21l( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(11)); +reg_def XMM21m( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(12)); +reg_def XMM21n( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(13)); +reg_def XMM21o( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(14)); +reg_def XMM21p( SOC, SOE, Op_RegF, 21, xmm21->as_VMReg()->next(15)); + +reg_def XMM22 ( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()); +reg_def XMM22b( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(1)); +reg_def XMM22c( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(2)); +reg_def XMM22d( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(3)); +reg_def XMM22e( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(4)); +reg_def XMM22f( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(5)); +reg_def XMM22g( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(6)); +reg_def XMM22h( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(7)); +reg_def XMM22i( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(8)); +reg_def XMM22j( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(9)); +reg_def XMM22k( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(10)); +reg_def XMM22l( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(11)); +reg_def XMM22m( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(12)); +reg_def XMM22n( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(13)); +reg_def XMM22o( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(14)); +reg_def XMM22p( SOC, SOE, Op_RegF, 22, xmm22->as_VMReg()->next(15)); + +reg_def XMM23 ( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()); +reg_def XMM23b( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(1)); +reg_def XMM23c( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(2)); +reg_def XMM23d( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(3)); +reg_def XMM23e( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(4)); +reg_def XMM23f( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(5)); +reg_def XMM23g( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(6)); +reg_def XMM23h( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(7)); +reg_def XMM23i( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(8)); +reg_def XMM23j( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(9)); +reg_def XMM23k( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(10)); +reg_def XMM23l( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(11)); +reg_def XMM23m( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(12)); +reg_def XMM23n( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(13)); +reg_def XMM23o( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(14)); +reg_def XMM23p( SOC, SOE, Op_RegF, 23, xmm23->as_VMReg()->next(15)); + +reg_def XMM24 ( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()); +reg_def XMM24b( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(1)); +reg_def XMM24c( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(2)); +reg_def XMM24d( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(3)); +reg_def XMM24e( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(4)); +reg_def XMM24f( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(5)); +reg_def XMM24g( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(6)); +reg_def XMM24h( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(7)); +reg_def XMM24i( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(8)); +reg_def XMM24j( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(9)); +reg_def XMM24k( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(10)); +reg_def XMM24l( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(11)); +reg_def XMM24m( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(12)); +reg_def XMM24n( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(13)); +reg_def XMM24o( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(14)); +reg_def XMM24p( SOC, SOE, Op_RegF, 24, xmm24->as_VMReg()->next(15)); + +reg_def XMM25 ( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()); +reg_def XMM25b( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(1)); +reg_def XMM25c( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(2)); +reg_def XMM25d( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(3)); +reg_def XMM25e( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(4)); +reg_def XMM25f( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(5)); +reg_def XMM25g( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(6)); +reg_def XMM25h( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(7)); +reg_def XMM25i( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(8)); +reg_def XMM25j( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(9)); +reg_def XMM25k( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(10)); +reg_def XMM25l( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(11)); +reg_def XMM25m( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(12)); +reg_def XMM25n( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(13)); +reg_def XMM25o( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(14)); +reg_def XMM25p( SOC, SOE, Op_RegF, 25, xmm25->as_VMReg()->next(15)); + +reg_def XMM26 ( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()); +reg_def XMM26b( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(1)); +reg_def XMM26c( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(2)); +reg_def XMM26d( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(3)); +reg_def XMM26e( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(4)); +reg_def XMM26f( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(5)); +reg_def XMM26g( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(6)); +reg_def XMM26h( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(7)); +reg_def XMM26i( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(8)); +reg_def XMM26j( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(9)); +reg_def XMM26k( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(10)); +reg_def XMM26l( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(11)); +reg_def XMM26m( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(12)); +reg_def XMM26n( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(13)); +reg_def XMM26o( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(14)); +reg_def XMM26p( SOC, SOE, Op_RegF, 26, xmm26->as_VMReg()->next(15)); + +reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(1)); +reg_def XMM27c( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(2)); +reg_def XMM27d( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(3)); +reg_def XMM27e( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(4)); +reg_def XMM27f( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(5)); +reg_def XMM27g( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(6)); +reg_def XMM27h( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(7)); +reg_def XMM27i( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(8)); +reg_def XMM27j( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(9)); +reg_def XMM27k( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(10)); +reg_def XMM27l( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(11)); +reg_def XMM27m( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(12)); +reg_def XMM27n( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(13)); +reg_def XMM27o( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(14)); +reg_def XMM27p( SOC, SOE, Op_RegF, 27, xmm27->as_VMReg()->next(15)); + +reg_def XMM28 ( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()); +reg_def XMM28b( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(1)); +reg_def XMM28c( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(2)); +reg_def XMM28d( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(3)); +reg_def XMM28e( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(4)); +reg_def XMM28f( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(5)); +reg_def XMM28g( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(6)); +reg_def XMM28h( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(7)); +reg_def XMM28i( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(8)); +reg_def XMM28j( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(9)); +reg_def XMM28k( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(10)); +reg_def XMM28l( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(11)); +reg_def XMM28m( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(12)); +reg_def XMM28n( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(13)); +reg_def XMM28o( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(14)); +reg_def XMM28p( SOC, SOE, Op_RegF, 28, xmm28->as_VMReg()->next(15)); + +reg_def XMM29 ( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()); +reg_def XMM29b( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(1)); +reg_def XMM29c( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(2)); +reg_def XMM29d( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(3)); +reg_def XMM29e( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(4)); +reg_def XMM29f( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(5)); +reg_def XMM29g( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(6)); +reg_def XMM29h( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(7)); +reg_def XMM29i( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(8)); +reg_def XMM29j( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(9)); +reg_def XMM29k( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(10)); +reg_def XMM29l( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(11)); +reg_def XMM29m( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(12)); +reg_def XMM29n( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(13)); +reg_def XMM29o( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(14)); +reg_def XMM29p( SOC, SOE, Op_RegF, 29, xmm29->as_VMReg()->next(15)); + +reg_def XMM30 ( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()); +reg_def XMM30b( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(1)); +reg_def XMM30c( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(2)); +reg_def XMM30d( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(3)); +reg_def XMM30e( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(4)); +reg_def XMM30f( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(5)); +reg_def XMM30g( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(6)); +reg_def XMM30h( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(7)); +reg_def XMM30i( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(8)); +reg_def XMM30j( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(9)); +reg_def XMM30k( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(10)); +reg_def XMM30l( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(11)); +reg_def XMM30m( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(12)); +reg_def XMM30n( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(13)); +reg_def XMM30o( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(14)); +reg_def XMM30p( SOC, SOE, Op_RegF, 30, xmm30->as_VMReg()->next(15)); + +reg_def XMM31 ( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()); +reg_def XMM31b( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(1)); +reg_def XMM31c( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(2)); +reg_def XMM31d( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(3)); +reg_def XMM31e( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(4)); +reg_def XMM31f( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(5)); +reg_def XMM31g( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(6)); +reg_def XMM31h( SOC, SOE, Op_RegF, 31, xmm31>-as_VMReg()->next(7)); +reg_def XMM31i( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(8)); +reg_def XMM31j( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(9)); +reg_def XMM31k( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(10)); +reg_def XMM31l( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(11)); +reg_def XMM31m( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(12)); +reg_def XMM31n( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(13)); +reg_def XMM31o( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(14)); +reg_def XMM31p( SOC, SOE, Op_RegF, 31, xmm31->as_VMReg()->next(15)); #else // _WIN64 @@ -226,6 +629,14 @@ reg_def XMM6e( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(4)); reg_def XMM6f( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(5)); reg_def XMM6g( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(6)); reg_def XMM6h( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(7)); +reg_def XMM6i( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(8)); +reg_def XMM6j( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(9)); +reg_def XMM6k( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(10)); +reg_def XMM6l( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(11)); +reg_def XMM6m( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(12)); +reg_def XMM6n( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(13)); +reg_def XMM6o( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(14)); +reg_def XMM6p( SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next(15)); reg_def XMM7 ( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()); reg_def XMM7b( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(1)); @@ -235,6 +646,14 @@ reg_def XMM7e( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(4)); reg_def XMM7f( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(5)); reg_def XMM7g( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(6)); reg_def XMM7h( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(7)); +reg_def XMM7i( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(8)); +reg_def XMM7j( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(9)); +reg_def XMM7k( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(10)); +reg_def XMM7l( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(11)); +reg_def XMM7m( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(12)); +reg_def XMM7n( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(13)); +reg_def XMM7o( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(14)); +reg_def XMM7p( SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next(15)); #ifdef _LP64 @@ -246,6 +665,14 @@ reg_def XMM8e( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(4)); reg_def XMM8f( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(5)); reg_def XMM8g( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(6)); reg_def XMM8h( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(7)); +reg_def XMM8i( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(8)); +reg_def XMM8j( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(9)); +reg_def XMM8k( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(10)); +reg_def XMM8l( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(11)); +reg_def XMM8m( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(12)); +reg_def XMM8n( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(13)); +reg_def XMM8o( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(14)); +reg_def XMM8p( SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next(15)); reg_def XMM9 ( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()); reg_def XMM9b( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(1)); @@ -255,6 +682,14 @@ reg_def XMM9e( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(4)); reg_def XMM9f( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(5)); reg_def XMM9g( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(6)); reg_def XMM9h( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(7)); +reg_def XMM9i( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(8)); +reg_def XMM9j( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(9)); +reg_def XMM9k( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(10)); +reg_def XMM9l( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(11)); +reg_def XMM9m( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(12)); +reg_def XMM9n( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(13)); +reg_def XMM9o( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(14)); +reg_def XMM9p( SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next(15)); reg_def XMM10 ( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()); reg_def XMM10b( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(1)); @@ -264,6 +699,14 @@ reg_def XMM10e( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(4)); reg_def XMM10f( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(5)); reg_def XMM10g( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(6)); reg_def XMM10h( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(7)); +reg_def XMM10i( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(8)); +reg_def XMM10j( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(9)); +reg_def XMM10k( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(10)); +reg_def XMM10l( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(11)); +reg_def XMM10m( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(12)); +reg_def XMM10n( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(13)); +reg_def XMM10o( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(14)); +reg_def XMM10p( SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next(15)); reg_def XMM11 ( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()); reg_def XMM11b( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(1)); @@ -273,6 +716,14 @@ reg_def XMM11e( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(4)); reg_def XMM11f( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(5)); reg_def XMM11g( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(6)); reg_def XMM11h( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(7)); +reg_def XMM11i( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(8)); +reg_def XMM11j( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(9)); +reg_def XMM11k( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(10)); +reg_def XMM11l( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(11)); +reg_def XMM11m( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(12)); +reg_def XMM11n( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(13)); +reg_def XMM11o( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(14)); +reg_def XMM11p( SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next(15)); reg_def XMM12 ( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()); reg_def XMM12b( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(1)); @@ -282,6 +733,14 @@ reg_def XMM12e( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(4)); reg_def XMM12f( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(5)); reg_def XMM12g( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(6)); reg_def XMM12h( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(7)); +reg_def XMM12i( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(8)); +reg_def XMM12j( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(9)); +reg_def XMM12k( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(10)); +reg_def XMM12l( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(11)); +reg_def XMM12m( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(12)); +reg_def XMM12n( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(13)); +reg_def XMM12o( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(14)); +reg_def XMM12p( SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next(15)); reg_def XMM13 ( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()); reg_def XMM13b( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(1)); @@ -291,6 +750,14 @@ reg_def XMM13e( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(4)); reg_def XMM13f( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(5)); reg_def XMM13g( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(6)); reg_def XMM13h( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(7)); +reg_def XMM13i( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(8)); +reg_def XMM13j( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(9)); +reg_def XMM13k( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(10)); +reg_def XMM13l( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(11)); +reg_def XMM13m( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(12)); +reg_def XMM13n( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(13)); +reg_def XMM13o( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(14)); +reg_def XMM13p( SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next(15)); reg_def XMM14 ( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()); reg_def XMM14b( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(1)); @@ -300,6 +767,14 @@ reg_def XMM14e( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(4)); reg_def XMM14f( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(5)); reg_def XMM14g( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(6)); reg_def XMM14h( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(7)); +reg_def XMM14i( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(8)); +reg_def XMM14j( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(9)); +reg_def XMM14k( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(10)); +reg_def XMM14l( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(11)); +reg_def XMM14m( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(12)); +reg_def XMM14n( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(13)); +reg_def XMM14o( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(14)); +reg_def XMM14p( SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next(15)); reg_def XMM15 ( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()); reg_def XMM15b( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(1)); @@ -309,6 +784,286 @@ reg_def XMM15e( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(4)); reg_def XMM15f( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(5)); reg_def XMM15g( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(6)); reg_def XMM15h( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(7)); +reg_def XMM15i( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(8)); +reg_def XMM15j( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(9)); +reg_def XMM15k( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(10)); +reg_def XMM15l( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(11)); +reg_def XMM15m( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(12)); +reg_def XMM15n( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(13)); +reg_def XMM15o( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(14)); +reg_def XMM15p( SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next(15)); + +reg_def XMM16 ( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()); +reg_def XMM16b( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(1)); +reg_def XMM16c( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(2)); +reg_def XMM16d( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(3)); +reg_def XMM16e( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(4)); +reg_def XMM16f( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(5)); +reg_def XMM16g( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(6)); +reg_def XMM16h( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(7)); +reg_def XMM16i( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(8)); +reg_def XMM16j( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(9)); +reg_def XMM16k( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(10)); +reg_def XMM16l( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(11)); +reg_def XMM16m( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(12)); +reg_def XMM16n( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(13)); +reg_def XMM16o( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(14)); +reg_def XMM16p( SOC, SOC, Op_RegF, 16, xmm16->as_VMReg()->next(15)); + +reg_def XMM17 ( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()); +reg_def XMM17b( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(1)); +reg_def XMM17c( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(2)); +reg_def XMM17d( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(3)); +reg_def XMM17e( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(4)); +reg_def XMM17f( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(5)); +reg_def XMM17g( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(6)); +reg_def XMM17h( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(7)); +reg_def XMM17i( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(8)); +reg_def XMM17j( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(9)); +reg_def XMM17k( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(10)); +reg_def XMM17l( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(11)); +reg_def XMM17m( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(12)); +reg_def XMM17n( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(13)); +reg_def XMM17o( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(14)); +reg_def XMM17p( SOC, SOC, Op_RegF, 17, xmm17->as_VMReg()->next(15)); + +reg_def XMM18 ( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()); +reg_def XMM18b( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(1)); +reg_def XMM18c( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(2)); +reg_def XMM18d( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(3)); +reg_def XMM18e( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(4)); +reg_def XMM18f( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(5)); +reg_def XMM18g( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(6)); +reg_def XMM18h( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(7)); +reg_def XMM18i( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(8)); +reg_def XMM18j( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(9)); +reg_def XMM18k( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(10)); +reg_def XMM18l( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(11)); +reg_def XMM18m( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(12)); +reg_def XMM18n( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(13)); +reg_def XMM18o( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(14)); +reg_def XMM18p( SOC, SOC, Op_RegF, 18, xmm18->as_VMReg()->next(15)); + +reg_def XMM19 ( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()); +reg_def XMM19b( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(1)); +reg_def XMM19c( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(2)); +reg_def XMM19d( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(3)); +reg_def XMM19e( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(4)); +reg_def XMM19f( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(5)); +reg_def XMM19g( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(6)); +reg_def XMM19h( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(7)); +reg_def XMM19i( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(8)); +reg_def XMM19j( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(9)); +reg_def XMM19k( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(10)); +reg_def XMM19l( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(11)); +reg_def XMM19m( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(12)); +reg_def XMM19n( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(13)); +reg_def XMM19o( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(14)); +reg_def XMM19p( SOC, SOC, Op_RegF, 19, xmm19->as_VMReg()->next(15)); + +reg_def XMM20 ( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()); +reg_def XMM20b( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(1)); +reg_def XMM20c( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(2)); +reg_def XMM20d( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(3)); +reg_def XMM20e( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(4)); +reg_def XMM20f( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(5)); +reg_def XMM20g( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(6)); +reg_def XMM20h( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(7)); +reg_def XMM20i( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(8)); +reg_def XMM20j( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(9)); +reg_def XMM20k( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(10)); +reg_def XMM20l( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(11)); +reg_def XMM20m( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(12)); +reg_def XMM20n( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(13)); +reg_def XMM20o( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(14)); +reg_def XMM20p( SOC, SOC, Op_RegF, 20, xmm20->as_VMReg()->next(15)); + +reg_def XMM21 ( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()); +reg_def XMM21b( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(1)); +reg_def XMM21c( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(2)); +reg_def XMM21d( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(3)); +reg_def XMM21e( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(4)); +reg_def XMM21f( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(5)); +reg_def XMM21g( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(6)); +reg_def XMM21h( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(7)); +reg_def XMM21i( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(8)); +reg_def XMM21j( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(9)); +reg_def XMM21k( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(10)); +reg_def XMM21l( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(11)); +reg_def XMM21m( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(12)); +reg_def XMM21n( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(13)); +reg_def XMM21o( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(14)); +reg_def XMM21p( SOC, SOC, Op_RegF, 21, xmm21->as_VMReg()->next(15)); + +reg_def XMM22 ( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()); +reg_def XMM22b( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(1)); +reg_def XMM22c( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(2)); +reg_def XMM22d( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(3)); +reg_def XMM22e( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(4)); +reg_def XMM22f( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(5)); +reg_def XMM22g( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(6)); +reg_def XMM22h( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(7)); +reg_def XMM22i( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(8)); +reg_def XMM22j( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(9)); +reg_def XMM22k( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(10)); +reg_def XMM22l( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(11)); +reg_def XMM22m( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(12)); +reg_def XMM22n( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(13)); +reg_def XMM22o( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(14)); +reg_def XMM22p( SOC, SOC, Op_RegF, 22, xmm22->as_VMReg()->next(15)); + +reg_def XMM23 ( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()); +reg_def XMM23b( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(1)); +reg_def XMM23c( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(2)); +reg_def XMM23d( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(3)); +reg_def XMM23e( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(4)); +reg_def XMM23f( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(5)); +reg_def XMM23g( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(6)); +reg_def XMM23h( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(7)); +reg_def XMM23i( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(8)); +reg_def XMM23j( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(9)); +reg_def XMM23k( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(10)); +reg_def XMM23l( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(11)); +reg_def XMM23m( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(12)); +reg_def XMM23n( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(13)); +reg_def XMM23o( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(14)); +reg_def XMM23p( SOC, SOC, Op_RegF, 23, xmm23->as_VMReg()->next(15)); + +reg_def XMM24 ( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()); +reg_def XMM24b( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(1)); +reg_def XMM24c( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(2)); +reg_def XMM24d( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(3)); +reg_def XMM24e( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(4)); +reg_def XMM24f( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(5)); +reg_def XMM24g( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(6)); +reg_def XMM24h( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(7)); +reg_def XMM24i( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(8)); +reg_def XMM24j( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(9)); +reg_def XMM24k( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(10)); +reg_def XMM24l( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(11)); +reg_def XMM24m( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(12)); +reg_def XMM24n( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(13)); +reg_def XMM24o( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(14)); +reg_def XMM24p( SOC, SOC, Op_RegF, 24, xmm24->as_VMReg()->next(15)); + +reg_def XMM25 ( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()); +reg_def XMM25b( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(1)); +reg_def XMM25c( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(2)); +reg_def XMM25d( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(3)); +reg_def XMM25e( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(4)); +reg_def XMM25f( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(5)); +reg_def XMM25g( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(6)); +reg_def XMM25h( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(7)); +reg_def XMM25i( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(8)); +reg_def XMM25j( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(9)); +reg_def XMM25k( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(10)); +reg_def XMM25l( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(11)); +reg_def XMM25m( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(12)); +reg_def XMM25n( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(13)); +reg_def XMM25o( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(14)); +reg_def XMM25p( SOC, SOC, Op_RegF, 25, xmm25->as_VMReg()->next(15)); + +reg_def XMM26 ( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()); +reg_def XMM26b( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(1)); +reg_def XMM26c( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(2)); +reg_def XMM26d( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(3)); +reg_def XMM26e( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(4)); +reg_def XMM26f( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(5)); +reg_def XMM26g( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(6)); +reg_def XMM26h( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(7)); +reg_def XMM26i( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(8)); +reg_def XMM26j( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(9)); +reg_def XMM26k( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(10)); +reg_def XMM26l( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(11)); +reg_def XMM26m( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(12)); +reg_def XMM26n( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(13)); +reg_def XMM26o( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(14)); +reg_def XMM26p( SOC, SOC, Op_RegF, 26, xmm26->as_VMReg()->next(15)); + +reg_def XMM27 ( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()); +reg_def XMM27b( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(1)); +reg_def XMM27c( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(2)); +reg_def XMM27d( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(3)); +reg_def XMM27e( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(4)); +reg_def XMM27f( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(5)); +reg_def XMM27g( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(6)); +reg_def XMM27h( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(7)); +reg_def XMM27i( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(8)); +reg_def XMM27j( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(9)); +reg_def XMM27k( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(10)); +reg_def XMM27l( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(11)); +reg_def XMM27m( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(12)); +reg_def XMM27n( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(13)); +reg_def XMM27o( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(14)); +reg_def XMM27p( SOC, SOC, Op_RegF, 27, xmm27->as_VMReg()->next(15)); + +reg_def XMM28 ( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()); +reg_def XMM28b( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(1)); +reg_def XMM28c( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(2)); +reg_def XMM28d( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(3)); +reg_def XMM28e( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(4)); +reg_def XMM28f( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(5)); +reg_def XMM28g( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(6)); +reg_def XMM28h( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(7)); +reg_def XMM28i( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(8)); +reg_def XMM28j( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(9)); +reg_def XMM28k( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(10)); +reg_def XMM28l( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(11)); +reg_def XMM28m( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(12)); +reg_def XMM28n( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(13)); +reg_def XMM28o( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(14)); +reg_def XMM28p( SOC, SOC, Op_RegF, 28, xmm28->as_VMReg()->next(15)); + +reg_def XMM29 ( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()); +reg_def XMM29b( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(1)); +reg_def XMM29c( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(2)); +reg_def XMM29d( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(3)); +reg_def XMM29e( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(4)); +reg_def XMM29f( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(5)); +reg_def XMM29g( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(6)); +reg_def XMM29h( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(7)); +reg_def XMM29i( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(8)); +reg_def XMM29j( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(9)); +reg_def XMM29k( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(10)); +reg_def XMM29l( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(11)); +reg_def XMM29m( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(12)); +reg_def XMM29n( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(13)); +reg_def XMM29o( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(14)); +reg_def XMM29p( SOC, SOC, Op_RegF, 29, xmm29->as_VMReg()->next(15)); + +reg_def XMM30 ( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()); +reg_def XMM30b( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(1)); +reg_def XMM30c( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(2)); +reg_def XMM30d( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(3)); +reg_def XMM30e( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(4)); +reg_def XMM30f( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(5)); +reg_def XMM30g( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(6)); +reg_def XMM30h( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(7)); +reg_def XMM30i( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(8)); +reg_def XMM30j( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(9)); +reg_def XMM30k( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(10)); +reg_def XMM30l( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(11)); +reg_def XMM30m( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(12)); +reg_def XMM30n( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(13)); +reg_def XMM30o( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(14)); +reg_def XMM30p( SOC, SOC, Op_RegF, 30, xmm30->as_VMReg()->next(15)); + +reg_def XMM31 ( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()); +reg_def XMM31b( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(1)); +reg_def XMM31c( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(2)); +reg_def XMM31d( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(3)); +reg_def XMM31e( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(4)); +reg_def XMM31f( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(5)); +reg_def XMM31g( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(6)); +reg_def XMM31h( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(7)); +reg_def XMM31i( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(8)); +reg_def XMM31j( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(9)); +reg_def XMM31k( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(10)); +reg_def XMM31l( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(11)); +reg_def XMM31m( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(12)); +reg_def XMM31n( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(13)); +reg_def XMM31o( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(14)); +reg_def XMM31p( SOC, SOC, Op_RegF, 31, xmm31->as_VMReg()->next(15)); #endif // _LP64 @@ -320,25 +1075,41 @@ reg_def RFLAGS(SOC, SOC, 0, 16, VMRegImpl::Bad()); reg_def RFLAGS(SOC, SOC, 0, 8, VMRegImpl::Bad()); #endif // _LP64 -alloc_class chunk1(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, - XMM1, XMM1b, XMM1c, XMM1d, XMM1e, XMM1f, XMM1g, XMM1h, - XMM2, XMM2b, XMM2c, XMM2d, XMM2e, XMM2f, XMM2g, XMM2h, - XMM3, XMM3b, XMM3c, XMM3d, XMM3e, XMM3f, XMM3g, XMM3h, - XMM4, XMM4b, XMM4c, XMM4d, XMM4e, XMM4f, XMM4g, XMM4h, - XMM5, XMM5b, XMM5c, XMM5d, XMM5e, XMM5f, XMM5g, XMM5h, - XMM6, XMM6b, XMM6c, XMM6d, XMM6e, XMM6f, XMM6g, XMM6h, - XMM7, XMM7b, XMM7c, XMM7d, XMM7e, XMM7f, XMM7g, XMM7h +alloc_class chunk1(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, XMM0i, XMM0j, XMM0k, XMM0l, XMM0m, XMM0n, XMM0o, XMM0p, + XMM1, XMM1b, XMM1c, XMM1d, XMM1e, XMM1f, XMM1g, XMM1h, XMM1i, XMM1j, XMM1k, XMM1l, XMM1m, XMM1n, XMM1o, XMM1p, + XMM2, XMM2b, XMM2c, XMM2d, XMM2e, XMM2f, XMM2g, XMM2h, XMM2i, XMM2j, XMM2k, XMM2l, XMM2m, XMM2n, XMM2o, XMM2p, + XMM3, XMM3b, XMM3c, XMM3d, XMM3e, XMM3f, XMM3g, XMM3h, XMM3i, XMM3j, XMM3k, XMM3l, XMM3m, XMM3n, XMM3o, XMM3p, + XMM4, XMM4b, XMM4c, XMM4d, XMM4e, XMM4f, XMM4g, XMM4h, XMM4i, XMM4j, XMM4k, XMM4l, XMM4m, XMM4n, XMM4o, XMM4p, + XMM5, XMM5b, XMM5c, XMM5d, XMM5e, XMM5f, XMM5g, XMM5h, XMM5i, XMM5j, XMM5k, XMM5l, XMM5m, XMM5n, XMM5o, XMM5p, + XMM6, XMM6b, XMM6c, XMM6d, XMM6e, XMM6f, XMM6g, XMM6h, XMM6i, XMM6j, XMM6k, XMM6l, XMM6m, XMM6n, XMM6o, XMM6p, + XMM7, XMM7b, XMM7c, XMM7d, XMM7e, XMM7f, XMM7g, XMM7h, XMM7i, XMM7j, XMM7k, XMM7l, XMM7m, XMM7n, XMM7o, XMM7p #ifdef _LP64 - ,XMM8, XMM8b, XMM8c, XMM8d, XMM8e, XMM8f, XMM8g, XMM8h, - XMM9, XMM9b, XMM9c, XMM9d, XMM9e, XMM9f, XMM9g, XMM9h, - XMM10, XMM10b, XMM10c, XMM10d, XMM10e, XMM10f, XMM10g, XMM10h, - XMM11, XMM11b, XMM11c, XMM11d, XMM11e, XMM11f, XMM11g, XMM11h, - XMM12, XMM12b, XMM12c, XMM12d, XMM12e, XMM12f, XMM12g, XMM12h, - XMM13, XMM13b, XMM13c, XMM13d, XMM13e, XMM13f, XMM13g, XMM13h, - XMM14, XMM14b, XMM14c, XMM14d, XMM14e, XMM14f, XMM14g, XMM14h, - XMM15, XMM15b, XMM15c, XMM15d, XMM15e, XMM15f, XMM15g, XMM15h + ,XMM8, XMM8b, XMM8c, XMM8d, XMM8e, XMM8f, XMM8g, XMM8h, XMM8i, XMM8j, XMM8k, XMM8l, XMM8m, XMM8n, XMM8o, XMM8p, + XMM9, XMM9b, XMM9c, XMM9d, XMM9e, XMM9f, XMM9g, XMM9h, XMM9i, XMM9j, XMM9k, XMM9l, XMM9m, XMM9n, XMM9o, XMM9p, + XMM10, XMM10b, XMM10c, XMM10d, XMM10e, XMM10f, XMM10g, XMM10h, XMM10i, XMM10j, XMM10k, XMM10l, XMM10m, XMM10n, XMM10o, XMM10p, + XMM11, XMM11b, XMM11c, XMM11d, XMM11e, XMM11f, XMM11g, XMM11h, XMM11i, XMM11j, XMM11k, XMM11l, XMM11m, XMM11n, XMM11o, XMM11p, + XMM12, XMM12b, XMM12c, XMM12d, XMM12e, XMM12f, XMM12g, XMM12h, XMM12i, XMM12j, XMM12k, XMM12l, XMM12m, XMM12n, XMM12o, XMM12p, + XMM13, XMM13b, XMM13c, XMM13d, XMM13e, XMM13f, XMM13g, XMM13h, XMM13i, XMM13j, XMM13k, XMM13l, XMM13m, XMM13n, XMM13o, XMM13p, + XMM14, XMM14b, XMM14c, XMM14d, XMM14e, XMM14f, XMM14g, XMM14h, XMM14i, XMM14j, XMM14k, XMM14l, XMM14m, XMM14n, XMM14o, XMM14p, + XMM15, XMM15b, XMM15c, XMM15d, XMM15e, XMM15f, XMM15g, XMM15h, XMM15i, XMM15j, XMM15k, XMM15l, XMM15m, XMM15n, XMM15o, XMM15p + ,XMM16, XMM16b, XMM16c, XMM16d, XMM16e, XMM16f, XMM16g, XMM16h, XMM16i, XMM16j, XMM16k, XMM16l, XMM16m, XMM16n, XMM16o, XMM16p, + XMM17, XMM17b, XMM17c, XMM17d, XMM17e, XMM17f, XMM17g, XMM17h, XMM17i, XMM17j, XMM17k, XMM17l, XMM17m, XMM17n, XMM17o, XMM17p, + XMM18, XMM18b, XMM18c, XMM18d, XMM18e, XMM18f, XMM18g, XMM18h, XMM18i, XMM18j, XMM18k, XMM18l, XMM18m, XMM18n, XMM18o, XMM18p, + XMM19, XMM19b, XMM19c, XMM19d, XMM19e, XMM19f, XMM19g, XMM19h, XMM19i, XMM19j, XMM19k, XMM19l, XMM19m, XMM19n, XMM19o, XMM19p, + XMM20, XMM20b, XMM20c, XMM20d, XMM20e, XMM20f, XMM20g, XMM20h, XMM20i, XMM20j, XMM20k, XMM20l, XMM20m, XMM20n, XMM20o, XMM20p, + XMM21, XMM21b, XMM21c, XMM21d, XMM21e, XMM21f, XMM21g, XMM21h, XMM21i, XMM21j, XMM21k, XMM21l, XMM21m, XMM21n, XMM21o, XMM21p, + XMM22, XMM22b, XMM22c, XMM22d, XMM22e, XMM22f, XMM22g, XMM22h, XMM22i, XMM22j, XMM22k, XMM22l, XMM22m, XMM22n, XMM22o, XMM22p, + XMM23, XMM23b, XMM23c, XMM23d, XMM23e, XMM23f, XMM23g, XMM23h, XMM23i, XMM23j, XMM23k, XMM23l, XMM23m, XMM23n, XMM23o, XMM23p, + XMM24, XMM24b, XMM24c, XMM24d, XMM24e, XMM24f, XMM24g, XMM24h, XMM24i, XMM24j, XMM24k, XMM24l, XMM24m, XMM24n, XMM24o, XMM24p, + XMM25, XMM25b, XMM25c, XMM25d, XMM25e, XMM25f, XMM25g, XMM25h, XMM25i, XMM25j, XMM25k, XMM25l, XMM25m, XMM25n, XMM25o, XMM25p, + XMM26, XMM26b, XMM26c, XMM26d, XMM26e, XMM26f, XMM26g, XMM26h, XMM26i, XMM26j, XMM26k, XMM26l, XMM26m, XMM26n, XMM26o, XMM26p, + XMM27, XMM27b, XMM27c, XMM27d, XMM27e, XMM27f, XMM27g, XMM27h, XMM27i, XMM27j, XMM27k, XMM27l, XMM27m, XMM27n, XMM27o, XMM27p, + XMM28, XMM28b, XMM28c, XMM28d, XMM28e, XMM28f, XMM28g, XMM28h, XMM28i, XMM28j, XMM28k, XMM28l, XMM28m, XMM28n, XMM28o, XMM28p, + XMM29, XMM29b, XMM29c, XMM29d, XMM29e, XMM29f, XMM29g, XMM29h, XMM29i, XMM29j, XMM29k, XMM29l, XMM29m, XMM29n, XMM29o, XMM29p, + XMM30, XMM30b, XMM30c, XMM30d, XMM30e, XMM30f, XMM30g, XMM30h, XMM30i, XMM30j, XMM30k, XMM30l, XMM30m, XMM30n, XMM30o, XMM30p, + XMM31, XMM31b, XMM31c, XMM31d, XMM31e, XMM31f, XMM31g, XMM31h, XMM31i, XMM31j, XMM31k, XMM31l, XMM31m, XMM31n, XMM31o, XMM31p #endif - ); + ); // flags allocation class should be last. alloc_class chunk2(RFLAGS); @@ -346,8 +1117,8 @@ alloc_class chunk2(RFLAGS); // Singleton class for condition codes reg_class int_flags(RFLAGS); -// Class for all float registers -reg_class float_reg(XMM0, +// Class for pre evex float registers +reg_class float_reg_legacy(XMM0, XMM1, XMM2, XMM3, @@ -367,8 +1138,47 @@ reg_class float_reg(XMM0, #endif ); -// Class for all double registers -reg_class double_reg(XMM0, XMM0b, +// Class for evex float registers +reg_class float_reg_evex(XMM0, + XMM1, + XMM2, + XMM3, + XMM4, + XMM5, + XMM6, + XMM7 +#ifdef _LP64 + ,XMM8, + XMM9, + XMM10, + XMM11, + XMM12, + XMM13, + XMM14, + XMM15, + XMM16, + XMM17, + XMM18, + XMM19, + XMM20, + XMM21, + XMM22, + XMM23, + XMM24, + XMM25, + XMM26, + XMM27, + XMM28, + XMM29, + XMM30, + XMM31 +#endif + ); + +reg_class_dynamic float_reg(float_reg_evex, float_reg_legacy, %{ VM_Version::supports_evex() %} ); + +// Class for pre evex double registers +reg_class double_reg_legacy(XMM0, XMM0b, XMM1, XMM1b, XMM2, XMM2b, XMM3, XMM3b, @@ -388,8 +1198,47 @@ reg_class double_reg(XMM0, XMM0b, #endif ); -// Class for all 32bit vector registers -reg_class vectors_reg(XMM0, +// Class for evex double registers +reg_class double_reg_evex(XMM0, XMM0b, + XMM1, XMM1b, + XMM2, XMM2b, + XMM3, XMM3b, + XMM4, XMM4b, + XMM5, XMM5b, + XMM6, XMM6b, + XMM7, XMM7b +#ifdef _LP64 + ,XMM8, XMM8b, + XMM9, XMM9b, + XMM10, XMM10b, + XMM11, XMM11b, + XMM12, XMM12b, + XMM13, XMM13b, + XMM14, XMM14b, + XMM15, XMM15b, + XMM16, XMM16b, + XMM17, XMM17b, + XMM18, XMM18b, + XMM19, XMM19b, + XMM20, XMM20b, + XMM21, XMM21b, + XMM22, XMM22b, + XMM23, XMM23b, + XMM24, XMM24b, + XMM25, XMM25b, + XMM26, XMM26b, + XMM27, XMM27b, + XMM28, XMM28b, + XMM29, XMM29b, + XMM30, XMM30b, + XMM31, XMM31b +#endif + ); + +reg_class_dynamic double_reg(double_reg_evex, double_reg_legacy, %{ VM_Version::supports_evex() %} ); + +// Class for pre evex 32bit vector registers +reg_class vectors_reg_legacy(XMM0, XMM1, XMM2, XMM3, @@ -409,8 +1258,47 @@ reg_class vectors_reg(XMM0, #endif ); +// Class for evex 32bit vector registers +reg_class vectors_reg_evex(XMM0, + XMM1, + XMM2, + XMM3, + XMM4, + XMM5, + XMM6, + XMM7 +#ifdef _LP64 + ,XMM8, + XMM9, + XMM10, + XMM11, + XMM12, + XMM13, + XMM14, + XMM15, + XMM16, + XMM17, + XMM18, + XMM19, + XMM20, + XMM21, + XMM22, + XMM23, + XMM24, + XMM25, + XMM26, + XMM27, + XMM28, + XMM29, + XMM30, + XMM31 +#endif + ); + +reg_class_dynamic vectors_reg(vectors_reg_evex, vectors_reg_legacy, %{ VM_Version::supports_evex() %} ); + // Class for all 64bit vector registers -reg_class vectord_reg(XMM0, XMM0b, +reg_class vectord_reg_legacy(XMM0, XMM0b, XMM1, XMM1b, XMM2, XMM2b, XMM3, XMM3b, @@ -430,8 +1318,47 @@ reg_class vectord_reg(XMM0, XMM0b, #endif ); +// Class for all 64bit vector registers +reg_class vectord_reg_evex(XMM0, XMM0b, + XMM1, XMM1b, + XMM2, XMM2b, + XMM3, XMM3b, + XMM4, XMM4b, + XMM5, XMM5b, + XMM6, XMM6b, + XMM7, XMM7b +#ifdef _LP64 + ,XMM8, XMM8b, + XMM9, XMM9b, + XMM10, XMM10b, + XMM11, XMM11b, + XMM12, XMM12b, + XMM13, XMM13b, + XMM14, XMM14b, + XMM15, XMM15b, + XMM16, XMM16b, + XMM17, XMM17b, + XMM18, XMM18b, + XMM19, XMM19b, + XMM20, XMM20b, + XMM21, XMM21b, + XMM22, XMM22b, + XMM23, XMM23b, + XMM24, XMM24b, + XMM25, XMM25b, + XMM26, XMM26b, + XMM27, XMM27b, + XMM28, XMM28b, + XMM29, XMM29b, + XMM30, XMM30b, + XMM31, XMM31b +#endif + ); + +reg_class_dynamic vectord_reg(vectord_reg_evex, vectord_reg_legacy, %{ VM_Version::supports_evex() %} ); + // Class for all 128bit vector registers -reg_class vectorx_reg(XMM0, XMM0b, XMM0c, XMM0d, +reg_class vectorx_reg_legacy(XMM0, XMM0b, XMM0c, XMM0d, XMM1, XMM1b, XMM1c, XMM1d, XMM2, XMM2b, XMM2c, XMM2d, XMM3, XMM3b, XMM3c, XMM3d, @@ -451,8 +1378,47 @@ reg_class vectorx_reg(XMM0, XMM0b, XMM0c, XMM0d, #endif ); +// Class for all 128bit vector registers +reg_class vectorx_reg_evex(XMM0, XMM0b, XMM0c, XMM0d, + XMM1, XMM1b, XMM1c, XMM1d, + XMM2, XMM2b, XMM2c, XMM2d, + XMM3, XMM3b, XMM3c, XMM3d, + XMM4, XMM4b, XMM4c, XMM4d, + XMM5, XMM5b, XMM5c, XMM5d, + XMM6, XMM6b, XMM6c, XMM6d, + XMM7, XMM7b, XMM7c, XMM7d +#ifdef _LP64 + ,XMM8, XMM8b, XMM8c, XMM8d, + XMM9, XMM9b, XMM9c, XMM9d, + XMM10, XMM10b, XMM10c, XMM10d, + XMM11, XMM11b, XMM11c, XMM11d, + XMM12, XMM12b, XMM12c, XMM12d, + XMM13, XMM13b, XMM13c, XMM13d, + XMM14, XMM14b, XMM14c, XMM14d, + XMM15, XMM15b, XMM15c, XMM15d, + XMM16, XMM16b, XMM16c, XMM16d, + XMM17, XMM17b, XMM17c, XMM17d, + XMM18, XMM18b, XMM18c, XMM18d, + XMM19, XMM19b, XMM19c, XMM19d, + XMM20, XMM20b, XMM20c, XMM20d, + XMM21, XMM21b, XMM21c, XMM21d, + XMM22, XMM22b, XMM22c, XMM22d, + XMM23, XMM23b, XMM23c, XMM23d, + XMM24, XMM24b, XMM24c, XMM24d, + XMM25, XMM25b, XMM25c, XMM25d, + XMM26, XMM26b, XMM26c, XMM26d, + XMM27, XMM27b, XMM27c, XMM27d, + XMM28, XMM28b, XMM28c, XMM28d, + XMM29, XMM29b, XMM29c, XMM29d, + XMM30, XMM30b, XMM30c, XMM30d, + XMM31, XMM31b, XMM31c, XMM31d +#endif + ); + +reg_class_dynamic vectorx_reg(vectorx_reg_evex, vectorx_reg_legacy, %{ VM_Version::supports_evex() %} ); + // Class for all 256bit vector registers -reg_class vectory_reg(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, +reg_class vectory_reg_legacy(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, XMM1, XMM1b, XMM1c, XMM1d, XMM1e, XMM1f, XMM1g, XMM1h, XMM2, XMM2b, XMM2c, XMM2d, XMM2e, XMM2f, XMM2g, XMM2h, XMM3, XMM3b, XMM3c, XMM3d, XMM3e, XMM3f, XMM3g, XMM3h, @@ -472,6 +1438,82 @@ reg_class vectory_reg(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM #endif ); +// Class for all 256bit vector registers +reg_class vectory_reg_evex(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, + XMM1, XMM1b, XMM1c, XMM1d, XMM1e, XMM1f, XMM1g, XMM1h, + XMM2, XMM2b, XMM2c, XMM2d, XMM2e, XMM2f, XMM2g, XMM2h, + XMM3, XMM3b, XMM3c, XMM3d, XMM3e, XMM3f, XMM3g, XMM3h, + XMM4, XMM4b, XMM4c, XMM4d, XMM4e, XMM4f, XMM4g, XMM4h, + XMM5, XMM5b, XMM5c, XMM5d, XMM5e, XMM5f, XMM5g, XMM5h, + XMM6, XMM6b, XMM6c, XMM6d, XMM6e, XMM6f, XMM6g, XMM6h, + XMM7, XMM7b, XMM7c, XMM7d, XMM7e, XMM7f, XMM7g, XMM7h +#ifdef _LP64 + ,XMM8, XMM8b, XMM8c, XMM8d, XMM8e, XMM8f, XMM8g, XMM8h, + XMM9, XMM9b, XMM9c, XMM9d, XMM9e, XMM9f, XMM9g, XMM9h, + XMM10, XMM10b, XMM10c, XMM10d, XMM10e, XMM10f, XMM10g, XMM10h, + XMM11, XMM11b, XMM11c, XMM11d, XMM11e, XMM11f, XMM11g, XMM11h, + XMM12, XMM12b, XMM12c, XMM12d, XMM12e, XMM12f, XMM12g, XMM12h, + XMM13, XMM13b, XMM13c, XMM13d, XMM13e, XMM13f, XMM13g, XMM13h, + XMM14, XMM14b, XMM14c, XMM14d, XMM14e, XMM14f, XMM14g, XMM14h, + XMM15, XMM15b, XMM15c, XMM15d, XMM15e, XMM15f, XMM15g, XMM15h, + XMM16, XMM16b, XMM16c, XMM16d, XMM16e, XMM16f, XMM16g, XMM16h, + XMM17, XMM17b, XMM17c, XMM17d, XMM17e, XMM17f, XMM17g, XMM17h, + XMM18, XMM18b, XMM18c, XMM18d, XMM18e, XMM18f, XMM18g, XMM18h, + XMM19, XMM19b, XMM19c, XMM19d, XMM19e, XMM19f, XMM19g, XMM19h, + XMM20, XMM20b, XMM20c, XMM20d, XMM20e, XMM20f, XMM20g, XMM20h, + XMM21, XMM21b, XMM21c, XMM21d, XMM21e, XMM21f, XMM21g, XMM21h, + XMM22, XMM22b, XMM22c, XMM22d, XMM22e, XMM22f, XMM22g, XMM22h, + XMM23, XMM23b, XMM23c, XMM23d, XMM23e, XMM23f, XMM23g, XMM23h, + XMM24, XMM24b, XMM24c, XMM24d, XMM24e, XMM24f, XMM24g, XMM24h, + XMM25, XMM25b, XMM25c, XMM25d, XMM25e, XMM25f, XMM25g, XMM25h, + XMM26, XMM26b, XMM26c, XMM26d, XMM26e, XMM26f, XMM26g, XMM26h, + XMM27, XMM27b, XMM27c, XMM27d, XMM27e, XMM27f, XMM27g, XMM27h, + XMM28, XMM28b, XMM28c, XMM28d, XMM28e, XMM28f, XMM28g, XMM28h, + XMM29, XMM29b, XMM29c, XMM29d, XMM29e, XMM29f, XMM29g, XMM29h, + XMM30, XMM30b, XMM30c, XMM30d, XMM30e, XMM30f, XMM30g, XMM30h, + XMM31, XMM31b, XMM31c, XMM31d, XMM31e, XMM31f, XMM31g, XMM31h +#endif + ); + +reg_class_dynamic vectory_reg(vectory_reg_evex, vectory_reg_legacy, %{ VM_Version::supports_evex() %} ); + +// Class for all 512bit vector registers +reg_class vectorz_reg(XMM0, XMM0b, XMM0c, XMM0d, XMM0e, XMM0f, XMM0g, XMM0h, XMM0i, XMM0j, XMM0k, XMM0l, XMM0m, XMM0n, XMM0o, XMM0p, + XMM1, XMM1b, XMM1c, XMM1d, XMM1e, XMM1f, XMM1g, XMM1h, XMM1i, XMM1j, XMM1k, XMM1l, XMM1m, XMM1n, XMM1o, XMM1p, + XMM2, XMM2b, XMM2c, XMM2d, XMM2e, XMM2f, XMM2g, XMM2h, XMM2i, XMM2j, XMM2k, XMM2l, XMM2m, XMM2n, XMM2o, XMM2p, + XMM3, XMM3b, XMM3c, XMM3d, XMM3e, XMM3f, XMM3g, XMM3h, XMM3i, XMM3j, XMM3k, XMM3l, XMM3m, XMM3n, XMM3o, XMM3p, + XMM4, XMM4b, XMM4c, XMM4d, XMM4e, XMM4f, XMM4g, XMM4h, XMM4i, XMM4j, XMM4k, XMM4l, XMM4m, XMM4n, XMM4o, XMM4p, + XMM5, XMM5b, XMM5c, XMM5d, XMM5e, XMM5f, XMM5g, XMM5h, XMM5i, XMM5j, XMM5k, XMM5l, XMM5m, XMM5n, XMM5o, XMM5p, + XMM6, XMM6b, XMM6c, XMM6d, XMM6e, XMM6f, XMM6g, XMM6h, XMM6i, XMM6j, XMM6k, XMM6l, XMM6m, XMM6n, XMM6o, XMM6p, + XMM7, XMM7b, XMM7c, XMM7d, XMM7e, XMM7f, XMM7g, XMM7h, XMM7i, XMM7j, XMM7k, XMM7l, XMM7m, XMM7n, XMM7o, XMM7p +#ifdef _LP64 + ,XMM8, XMM8b, XMM8c, XMM8d, XMM8e, XMM8f, XMM8g, XMM8h, XMM8i, XMM8j, XMM8k, XMM8l, XMM8m, XMM8n, XMM8o, XMM8p, + XMM9, XMM9b, XMM9c, XMM9d, XMM9e, XMM9f, XMM9g, XMM9h, XMM9i, XMM9j, XMM9k, XMM9l, XMM9m, XMM9n, XMM9o, XMM9p, + XMM10, XMM10b, XMM10c, XMM10d, XMM10e, XMM10f, XMM10g, XMM10h, XMM10i, XMM10j, XMM10k, XMM10l, XMM10m, XMM10n, XMM10o, XMM10p, + XMM11, XMM11b, XMM11c, XMM11d, XMM11e, XMM11f, XMM11g, XMM11h, XMM11i, XMM11j, XMM11k, XMM11l, XMM11m, XMM11n, XMM11o, XMM11p, + XMM12, XMM12b, XMM12c, XMM12d, XMM12e, XMM12f, XMM12g, XMM12h, XMM12i, XMM12j, XMM12k, XMM12l, XMM12m, XMM12n, XMM12o, XMM12p, + XMM13, XMM13b, XMM13c, XMM13d, XMM13e, XMM13f, XMM13g, XMM13h, XMM13i, XMM13j, XMM13k, XMM13l, XMM13m, XMM13n, XMM13o, XMM13p, + XMM14, XMM14b, XMM14c, XMM14d, XMM14e, XMM14f, XMM14g, XMM14h, XMM14i, XMM14j, XMM14k, XMM14l, XMM14m, XMM14n, XMM14o, XMM14p, + XMM15, XMM15b, XMM15c, XMM15d, XMM15e, XMM15f, XMM15g, XMM15h, XMM15i, XMM15j, XMM15k, XMM15l, XMM15m, XMM15n, XMM15o, XMM15p + ,XMM16, XMM16b, XMM16c, XMM16d, XMM16e, XMM16f, XMM16g, XMM16h, XMM16i, XMM16j, XMM16k, XMM16l, XMM16m, XMM16n, XMM16o, XMM16p, + XMM17, XMM17b, XMM17c, XMM17d, XMM17e, XMM17f, XMM17g, XMM17h, XMM17i, XMM17j, XMM17k, XMM17l, XMM17m, XMM17n, XMM17o, XMM17p, + XMM18, XMM18b, XMM18c, XMM18d, XMM18e, XMM18f, XMM18g, XMM18h, XMM18i, XMM18j, XMM18k, XMM18l, XMM18m, XMM18n, XMM18o, XMM18p, + XMM19, XMM19b, XMM19c, XMM19d, XMM19e, XMM19f, XMM19g, XMM19h, XMM19i, XMM19j, XMM19k, XMM19l, XMM19m, XMM19n, XMM19o, XMM19p, + XMM20, XMM20b, XMM20c, XMM20d, XMM20e, XMM20f, XMM20g, XMM20h, XMM20i, XMM20j, XMM20k, XMM20l, XMM20m, XMM20n, XMM20o, XMM20p, + XMM21, XMM21b, XMM21c, XMM21d, XMM21e, XMM21f, XMM21g, XMM21h, XMM21i, XMM21j, XMM21k, XMM21l, XMM21m, XMM21n, XMM21o, XMM21p, + XMM22, XMM22b, XMM22c, XMM22d, XMM22e, XMM22f, XMM22g, XMM22h, XMM22i, XMM22j, XMM22k, XMM22l, XMM22m, XMM22n, XMM22o, XMM22p, + XMM23, XMM23b, XMM23c, XMM23d, XMM23e, XMM23f, XMM23g, XMM23h, XMM23i, XMM23j, XMM23k, XMM23l, XMM23m, XMM23n, XMM23o, XMM23p, + XMM24, XMM24b, XMM24c, XMM24d, XMM24e, XMM24f, XMM24g, XMM24h, XMM24i, XMM24j, XMM24k, XMM24l, XMM24m, XMM24n, XMM24o, XMM24p, + XMM25, XMM25b, XMM25c, XMM25d, XMM25e, XMM25f, XMM25g, XMM25h, XMM25i, XMM25j, XMM25k, XMM25l, XMM25m, XMM25n, XMM25o, XMM25p, + XMM26, XMM26b, XMM26c, XMM26d, XMM26e, XMM26f, XMM26g, XMM26h, XMM26i, XMM26j, XMM26k, XMM26l, XMM26m, XMM26n, XMM26o, XMM26p, + XMM27, XMM27b, XMM27c, XMM27d, XMM27e, XMM27f, XMM27g, XMM27h, XMM27i, XMM27j, XMM27k, XMM27l, XMM27m, XMM27n, XMM27o, XMM27p, + XMM28, XMM28b, XMM28c, XMM28d, XMM28e, XMM28f, XMM28g, XMM28h, XMM28i, XMM28j, XMM28k, XMM28l, XMM28m, XMM28n, XMM28o, XMM28p, + XMM29, XMM29b, XMM29c, XMM29d, XMM29e, XMM29f, XMM29g, XMM29h, XMM29i, XMM29j, XMM29k, XMM29l, XMM29m, XMM29n, XMM29o, XMM29p, + XMM30, XMM30b, XMM30c, XMM30d, XMM30e, XMM30f, XMM30g, XMM30h, XMM30i, XMM30j, XMM30k, XMM30l, XMM30m, XMM30n, XMM30o, XMM30p, + XMM31, XMM31b, XMM31c, XMM31d, XMM31e, XMM31f, XMM31g, XMM31h, XMM31i, XMM31j, XMM31k, XMM31l, XMM31m, XMM31n, XMM31o, XMM31p +#endif + ); + %} @@ -623,6 +1665,10 @@ const bool Matcher::match_rule_supported(int opcode) { if ((UseSSE < 4) && (UseAVX < 1)) // only with SSE4_1 or AVX return false; break; + case Op_MulVL: + case Op_MulReductionVL: + if (VM_Version::supports_avx512dq() == false) + return false; case Op_AddReductionVL: if (UseAVX < 3) // only EVEX : vector connectivity becomes an issue here return false; @@ -657,10 +1703,11 @@ const int Matcher::vector_width_in_bytes(BasicType bt) { if (UseSSE < 2) return 0; // SSE2 supports 128bit vectors for all types. // AVX2 supports 256bit vectors for all types. - int size = (UseAVX > 1) ? 32 : 16; + // AVX2/EVEX supports 512bit vectors for all types. + int size = (UseAVX > 1) ? (1 << UseAVX) * 8 : 16; // AVX1 supports 256bit vectors only for FLOAT and DOUBLE. if (UseAVX > 0 && (bt == T_FLOAT || bt == T_DOUBLE)) - size = 32; + size = (UseAVX > 2) ? 64 : 32; // Use flag to limit vector size. size = MIN2(size,(int)MaxVectorSize); // Minimum 2 values in vector (or 4 for bytes). @@ -702,6 +1749,7 @@ const int Matcher::vector_ideal_reg(int size) { case 8: return Op_VecD; case 16: return Op_VecX; case 32: return Op_VecY; + case 64: return Op_VecZ; } ShouldNotReachHere(); return 0; @@ -745,6 +1793,9 @@ static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo case Op_VecY: __ vmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); break; + case Op_VecZ: + __ evmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 2); + break; default: ShouldNotReachHere(); } @@ -763,6 +1814,7 @@ static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo st->print("movdqu %s,%s\t# spill",Matcher::regName[dst_lo],Matcher::regName[src_lo]); break; case Op_VecY: + case Op_VecZ: st->print("vmovdqu %s,%s\t# spill",Matcher::regName[dst_lo],Matcher::regName[src_lo]); break; default: @@ -771,7 +1823,7 @@ static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo #endif } // VEX_2bytes prefix is used if UseAVX > 0, and it takes the same 2 bytes as SIMD prefix. - return 4; + return (UseAVX > 2) ? 6 : 4; } static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, @@ -796,6 +1848,9 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, case Op_VecY: __ vmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); break; + case Op_VecZ: + __ evmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset), 2); + break; default: ShouldNotReachHere(); } @@ -813,13 +1868,16 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, case Op_VecY: __ vmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); break; + case Op_VecZ: + __ evmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 2); + break; default: ShouldNotReachHere(); } } int size = __ offset() - offset; #ifdef ASSERT - int offset_size = (stack_offset == 0) ? 0 : ((stack_offset < 0x80) ? 1 : 4); + int offset_size = (stack_offset == 0) ? 0 : ((stack_offset < 0x80) ? 1 : (UseAVX > 2) ? 6 : 4); // VEX_2bytes prefix is used if UseAVX > 0, so it takes the same 2 bytes as SIMD prefix. assert(!do_size || size == (5+offset_size), "incorrect size calculattion"); #endif @@ -838,6 +1896,7 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, st->print("movdqu %s,[rsp + %d]\t# spill", Matcher::regName[reg], stack_offset); break; case Op_VecY: + case Op_VecZ: st->print("vmovdqu %s,[rsp + %d]\t# spill", Matcher::regName[reg], stack_offset); break; default: @@ -855,6 +1914,7 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, st->print("movdqu [rsp + %d],%s\t# spill", stack_offset, Matcher::regName[reg]); break; case Op_VecY: + case Op_VecZ: st->print("vmovdqu [rsp + %d],%s\t# spill", stack_offset, Matcher::regName[reg]); break; default: @@ -863,7 +1923,7 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, } #endif } - int offset_size = (stack_offset == 0) ? 0 : ((stack_offset < 0x80) ? 1 : 4); + int offset_size = (stack_offset == 0) ? 0 : ((stack_offset < 0x80) ? 1 : (UseAVX > 2) ? 6 : 4); // VEX_2bytes prefix is used if UseAVX > 0, so it takes the same 2 bytes as SIMD prefix. return 5+offset_size; } @@ -952,40 +2012,15 @@ encode %{ // in the ADLC because operands constitute user defined types which are used in // instruction definitions. -// Vectors -operand vecS() %{ - constraint(ALLOC_IN_RC(vectors_reg)); - match(VecS); +// This one generically applies only for evex, so only one version +operand vecZ() %{ + constraint(ALLOC_IN_RC(vectorz_reg)); + match(VecZ); format %{ %} interface(REG_INTER); %} -operand vecD() %{ - constraint(ALLOC_IN_RC(vectord_reg)); - match(VecD); - - format %{ %} - interface(REG_INTER); -%} - -operand vecX() %{ - constraint(ALLOC_IN_RC(vectorx_reg)); - match(VecX); - - format %{ %} - interface(REG_INTER); -%} - -operand vecY() %{ - constraint(ALLOC_IN_RC(vectory_reg)); - match(VecY); - - format %{ %} - interface(REG_INTER); -%} - - // INSTRUCTIONS -- Platform independent definitions (same for 32- and 64-bit) // ============================================================================ @@ -1586,9 +2621,9 @@ instruct absF_reg_reg(regF dst, regF src) %{ ins_cost(150); format %{ "vandps $dst, $src, [0x7fffffff]\t# abs float by sign masking" %} ins_encode %{ - bool vector256 = false; + int vector_len = 0; __ vandps($dst$$XMMRegister, $src$$XMMRegister, - ExternalAddress(float_signmask()), vector256); + ExternalAddress(float_signmask()), vector_len); %} ins_pipe(pipe_slow); %} @@ -1612,9 +2647,9 @@ instruct absD_reg_reg(regD dst, regD src) %{ format %{ "vandpd $dst, $src, [0x7fffffffffffffff]\t" "# abs double by sign masking" %} ins_encode %{ - bool vector256 = false; + int vector_len = 0; __ vandpd($dst$$XMMRegister, $src$$XMMRegister, - ExternalAddress(double_signmask()), vector256); + ExternalAddress(double_signmask()), vector_len); %} ins_pipe(pipe_slow); %} @@ -1636,9 +2671,9 @@ instruct negF_reg_reg(regF dst, regF src) %{ ins_cost(150); format %{ "vxorps $dst, $src, [0x80000000]\t# neg float by sign flipping" %} ins_encode %{ - bool vector256 = false; + int vector_len = 0; __ vxorps($dst$$XMMRegister, $src$$XMMRegister, - ExternalAddress(float_signflip()), vector256); + ExternalAddress(float_signflip()), vector_len); %} ins_pipe(pipe_slow); %} @@ -1662,9 +2697,9 @@ instruct negD_reg_reg(regD dst, regD src) %{ format %{ "vxorpd $dst, $src, [0x8000000000000000]\t" "# neg double by sign flipping" %} ins_encode %{ - bool vector256 = false; + int vector_len = 0; __ vxorpd($dst$$XMMRegister, $src$$XMMRegister, - ExternalAddress(double_signflip()), vector256); + ExternalAddress(double_signflip()), vector_len); %} ins_pipe(pipe_slow); %} @@ -1739,7 +2774,6 @@ instruct sqrtD_imm(regD dst, immD con) %{ ins_pipe(pipe_slow); %} - // ====================VECTOR INSTRUCTIONS===================================== // Load vectors (4 bytes long) @@ -1790,6 +2824,19 @@ instruct loadV32(vecY dst, memory mem) %{ ins_pipe( pipe_slow ); %} +// Load vectors (64 bytes long) +instruct loadV64(vecZ dst, memory mem) %{ + predicate(n->as_LoadVector()->memory_size() == 64); + match(Set dst (LoadVector mem)); + ins_cost(125); + format %{ "vmovdqu $dst k0,$mem\t! load vector (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ evmovdqu($dst$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + // Store vectors instruct storeV4(memory mem, vecS src) %{ predicate(n->as_StoreVector()->memory_size() == 4); @@ -1835,6 +2882,18 @@ instruct storeV32(memory mem, vecY src) %{ ins_pipe( pipe_slow ); %} +instruct storeV64(memory mem, vecZ src) %{ + predicate(n->as_StoreVector()->memory_size() == 64); + match(Set mem (StoreVector mem src)); + ins_cost(145); + format %{ "vmovdqu $mem k0,$src\t! store vector (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ evmovdqu($mem$$Address, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + // Replicate byte scalar to be vector instruct Repl4B(vecS dst, rRegI src) %{ predicate(n->as_Vector()->length() == 4); @@ -1898,6 +2957,26 @@ instruct Repl32B(vecY dst, rRegI src) %{ ins_pipe( pipe_slow ); %} +instruct Repl64B(vecZ dst, rRegI src) %{ + predicate(n->as_Vector()->length() == 64); + match(Set dst (ReplicateB src)); + format %{ "movd $dst,$src\n\t" + "punpcklbw $dst,$dst\n\t" + "pshuflw $dst,$dst,0x00\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate32B\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate632B" %} + ins_encode %{ + __ movdl($dst$$XMMRegister, $src$$Register); + __ punpcklbw($dst$$XMMRegister, $dst$$XMMRegister); + __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate byte scalar immediate to be vector by loading from const table. instruct Repl4B_imm(vecS dst, immI con) %{ predicate(n->as_Vector()->length() == 4); @@ -1945,6 +3024,22 @@ instruct Repl32B_imm(vecY dst, immI con) %{ ins_pipe( pipe_slow ); %} +instruct Repl64B_imm(vecZ dst, immI con) %{ + predicate(n->as_Vector()->length() == 64); + match(Set dst (ReplicateB con)); + format %{ "movq $dst,[$constantaddress]\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate32B($con)\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate32B($con)" %} + ins_encode %{ + __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 1))); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate byte scalar zero to be vector instruct Repl4B_zero(vecS dst, immI0 zero) %{ predicate(n->as_Vector()->length() == 4); @@ -1982,8 +3077,20 @@ instruct Repl32B_zero(vecY dst, immI0 zero) %{ format %{ "vpxor $dst,$dst,$dst\t! replicate32B zero" %} ins_encode %{ // Use vxorpd since AVX does not have vpxor for 256-bit (AVX2 will have it). - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl64B_zero(vecZ dst, immI0 zero) %{ + predicate(n->as_Vector()->length() == 64); + match(Set dst (ReplicateB zero)); + format %{ "vpxor $dst k0,$dst,$dst\t! replicate64B zero" %} + ins_encode %{ + // Use vxorpd since AVX does not have vpxor for 512-bit (EVEX will have it). + int vector_len = 2; + __ vpxor($dst$$XMMRegister,$dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2043,6 +3150,24 @@ instruct Repl16S(vecY dst, rRegI src) %{ ins_pipe( pipe_slow ); %} +instruct Repl32S(vecZ dst, rRegI src) %{ + predicate(n->as_Vector()->length() == 32); + match(Set dst (ReplicateS src)); + format %{ "movd $dst,$src\n\t" + "pshuflw $dst,$dst,0x00\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate16S\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate16S" %} + ins_encode %{ + __ movdl($dst$$XMMRegister, $src$$Register); + __ pshuflw($dst$$XMMRegister, $dst$$XMMRegister, 0x00); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate char/short (2 byte) scalar immediate to be vector by loading from const table. instruct Repl2S_imm(vecS dst, immI con) %{ predicate(n->as_Vector()->length() == 2); @@ -2090,6 +3215,22 @@ instruct Repl16S_imm(vecY dst, immI con) %{ ins_pipe( pipe_slow ); %} +instruct Repl32S_imm(vecZ dst, immI con) %{ + predicate(n->as_Vector()->length() == 32); + match(Set dst (ReplicateS con)); + format %{ "movq $dst,[$constantaddress]\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate16S($con)\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate16S($con)" %} + ins_encode %{ + __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 2))); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate char/short (2 byte) scalar zero to be vector instruct Repl2S_zero(vecS dst, immI0 zero) %{ predicate(n->as_Vector()->length() == 2); @@ -2127,8 +3268,20 @@ instruct Repl16S_zero(vecY dst, immI0 zero) %{ format %{ "vpxor $dst,$dst,$dst\t! replicate16S zero" %} ins_encode %{ // Use vxorpd since AVX does not have vpxor for 256-bit (AVX2 will have it). - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl32S_zero(vecZ dst, immI0 zero) %{ + predicate(n->as_Vector()->length() == 32); + match(Set dst (ReplicateS zero)); + format %{ "vpxor $dst k0,$dst,$dst\t! replicate32S zero" %} + ins_encode %{ + // Use vxorpd since AVX does not have vpxor for 512-bit (EVEX will have it). + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2172,6 +3325,22 @@ instruct Repl8I(vecY dst, rRegI src) %{ ins_pipe( pipe_slow ); %} +instruct Repl16I(vecZ dst, rRegI src) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateI src)); + format %{ "movd $dst,$src\n\t" + "pshufd $dst,$dst,0x00\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate8I\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate8I" %} + ins_encode %{ + __ movdl($dst$$XMMRegister, $src$$Register); + __ pshufd($dst$$XMMRegister, $dst$$XMMRegister, 0x00); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate integer (4 byte) scalar immediate to be vector by loading from const table. instruct Repl2I_imm(vecD dst, immI con) %{ predicate(n->as_Vector()->length() == 2); @@ -2209,6 +3378,22 @@ instruct Repl8I_imm(vecY dst, immI con) %{ ins_pipe( pipe_slow ); %} +instruct Repl16I_imm(vecZ dst, immI con) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateI con)); + format %{ "movq $dst,[$constantaddress]\t! replicate16I($con)\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\n\t" + "vinserti64x4h $dst k0,$dst,$dst" %} + ins_encode %{ + __ movq($dst$$XMMRegister, $constantaddress(replicate8_imm($con$$constant, 4))); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Integer could be loaded into xmm register directly from memory. instruct Repl2I_mem(vecD dst, memory mem) %{ predicate(n->as_Vector()->length() == 2); @@ -2248,6 +3433,22 @@ instruct Repl8I_mem(vecY dst, memory mem) %{ ins_pipe( pipe_slow ); %} +instruct Repl16I_mem(vecZ dst, memory mem) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateI (LoadI mem))); + format %{ "movd $dst,$mem\n\t" + "pshufd $dst,$dst,0x00\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate8I\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate8I" %} + ins_encode %{ + __ movdl($dst$$XMMRegister, $mem$$Address); + __ pshufd($dst$$XMMRegister, $dst$$XMMRegister, 0x00); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate integer (4 byte) scalar zero to be vector instruct Repl2I_zero(vecD dst, immI0 zero) %{ predicate(n->as_Vector()->length() == 2); @@ -2275,8 +3476,20 @@ instruct Repl8I_zero(vecY dst, immI0 zero) %{ format %{ "vpxor $dst,$dst,$dst\t! replicate8I zero" %} ins_encode %{ // Use vxorpd since AVX does not have vpxor for 256-bit (AVX2 will have it). - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl16I_zero(vecZ dst, immI0 zero) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateI zero)); + format %{ "vpxor $dst k0,$dst,$dst\t! replicate16I zero" %} + ins_encode %{ + // Use vxorpd since AVX does not have vpxor for 512-bit (AVX2 will have it). + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2308,6 +3521,22 @@ instruct Repl4L(vecY dst, rRegL src) %{ %} ins_pipe( pipe_slow ); %} + +instruct Repl8L(vecZ dst, rRegL src) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateL src)); + format %{ "movdq $dst,$src\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate4L\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate4L" %} + ins_encode %{ + __ movdq($dst$$XMMRegister, $src$$Register); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} #else // _LP64 instruct Repl2L(vecX dst, eRegL src, regD tmp) %{ predicate(n->as_Vector()->length() == 2); @@ -2344,6 +3573,26 @@ instruct Repl4L(vecY dst, eRegL src, regD tmp) %{ %} ins_pipe( pipe_slow ); %} + +instruct Repl8L(vecZ dst, eRegL src, regD tmp) %{ + predicate(n->as_Vector()->length() == 4); + match(Set dst (ReplicateL src)); + effect(TEMP dst, USE src, TEMP tmp); + format %{ "movdl $dst,$src.lo\n\t" + "movdl $tmp,$src.hi\n\t" + "punpckldq $dst,$tmp\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate4L\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate4L" %} + ins_encode %{ + __ movdl($dst$$XMMRegister, $src$$Register); + __ movdl($tmp$$XMMRegister, HIGH_FROM_LOW($src$$Register)); + __ punpckldq($dst$$XMMRegister, $tmp$$XMMRegister); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} #endif // _LP64 // Replicate long (8 byte) scalar immediate to be vector by loading from const table. @@ -2373,6 +3622,22 @@ instruct Repl4L_imm(vecY dst, immL con) %{ ins_pipe( pipe_slow ); %} +instruct Repl8L_imm(vecZ dst, immL con) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateL con)); + format %{ "movq $dst,[$constantaddress]\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate4L($con)\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate4L($con)" %} + ins_encode %{ + __ movq($dst$$XMMRegister, $constantaddress($con)); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Long could be loaded into xmm register directly from memory. instruct Repl2L_mem(vecX dst, memory mem) %{ predicate(n->as_Vector()->length() == 2); @@ -2400,6 +3665,22 @@ instruct Repl4L_mem(vecY dst, memory mem) %{ ins_pipe( pipe_slow ); %} +instruct Repl8L_mem(vecZ dst, memory mem) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateL (LoadL mem))); + format %{ "movq $dst,$mem\n\t" + "punpcklqdq $dst,$dst\n\t" + "vinserti128h $dst,$dst,$dst\t! lower replicate4L\n\t" + "vinserti64x4h $dst k0,$dst,$dst\t! upper replicate4L" %} + ins_encode %{ + __ movq($dst$$XMMRegister, $mem$$Address); + __ punpcklqdq($dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinserti64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate long (8 byte) scalar zero to be vector instruct Repl2L_zero(vecX dst, immL0 zero) %{ predicate(n->as_Vector()->length() == 2); @@ -2417,8 +3698,20 @@ instruct Repl4L_zero(vecY dst, immL0 zero) %{ format %{ "vpxor $dst,$dst,$dst\t! replicate4L zero" %} ins_encode %{ // Use vxorpd since AVX does not have vpxor for 256-bit (AVX2 will have it). - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl8L_zero(vecZ dst, immL0 zero) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateL zero)); + format %{ "vpxor $dst k0,$dst,$dst\t! replicate8L zero" %} + ins_encode %{ + // Use vxorpd since AVX does not have vpxor for 512-bit (EVEX will have it). + int vector_len = 2; + __ vpxor($dst$$XMMRegister,$dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2456,6 +3749,20 @@ instruct Repl8F(vecY dst, regF src) %{ ins_pipe( pipe_slow ); %} +instruct Repl16F(vecZ dst, regF src) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateF src)); + format %{ "pshufd $dst,$src,0x00\n\t" + "vinsertf128h $dst,$dst,$dst\t! lower replicate8F\n\t" + "vinsertf64x4h $dst k0,$dst,$dst\t! lower replicate8F" %} + ins_encode %{ + __ pshufd($dst$$XMMRegister, $src$$XMMRegister, 0x00); + __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinsertf64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate float (4 byte) scalar zero to be vector instruct Repl2F_zero(vecD dst, immF0 zero) %{ predicate(n->as_Vector()->length() == 2); @@ -2482,8 +3789,19 @@ instruct Repl8F_zero(vecY dst, immF0 zero) %{ match(Set dst (ReplicateF zero)); format %{ "vxorps $dst,$dst,$dst\t! replicate8F zero" %} ins_encode %{ - bool vector256 = true; - __ vxorps($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vxorps($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl16F_zero(vecZ dst, immF0 zero) %{ + predicate(n->as_Vector()->length() == 16); + match(Set dst (ReplicateF zero)); + format %{ "vxorps $dst k0,$dst,$dst\t! replicate16F zero" %} + ins_encode %{ + int vector_len = 2; + __ vxorps($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2511,6 +3829,20 @@ instruct Repl4D(vecY dst, regD src) %{ ins_pipe( pipe_slow ); %} +instruct Repl8D(vecZ dst, regD src) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateD src)); + format %{ "pshufd $dst,$src,0x44\n\t" + "vinsertf128h $dst,$dst,$dst\t! lower replicate4D\n\t" + "vinsertf64x4h $dst k0,$dst,$dst\t! upper replicate4D" %} + ins_encode %{ + __ pshufd($dst$$XMMRegister, $src$$XMMRegister, 0x44); + __ vinsertf128h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + __ vinsertf64x4h($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // Replicate double (8 byte) scalar zero to be vector instruct Repl2D_zero(vecX dst, immD0 zero) %{ predicate(n->as_Vector()->length() == 2); @@ -2527,8 +3859,19 @@ instruct Repl4D_zero(vecY dst, immD0 zero) %{ match(Set dst (ReplicateD zero)); format %{ "vxorpd $dst,$dst,$dst,vect256\t! replicate4D zero" %} ins_encode %{ - bool vector256 = true; - __ vxorpd($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector256); + int vector_len = 1; + __ vxorpd($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( fpu_reg_reg ); +%} + +instruct Repl8D_zero(vecZ dst, immD0 zero) %{ + predicate(n->as_Vector()->length() == 8); + match(Set dst (ReplicateD zero)); + format %{ "vxorpd $dst k0,$dst,$dst,vect512\t! replicate8D zero" %} + ins_encode %{ + int vector_len = 2; + __ vxorpd($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); %} ins_pipe( fpu_reg_reg ); %} @@ -2555,17 +3898,38 @@ instruct rsadd2I_reduction_reg(rRegI dst, rRegI src1, vecD src2, regF tmp, regF %} instruct rvadd2I_reduction_reg(rRegI dst, rRegI src1, vecD src2, regF tmp, regF tmp2) %{ - predicate(UseAVX > 0); + predicate(UseAVX > 0 && UseAVX < 3); match(Set dst (AddReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "vphaddd $tmp,$src2,$src2\n\t" + format %{ "vphaddd $tmp,$src2,$src2\n\t" + "movd $tmp2,$src1\n\t" + "vpaddd $tmp2,$tmp2,$tmp\n\t" + "movd $dst,$tmp2\t! add reduction2I" %} + ins_encode %{ + int vector_len = 0; + __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, vector_len); + __ movdl($tmp2$$XMMRegister, $src1$$Register); + __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, vector_len); + __ movdl($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvadd2I_reduction_reg_evex(rRegI dst, rRegI src1, vecD src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVI src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "pshufd $tmp2,$src2,0x1\n\t" + "vpaddd $tmp,$src2,$tmp2\n\t" "movd $tmp2,$src1\n\t" - "vpaddd $tmp2,$tmp2,$tmp\n\t" + "vpaddd $tmp2,$tmp,$tmp2\n\t" "movd $dst,$tmp2\t! add reduction2I" %} ins_encode %{ - __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, false); + int vector_len = 0; + __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vpaddd($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, false); + __ vpaddd($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); @@ -2593,47 +3957,203 @@ instruct rsadd4I_reduction_reg(rRegI dst, rRegI src1, vecX src2, regF tmp, regF %} instruct rvadd4I_reduction_reg(rRegI dst, rRegI src1, vecX src2, regF tmp, regF tmp2) %{ - predicate(UseAVX > 0); + predicate(UseAVX > 0 && UseAVX < 3); match(Set dst (AddReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "vphaddd $tmp,$src2,$src2\n\t" - "vphaddd $tmp,$tmp,$tmp2\n\t" + format %{ "vphaddd $tmp,$src2,$src2\n\t" + "vphaddd $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpaddd $tmp2,$tmp2,$tmp\n\t" + "movd $dst,$tmp2\t! add reduction4I" %} + ins_encode %{ + int vector_len = 0; + __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, vector_len); + __ vphaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ movdl($tmp2$$XMMRegister, $src1$$Register); + __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, vector_len); + __ movdl($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvadd4I_reduction_reg_evex(rRegI dst, rRegI src1, vecX src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVI src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "pshufd $tmp2,$src2,0xE\n\t" + "vpaddd $tmp,$src2,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" "movd $tmp2,$src1\n\t" - "vpaddd $tmp2,$tmp2,$tmp\n\t" + "vpaddd $tmp2,$tmp,$tmp2\n\t" "movd $dst,$tmp2\t! add reduction4I" %} ins_encode %{ - __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, false); - __ vphaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + int vector_len = 0; + __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0xE); + __ vpaddd($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, false); + __ vpaddd($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); %} instruct rvadd8I_reduction_reg(rRegI dst, rRegI src1, vecY src2, regF tmp, regF tmp2) %{ - predicate(UseAVX > 0); + predicate(UseAVX > 0 && UseAVX < 3); match(Set dst (AddReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "vphaddd $tmp,$src2,$src2\n\t" - "vphaddd $tmp,$tmp,$tmp2\n\t" - "vextractf128 $tmp2,$tmp\n\t" - "vpaddd $tmp,$tmp,$tmp2\n\t" - "movd $tmp2,$src1\n\t" - "vpaddd $tmp2,$tmp2,$tmp\n\t" - "movd $dst,$tmp2\t! add reduction8I" %} + format %{ "vphaddd $tmp,$src2,$src2\n\t" + "vphaddd $tmp,$tmp,$tmp2\n\t" + "vextracti128 $tmp2,$tmp\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpaddd $tmp2,$tmp2,$tmp\n\t" + "movd $dst,$tmp2\t! add reduction8I" %} ins_encode %{ - __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, true); - __ vphaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, true); - __ vextractf128h($tmp2$$XMMRegister, $tmp$$XMMRegister); - __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + int vector_len = 1; + __ vphaddd($tmp$$XMMRegister, $src2$$XMMRegister, $src2$$XMMRegister, vector_len); + __ vphaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ vextracti128h($tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, false); + __ vpaddd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); %} +instruct rvadd8I_reduction_reg_evex(rRegI dst, rRegI src1, vecY src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVI src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "vextracti128 $tmp,$src2\n\t" + "vpaddd $tmp,$tmp,$src2\n\t" + "pshufd $tmp2,$tmp,0xE\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpaddd $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! add reduction8I" %} + ins_encode %{ + int vector_len = 0; + __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, vector_len); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ movdl($tmp2$$XMMRegister, $src1$$Register); + __ vpaddd($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); + __ movdl($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvadd16I_reduction_reg_evex(rRegI dst, rRegI src1, vecZ src2, regF tmp, regF tmp2, regF tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVI src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vextracti64x4 $tmp3,$src2\n\t" + "vpaddd $tmp3,$tmp3,$src2\n\t" + "vextracti128 $tmp,$tmp3\n\t" + "vpaddd $tmp,$tmp,$tmp3\n\t" + "pshufd $tmp2,$tmp,0xE\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpaddd $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpaddd $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! mul reduction16I" %} + ins_encode %{ + __ vextracti64x4h($tmp3$$XMMRegister, $src2$$XMMRegister); + __ vpaddd($tmp3$$XMMRegister, $tmp3$$XMMRegister, $src2$$XMMRegister, 1); + __ vextracti128h($tmp$$XMMRegister, $tmp3$$XMMRegister); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp3$$XMMRegister, 0); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); + __ vpaddd($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdl($tmp2$$XMMRegister, $src1$$Register); + __ vpaddd($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdl($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +#ifdef _LP64 +instruct rvadd2L_reduction_reg(rRegL dst, rRegL src1, vecX src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "pshufd $tmp2,$src2,0xE\n\t" + "vpaddq $tmp,$src2,$tmp2\n\t" + "movdq $tmp2,$src1\n\t" + "vpaddq $tmp2,$tmp,$tmp2\n\t" + "movdq $dst,$tmp2\t! add reduction2L" %} + ins_encode %{ + __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0xE); + __ vpaddq($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdq($tmp2$$XMMRegister, $src1$$Register); + __ vpaddq($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvadd4L_reduction_reg(rRegL dst, rRegL src1, vecY src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "vextracti64x2 $tmp,$src2, 0x1\n\t" + "vpaddq $tmp2,$tmp,$src2\n\t" + "pshufd $tmp,$tmp2,0xE\n\t" + "vpaddq $tmp2,$tmp2,$tmp\n\t" + "movdq $tmp,$src1\n\t" + "vpaddq $tmp2,$tmp2,$tmp\n\t" + "movdq $dst,$tmp2\t! add reduction4L" %} + ins_encode %{ + __ vextracti64x2h($tmp$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vpaddq($tmp2$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, 0); + __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($tmp$$XMMRegister, $src1$$Register); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvadd8L_reduction_reg(rRegL dst, rRegL src1, vecZ src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "vextracti64x4 $tmp2,$src2\n\t" + "vpaddq $tmp2,$tmp2,$src2\n\t" + "vextracti128 $tmp,$tmp2\n\t" + "vpaddq $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp2,0xE\n\t" + "vpaddq $tmp2,$tmp2,$tmp\n\t" + "movdq $tmp,$src1\n\t" + "vpaddq $tmp2,$tmp2,$tmp\n\t" + "movdq $dst,$tmp2\t! add reduction8L" %} + ins_encode %{ + __ vextracti64x4h($tmp2$$XMMRegister, $src2$$XMMRegister); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $src2$$XMMRegister, 1); + __ vextracti128h($tmp$$XMMRegister, $tmp2$$XMMRegister); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($tmp$$XMMRegister, $src1$$Register); + __ vpaddq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} +#endif + instruct rsadd2F_reduction_reg(regF dst, regF src1, vecD src2, regF tmp, regF tmp2) %{ predicate(UseSSE >= 1 && UseAVX == 0); match(Set dst (AddReductionVF src1 src2)); @@ -2757,6 +4277,77 @@ instruct radd8F_reduction_reg(regF dst, regF src1, vecY src2, regF tmp, regF tmp ins_pipe( pipe_slow ); %} +instruct radd16F_reduction_reg(regF dst, regF src1, vecZ src2, regF tmp, regF tmp2, regF tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVF src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vaddss $tmp2,$src1,$src2\n\t" + "pshufd $tmp,$src2,0x01\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$src2,0x02\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$src2,0x03\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x1\n\t" + "vaddss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x2\n\t" + "vaddss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x3\n\t" + "vaddss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vaddss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vaddss $dst,$tmp2,$tmp\t! add reduction16F" %} + ins_encode %{ + __ vaddss($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x01); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x02); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x2); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x3); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vaddss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vaddss($dst$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct rsadd2D_reduction_reg(regD dst, regD src1, vecX src2, regD tmp) %{ predicate(UseSSE >= 1 && UseAVX == 0); match(Set dst (AddReductionVD src1 src2)); @@ -2812,6 +4403,45 @@ instruct rvadd4D_reduction_reg(regD dst, regD src1, vecY src2, regD tmp, regD tm ins_pipe( pipe_slow ); %} +instruct rvadd8D_reduction_reg(regD dst, regD src1, vecZ src2, regD tmp, regD tmp2, regD tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (AddReductionVD src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vaddsd $tmp2,$src1,$src2\n\t" + "pshufd $tmp,$src2,0xE\n\t" + "vaddsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x1\n\t" + "vaddsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0xE\n\t" + "vaddsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x2\n\t" + "vaddsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0xE\n\t" + "vaddsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x3\n\t" + "vaddsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0xE\n\t" + "vaddsd $dst,$tmp2,$tmp\t! add reduction8D" %} + ins_encode %{ + __ vaddsd($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x2); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x3); + __ vaddsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vaddsd($dst$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct rsmul2I_reduction_reg(rRegI dst, rRegI src1, vecD src2, regF tmp, regF tmp2) %{ predicate(UseSSE > 3 && UseAVX == 0); match(Set dst (MulReductionVI src1 src2)); @@ -2835,16 +4465,17 @@ instruct rvmul2I_reduction_reg(rRegI dst, rRegI src1, vecD src2, regF tmp, regF predicate(UseAVX > 0); match(Set dst (MulReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "pshufd $tmp2,$src2,0x1\n\t" - "vpmulld $tmp,$src2,$tmp2\n\t" - "movd $tmp2,$src1\n\t" - "vpmulld $tmp2,$tmp,$tmp2\n\t" - "movd $dst,$tmp2\t! mul reduction2I" %} + format %{ "pshufd $tmp2,$src2,0x1\n\t" + "vpmulld $tmp,$src2,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpmulld $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! mul reduction2I" %} ins_encode %{ + int vector_len = 0; __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0x1); - __ vpmulld($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); @@ -2877,20 +4508,21 @@ instruct rvmul4I_reduction_reg(rRegI dst, rRegI src1, vecX src2, regF tmp, regF predicate(UseAVX > 0); match(Set dst (MulReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "pshufd $tmp2,$src2,0xE\n\t" - "vpmulld $tmp,$src2,$tmp2\n\t" - "pshufd $tmp2,$tmp,0x1\n\t" - "vpmulld $tmp,$tmp,$tmp2\n\t" - "movd $tmp2,$src1\n\t" - "vpmulld $tmp2,$tmp,$tmp2\n\t" - "movd $dst,$tmp2\t! mul reduction4I" %} + format %{ "pshufd $tmp2,$src2,0xE\n\t" + "vpmulld $tmp,$src2,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpmulld $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpmulld $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! mul reduction4I" %} ins_encode %{ + int vector_len = 0; __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0xE); - __ vpmulld($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); - __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); @@ -2900,30 +4532,133 @@ instruct rvmul8I_reduction_reg(rRegI dst, rRegI src1, vecY src2, regF tmp, regF predicate(UseAVX > 0); match(Set dst (MulReductionVI src1 src2)); effect(TEMP tmp, TEMP tmp2); - format %{ "vextractf128 $tmp,$src2\n\t" - "vpmulld $tmp,$tmp,$src2\n\t" - "pshufd $tmp2,$tmp,0xE\n\t" - "vpmulld $tmp,$tmp,$tmp2\n\t" - "pshufd $tmp2,$tmp,0x1\n\t" - "vpmulld $tmp,$tmp,$tmp2\n\t" - "movd $tmp2,$src1\n\t" - "vpmulld $tmp2,$tmp,$tmp2\n\t" - "movd $dst,$tmp2\t! mul reduction8I" %} + format %{ "vextracti128 $tmp,$src2\n\t" + "vpmulld $tmp,$tmp,$src2\n\t" + "pshufd $tmp2,$tmp,0xE\n\t" + "vpmulld $tmp,$tmp,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpmulld $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpmulld $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! mul reduction8I" %} ins_encode %{ - __ vextractf128h($tmp$$XMMRegister, $src2$$XMMRegister); - __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, false); + int vector_len = 0; + __ vextracti128h($tmp$$XMMRegister, $src2$$XMMRegister); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, vector_len); __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE); - __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); - __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($tmp2$$XMMRegister, $src1$$Register); - __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, false); + __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ movdl($dst$$Register, $tmp2$$XMMRegister); %} ins_pipe( pipe_slow ); %} -instruct rsmul2F_reduction_reg(regF dst, regF src1, vecD src2, regF tmp, regF tmp2) %{ +instruct rvmul16I_reduction_reg(rRegI dst, rRegI src1, vecZ src2, regF tmp, regF tmp2, regF tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (MulReductionVI src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vextracti64x4 $tmp3,$src2\n\t" + "vpmulld $tmp3,$tmp3,$src2\n\t" + "vextracti128 $tmp,$tmp3\n\t" + "vpmulld $tmp,$tmp,$src2\n\t" + "pshufd $tmp2,$tmp,0xE\n\t" + "vpmulld $tmp,$tmp,$tmp2\n\t" + "pshufd $tmp2,$tmp,0x1\n\t" + "vpmulld $tmp,$tmp,$tmp2\n\t" + "movd $tmp2,$src1\n\t" + "vpmulld $tmp2,$tmp,$tmp2\n\t" + "movd $dst,$tmp2\t! mul reduction16I" %} + ins_encode %{ + __ vextracti64x4h($tmp3$$XMMRegister, $src2$$XMMRegister); + __ vpmulld($tmp3$$XMMRegister, $tmp3$$XMMRegister, $src2$$XMMRegister, 1); + __ vextracti128h($tmp$$XMMRegister, $tmp3$$XMMRegister); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp3$$XMMRegister, 0); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0xE); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ pshufd($tmp2$$XMMRegister, $tmp$$XMMRegister, 0x1); + __ vpmulld($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdl($tmp2$$XMMRegister, $src1$$Register); + __ vpmulld($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdl($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +#ifdef _LP64 +instruct rvmul2L_reduction_reg(rRegL dst, rRegL src1, vecX src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq()); + match(Set dst (MulReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "pshufd $tmp2,$src2,0xE\n\t" + "vpmullq $tmp,$src2,$tmp2\n\t" + "movdq $tmp2,$src1\n\t" + "vpmullq $tmp2,$tmp,$tmp2\n\t" + "movdq $dst,$tmp2\t! mul reduction2L" %} + ins_encode %{ + __ pshufd($tmp2$$XMMRegister, $src2$$XMMRegister, 0xE); + __ vpmullq($tmp$$XMMRegister, $src2$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdq($tmp2$$XMMRegister, $src1$$Register); + __ vpmullq($tmp2$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvmul4L_reduction_reg(rRegL dst, rRegL src1, vecY src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq()); + match(Set dst (MulReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "vextracti64x2 $tmp,$src2, 0x1\n\t" + "vpmullq $tmp2,$tmp,$src2\n\t" + "pshufd $tmp,$tmp2,0xE\n\t" + "vpmullq $tmp2,$tmp2,$tmp\n\t" + "movdq $tmp,$src1\n\t" + "vpmullq $tmp2,$tmp2,$tmp\n\t" + "movdq $dst,$tmp2\t! mul reduction4L" %} + ins_encode %{ + __ vextracti64x2h($tmp$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vpmullq($tmp2$$XMMRegister, $tmp$$XMMRegister, $src2$$XMMRegister, 0); + __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($tmp$$XMMRegister, $src1$$Register); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct rvmul8L_reduction_reg(rRegL dst, rRegL src1, vecZ src2, regF tmp, regF tmp2) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq()); + match(Set dst (MulReductionVL src1 src2)); + effect(TEMP tmp, TEMP tmp2); + format %{ "vextracti64x4 $tmp2,$src2\n\t" + "vpmullq $tmp2,$tmp2,$src2\n\t" + "vextracti128 $tmp,$tmp2\n\t" + "vpmullq $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp2,0xE\n\t" + "vpmullq $tmp2,$tmp2,$tmp\n\t" + "movdq $tmp,$src1\n\t" + "vpmullq $tmp2,$tmp2,$tmp\n\t" + "movdq $dst,$tmp2\t! mul reduction8L" %} + ins_encode %{ + __ vextracti64x4h($tmp2$$XMMRegister, $src2$$XMMRegister); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $src2$$XMMRegister, 1); + __ vextracti128h($tmp$$XMMRegister, $tmp2$$XMMRegister); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ pshufd($tmp$$XMMRegister, $tmp2$$XMMRegister, 0xE); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($tmp$$XMMRegister, $src1$$Register); + __ vpmullq($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister, 0); + __ movdq($dst$$Register, $tmp2$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} +#endif + +instruct rsmul2F_reduction(regF dst, regF src1, vecD src2, regF tmp, regF tmp2) %{ predicate(UseSSE >= 1 && UseAVX == 0); match(Set dst (MulReductionVF src1 src2)); effect(TEMP tmp, TEMP tmp2); @@ -2931,7 +4666,7 @@ instruct rsmul2F_reduction_reg(regF dst, regF src1, vecD src2, regF tmp, regF tm "mulss $tmp,$src2\n\t" "pshufd $tmp2,$src2,0x01\n\t" "mulss $tmp,$tmp2\n\t" - "movdqu $dst,$tmp\t! add reduction2F" %} + "movdqu $dst,$tmp\t! mul reduction2F" %} ins_encode %{ __ movdqu($tmp$$XMMRegister, $src1$$XMMRegister); __ mulss($tmp$$XMMRegister, $src2$$XMMRegister); @@ -2948,7 +4683,7 @@ instruct rvmul2F_reduction_reg(regF dst, regF src1, vecD src2, regF tmp, regF tm effect(TEMP tmp, TEMP tmp2); format %{ "vmulss $tmp2,$src1,$src2\n\t" "pshufd $tmp,$src2,0x01\n\t" - "vmulss $dst,$tmp2,$tmp\t! add reduction2F" %} + "vmulss $dst,$tmp2,$tmp\t! mul reduction2F" %} ins_encode %{ __ vmulss($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x01); @@ -2969,7 +4704,7 @@ instruct rsmul4F_reduction_reg(regF dst, regF src1, vecX src2, regF tmp, regF tm "mulss $tmp,$tmp2\n\t" "pshufd $tmp2,$src2,0x03\n\t" "mulss $tmp,$tmp2\n\t" - "movdqu $dst,$tmp\t! add reduction4F" %} + "movdqu $dst,$tmp\t! mul reduction4F" %} ins_encode %{ __ movdqu($tmp$$XMMRegister, $src1$$XMMRegister); __ mulss($tmp$$XMMRegister, $src2$$XMMRegister); @@ -2994,7 +4729,7 @@ instruct rvmul4F_reduction_reg(regF dst, regF src1, vecX src2, regF tmp, regF tm "pshufd $tmp,$src2,0x02\n\t" "vmulss $tmp2,$tmp2,$tmp\n\t" "pshufd $tmp,$src2,0x03\n\t" - "vmulss $dst,$tmp2,$tmp\t! add reduction4F" %} + "vmulss $dst,$tmp2,$tmp\t! mul reduction4F" %} ins_encode %{ __ vmulss($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x01); @@ -3046,6 +4781,77 @@ instruct rvmul8F_reduction_reg(regF dst, regF src1, vecY src2, regF tmp, regF tm ins_pipe( pipe_slow ); %} +instruct rvmul16F_reduction_reg(regF dst, regF src1, vecZ src2, regF tmp, regF tmp2, regF tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (MulReductionVF src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vmulss $tmp2,$src1,$src2\n\t" + "pshufd $tmp,$src2,0x01\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$src2,0x02\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$src2,0x03\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "vextractf32x4 $tmp3,$src2, 0x1\n\t" + "vmulss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "vextractf32x4 $tmp3,$src2, 0x2\n\t" + "vmulss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "vextractf32x4 $tmp3,$src2, 0x3\n\t" + "vmulss $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0x01\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x02\n\t" + "vmulss $tmp2,$tmp2,$tmp\n\t" + "pshufd $tmp,$tmp3,0x03\n\t" + "vmulss $dst,$tmp2,$tmp\t! mul reduction16F" %} + ins_encode %{ + __ vmulss($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x01); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x02); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0x03); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x2); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf32x4h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x3); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x01); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x02); + __ vmulss($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0x03); + __ vmulss($dst$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct rsmul2D_reduction_reg(regD dst, regD src1, vecX src2, regD tmp) %{ predicate(UseSSE >= 1 && UseAVX == 0); match(Set dst (MulReductionVD src1 src2)); @@ -3053,7 +4859,7 @@ instruct rsmul2D_reduction_reg(regD dst, regD src1, vecX src2, regD tmp) %{ format %{ "movdqu $tmp,$src1\n\t" "mulsd $tmp,$src2\n\t" "pshufd $dst,$src2,0xE\n\t" - "mulsd $dst,$tmp\t! add reduction2D" %} + "mulsd $dst,$tmp\t! mul reduction2D" %} ins_encode %{ __ movdqu($tmp$$XMMRegister, $src1$$XMMRegister); __ mulsd($tmp$$XMMRegister, $src2$$XMMRegister); @@ -3101,6 +4907,45 @@ instruct rvmul4D_reduction_reg(regD dst, regD src1, vecY src2, regD tmp, regD tm ins_pipe( pipe_slow ); %} +instruct rvmul8D_reduction_reg(regD dst, regD src1, vecZ src2, regD tmp, regD tmp2, regD tmp3) %{ + predicate(UseAVX > 2); + match(Set dst (MulReductionVD src1 src2)); + effect(TEMP tmp, TEMP tmp2, TEMP tmp3); + format %{ "vmulsd $tmp2,$src1,$src2\n\t" + "pshufd $tmp,$src2,0xE\n\t" + "vmulsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x1\n\t" + "vmulsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$src2,0xE\n\t" + "vmulsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x2\n\t" + "vmulsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0xE\n\t" + "vmulsd $tmp2,$tmp2,$tmp\n\t" + "vextractf64x2 $tmp3,$src2, 0x3\n\t" + "vmulsd $tmp2,$tmp2,$tmp3\n\t" + "pshufd $tmp,$tmp3,0xE\n\t" + "vmulsd $dst,$tmp2,$tmp\t! mul reduction8D" %} + ins_encode %{ + __ vmulsd($tmp2$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $src2$$XMMRegister, 0xE); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x1); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x2); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + __ vextractf64x2h($tmp3$$XMMRegister, $src2$$XMMRegister, 0x3); + __ vmulsd($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister); + __ pshufd($tmp$$XMMRegister, $tmp3$$XMMRegister, 0xE); + __ vmulsd($dst$$XMMRegister, $tmp2$$XMMRegister, $tmp$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + // ====================VECTOR ARITHMETIC======================================= // --------------------------------- ADD -------------------------------------- @@ -3121,8 +4966,8 @@ instruct vadd4B_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (AddVB src1 src2)); format %{ "vpaddb $dst,$src1,$src2\t! add packed4B" %} ins_encode %{ - bool vector256 = false; - __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3142,8 +4987,8 @@ instruct vadd8B_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (AddVB src1 src2)); format %{ "vpaddb $dst,$src1,$src2\t! add packed8B" %} ins_encode %{ - bool vector256 = false; - __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3163,8 +5008,8 @@ instruct vadd16B_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVB src1 src2)); format %{ "vpaddb $dst,$src1,$src2\t! add packed16B" %} ins_encode %{ - bool vector256 = false; - __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3174,8 +5019,8 @@ instruct vadd16B_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVB src (LoadVector mem))); format %{ "vpaddb $dst,$src,$mem\t! add packed16B" %} ins_encode %{ - bool vector256 = false; - __ vpaddb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpaddb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3185,8 +5030,8 @@ instruct vadd32B_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVB src1 src2)); format %{ "vpaddb $dst,$src1,$src2\t! add packed32B" %} ins_encode %{ - bool vector256 = true; - __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3196,8 +5041,30 @@ instruct vadd32B_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVB src (LoadVector mem))); format %{ "vpaddb $dst,$src,$mem\t! add packed32B" %} ins_encode %{ - bool vector256 = true; - __ vpaddb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpaddb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd64B_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 64); + match(Set dst (AddVB src1 src2)); + format %{ "vpaddb $dst,$src1,$src2\t! add packed64B" %} + ins_encode %{ + int vector_len = 2; + __ vpaddb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd64B_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 64); + match(Set dst (AddVB src (LoadVector mem))); + format %{ "vpaddb $dst,$src,$mem\t! add packed64B" %} + ins_encode %{ + int vector_len = 2; + __ vpaddb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3218,8 +5085,8 @@ instruct vadd2S_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (AddVS src1 src2)); format %{ "vpaddw $dst,$src1,$src2\t! add packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3239,8 +5106,8 @@ instruct vadd4S_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (AddVS src1 src2)); format %{ "vpaddw $dst,$src1,$src2\t! add packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3260,8 +5127,8 @@ instruct vadd8S_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVS src1 src2)); format %{ "vpaddw $dst,$src1,$src2\t! add packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3271,8 +5138,8 @@ instruct vadd8S_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVS src (LoadVector mem))); format %{ "vpaddw $dst,$src,$mem\t! add packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpaddw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpaddw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3282,8 +5149,8 @@ instruct vadd16S_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVS src1 src2)); format %{ "vpaddw $dst,$src1,$src2\t! add packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3293,8 +5160,30 @@ instruct vadd16S_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVS src (LoadVector mem))); format %{ "vpaddw $dst,$src,$mem\t! add packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpaddw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpaddw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd32S_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (AddVS src1 src2)); + format %{ "vpaddw $dst,$src1,$src2\t! add packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpaddw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd32S_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (AddVS src (LoadVector mem))); + format %{ "vpaddw $dst,$src,$mem\t! add packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpaddw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3315,8 +5204,8 @@ instruct vadd2I_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (AddVI src1 src2)); format %{ "vpaddd $dst,$src1,$src2\t! add packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3336,8 +5225,8 @@ instruct vadd4I_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVI src1 src2)); format %{ "vpaddd $dst,$src1,$src2\t! add packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3347,8 +5236,8 @@ instruct vadd4I_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVI src (LoadVector mem))); format %{ "vpaddd $dst,$src,$mem\t! add packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpaddd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpaddd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3358,8 +5247,8 @@ instruct vadd8I_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVI src1 src2)); format %{ "vpaddd $dst,$src1,$src2\t! add packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3369,8 +5258,30 @@ instruct vadd8I_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVI src (LoadVector mem))); format %{ "vpaddd $dst,$src,$mem\t! add packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpaddd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpaddd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd16I_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (AddVI src1 src2)); + format %{ "vpaddd $dst,$src1,$src2\t! add packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpaddd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd16I_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (AddVI src (LoadVector mem))); + format %{ "vpaddd $dst,$src,$mem\t! add packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpaddd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3391,8 +5302,8 @@ instruct vadd2L_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVL src1 src2)); format %{ "vpaddq $dst,$src1,$src2\t! add packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpaddq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpaddq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3402,8 +5313,8 @@ instruct vadd2L_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVL src (LoadVector mem))); format %{ "vpaddq $dst,$src,$mem\t! add packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpaddq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpaddq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3413,8 +5324,8 @@ instruct vadd4L_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVL src1 src2)); format %{ "vpaddq $dst,$src1,$src2\t! add packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpaddq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpaddq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3424,8 +5335,30 @@ instruct vadd4L_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVL src (LoadVector mem))); format %{ "vpaddq $dst,$src,$mem\t! add packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpaddq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpaddq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd8L_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (AddVL src1 src2)); + format %{ "vpaddq $dst,$src1,$src2\t! add packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpaddq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd8L_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (AddVL src (LoadVector mem))); + format %{ "vpaddq $dst,$src,$mem\t! add packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpaddq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3446,8 +5379,8 @@ instruct vadd2F_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (AddVF src1 src2)); format %{ "vaddps $dst,$src1,$src2\t! add packed2F" %} ins_encode %{ - bool vector256 = false; - __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3467,8 +5400,8 @@ instruct vadd4F_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVF src1 src2)); format %{ "vaddps $dst,$src1,$src2\t! add packed4F" %} ins_encode %{ - bool vector256 = false; - __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3478,8 +5411,8 @@ instruct vadd4F_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVF src (LoadVector mem))); format %{ "vaddps $dst,$src,$mem\t! add packed4F" %} ins_encode %{ - bool vector256 = false; - __ vaddps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vaddps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3489,8 +5422,8 @@ instruct vadd8F_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVF src1 src2)); format %{ "vaddps $dst,$src1,$src2\t! add packed8F" %} ins_encode %{ - bool vector256 = true; - __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3500,8 +5433,30 @@ instruct vadd8F_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVF src (LoadVector mem))); format %{ "vaddps $dst,$src,$mem\t! add packed8F" %} ins_encode %{ - bool vector256 = true; - __ vaddps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vaddps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd16F_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (AddVF src1 src2)); + format %{ "vaddps $dst,$src1,$src2\t! add packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vaddps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd16F_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (AddVF src (LoadVector mem))); + format %{ "vaddps $dst,$src,$mem\t! add packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vaddps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3522,8 +5477,8 @@ instruct vadd2D_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AddVD src1 src2)); format %{ "vaddpd $dst,$src1,$src2\t! add packed2D" %} ins_encode %{ - bool vector256 = false; - __ vaddpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vaddpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3533,8 +5488,8 @@ instruct vadd2D_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AddVD src (LoadVector mem))); format %{ "vaddpd $dst,$src,$mem\t! add packed2D" %} ins_encode %{ - bool vector256 = false; - __ vaddpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vaddpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3544,8 +5499,8 @@ instruct vadd4D_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AddVD src1 src2)); format %{ "vaddpd $dst,$src1,$src2\t! add packed4D" %} ins_encode %{ - bool vector256 = true; - __ vaddpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vaddpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3555,8 +5510,30 @@ instruct vadd4D_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AddVD src (LoadVector mem))); format %{ "vaddpd $dst,$src,$mem\t! add packed4D" %} ins_encode %{ - bool vector256 = true; - __ vaddpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vaddpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd8D_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (AddVD src1 src2)); + format %{ "vaddpd $dst,$src1,$src2\t! add packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vaddpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vadd8D_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (AddVD src (LoadVector mem))); + format %{ "vaddpd $dst,$src,$mem\t! add packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vaddpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3579,8 +5556,8 @@ instruct vsub4B_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (SubVB src1 src2)); format %{ "vpsubb $dst,$src1,$src2\t! sub packed4B" %} ins_encode %{ - bool vector256 = false; - __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3600,8 +5577,8 @@ instruct vsub8B_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (SubVB src1 src2)); format %{ "vpsubb $dst,$src1,$src2\t! sub packed8B" %} ins_encode %{ - bool vector256 = false; - __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3621,8 +5598,8 @@ instruct vsub16B_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVB src1 src2)); format %{ "vpsubb $dst,$src1,$src2\t! sub packed16B" %} ins_encode %{ - bool vector256 = false; - __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3632,8 +5609,8 @@ instruct vsub16B_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVB src (LoadVector mem))); format %{ "vpsubb $dst,$src,$mem\t! sub packed16B" %} ins_encode %{ - bool vector256 = false; - __ vpsubb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpsubb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3643,8 +5620,8 @@ instruct vsub32B_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVB src1 src2)); format %{ "vpsubb $dst,$src1,$src2\t! sub packed32B" %} ins_encode %{ - bool vector256 = true; - __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3654,8 +5631,30 @@ instruct vsub32B_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVB src (LoadVector mem))); format %{ "vpsubb $dst,$src,$mem\t! sub packed32B" %} ins_encode %{ - bool vector256 = true; - __ vpsubb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpsubb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub64B_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 64); + match(Set dst (SubVB src1 src2)); + format %{ "vpsubb $dst,$src1,$src2\t! sub packed64B" %} + ins_encode %{ + int vector_len = 2; + __ vpsubb($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub64B_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 64); + match(Set dst (SubVB src (LoadVector mem))); + format %{ "vpsubb $dst,$src,$mem\t! sub packed64B" %} + ins_encode %{ + int vector_len = 2; + __ vpsubb($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3676,8 +5675,8 @@ instruct vsub2S_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (SubVS src1 src2)); format %{ "vpsubw $dst,$src1,$src2\t! sub packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3697,8 +5696,8 @@ instruct vsub4S_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (SubVS src1 src2)); format %{ "vpsubw $dst,$src1,$src2\t! sub packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3718,8 +5717,8 @@ instruct vsub8S_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVS src1 src2)); format %{ "vpsubw $dst,$src1,$src2\t! sub packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3729,8 +5728,8 @@ instruct vsub8S_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVS src (LoadVector mem))); format %{ "vpsubw $dst,$src,$mem\t! sub packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsubw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpsubw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3740,8 +5739,8 @@ instruct vsub16S_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVS src1 src2)); format %{ "vpsubw $dst,$src1,$src2\t! sub packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3751,8 +5750,30 @@ instruct vsub16S_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVS src (LoadVector mem))); format %{ "vpsubw $dst,$src,$mem\t! sub packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsubw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpsubw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub32S_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (SubVS src1 src2)); + format %{ "vpsubw $dst,$src1,$src2\t! sub packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsubw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub32S_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (SubVS src (LoadVector mem))); + format %{ "vpsubw $dst,$src,$mem\t! sub packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsubw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3773,8 +5794,8 @@ instruct vsub2I_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (SubVI src1 src2)); format %{ "vpsubd $dst,$src1,$src2\t! sub packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3794,8 +5815,8 @@ instruct vsub4I_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVI src1 src2)); format %{ "vpsubd $dst,$src1,$src2\t! sub packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3805,8 +5826,8 @@ instruct vsub4I_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVI src (LoadVector mem))); format %{ "vpsubd $dst,$src,$mem\t! sub packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsubd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpsubd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3816,8 +5837,8 @@ instruct vsub8I_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVI src1 src2)); format %{ "vpsubd $dst,$src1,$src2\t! sub packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3827,8 +5848,30 @@ instruct vsub8I_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVI src (LoadVector mem))); format %{ "vpsubd $dst,$src,$mem\t! sub packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsubd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpsubd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub16I_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (SubVI src1 src2)); + format %{ "vpsubd $dst,$src1,$src2\t! sub packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsubd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub16I_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (SubVI src (LoadVector mem))); + format %{ "vpsubd $dst,$src,$mem\t! sub packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsubd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3849,8 +5892,8 @@ instruct vsub2L_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVL src1 src2)); format %{ "vpsubq $dst,$src1,$src2\t! sub packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsubq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpsubq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3860,8 +5903,8 @@ instruct vsub2L_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVL src (LoadVector mem))); format %{ "vpsubq $dst,$src,$mem\t! sub packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsubq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpsubq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3871,8 +5914,8 @@ instruct vsub4L_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVL src1 src2)); format %{ "vpsubq $dst,$src1,$src2\t! sub packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsubq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpsubq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3882,8 +5925,30 @@ instruct vsub4L_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVL src (LoadVector mem))); format %{ "vpsubq $dst,$src,$mem\t! sub packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsubq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpsubq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub8L_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (SubVL src1 src2)); + format %{ "vpsubq $dst,$src1,$src2\t! sub packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsubq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub8L_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (SubVL src (LoadVector mem))); + format %{ "vpsubq $dst,$src,$mem\t! sub packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsubq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3904,8 +5969,8 @@ instruct vsub2F_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (SubVF src1 src2)); format %{ "vsubps $dst,$src1,$src2\t! sub packed2F" %} ins_encode %{ - bool vector256 = false; - __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3925,8 +5990,8 @@ instruct vsub4F_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVF src1 src2)); format %{ "vsubps $dst,$src1,$src2\t! sub packed4F" %} ins_encode %{ - bool vector256 = false; - __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3936,8 +6001,8 @@ instruct vsub4F_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVF src (LoadVector mem))); format %{ "vsubps $dst,$src,$mem\t! sub packed4F" %} ins_encode %{ - bool vector256 = false; - __ vsubps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vsubps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3947,8 +6012,8 @@ instruct vsub8F_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVF src1 src2)); format %{ "vsubps $dst,$src1,$src2\t! sub packed8F" %} ins_encode %{ - bool vector256 = true; - __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3958,8 +6023,30 @@ instruct vsub8F_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVF src (LoadVector mem))); format %{ "vsubps $dst,$src,$mem\t! sub packed8F" %} ins_encode %{ - bool vector256 = true; - __ vsubps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vsubps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub16F_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (SubVF src1 src2)); + format %{ "vsubps $dst,$src1,$src2\t! sub packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vsubps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub16F_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (SubVF src (LoadVector mem))); + format %{ "vsubps $dst,$src,$mem\t! sub packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vsubps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3980,8 +6067,8 @@ instruct vsub2D_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (SubVD src1 src2)); format %{ "vsubpd $dst,$src1,$src2\t! sub packed2D" %} ins_encode %{ - bool vector256 = false; - __ vsubpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vsubpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -3991,8 +6078,8 @@ instruct vsub2D_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (SubVD src (LoadVector mem))); format %{ "vsubpd $dst,$src,$mem\t! sub packed2D" %} ins_encode %{ - bool vector256 = false; - __ vsubpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vsubpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4002,8 +6089,8 @@ instruct vsub4D_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (SubVD src1 src2)); format %{ "vsubpd $dst,$src1,$src2\t! sub packed4D" %} ins_encode %{ - bool vector256 = true; - __ vsubpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vsubpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4013,8 +6100,30 @@ instruct vsub4D_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (SubVD src (LoadVector mem))); format %{ "vsubpd $dst,$src,$mem\t! sub packed4D" %} ins_encode %{ - bool vector256 = true; - __ vsubpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vsubpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub8D_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (SubVD src1 src2)); + format %{ "vsubpd $dst,$src1,$src2\t! sub packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vsubpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsub8D_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (SubVD src (LoadVector mem))); + format %{ "vsubpd $dst,$src,$mem\t! sub packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vsubpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4037,8 +6146,8 @@ instruct vmul2S_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (MulVS src1 src2)); format %{ "vpmullw $dst,$src1,$src2\t! mul packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4058,8 +6167,8 @@ instruct vmul4S_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (MulVS src1 src2)); format %{ "vpmullw $dst,$src1,$src2\t! mul packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4079,8 +6188,8 @@ instruct vmul8S_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (MulVS src1 src2)); format %{ "vpmullw $dst,$src1,$src2\t! mul packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4090,8 +6199,8 @@ instruct vmul8S_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (MulVS src (LoadVector mem))); format %{ "vpmullw $dst,$src,$mem\t! mul packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpmullw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpmullw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4101,8 +6210,8 @@ instruct vmul16S_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (MulVS src1 src2)); format %{ "vpmullw $dst,$src1,$src2\t! mul packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4112,8 +6221,30 @@ instruct vmul16S_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (MulVS src (LoadVector mem))); format %{ "vpmullw $dst,$src,$mem\t! mul packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpmullw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpmullw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul32S_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (MulVS src1 src2)); + format %{ "vpmullw $dst,$src1,$src2\t! mul packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpmullw($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul32S_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (MulVS src (LoadVector mem))); + format %{ "vpmullw $dst,$src,$mem\t! mul packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpmullw($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4134,8 +6265,19 @@ instruct vmul2I_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (MulVI src1 src2)); format %{ "vpmulld $dst,$src1,$src2\t! mul packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul2L_reg(vecX dst, vecX src1, vecX src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 2 && VM_Version::supports_avx512dq()); + match(Set dst (MulVL src1 src2)); + format %{ "vpmullq $dst,$src1,$src2\t! mul packed2L" %} + ins_encode %{ + int vector_len = 0; + __ vpmullq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4155,8 +6297,8 @@ instruct vmul4I_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (MulVI src1 src2)); format %{ "vpmulld $dst,$src1,$src2\t! mul packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4166,8 +6308,30 @@ instruct vmul4I_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (MulVI src (LoadVector mem))); format %{ "vpmulld $dst,$src,$mem\t! mul packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpmulld($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpmulld($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul4L_reg(vecY dst, vecY src1, vecY src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 4 && VM_Version::supports_avx512dq()); + match(Set dst (MulVL src1 src2)); + format %{ "vpmullq $dst,$src1,$src2\t! mul packed4L" %} + ins_encode %{ + int vector_len = 1; + __ vpmullq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul4L_mem(vecY dst, vecY src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 4 && VM_Version::supports_avx512dq()); + match(Set dst (MulVL src (LoadVector mem))); + format %{ "vpmullq $dst,$src,$mem\t! mul packed4L" %} + ins_encode %{ + int vector_len = 1; + __ vpmullq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4177,8 +6341,30 @@ instruct vmul8I_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (MulVI src1 src2)); format %{ "vpmulld $dst,$src1,$src2\t! mul packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul8L_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && VM_Version::supports_avx512dq()); + match(Set dst (MulVL src1 src2)); + format %{ "vpmullq $dst,$src1,$src2\t! mul packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpmullq($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul16I_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (MulVI src1 src2)); + format %{ "vpmulld $dst,$src1,$src2\t! mul packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpmulld($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4188,8 +6374,30 @@ instruct vmul8I_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (MulVI src (LoadVector mem))); format %{ "vpmulld $dst,$src,$mem\t! mul packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpmulld($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpmulld($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul8L_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && VM_Version::supports_avx512dq()); + match(Set dst (MulVL src (LoadVector mem))); + format %{ "vpmullq $dst,$src,$mem\t! mul packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpmullq($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul16I_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (MulVI src (LoadVector mem))); + format %{ "vpmulld $dst,$src,$mem\t! mul packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpmulld($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4210,8 +6418,8 @@ instruct vmul2F_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (MulVF src1 src2)); format %{ "vmulps $dst,$src1,$src2\t! mul packed2F" %} ins_encode %{ - bool vector256 = false; - __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4231,8 +6439,8 @@ instruct vmul4F_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (MulVF src1 src2)); format %{ "vmulps $dst,$src1,$src2\t! mul packed4F" %} ins_encode %{ - bool vector256 = false; - __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4242,8 +6450,8 @@ instruct vmul4F_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (MulVF src (LoadVector mem))); format %{ "vmulps $dst,$src,$mem\t! mul packed4F" %} ins_encode %{ - bool vector256 = false; - __ vmulps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vmulps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4253,8 +6461,8 @@ instruct vmul8F_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (MulVF src1 src2)); format %{ "vmulps $dst,$src1,$src2\t! mul packed8F" %} ins_encode %{ - bool vector256 = true; - __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4264,8 +6472,30 @@ instruct vmul8F_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (MulVF src (LoadVector mem))); format %{ "vmulps $dst,$src,$mem\t! mul packed8F" %} ins_encode %{ - bool vector256 = true; - __ vmulps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vmulps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul16F_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (MulVF src1 src2)); + format %{ "vmulps $dst,$src1,$src2\t! mul packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vmulps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul16F_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (MulVF src (LoadVector mem))); + format %{ "vmulps $dst,$src,$mem\t! mul packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vmulps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4286,8 +6516,8 @@ instruct vmul2D_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (MulVD src1 src2)); format %{ "vmulpd $dst,$src1,$src2\t! mul packed2D" %} ins_encode %{ - bool vector256 = false; - __ vmulpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vmulpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4297,8 +6527,8 @@ instruct vmul2D_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (MulVD src (LoadVector mem))); format %{ "vmulpd $dst,$src,$mem\t! mul packed2D" %} ins_encode %{ - bool vector256 = false; - __ vmulpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vmulpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4308,8 +6538,8 @@ instruct vmul4D_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (MulVD src1 src2)); format %{ "vmulpd $dst,$src1,$src2\t! mul packed4D" %} ins_encode %{ - bool vector256 = true; - __ vmulpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vmulpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4319,8 +6549,30 @@ instruct vmul4D_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (MulVD src (LoadVector mem))); format %{ "vmulpd $dst,$src,$mem\t! mul packed4D" %} ins_encode %{ - bool vector256 = true; - __ vmulpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vmulpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul8D_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (MulVD src1 src2)); + format %{ "vmulpd $dst k0,$src1,$src2\t! mul packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vmulpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vmul8D_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (MulVD src (LoadVector mem))); + format %{ "vmulpd $dst k0,$src,$mem\t! mul packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vmulpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4343,8 +6595,8 @@ instruct vdiv2F_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (DivVF src1 src2)); format %{ "vdivps $dst,$src1,$src2\t! div packed2F" %} ins_encode %{ - bool vector256 = false; - __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4364,8 +6616,8 @@ instruct vdiv4F_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (DivVF src1 src2)); format %{ "vdivps $dst,$src1,$src2\t! div packed4F" %} ins_encode %{ - bool vector256 = false; - __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4375,8 +6627,8 @@ instruct vdiv4F_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (DivVF src (LoadVector mem))); format %{ "vdivps $dst,$src,$mem\t! div packed4F" %} ins_encode %{ - bool vector256 = false; - __ vdivps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vdivps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4386,8 +6638,8 @@ instruct vdiv8F_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (DivVF src1 src2)); format %{ "vdivps $dst,$src1,$src2\t! div packed8F" %} ins_encode %{ - bool vector256 = true; - __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4397,8 +6649,30 @@ instruct vdiv8F_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (DivVF src (LoadVector mem))); format %{ "vdivps $dst,$src,$mem\t! div packed8F" %} ins_encode %{ - bool vector256 = true; - __ vdivps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vdivps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vdiv16F_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 16); + match(Set dst (DivVF src1 src2)); + format %{ "vdivps $dst,$src1,$src2\t! div packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vdivps($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vdiv16F_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 16); + match(Set dst (DivVF src (LoadVector mem))); + format %{ "vdivps $dst,$src,$mem\t! div packed16F" %} + ins_encode %{ + int vector_len = 2; + __ vdivps($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4419,8 +6693,8 @@ instruct vdiv2D_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (DivVD src1 src2)); format %{ "vdivpd $dst,$src1,$src2\t! div packed2D" %} ins_encode %{ - bool vector256 = false; - __ vdivpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vdivpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4430,8 +6704,8 @@ instruct vdiv2D_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (DivVD src (LoadVector mem))); format %{ "vdivpd $dst,$src,$mem\t! div packed2D" %} ins_encode %{ - bool vector256 = false; - __ vdivpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vdivpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4441,8 +6715,8 @@ instruct vdiv4D_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (DivVD src1 src2)); format %{ "vdivpd $dst,$src1,$src2\t! div packed4D" %} ins_encode %{ - bool vector256 = true; - __ vdivpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vdivpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4452,8 +6726,30 @@ instruct vdiv4D_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (DivVD src (LoadVector mem))); format %{ "vdivpd $dst,$src,$mem\t! div packed4D" %} ins_encode %{ - bool vector256 = true; - __ vdivpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vdivpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vdiv8D_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (DivVD src1 src2)); + format %{ "vdivpd $dst,$src1,$src2\t! div packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vdivpd($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vdiv8D_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (DivVD src (LoadVector mem))); + format %{ "vdivpd $dst,$src,$mem\t! div packed8D" %} + ins_encode %{ + int vector_len = 2; + __ vdivpd($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4500,8 +6796,8 @@ instruct vsll2S_reg(vecS dst, vecS src, vecS shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4511,8 +6807,8 @@ instruct vsll2S_reg_imm(vecS dst, vecS src, immI8 shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4542,8 +6838,8 @@ instruct vsll4S_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4553,8 +6849,8 @@ instruct vsll4S_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4584,8 +6880,8 @@ instruct vsll8S_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4595,8 +6891,8 @@ instruct vsll8S_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4606,8 +6902,8 @@ instruct vsll16S_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4617,8 +6913,30 @@ instruct vsll16S_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (LShiftVS src shift)); format %{ "vpsllw $dst,$src,$shift\t! left shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll32S_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (LShiftVS src shift)); + format %{ "vpsllw $dst,$src,$shift\t! left shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll32S_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (LShiftVS src shift)); + format %{ "vpsllw $dst,$src,$shift\t! left shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsllw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4649,8 +6967,8 @@ instruct vsll2I_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4660,8 +6978,8 @@ instruct vsll2I_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4691,8 +7009,8 @@ instruct vsll4I_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4702,8 +7020,8 @@ instruct vsll4I_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4713,8 +7031,8 @@ instruct vsll8I_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4724,8 +7042,30 @@ instruct vsll8I_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (LShiftVI src shift)); format %{ "vpslld $dst,$src,$shift\t! left shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll16I_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (LShiftVI src shift)); + format %{ "vpslld $dst,$src,$shift\t! left shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll16I_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (LShiftVI src shift)); + format %{ "vpslld $dst,$src,$shift\t! left shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpslld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4756,8 +7096,8 @@ instruct vsll2L_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (LShiftVL src shift)); format %{ "vpsllq $dst,$src,$shift\t! left shift packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4767,8 +7107,8 @@ instruct vsll2L_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (LShiftVL src shift)); format %{ "vpsllq $dst,$src,$shift\t! left shift packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4778,8 +7118,8 @@ instruct vsll4L_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (LShiftVL src shift)); format %{ "vpsllq $dst,$src,$shift\t! left shift packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4789,8 +7129,30 @@ instruct vsll4L_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (LShiftVL src shift)); format %{ "vpsllq $dst,$src,$shift\t! left shift packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll8L_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (LShiftVL src shift)); + format %{ "vpsllq $dst,$src,$shift\t! left shift packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsll8L_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (LShiftVL src shift)); + format %{ "vpsllq $dst,$src,$shift\t! left shift packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsllq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4827,8 +7189,8 @@ instruct vsrl2S_reg(vecS dst, vecS src, vecS shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4838,8 +7200,8 @@ instruct vsrl2S_reg_imm(vecS dst, vecS src, immI8 shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4869,8 +7231,8 @@ instruct vsrl4S_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4880,8 +7242,8 @@ instruct vsrl4S_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4911,8 +7273,8 @@ instruct vsrl8S_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4922,8 +7284,8 @@ instruct vsrl8S_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4933,8 +7295,8 @@ instruct vsrl16S_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4944,8 +7306,30 @@ instruct vsrl16S_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (URShiftVS src shift)); format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl32S_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (URShiftVS src shift)); + format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl32S_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (URShiftVS src shift)); + format %{ "vpsrlw $dst,$src,$shift\t! logical right shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsrlw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4976,8 +7360,8 @@ instruct vsrl2I_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -4987,8 +7371,8 @@ instruct vsrl2I_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5018,8 +7402,8 @@ instruct vsrl4I_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5029,8 +7413,8 @@ instruct vsrl4I_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5040,8 +7424,8 @@ instruct vsrl8I_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5051,8 +7435,30 @@ instruct vsrl8I_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (URShiftVI src shift)); format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl16I_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (URShiftVI src shift)); + format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl16I_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (URShiftVI src shift)); + format %{ "vpsrld $dst,$src,$shift\t! logical right shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsrld($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5083,8 +7489,8 @@ instruct vsrl2L_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (URShiftVL src shift)); format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5094,8 +7500,8 @@ instruct vsrl2L_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (URShiftVL src shift)); format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed2L" %} ins_encode %{ - bool vector256 = false; - __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5105,8 +7511,8 @@ instruct vsrl4L_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (URShiftVL src shift)); format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5116,8 +7522,30 @@ instruct vsrl4L_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (URShiftVL src shift)); format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed4L" %} ins_encode %{ - bool vector256 = true; - __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl8L_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (URShiftVL src shift)); + format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsrl8L_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8); + match(Set dst (URShiftVL src shift)); + format %{ "vpsrlq $dst,$src,$shift\t! logical right shift packed8L" %} + ins_encode %{ + int vector_len = 2; + __ vpsrlq($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5150,8 +7578,8 @@ instruct vsra2S_reg(vecS dst, vecS src, vecS shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5161,8 +7589,8 @@ instruct vsra2S_reg_imm(vecS dst, vecS src, immI8 shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed2S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5192,8 +7620,8 @@ instruct vsra4S_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5203,8 +7631,8 @@ instruct vsra4S_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed4S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5234,8 +7662,8 @@ instruct vsra8S_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5245,8 +7673,8 @@ instruct vsra8S_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed8S" %} ins_encode %{ - bool vector256 = false; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5256,8 +7684,8 @@ instruct vsra16S_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5267,8 +7695,30 @@ instruct vsra16S_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (RShiftVS src shift)); format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed16S" %} ins_encode %{ - bool vector256 = true; - __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsra32S_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (RShiftVS src shift)); + format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsra32S_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32); + match(Set dst (RShiftVS src shift)); + format %{ "vpsraw $dst,$src,$shift\t! arithmetic right shift packed32S" %} + ins_encode %{ + int vector_len = 2; + __ vpsraw($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5299,8 +7749,8 @@ instruct vsra2I_reg(vecD dst, vecD src, vecS shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5310,8 +7760,8 @@ instruct vsra2I_reg_imm(vecD dst, vecD src, immI8 shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed2I" %} ins_encode %{ - bool vector256 = false; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5341,8 +7791,8 @@ instruct vsra4I_reg(vecX dst, vecX src, vecS shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 0; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5352,8 +7802,8 @@ instruct vsra4I_reg_imm(vecX dst, vecX src, immI8 shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed4I" %} ins_encode %{ - bool vector256 = false; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 0; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5363,8 +7813,8 @@ instruct vsra8I_reg(vecY dst, vecY src, vecS shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector256); + int vector_len = 1; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5374,8 +7824,30 @@ instruct vsra8I_reg_imm(vecY dst, vecY src, immI8 shift) %{ match(Set dst (RShiftVI src shift)); format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed8I" %} ins_encode %{ - bool vector256 = true; - __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector256); + int vector_len = 1; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsra16I_reg(vecZ dst, vecZ src, vecS shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (RShiftVI src shift)); + format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, $shift$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vsra16I_reg_imm(vecZ dst, vecZ src, immI8 shift) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16); + match(Set dst (RShiftVI src shift)); + format %{ "vpsrad $dst,$src,$shift\t! arithmetic right shift packed16I" %} + ins_encode %{ + int vector_len = 2; + __ vpsrad($dst$$XMMRegister, $src$$XMMRegister, (int)$shift$$constant, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5400,8 +7872,8 @@ instruct vand4B_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (AndV src1 src2)); format %{ "vpand $dst,$src1,$src2\t! and vectors (4 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5421,8 +7893,8 @@ instruct vand8B_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (AndV src1 src2)); format %{ "vpand $dst,$src1,$src2\t! and vectors (8 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5442,8 +7914,8 @@ instruct vand16B_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (AndV src1 src2)); format %{ "vpand $dst,$src1,$src2\t! and vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5453,8 +7925,8 @@ instruct vand16B_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (AndV src (LoadVector mem))); format %{ "vpand $dst,$src,$mem\t! and vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpand($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5464,8 +7936,8 @@ instruct vand32B_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (AndV src1 src2)); format %{ "vpand $dst,$src1,$src2\t! and vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5475,8 +7947,30 @@ instruct vand32B_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (AndV src (LoadVector mem))); format %{ "vpand $dst,$src,$mem\t! and vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpand($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vand64B_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (AndV src1 src2)); + format %{ "vpand $dst,$src1,$src2\t! and vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpand($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vand64B_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (AndV src (LoadVector mem))); + format %{ "vpand $dst,$src,$mem\t! and vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5498,8 +7992,8 @@ instruct vor4B_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (OrV src1 src2)); format %{ "vpor $dst,$src1,$src2\t! or vectors (4 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5519,8 +8013,8 @@ instruct vor8B_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (OrV src1 src2)); format %{ "vpor $dst,$src1,$src2\t! or vectors (8 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5540,8 +8034,8 @@ instruct vor16B_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (OrV src1 src2)); format %{ "vpor $dst,$src1,$src2\t! or vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5551,8 +8045,8 @@ instruct vor16B_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (OrV src (LoadVector mem))); format %{ "vpor $dst,$src,$mem\t! or vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5562,8 +8056,8 @@ instruct vor32B_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (OrV src1 src2)); format %{ "vpor $dst,$src1,$src2\t! or vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5573,8 +8067,30 @@ instruct vor32B_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (OrV src (LoadVector mem))); format %{ "vpor $dst,$src,$mem\t! or vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vor64B_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (OrV src1 src2)); + format %{ "vpor $dst,$src1,$src2\t! or vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vor64B_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (OrV src (LoadVector mem))); + format %{ "vpor $dst,$src,$mem\t! or vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5596,8 +8112,8 @@ instruct vxor4B_reg(vecS dst, vecS src1, vecS src2) %{ match(Set dst (XorV src1 src2)); format %{ "vpxor $dst,$src1,$src2\t! xor vectors (4 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5617,8 +8133,8 @@ instruct vxor8B_reg(vecD dst, vecD src1, vecD src2) %{ match(Set dst (XorV src1 src2)); format %{ "vpxor $dst,$src1,$src2\t! xor vectors (8 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5638,8 +8154,8 @@ instruct vxor16B_reg(vecX dst, vecX src1, vecX src2) %{ match(Set dst (XorV src1 src2)); format %{ "vpxor $dst,$src1,$src2\t! xor vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 0; + __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5649,8 +8165,8 @@ instruct vxor16B_mem(vecX dst, vecX src, memory mem) %{ match(Set dst (XorV src (LoadVector mem))); format %{ "vpxor $dst,$src,$mem\t! xor vectors (16 bytes)" %} ins_encode %{ - bool vector256 = false; - __ vpxor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 0; + __ vpxor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5660,8 +8176,8 @@ instruct vxor32B_reg(vecY dst, vecY src1, vecY src2) %{ match(Set dst (XorV src1 src2)); format %{ "vpxor $dst,$src1,$src2\t! xor vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} @@ -5671,8 +8187,30 @@ instruct vxor32B_mem(vecY dst, vecY src, memory mem) %{ match(Set dst (XorV src (LoadVector mem))); format %{ "vpxor $dst,$src,$mem\t! xor vectors (32 bytes)" %} ins_encode %{ - bool vector256 = true; - __ vpxor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector256); + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vxor64B_reg(vecZ dst, vecZ src1, vecZ src2) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (XorV src1 src2)); + format %{ "vpxor $dst,$src1,$src2\t! xor vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vxor64B_mem(vecZ dst, vecZ src, memory mem) %{ + predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); + match(Set dst (XorV src (LoadVector mem))); + format %{ "vpxor $dst,$src,$mem\t! xor vectors (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $src$$XMMRegister, $mem$$Address, vector_len); %} ins_pipe( pipe_slow ); %} diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 709c908c3b4..23731beea1a 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -101,6 +101,17 @@ reg_def FPR6L( SOC, SOC, Op_RegF, 6, as_FloatRegister(5)->as_VMReg()); reg_def FPR6H( SOC, SOC, Op_RegF, 6, as_FloatRegister(5)->as_VMReg()->next()); reg_def FPR7L( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()); reg_def FPR7H( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next()); +// +// Empty fill registers, which are never used, but supply alignment to xmm regs +// +reg_def FILL0( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(2)); +reg_def FILL1( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(3)); +reg_def FILL2( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(4)); +reg_def FILL3( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(5)); +reg_def FILL4( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(6)); +reg_def FILL5( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(7)); +reg_def FILL6( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(8)); +reg_def FILL7( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next(9)); // Specify priority of register selection within phases of register // allocation. Highest priority is first. A useful heuristic is to @@ -112,7 +123,8 @@ reg_def FPR7H( SOC, SOC, Op_RegF, 7, as_FloatRegister(6)->as_VMReg()->next()); alloc_class chunk0( ECX, EBX, EBP, EDI, EAX, EDX, ESI, ESP, FPR0L, FPR0H, FPR1L, FPR1H, FPR2L, FPR2H, FPR3L, FPR3H, FPR4L, FPR4H, FPR5L, FPR5H, - FPR6L, FPR6H, FPR7L, FPR7H ); + FPR6L, FPR6H, FPR7L, FPR7H, + FILL0, FILL1, FILL2, FILL3, FILL4, FILL5, FILL6, FILL7); //----------Architecture Description Register Classes-------------------------- @@ -131,7 +143,7 @@ reg_class any_reg_with_ebp(EAX, EDX, EBP, EDI, ESI, ECX, EBX, ESP); // Class for all registers (excluding EBP) reg_class any_reg_no_ebp(EAX, EDX, EDI, ESI, ECX, EBX, ESP); // Dynamic register class that selects at runtime between register classes -// any_reg and any_no_ebp_reg (depending on the value of the flag PreserveFramePointer). +// any_reg and any_no_ebp_reg (depending on the value of the flag PreserveFramePointer). // Equivalent to: return PreserveFramePointer ? any_no_ebp_reg : any_reg; reg_class_dynamic any_reg(any_reg_no_ebp, any_reg_with_ebp, %{ PreserveFramePointer %}); @@ -279,7 +291,9 @@ static int pre_call_resets_size() { size += 6; // fldcw } if (C->max_vector_size() > 16) { - size += 3; // vzeroupper + if(UseAVX <= 2) { + size += 3; // vzeroupper + } } return size; } @@ -288,7 +302,7 @@ static int pre_call_resets_size() { // from the start of the call to the point where the return address // will point. int MachCallStaticJavaNode::ret_addr_offset() { - return 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points + return 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points } int MachCallDynamicJavaNode::ret_addr_offset() { @@ -767,6 +781,12 @@ static int impl_helper( CodeBuffer *cbuf, bool do_size, bool is_load, int offset // Helper for XMM registers. Extra opcode bits, limited syntax. static int impl_x_helper( CodeBuffer *cbuf, bool do_size, bool is_load, int offset, int reg_lo, int reg_hi, int size, outputStream* st ) { + int in_size_in_bits = Assembler::EVEX_32bit; + int evex_encoding = 0; + if (reg_lo+1 == reg_hi) { + in_size_in_bits = Assembler::EVEX_64bit; + evex_encoding = Assembler::VEX_W; + } if (cbuf) { MacroAssembler _masm(cbuf); if (reg_lo+1 == reg_hi) { // double move? @@ -799,7 +819,17 @@ static int impl_x_helper( CodeBuffer *cbuf, bool do_size, bool is_load, } #endif } - int offset_size = (offset == 0) ? 0 : ((offset <= 127) ? 1 : 4); + bool is_single_byte = false; + if ((UseAVX > 2) && (offset != 0)) { + is_single_byte = Assembler::query_compressed_disp_byte(offset, true, 0, Assembler::EVEX_T1S, in_size_in_bits, evex_encoding); + } + int offset_size = 0; + if (UseAVX > 2 ) { + offset_size = (offset == 0) ? 0 : ((is_single_byte) ? 1 : 4); + } else { + offset_size = (offset == 0) ? 0 : ((offset <= 127) ? 1 : 4); + } + size += (UseAVX > 2) ? 2 : 0; // Need an additional two bytes for EVEX // VEX_2bytes prefix is used if UseAVX > 0, so it takes the same 2 bytes as SIMD prefix. return size+5+offset_size; } @@ -835,8 +865,8 @@ static int impl_movx_helper( CodeBuffer *cbuf, bool do_size, int src_lo, int dst #endif } // VEX_2bytes prefix is used if UseAVX > 0, and it takes the same 2 bytes as SIMD prefix. - // Only MOVAPS SSE prefix uses 1 byte. - int sz = 4; + // Only MOVAPS SSE prefix uses 1 byte. EVEX uses an additional 2 bytes. + int sz = (UseAVX > 2) ? 6 : 4; if (!(src_lo+1 == src_hi && dst_lo+1 == dst_hi) && UseXmmRegToRegMoveAll && (UseAVX == 0)) sz = 3; return size + sz; @@ -854,7 +884,7 @@ static int impl_movgpr2x_helper( CodeBuffer *cbuf, bool do_size, int src_lo, int st->print("movdl %s, %s\t# spill", Matcher::regName[dst_lo], Matcher::regName[src_lo]); #endif } - return 4; + return (UseAVX> 2) ? 6 : 4; } @@ -870,7 +900,7 @@ static int impl_movx2gpr_helper( CodeBuffer *cbuf, bool do_size, int src_lo, int st->print("movdl %s, %s\t# spill", Matcher::regName[dst_lo], Matcher::regName[src_lo]); #endif } - return 4; + return (UseAVX> 2) ? 6 : 4; } static int impl_mov_helper( CodeBuffer *cbuf, bool do_size, int src, int dst, int size, outputStream* st ) { @@ -941,9 +971,8 @@ static int vec_stack_to_stack_helper(CodeBuffer *cbuf, bool do_size, int src_off calc_size += 3+src_offset_size + 3+dst_offset_size; break; case Op_VecX: - calc_size = 6 + 6 + 5+src_offset_size + 5+dst_offset_size; - break; case Op_VecY: + case Op_VecZ: calc_size = 6 + 6 + 5+src_offset_size + 5+dst_offset_size; break; default: @@ -974,6 +1003,11 @@ static int vec_stack_to_stack_helper(CodeBuffer *cbuf, bool do_size, int src_off __ vmovdqu(xmm0, Address(rsp, src_offset)); __ vmovdqu(Address(rsp, dst_offset), xmm0); __ vmovdqu(xmm0, Address(rsp, -32)); + case Op_VecZ: + __ evmovdqu(Address(rsp, -64), xmm0, 2); + __ evmovdqu(xmm0, Address(rsp, src_offset), 2); + __ evmovdqu(Address(rsp, dst_offset), xmm0, 2); + __ evmovdqu(xmm0, Address(rsp, -64), 2); break; default: ShouldNotReachHere(); @@ -1009,6 +1043,12 @@ static int vec_stack_to_stack_helper(CodeBuffer *cbuf, bool do_size, int src_off "vmovdqu [rsp + #%d], xmm0\n\t" "vmovdqu xmm0, [rsp - #32]", src_offset, dst_offset); + case Op_VecZ: + st->print("vmovdqu [rsp - #64], xmm0\t# 512-bit mem-mem spill\n\t" + "vmovdqu xmm0, [rsp + #%d]\n\t" + "vmovdqu [rsp + #%d], xmm0\n\t" + "vmovdqu xmm0, [rsp - #64]", + src_offset, dst_offset); break; default: ShouldNotReachHere(); @@ -1042,7 +1082,7 @@ uint MachSpillCopyNode::implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bo uint ireg = ideal_reg(); assert((src_first_rc != rc_int && dst_first_rc != rc_int), "sanity"); assert((src_first_rc != rc_float && dst_first_rc != rc_float), "sanity"); - assert((ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY), "sanity"); + assert((ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY || ireg == Op_VecZ ), "sanity"); if( src_first_rc == rc_stack && dst_first_rc == rc_stack ) { // mem -> mem int src_offset = ra_->reg2offset(src_first); @@ -3998,7 +4038,7 @@ operand regFPR1(regFPR reg) %{ // XMM Float register operands operand regF() %{ predicate( UseSSE>=1 ); - constraint(ALLOC_IN_RC(float_reg)); + constraint(ALLOC_IN_RC(float_reg_legacy)); match(RegF); format %{ %} interface(REG_INTER); @@ -4007,12 +4047,45 @@ operand regF() %{ // XMM Double register operands operand regD() %{ predicate( UseSSE>=2 ); - constraint(ALLOC_IN_RC(double_reg)); + constraint(ALLOC_IN_RC(double_reg_legacy)); match(RegD); format %{ %} interface(REG_INTER); %} +// Vectors : note, we use legacy registers to avoid extra (unneeded in 32-bit VM) +// runtime code generation via reg_class_dynamic. +operand vecS() %{ + constraint(ALLOC_IN_RC(vectors_reg_legacy)); + match(VecS); + + format %{ %} + interface(REG_INTER); +%} + +operand vecD() %{ + constraint(ALLOC_IN_RC(vectord_reg_legacy)); + match(VecD); + + format %{ %} + interface(REG_INTER); +%} + +operand vecX() %{ + constraint(ALLOC_IN_RC(vectorx_reg_legacy)); + match(VecX); + + format %{ %} + interface(REG_INTER); +%} + +operand vecY() %{ + constraint(ALLOC_IN_RC(vectory_reg_legacy)); + match(VecY); + + format %{ %} + interface(REG_INTER); +%} //----------Memory Operands---------------------------------------------------- // Direct Memory Operand @@ -5020,11 +5093,11 @@ instruct bytes_reverse_unsigned_short(rRegI dst, eFlagsReg cr) %{ match(Set dst (ReverseBytesUS dst)); effect(KILL cr); - format %{ "BSWAP $dst\n\t" + format %{ "BSWAP $dst\n\t" "SHR $dst,16\n\t" %} ins_encode %{ __ bswapl($dst$$Register); - __ shrl($dst$$Register, 16); + __ shrl($dst$$Register, 16); %} ins_pipe( ialu_reg ); %} @@ -5033,11 +5106,11 @@ instruct bytes_reverse_short(rRegI dst, eFlagsReg cr) %{ match(Set dst (ReverseBytesS dst)); effect(KILL cr); - format %{ "BSWAP $dst\n\t" + format %{ "BSWAP $dst\n\t" "SAR $dst,16\n\t" %} ins_encode %{ __ bswapl($dst$$Register); - __ sarl($dst$$Register, 16); + __ sarl($dst$$Register, 16); %} ins_pipe( ialu_reg ); %} @@ -6525,7 +6598,7 @@ instruct membar_volatile(eFlagsReg cr) %{ effect(KILL cr); ins_cost(400); - format %{ + format %{ $$template if (os::is_MP()) { $$emit$$"LOCK ADDL [ESP + #0], 0\t! membar_volatile" @@ -8288,10 +8361,10 @@ instruct xorI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ // Xor Register with Immediate -1 instruct xorI_eReg_im1(rRegI dst, immI_M1 imm) %{ - match(Set dst (XorI dst imm)); + match(Set dst (XorI dst imm)); size(2); - format %{ "NOT $dst" %} + format %{ "NOT $dst" %} ins_encode %{ __ notl($dst$$Register); %} @@ -8939,7 +9012,7 @@ instruct xorl_eReg(eRegL dst, eRegL src, eFlagsReg cr) %{ // Xor Long Register with Immediate -1 instruct xorl_eReg_im1(eRegL dst, immL_M1 imm) %{ - match(Set dst (XorL dst imm)); + match(Set dst (XorL dst imm)); format %{ "NOT $dst.lo\n\t" "NOT $dst.hi" %} ins_encode %{ @@ -8994,7 +9067,7 @@ instruct shlL_eReg_2(eRegL dst, immI_2 cnt, eFlagsReg cr) %{ effect(KILL cr); ins_cost(100); format %{ "ADD $dst.lo,$dst.lo\n\t" - "ADC $dst.hi,$dst.hi\n\t" + "ADC $dst.hi,$dst.hi\n\t" "ADD $dst.lo,$dst.lo\n\t" "ADC $dst.hi,$dst.hi" %} ins_encode %{ @@ -9013,9 +9086,9 @@ instruct shlL_eReg_3(eRegL dst, immI_3 cnt, eFlagsReg cr) %{ effect(KILL cr); ins_cost(100); format %{ "ADD $dst.lo,$dst.lo\n\t" - "ADC $dst.hi,$dst.hi\n\t" + "ADC $dst.hi,$dst.hi\n\t" "ADD $dst.lo,$dst.lo\n\t" - "ADC $dst.hi,$dst.hi\n\t" + "ADC $dst.hi,$dst.hi\n\t" "ADD $dst.lo,$dst.lo\n\t" "ADC $dst.hi,$dst.hi" %} ins_encode %{ @@ -11168,7 +11241,6 @@ instruct convL2I_reg( rRegI dst, eRegL src ) %{ ins_pipe( ialu_reg_reg ); %} - instruct MoveF2I_stack_reg(rRegI dst, stackSlotF src) %{ match(Set dst (MoveF2I src)); effect( DEF dst, USE src ); @@ -11400,7 +11472,7 @@ instruct rep_stos(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlag format %{ "XOR EAX,EAX\t# ClearArray:\n\t" "SHL ECX,1\t# Convert doublewords to words\n\t" "REP STOS\t# store EAX into [EDI++] while ECX--" %} - ins_encode %{ + ins_encode %{ __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); %} ins_pipe( pipe_slow ); @@ -11413,7 +11485,7 @@ instruct rep_fast_stosb(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, format %{ "XOR EAX,EAX\t# ClearArray:\n\t" "SHL ECX,3\t# Convert doublewords to bytes\n\t" "REP STOSB\t# store EAX into [EDI++] while ECX--" %} - ins_encode %{ + ins_encode %{ __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); %} ins_pipe( pipe_slow ); diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 9abe58f5371..538ec3a360d 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -172,7 +172,7 @@ reg_class no_reg(); // Class for all pointer registers (including RSP and RBP) reg_class any_reg_with_rbp(RAX, RAX_H, RDX, RDX_H, - RBP, RBP_H, + RBP, RBP_H, RDI, RDI_H, RSI, RSI_H, RCX, RCX_H, @@ -189,7 +189,7 @@ reg_class any_reg_with_rbp(RAX, RAX_H, // Class for all pointer registers (including RSP, but excluding RBP) reg_class any_reg_no_rbp(RAX, RAX_H, - RDX, RDX_H, + RDX, RDX_H, RDI, RDI_H, RSI, RSI_H, RCX, RCX_H, @@ -205,10 +205,10 @@ reg_class any_reg_no_rbp(RAX, RAX_H, R15, R15_H); // Dynamic register class that selects at runtime between register classes -// any_reg_no_rbp and any_reg_with_rbp (depending on the value of the flag PreserveFramePointer). +// any_reg_no_rbp and any_reg_with_rbp (depending on the value of the flag PreserveFramePointer). // Equivalent to: return PreserveFramePointer ? any_reg_no_rbp : any_reg_with_rbp; reg_class_dynamic any_reg(any_reg_no_rbp, any_reg_with_rbp, %{ PreserveFramePointer %}); - + // Class for all pointer registers (excluding RSP) reg_class ptr_reg_with_rbp(RAX, RAX_H, RDX, RDX_H, @@ -226,7 +226,7 @@ reg_class ptr_reg_with_rbp(RAX, RAX_H, // Class for all pointer registers (excluding RSP and RBP) reg_class ptr_reg_no_rbp(RAX, RAX_H, - RDX, RDX_H, + RDX, RDX_H, RDI, RDI_H, RSI, RSI_H, RCX, RCX_H, @@ -536,7 +536,11 @@ source %{ #define __ _masm. static int clear_avx_size() { - return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper + if(UseAVX > 2) { + return 0; // vzeroupper is ignored + } else { + return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper + } } // !!!!! Special hack to get all types of calls to specify the byte offset @@ -545,7 +549,7 @@ static int clear_avx_size() { int MachCallStaticJavaNode::ret_addr_offset() { int offset = 5; // 5 bytes from start of call to where return address points - offset += clear_avx_size(); + offset += clear_avx_size(); return offset; } @@ -860,7 +864,7 @@ void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const { st->print("subq rsp, #%d\t# Create frame",framesize); st->print("\n\t"); framesize -= wordSize; - st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize); + st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize); if (PreserveFramePointer) { st->print("\n\t"); st->print("movq rbp, [rsp + #%d]\t# Save the caller's SP into rbp", (framesize + wordSize)); @@ -1070,6 +1074,11 @@ static void vec_stack_to_stack_helper(CodeBuffer *cbuf, int src_offset, __ vmovdqu(xmm0, Address(rsp, src_offset)); __ vmovdqu(Address(rsp, dst_offset), xmm0); __ vmovdqu(xmm0, Address(rsp, -32)); + case Op_VecZ: + __ evmovdqu(Address(rsp, -64), xmm0, 2); + __ evmovdqu(xmm0, Address(rsp, src_offset), 2); + __ evmovdqu(Address(rsp, dst_offset), xmm0, 2); + __ evmovdqu(xmm0, Address(rsp, -64), 2); break; default: ShouldNotReachHere(); @@ -1103,6 +1112,13 @@ static void vec_stack_to_stack_helper(CodeBuffer *cbuf, int src_offset, "vmovdqu xmm0, [rsp - #32]", src_offset, dst_offset); break; + case Op_VecZ: + st->print("vmovdqu [rsp - #64], xmm0\t# 512-bit mem-mem spill\n\t" + "vmovdqu xmm0, [rsp + #%d]\n\t" + "vmovdqu [rsp + #%d], xmm0\n\t" + "vmovdqu xmm0, [rsp - #64]", + src_offset, dst_offset); + break; default: ShouldNotReachHere(); } @@ -1136,7 +1152,7 @@ uint MachSpillCopyNode::implementation(CodeBuffer* cbuf, if (bottom_type()->isa_vect() != NULL) { uint ireg = ideal_reg(); assert((src_first_rc != rc_int && dst_first_rc != rc_int), "sanity"); - assert((ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY), "sanity"); + assert((ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY || ireg == Op_VecZ ), "sanity"); if( src_first_rc == rc_stack && dst_first_rc == rc_stack ) { // mem -> mem int src_offset = ra_->reg2offset(src_first); @@ -1573,7 +1589,7 @@ uint MachUEPNode::size(PhaseRegAlloc* ra_) const return MachNode::size(ra_); // too many variables; just compute it // the hard way } - + //============================================================================= @@ -2832,7 +2848,7 @@ frame RAX_H_num // Op_RegL }; // Excluded flags and vector registers. - assert(ARRAY_SIZE(hi) == _last_machine_leaf - 5, "missing type"); + assert(ARRAY_SIZE(hi) == _last_machine_leaf - 6, "missing type"); return OptoRegPair(hi[ideal_reg], lo[ideal_reg]); %} %} @@ -3335,7 +3351,7 @@ operand no_rax_rdx_RegI() // Pointer Register operand any_RegP() %{ - constraint(ALLOC_IN_RC(any_reg)); + constraint(ALLOC_IN_RC(any_reg)); match(RegP); match(rax_RegP); match(rbx_RegP); @@ -3589,20 +3605,51 @@ operand rFlagsRegUCF() %{ %} // Float register operands -operand regF() -%{ - constraint(ALLOC_IN_RC(float_reg)); - match(RegF); +operand regF() %{ + constraint(ALLOC_IN_RC(float_reg)); + match(RegF); + + format %{ %} + interface(REG_INTER); +%} + +// Double register operands +operand regD() %{ + constraint(ALLOC_IN_RC(double_reg)); + match(RegD); + + format %{ %} + interface(REG_INTER); +%} + +// Vectors +operand vecS() %{ + constraint(ALLOC_IN_RC(vectors_reg)); + match(VecS); format %{ %} interface(REG_INTER); %} -// Double register operands -operand regD() -%{ - constraint(ALLOC_IN_RC(double_reg)); - match(RegD); +operand vecD() %{ + constraint(ALLOC_IN_RC(vectord_reg)); + match(VecD); + + format %{ %} + interface(REG_INTER); +%} + +operand vecX() %{ + constraint(ALLOC_IN_RC(vectorx_reg)); + match(VecX); + + format %{ %} + interface(REG_INTER); +%} + +operand vecY() %{ + constraint(ALLOC_IN_RC(vectory_reg)); + match(VecY); format %{ %} interface(REG_INTER); @@ -4947,7 +4994,7 @@ instruct loadI2L_immU31(rRegL dst, memory mem, immU31 mask, rFlagsReg cr) %{ %} // Load Unsigned Integer into Long Register -instruct loadUI2L(rRegL dst, memory mem, immL_32bits mask) +instruct loadUI2L(rRegL dst, memory mem, immL_32bits mask) %{ match(Set dst (AndL (ConvI2L (LoadI mem)) mask)); @@ -10374,7 +10421,7 @@ instruct rep_stos(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy, format %{ "xorq rax, rax\t# ClearArray:\n\t" "rep stosq\t# Store rax to *rdi++ while rcx--" %} - ins_encode %{ + ins_encode %{ __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); %} ins_pipe(pipe_slow); @@ -10389,7 +10436,7 @@ instruct rep_fast_stosb(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dum format %{ "xorq rax, rax\t# ClearArray:\n\t" "shlq rcx,3\t# Convert doublewords to bytes\n\t" "rep stosb\t# Store rax to *rdi++ while rcx--" %} - ins_encode %{ + ins_encode %{ __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); %} ins_pipe( pipe_slow ); diff --git a/hotspot/src/cpu/zero/vm/entry_zero.hpp b/hotspot/src/cpu/zero/vm/entry_zero.hpp index 20f5d33dfd5..afef3d82476 100644 --- a/hotspot/src/cpu/zero/vm/entry_zero.hpp +++ b/hotspot/src/cpu/zero/vm/entry_zero.hpp @@ -26,6 +26,8 @@ #ifndef CPU_ZERO_VM_ENTRY_ZERO_HPP #define CPU_ZERO_VM_ENTRY_ZERO_HPP +#include "interpreter/cppInterpreter.hpp" + class ZeroEntry { public: ZeroEntry() { diff --git a/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp b/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp index 98a2121a8da..144683f2b4f 100644 --- a/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp +++ b/hotspot/src/cpu/zero/vm/nativeInst_zero.cpp @@ -25,6 +25,8 @@ #include "precompiled.hpp" #include "assembler_zero.inline.hpp" +#include "entry_zero.hpp" +#include "interpreter/cppInterpreter.hpp" #include "memory/resourceArea.hpp" #include "nativeInst_zero.hpp" #include "oops/oop.inline.hpp" diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 8270f6e3659..013ee143c92 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -3474,25 +3474,69 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, return addr; } +// Helper for os::Linux::reserve_memory_special_huge_tlbfs_mixed(). +// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address +// (req_addr != NULL) or with a given alignment. +// - bytes shall be a multiple of alignment. +// - req_addr can be NULL. If not NULL, it must be a multiple of alignment. +// - alignment sets the alignment at which memory shall be allocated. +// It must be a multiple of allocation granularity. +// Returns address of memory or NULL. If req_addr was not NULL, will only return +// req_addr or NULL. +static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) { + + size_t extra_size = bytes; + if (req_addr == NULL && alignment > 0) { + extra_size += alignment; + } + + char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1, 0); + if (start == MAP_FAILED) { + start = NULL; + } else { + if (req_addr != NULL) { + if (start != req_addr) { + ::munmap(start, extra_size); + start = NULL; + } + } else { + char* const start_aligned = (char*) align_ptr_up(start, alignment); + char* const end_aligned = start_aligned + bytes; + char* const end = start + extra_size; + if (start_aligned > start) { + ::munmap(start, start_aligned - start); + } + if (end_aligned < end) { + ::munmap(end_aligned, end - end_aligned); + } + start = start_aligned; + } + } + return start; + +} + +// Reserve memory using mmap(MAP_HUGETLB). +// - bytes shall be a multiple of alignment. +// - req_addr can be NULL. If not NULL, it must be a multiple of alignment. +// - alignment sets the alignment at which memory shall be allocated. +// It must be a multiple of allocation granularity. +// Returns address of memory or NULL. If req_addr was not NULL, will only return +// req_addr or NULL. char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, size_t alignment, char* req_addr, bool exec) { size_t large_page_size = os::large_page_size(); - assert(bytes >= large_page_size, "Shouldn't allocate large pages for small sizes"); - // Allocate small pages. + assert(is_ptr_aligned(req_addr, alignment), "Must be"); + assert(is_size_aligned(bytes, alignment), "Must be"); - char* start; - if (req_addr != NULL) { - assert(is_ptr_aligned(req_addr, alignment), "Must be"); - assert(is_size_aligned(bytes, alignment), "Must be"); - start = os::reserve_memory(bytes, req_addr); - assert(start == NULL || start == req_addr, "Must be"); - } else { - start = os::reserve_memory_aligned(bytes, alignment); - } + // First reserve - but not commit - the address range in small pages. + char* const start = anon_mmap_aligned(bytes, alignment, req_addr); if (start == NULL) { return NULL; @@ -3500,13 +3544,6 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, assert(is_ptr_aligned(start, alignment), "Must be"); - if (MemTracker::tracking_level() > NMT_minimal) { - // os::reserve_memory_special will record this memory area. - // Need to release it here to prevent overlapping reservations. - Tracker tkr = MemTracker::get_virtual_memory_release_tracker(); - tkr.record((address)start, bytes); - } - char* end = start + bytes; // Find the regions of the allocated chunk that can be promoted to large pages. @@ -3526,9 +3563,9 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; - void* result; + // Commit small-paged leading area. if (start != lp_start) { result = ::mmap(start, lp_start - start, prot, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, @@ -3539,11 +3576,12 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, } } + // Commit large-paged area. result = ::mmap(lp_start, lp_bytes, prot, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED|MAP_HUGETLB, -1, 0); if (result == MAP_FAILED) { - warn_on_large_pages_failure(req_addr, bytes, errno); + warn_on_large_pages_failure(lp_start, lp_bytes, errno); // If the mmap above fails, the large pages region will be unmapped and we // have regions before and after with small pages. Release these regions. // @@ -3556,6 +3594,7 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_mixed(size_t bytes, return NULL; } + // Commit small-paged trailing area. if (lp_end != end) { result = ::mmap(lp_end, end - lp_end, prot, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, @@ -3575,7 +3614,7 @@ char* os::Linux::reserve_memory_special_huge_tlbfs(size_t bytes, bool exec) { assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages"); assert(is_ptr_aligned(req_addr, alignment), "Must be"); - assert(is_power_of_2(alignment), "Must be"); + assert(is_size_aligned(alignment, os::vm_allocation_granularity()), "Must be"); assert(is_power_of_2(os::large_page_size()), "Must be"); assert(bytes >= os::large_page_size(), "Shouldn't allocate large pages for small sizes"); @@ -4760,8 +4799,8 @@ jint os::init_2(void) { FLAG_IS_DEFAULT(UseSHM) && FLAG_IS_DEFAULT(UseHugeTLBFS)) { UseLargePages = false; - } else { - warning("UseNUMA is not fully compatible with SHM/HugeTLBFS large pages, disabling adaptive resizing"); + } else if (UseAdaptiveSizePolicy || UseAdaptiveNUMAChunkSizing) { + warning("UseNUMA is not fully compatible with SHM/HugeTLBFS large pages, disabling adaptive resizing (-XX:-UseAdaptiveSizePolicy -XX:-UseAdaptiveNUMAChunkSizing)"); UseAdaptiveSizePolicy = false; UseAdaptiveNUMAChunkSizing = false; } @@ -6086,47 +6125,100 @@ class TestReserveMemorySpecial : AllStatic { } } - static void test_reserve_memory_special_huge_tlbfs_mixed(size_t size, size_t alignment) { - if (!UseHugeTLBFS) { - return; - } - - test_log("test_reserve_memory_special_huge_tlbfs_mixed(" SIZE_FORMAT ", " SIZE_FORMAT ")", - size, alignment); - - assert(size >= os::large_page_size(), "Incorrect input to test"); - - char* addr = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false); - - if (addr != NULL) { - small_page_write(addr, size); - - os::Linux::release_memory_special_huge_tlbfs(addr, size); - } - } - - static void test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(size_t size) { - size_t lp = os::large_page_size(); - size_t ag = os::vm_allocation_granularity(); - - for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { - test_reserve_memory_special_huge_tlbfs_mixed(size, alignment); - } - } - static void test_reserve_memory_special_huge_tlbfs_mixed() { size_t lp = os::large_page_size(); size_t ag = os::vm_allocation_granularity(); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + ag); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp + lp / 2); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + ag); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 - ag); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 2 + lp / 2); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10); - test_reserve_memory_special_huge_tlbfs_mixed_all_alignments(lp * 10 + lp / 2); + // sizes to test + const size_t sizes[] = { + lp, lp + ag, lp + lp / 2, lp * 2, + lp * 2 + ag, lp * 2 - ag, lp * 2 + lp / 2, + lp * 10, lp * 10 + lp / 2 + }; + const int num_sizes = sizeof(sizes) / sizeof(size_t); + + // For each size/alignment combination, we test three scenarios: + // 1) with req_addr == NULL + // 2) with a non-null req_addr at which we expect to successfully allocate + // 3) with a non-null req_addr which contains a pre-existing mapping, at which we + // expect the allocation to either fail or to ignore req_addr + + // Pre-allocate two areas; they shall be as large as the largest allocation + // and aligned to the largest alignment we will be testing. + const size_t mapping_size = sizes[num_sizes - 1] * 2; + char* const mapping1 = (char*) ::mmap(NULL, mapping_size, + PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1, 0); + assert(mapping1 != MAP_FAILED, "should work"); + + char* const mapping2 = (char*) ::mmap(NULL, mapping_size, + PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1, 0); + assert(mapping2 != MAP_FAILED, "should work"); + + // Unmap the first mapping, but leave the second mapping intact: the first + // mapping will serve as a value for a "good" req_addr (case 2). The second + // mapping, still intact, as "bad" req_addr (case 3). + ::munmap(mapping1, mapping_size); + + // Case 1 + test_log("%s, req_addr NULL:", __FUNCTION__); + test_log("size align result"); + + for (int i = 0; i < num_sizes; i++) { + const size_t size = sizes[i]; + for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { + char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, NULL, false); + test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " -> " PTR_FORMAT " %s", + size, alignment, p, (p != NULL ? "" : "(failed)")); + if (p != NULL) { + assert(is_ptr_aligned(p, alignment), "must be"); + small_page_write(p, size); + os::Linux::release_memory_special_huge_tlbfs(p, size); + } + } + } + + // Case 2 + test_log("%s, req_addr non-NULL:", __FUNCTION__); + test_log("size align req_addr result"); + + for (int i = 0; i < num_sizes; i++) { + const size_t size = sizes[i]; + for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { + char* const req_addr = (char*) align_ptr_up(mapping1, alignment); + char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, req_addr, false); + test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " " PTR_FORMAT " -> " PTR_FORMAT " %s", + size, alignment, req_addr, p, + ((p != NULL ? (p == req_addr ? "(exact match)" : "") : "(failed)"))); + if (p != NULL) { + assert(p == req_addr, "must be"); + small_page_write(p, size); + os::Linux::release_memory_special_huge_tlbfs(p, size); + } + } + } + + // Case 3 + test_log("%s, req_addr non-NULL with preexisting mapping:", __FUNCTION__); + test_log("size align req_addr result"); + + for (int i = 0; i < num_sizes; i++) { + const size_t size = sizes[i]; + for (size_t alignment = ag; is_size_aligned(size, alignment); alignment *= 2) { + char* const req_addr = (char*) align_ptr_up(mapping2, alignment); + char* p = os::Linux::reserve_memory_special_huge_tlbfs_mixed(size, alignment, req_addr, false); + test_log(SIZE_FORMAT_HEX " " SIZE_FORMAT_HEX " " PTR_FORMAT " -> " PTR_FORMAT " %s", + size, alignment, req_addr, p, + ((p != NULL ? "" : "(failed)"))); + // as the area around req_addr contains already existing mappings, the API should always + // return NULL (as per contract, it cannot return another address) + assert(p == NULL, "must be"); + } + } + + ::munmap(mapping2, mapping_size); + } static void test_reserve_memory_special_huge_tlbfs() { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/build-impl.xml b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/build-impl.xml index 5fe569eec79..152f6e32395 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/build-impl.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/build-impl.xml @@ -4,6 +4,13 @@ *** EDIT ../build.xml INSTEAD *** --> + + + + + + + You must set 'suite.dir' to point to your containing module suite @@ -16,13 +23,21 @@ + + + + + + + - - + + + - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties index 5018df1e656..3306e529b83 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties @@ -1,8 +1,5 @@ -build.xml.data.CRC32=ebcf0422 -build.xml.script.CRC32=d7a2678d -build.xml.stylesheet.CRC32=79c3b980 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=ebcf0422 -nbproject/build-impl.xml.script.CRC32=57997f94 -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65 +nbproject/build-impl.xml.script.CRC32=42ef3ff6 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java index 56163f0d99e..8c3d92dc064 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,40 +25,58 @@ package com.sun.hotspot.igv.svg; import java.awt.Graphics2D; import java.io.Writer; +import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import org.w3c.dom.DOMImplementation; /** - * + * Utility class * @author Thomas Wuerthinger */ public class BatikSVG { - private static Constructor SVGGraphics2DConstructor; - private static Method Method_stream; - private static Method Method_createDefault; - private static Method Method_getDOMImplementation; - private static Method Method_setEmbeddedFontsOn; + private BatikSVG() { + } + private static Constructor SVGGraphics2DConstructor; + private static Method streamMethod; + private static Method createDefaultMethod; + private static Method getDOMImplementationMethod; + private static Method setEmbeddedFontsOnMethod; + private static Class classSVGGraphics2D; + + /** + * Creates a graphics object that allows to be exported to SVG data using the {@link #printToStream(Graphics2D, Writer, boolean) printToStream} method. + * @return the newly created Graphics2D object or null if the library does not exist + */ public static Graphics2D createGraphicsObject() { try { if (SVGGraphics2DConstructor == null) { - ClassLoader cl = BatikSVG.class.getClassLoader(); - Class Class_GenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation"); - Class Class_SVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext"); - Class Class_SVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D"); - Method_getDOMImplementation = Class_GenericDOMImplementation.getDeclaredMethod("getDOMImplementation", new Class[0]); - Method_createDefault = Class_SVGGeneratorContext.getDeclaredMethod("createDefault", new Class[]{org.w3c.dom.Document.class}); - Method_setEmbeddedFontsOn = Class_SVGGeneratorContext.getDeclaredMethod("setEmbeddedFontsOn", new Class[]{boolean.class}); - Method_stream = Class_SVGGraphics2D.getDeclaredMethod("stream", Writer.class, boolean.class); - SVGGraphics2DConstructor = Class_SVGGraphics2D.getConstructor(Class_SVGGeneratorContext, boolean.class); + String batikJar = System.getenv().get("IGV_BATIK_JAR"); + if (batikJar == null) { + return null; + } + // Load batik in it's own class loader since some it's support jars interfere with the JDK + URL url = new File(batikJar).toURI().toURL(); + ClassLoader cl = new URLClassLoader(new URL[] { url }); + Class classGenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation"); + Class classSVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext"); + classSVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D"); + getDOMImplementationMethod = classGenericDOMImplementation.getDeclaredMethod("getDOMImplementation", new Class[0]); + createDefaultMethod = classSVGGeneratorContext.getDeclaredMethod("createDefault", new Class[]{org.w3c.dom.Document.class}); + setEmbeddedFontsOnMethod = classSVGGeneratorContext.getDeclaredMethod("setEmbeddedFontsOn", new Class[]{boolean.class}); + streamMethod = classSVGGraphics2D.getDeclaredMethod("stream", Writer.class, boolean.class); + SVGGraphics2DConstructor = classSVGGraphics2D.getConstructor(classSVGGeneratorContext, boolean.class); } - DOMImplementation dom = (DOMImplementation) Method_getDOMImplementation.invoke(null); + DOMImplementation dom = (DOMImplementation) getDOMImplementationMethod.invoke(null); org.w3c.dom.Document document = dom.createDocument("http://www.w3.org/2000/svg", "svg", null); - Object ctx = Method_createDefault.invoke(null, document); - Method_setEmbeddedFontsOn.invoke(ctx, true); + Object ctx = createDefaultMethod.invoke(null, document); + setEmbeddedFontsOnMethod.invoke(ctx, true); Graphics2D svgGenerator = (Graphics2D) SVGGraphics2DConstructor.newInstance(ctx, true); return svgGenerator; } catch (ClassNotFoundException e) { @@ -71,12 +89,22 @@ public class BatikSVG { return null; } catch (InstantiationException e) { return null; + } catch (MalformedURLException e) { + return null; } } + /** + * Serializes a graphics object to a stream in SVG format. + * @param svgGenerator the graphics object. Only graphics objects created by the {@link #createGraphicsObject() createGraphicsObject} method are valid. + * @param stream the stream to which the data is written + * @param useCSS whether to use CSS styles in the SVG output + */ public static void printToStream(Graphics2D svgGenerator, Writer stream, boolean useCSS) { + assert classSVGGraphics2D != null; + assert classSVGGraphics2D.isInstance(svgGenerator); try { - Method_stream.invoke(svgGenerator, stream, useCSS); + streamMethod.invoke(svgGenerator, stream, useCSS); } catch (IllegalAccessException e) { assert false; } catch (InvocationTargetException e) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/PreferenceConstants.java b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/package-info.java similarity index 73% rename from hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/PreferenceConstants.java rename to hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/package-info.java index 43a94dfa587..272fc48e96f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/PreferenceConstants.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,9 @@ * questions. * */ -package com.sun.hotspot.igv.view; - /** - * - * @author Thomas Wuerthinger + * This package is used to proxy the SVG export functionality of the BatikSVG library. Reflection is used such that the + * library is optional and need not be present at build time. */ -public class PreferenceConstants { +package com.sun.hotspot.igv.svg; - public static final String KEY_LINE_GENERATOR = "lineGenerator"; - public static final String DEFAULT_LINE_GENERATOR = "com.sun.hotspot.igv.positioning.BasicLineGenerator"; -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/manifest.mf index a04660a02f9..49070d0c588 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/manifest.mf +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/manifest.mf @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.bytecodes -OpenIDE-Module-Layer: com/sun/hotspot/igv/bytecodes/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/bytecodes/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.bytecodes +OpenIDE-Module-Layer: com/sun/hotspot/igv/bytecodes/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/bytecodes/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml index 91bd8120565..823323dc054 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml @@ -14,13 +14,37 @@ 1.0 + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.util + + + + 1.0 + + org.jdesktop.layout 1 - 1.4 + 1.16.1 + + + + org.openide.awt + + + + 7.39.1 @@ -28,7 +52,7 @@ - 6.11 + 6.34.1 @@ -36,7 +60,7 @@ - 7.2.0.1 + 7.20.1 @@ -44,7 +68,15 @@ - 7.9.0.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 @@ -52,7 +84,7 @@ - 6.16 + 6.39.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties index cd6852f9dd9..01232978883 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/Bundle.properties @@ -1,5 +1,5 @@ -CTL_BytecodeViewAction=Open BytecodeView Window -CTL_BytecodeViewTopComponent=BytecodeView Window +CTL_BytecodeViewAction=Bytecode +CTL_BytecodeViewTopComponent=Bytecode CTL_SelectBytecodesAction=Select nodes -HINT_BytecodeViewTopComponent=This is a BytecodeView window +HINT_BytecodeViewTopComponent=Shows the bytecode associated with the displayed graph. OpenIDE-Module-Name=Bytecodes diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java index 9072b34819e..86449e58817 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,14 +29,14 @@ import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; import java.awt.Image; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.swing.Action; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; -import org.openide.util.Utilities; +import org.openide.util.ImageUtilities; /** * @@ -49,29 +49,35 @@ public class BytecodeNode extends AbstractNode { public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) { super(Children.LEAF); - this.setDisplayName(bytecode.getBci() + " " + bytecode.getName()); + String displayName = bytecode.getBci() + " " + bytecode.getName() + " " + bytecode.getOperands(); bciValue = bytecode.getBci() + " " + bciValue; bciValue = bciValue.trim(); - Properties.PropertySelector selector = new Properties.PropertySelector(graph.getNodes()); + Properties.PropertySelector selector = new Properties.PropertySelector<>(graph.getNodes()); StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue); List nodeList = selector.selectMultiple(matcher); if (nodeList.size() > 0) { - nodes = new HashSet(); + nodes = new LinkedHashSet<>(); for (InputNode n : nodeList) { nodes.add(n); } - this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)"); + displayName += " (" + nodes.size() + " nodes)"; } + + if (bytecode.getComment() != null) { + displayName += " // " + bytecode.getComment(); + } + + this.setDisplayName(displayName); } @Override public Image getIcon(int i) { if (nodes != null) { - return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.gif"); + return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.png"); } else { - return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.gif"); + return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.png"); } } @@ -91,6 +97,7 @@ public class BytecodeNode extends AbstractNode { } @Override + @SuppressWarnings("unchecked") public T getCookie(Class aClass) { if (aClass == SelectBytecodesCookie.class && nodes != null) { return (T) (new SelectBytecodesCookie(nodes)); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java index b81ae3c16f7..260b6984e31 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ public class BytecodeViewAction extends AbstractAction { super(NbBundle.getMessage(BytecodeViewAction.class, "CTL_BytecodeViewAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = BytecodeViewTopComponent.findInstance(); win.open(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form index c2549ecaf63..7061b53f324 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form @@ -3,6 +3,8 @@
+ + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java index 0c591126bf3..04deab3f9ff 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package com.sun.hotspot.igv.bytecodes; import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.BorderLayout; import java.io.Serializable; import javax.swing.SwingUtilities; @@ -33,11 +34,7 @@ import org.openide.ErrorManager; import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; import org.openide.explorer.view.BeanTreeView; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; +import org.openide.util.*; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; @@ -91,6 +88,7 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables + /** * Gets default instance. Do not use directly: reserved for *.settings files only, * i.e. deserialization routines; otherwise you could get a non-deserialized instance. @@ -126,7 +124,7 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan @Override public void componentOpened() { - Lookup.Template tpl = new Lookup.Template(Object.class); + Lookup.Template tpl = new Lookup.Template<>(InputGraphProvider.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -147,23 +145,47 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan return PREFERRED_ID; } + @Override public ExplorerManager getExplorerManager() { return manager; } + @Override + public void requestActive() { + super.requestActive(); + this.treeView.requestFocus(); + } + + @Override + public boolean requestFocus(boolean temporary) { + this.treeView.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + this.treeView.requestFocus(); + return super.requestFocusInWindow(temporary); + } + + @Override public void resultChanged(LookupEvent lookupEvent) { - final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); - if (p != null) { + final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - InputGraph graph = p.getGraph(); - if (graph != null) { - Group g = graph.getGroup(); - rootNode.update(graph, g.getMethod()); - } - } + if (p != null) { + InputGraph graph = p.getGraph(); + if (graph != null) { + Group g = graph.getGroup(); + rootNode.update(graph, g.getMethod()); + return; + } + } + rootNode.update(null, null); + } }); - } + } final static class ResolvableHelper implements Serializable { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java index a77569800a1..383950b422f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/MethodNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ import java.awt.Image; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; -import org.openide.util.Utilities; +import org.openide.util.ImageUtilities; /** * @@ -38,7 +38,7 @@ import org.openide.util.Utilities; */ public class MethodNode extends AbstractNode { - private static class MethodNodeChildren extends Children.Keys { + private static class MethodNodeChildren extends Children.Keys { private InputMethod method; private InputGraph graph; @@ -50,9 +50,8 @@ public class MethodNode extends AbstractNode { this.graph = graph; } - protected Node[] createNodes(Object object) { - assert object instanceof InputBytecode; - InputBytecode bc = (InputBytecode) object; + @Override + protected Node[] createNodes(InputBytecode bc) { if (bc.getInlined() == null) { return new Node[]{new BytecodeNode(bc, graph, bciString)}; } else { @@ -84,7 +83,7 @@ public class MethodNode extends AbstractNode { @Override public Image getIcon(int i) { - return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/method.gif"); + return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/method.png"); } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java index a7e02479131..e1460753a5b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,9 @@ package com.sun.hotspot.igv.bytecodes; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import org.openide.nodes.Node; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.actions.CookieAction; @@ -36,22 +36,26 @@ import org.openide.util.actions.CookieAction; */ public final class SelectBytecodesAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { SelectBytecodesCookie c = activatedNodes[0].getCookie(SelectBytecodesCookie.class); - InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { p.setSelectedNodes(c.getNodes()); } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } + @Override public String getName() { return NbBundle.getMessage(SelectBytecodesAction.class, "CTL_SelectBytecodesAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ SelectBytecodesCookie.class @@ -64,6 +68,7 @@ public final class SelectBytecodesAction extends CookieAction { putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -73,3 +78,4 @@ public final class SelectBytecodesAction extends CookieAction { return false; } } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesCookie.java index ac1bb07be2b..72311470d91 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesCookie.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesCookie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.gif deleted file mode 100644 index 5a2a355e391..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.png b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.png new file mode 100644 index 00000000000..8e4f34c9cf6 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/bytecode.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.gif deleted file mode 100644 index fc6595b2c98..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.png b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.png new file mode 100644 index 00000000000..35067f72498 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/link.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.gif deleted file mode 100644 index dc90fd03877..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.png b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.png new file mode 100644 index 00000000000..b0f2a53a601 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/images/method.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf index 3ed19068d76..c745f8a82b4 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/manifest.mf @@ -1,6 +1,6 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.controlflow -OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.controlflow +OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml index 212cf234593..d992b332a5a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml @@ -30,13 +30,21 @@ 1.0 + + com.sun.hotspot.igv.util + + + + 1.0 + + org.jdesktop.layout 1 - 1.4 + 1.16.1 @@ -52,7 +60,15 @@ - 7.9.0.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java index ef479dbca56..8b2b90e7079 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,9 @@ package com.sun.hotspot.igv.controlflow; import com.sun.hotspot.igv.data.InputBlockEdge; import com.sun.hotspot.igv.layout.Link; import com.sun.hotspot.igv.layout.Port; +import java.awt.BasicStroke; import java.awt.Point; +import java.awt.Stroke; import java.util.ArrayList; import java.util.List; import org.netbeans.api.visual.widget.ConnectionWidget; @@ -37,12 +39,19 @@ import org.netbeans.api.visual.widget.ConnectionWidget; */ public class BlockConnectionWidget extends ConnectionWidget implements Link { + private static final Stroke NORMAL_STROKE = new BasicStroke(1.0f); + private static final Stroke BOLD_STROKE = new BasicStroke(2.5f); + private static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0); + private static final Stroke BOLD_DASHED_STROKE = new BasicStroke(2.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0); + private BlockWidget from; private BlockWidget to; private Port inputSlot; private Port outputSlot; private List points; private InputBlockEdge edge; + private boolean isDashed = false; + private boolean isBold = false; public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) { super(scene); @@ -67,6 +76,30 @@ public class BlockConnectionWidget extends ConnectionWidget implements Link { return outputSlot; } + public void setBold(boolean bold) { + this.isBold = bold; + updateStroke(); + } + + public void setDashed(boolean dashed) { + this.isDashed = dashed; + updateStroke(); + } + + private void updateStroke() { + Stroke stroke = NORMAL_STROKE; + if (isBold) { + if (isDashed) { + stroke = BOLD_DASHED_STROKE; + } else { + stroke = BOLD_STROKE; + } + } else if (isDashed) { + stroke = DASHED_STROKE; + } + setStroke(stroke); + } + public void setControlPoints(List p) { this.points = p; } @@ -80,4 +113,9 @@ public class BlockConnectionWidget extends ConnectionWidget implements Link { public String toString() { return "Connection[ " + from.toString() + " - " + to.toString() + "]"; } + + @Override + public boolean isVIP() { + return isBold; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java index a739e07df8b..6f4aa4d3f9f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Point; +import java.awt.Rectangle; import org.netbeans.api.visual.border.BorderFactory; import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.LabelWidget; @@ -41,13 +42,13 @@ import org.netbeans.api.visual.widget.LabelWidget; */ public class BlockWidget extends LabelWidget implements Vertex { - public static final Dimension SIZE = new Dimension(20, 20); + public static final Dimension MIN_SIZE = new Dimension(20, 20); private InputBlock block; private Port inputSlot; private Port outputSlot; private Cluster cluster; private boolean root; - private static final Font font = new Font(Font.SERIF, Font.PLAIN, 12); + private static final Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 12); private static final Font boldFont = font.deriveFont(Font.BOLD); public static final Color NORMAL_FOREGROUND_COLOR = Color.BLACK; public static final Color HOVER_FOREGROUND_COLOR = Color.BLUE; @@ -59,29 +60,24 @@ public class BlockWidget extends LabelWidget implements Vertex { this.setLabel(block.getName()); this.setForeground(NORMAL_FOREGROUND_COLOR); this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - this.setMinimumSize(SIZE); - this.setMaximumSize(SIZE); + this.setMinimumSize(MIN_SIZE); this.setFont(font); + this.setAlignment(Alignment.CENTER); final BlockWidget widget = this; inputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2)); + return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); } - public Vertex getVertex() { return widget; } }; - outputSlot = new Port() { - public Point getRelativePosition() { - return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2)); + return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); } - public Vertex getVertex() { return widget; } @@ -101,7 +97,12 @@ public class BlockWidget extends LabelWidget implements Vertex { } public Dimension getSize() { - return SIZE; + Rectangle bounds = getBounds(); + if (bounds != null) { + return bounds.getSize(); + } else { + return MIN_SIZE; + } } public void setPosition(Point p) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties index 31865f13af1..587299c05df 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties @@ -1,4 +1,4 @@ -CTL_ControlFlowAction=Open ControlFlow Window -CTL_ControlFlowTopComponent=ControlFlow Window -HINT_ControlFlowTopComponent=This is a ControlFlow window +CTL_ControlFlowAction=Control Flow +CTL_ControlFlowTopComponent=Control Flow +HINT_ControlFlowTopComponent=Shows the blocks of the current graph. OpenIDE-Module-Name=ControlFlow diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java index 5236f824a25..43b8fae8f58 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java index 1d2c9a2cb88..b858ef0aa27 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,17 @@ */ package com.sun.hotspot.igv.controlflow; -import com.sun.hotspot.igv.data.InputBlock; import com.sun.hotspot.igv.data.InputBlockEdge; +import com.sun.hotspot.igv.data.InputBlock; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.Color; import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.HashSet; -import java.util.HashMap; import java.util.Set; import javax.swing.BorderFactory; import org.netbeans.api.visual.action.ActionFactory; @@ -44,15 +44,14 @@ import org.netbeans.api.visual.action.SelectProvider; import org.netbeans.api.visual.action.WidgetAction; import org.netbeans.api.visual.anchor.AnchorFactory; import org.netbeans.api.visual.anchor.AnchorShape; -import org.netbeans.api.visual.layout.LayoutFactory; import org.netbeans.api.visual.router.RouterFactory; import org.netbeans.api.visual.widget.LayerWidget; import org.netbeans.api.visual.widget.Widget; import org.netbeans.api.visual.graph.GraphScene; import org.netbeans.api.visual.graph.layout.GraphLayout; +import org.netbeans.api.visual.layout.LayoutFactory; import org.netbeans.api.visual.layout.SceneLayout; import org.netbeans.api.visual.widget.ConnectionWidget; -import org.openide.util.Lookup; /** * @@ -61,13 +60,12 @@ import org.openide.util.Lookup; public class ControlFlowScene extends GraphScene implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { private HashSet selection; - private HashMap blockMap; private InputGraph oldGraph; private LayerWidget edgeLayer; private LayerWidget mainLayer; private LayerWidget selectLayer; private WidgetAction hoverAction = this.createWidgetHoverAction(); - private WidgetAction selectAction = ActionFactory.createSelectAction(this); + private WidgetAction selectAction = new DoubleClickSelectAction(this); private WidgetAction moveAction = ActionFactory.createMoveAction(null, this); public ControlFlowScene() { @@ -111,27 +109,21 @@ public class ControlFlowScene extends GraphScene imp addNode(b); } - for (InputBlock b : g.getBlocks()) { - for (InputBlockEdge e : b.getOutputs()) { - addEdge(e); - assert g.getBlocks().contains(e.getFrom()); - assert g.getBlocks().contains(e.getTo()); - this.setEdgeSource(e, e.getFrom()); - this.setEdgeTarget(e, e.getTo()); - } + for (InputBlockEdge e : g.getBlockEdges()) { + addEdge(e); + assert g.getBlocks().contains(e.getFrom()); + assert g.getBlocks().contains(e.getTo()); + this.setEdgeSource(e, e.getFrom()); + this.setEdgeTarget(e, e.getTo()); } - GraphLayout layout = new HierarchicalGraphLayout();//GridGraphLayout(); + GraphLayout layout = new HierarchicalGraphLayout();//GridGraphLayout(); SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout); sceneLayout.invokeLayout(); this.validate(); } - public BlockWidget getBlockWidget(InputBlock b) { - return blockMap.get(b); - } - public void clearSelection() { for (BlockWidget w : selection) { w.setState(w.getState().deriveSelected(false)); @@ -141,7 +133,7 @@ public class ControlFlowScene extends GraphScene imp } public void selectionChanged() { - InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { Set inputNodes = new HashSet(); for (BlockWidget w : selection) { @@ -204,15 +196,19 @@ public class ControlFlowScene extends GraphScene imp } public void setNewLocation(Widget widget, Point location) { - Point originalLocation = getOriginalLocation(widget); - int xOffset = location.x - originalLocation.x; - int yOffset = location.y - originalLocation.y; - for (Widget w : this.selection) { - Point p = new Point(w.getPreferredLocation()); - p.translate(xOffset, yOffset); - w.setPreferredLocation(p); + if (selection.contains(widget)) { + // move entire selection + Point originalLocation = getOriginalLocation(widget); + int xOffset = location.x - originalLocation.x; + int yOffset = location.y - originalLocation.y; + for (Widget w : selection) { + Point p = new Point(w.getPreferredLocation()); + p.translate(xOffset, yOffset); + w.setPreferredLocation(p); + } + } else { + widget.setPreferredLocation(location); } - } public Widget createSelectionWidget() { @@ -271,7 +267,15 @@ public class ControlFlowScene extends GraphScene imp } protected Widget attachEdgeWidget(InputBlockEdge edge) { - ConnectionWidget w = new BlockConnectionWidget(this, edge); + BlockConnectionWidget w = new BlockConnectionWidget(this, edge); + switch (edge.getState()) { + case NEW: + w.setBold(true); + break; + case DELETED: + w.setDashed(true); + break; + } w.setRouter(RouterFactory.createDirectRouter()); w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED); edgeLayer.addChild(w); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form index c2549ecaf63..7061b53f324 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form @@ -3,6 +3,8 @@ + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java index 04aeaaebbbc..d3a519c84e0 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package com.sun.hotspot.igv.controlflow; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.BorderLayout; import java.io.Serializable; import javax.swing.JScrollPane; @@ -63,17 +64,7 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen this.add(panel, BorderLayout.CENTER); } - @Override - public void requestFocus() { - super.requestFocus(); - scene.getView().requestFocus(); - } - @Override - public boolean requestFocusInWindow() { - super.requestFocusInWindow(); - return scene.getView().requestFocusInWindow(); - } /** This method is called from within the constructor to * initialize the form. @@ -96,6 +87,7 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables + /** * Gets default instance. Do not use directly: reserved for *.settings files only, * i.e. deserialization routines; otherwise you could get a non-deserialized instance. @@ -131,7 +123,7 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen @Override public void componentOpened() { - Lookup.Template tpl = new Lookup.Template(Object.class); + Lookup.Template tpl = new Lookup.Template(InputGraphProvider.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -143,16 +135,16 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen } public void resultChanged(LookupEvent lookupEvent) { - - final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { SwingUtilities.invokeLater(new Runnable() { + public void run() { - InputGraph g = p.getGraph(); - if (g != null) { - scene.setGraph(g); - } - } + InputGraph g = p.getGraph(); + if (g != null) { + scene.setGraph(g); + } + } }); } } @@ -169,8 +161,8 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen @Override public void requestActive() { - scene.getView().requestFocusInWindow(); super.requestActive(); + scene.getView().requestFocus(); } final static class ResolvableHelper implements Serializable { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java new file mode 100644 index 00000000000..73c1a2441be --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.controlflow; + +import java.awt.Point; +import java.awt.event.MouseEvent; +import org.netbeans.api.visual.action.SelectProvider; +import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.widget.Widget; + +/** + * Selection action that acts on double-click only. Does not support aiming. + * + * @author Peter Hofer + */ +public class DoubleClickSelectAction extends WidgetAction.LockedAdapter { + + private final SelectProvider provider; + + public DoubleClickSelectAction(SelectProvider provider) { + this.provider = provider; + } + + protected boolean isLocked() { + return false; + } + + @Override + public State mousePressed(Widget widget, WidgetMouseEvent event) { + if (event.getClickCount() >= 2 && (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2)) { + boolean invert = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0; + Point point = event.getPoint(); + if (provider.isSelectionAllowed(widget, point, invert)) { + provider.select(widget, point, invert); + return State.CHAIN_ONLY; + } + } + return State.REJECTED; + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java index 5f00f6ba5f4..087f3398e95 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import java.awt.Point; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -76,6 +76,10 @@ public class HierarchicalGraphLayout extends GraphLayout { public void setControlPoints(List list) { // Do nothing for now } + + public boolean isVIP() { + return false; + } } private class VertexWrapper implements Vertex { @@ -127,6 +131,7 @@ public class HierarchicalGraphLayout extends GraphLayout { } public int compareTo(Vertex o) { + @SuppressWarnings("unchecked") VertexWrapper vw = (VertexWrapper) o; return node.toString().compareTo(vw.node.toString()); } @@ -138,8 +143,8 @@ public class HierarchicalGraphLayout extends GraphLayout { protected void performGraphLayout(UniversalGraph graph) { - Set links = new HashSet(); - Set vertices = new HashSet(); + Set links = new LinkedHashSet(); + Set vertices = new LinkedHashSet(); Map vertexMap = new HashMap(); for (N node : graph.getNodes()) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml index ad5afed1591..9342c8124fd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml @@ -1,126 +1,142 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.coordinator - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - com.sun.hotspot.igv.difference - - - - 1.0 - - - - com.sun.hotspot.igv.settings - - - - 1.0 - - - - com.sun.hotspot.igv.util - - - - 1.0 - - - - org.netbeans.api.progress - - - - 1 - 1.10.0.1 - - - - org.openide.actions - - - - 6.6.1.1 - - - - org.openide.awt - - - - 6.11.0.1 - - - - org.openide.dialogs - - - - 7.5.1 - - - - org.openide.explorer - - - - 6.11 - - - - org.openide.filesystems - - - - 7.3 - - - - org.openide.loaders - - - - 6.7 - - - - org.openide.nodes - - - - 7.2.0.1 - - - - org.openide.util - - - - 7.9.0.1 - - - - org.openide.windows - - - - 6.16 - - - - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.coordinator + + + + com.sun.hotspot.igv.connection + + + + 1.0 + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.difference + + + + 1.0 + + + + com.sun.hotspot.igv.settings + + + + 1.0 + + + + com.sun.hotspot.igv.util + + + + 1.0 + + + + org.netbeans.api.progress + + + + 1 + 1.23.1 + + + + org.openide.actions + + + + 6.21.1 + + + + org.openide.awt + + + + 7.30.1 + + + + org.openide.dialogs + + + + 7.18.1 + + + + org.openide.explorer + + + + 6.34.1 + + + + org.openide.filesystems + + + + 7.46.1 + + + + org.openide.loaders + + + + 7.20.1 + + + + org.openide.nodes + + + + 7.20.1 + + + + org.openide.util + + + + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 + + + + org.openide.windows + + + + 6.39.1 + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer deleted file mode 100644 index bf7aace9e7d..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer +++ /dev/null @@ -1,2 +0,0 @@ -com.sun.hotspot.igv.coordinator.StandardGroupOrganizer -com.sun.hotspot.igv.coordinator.GraphCountGroupOrganizer \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties index 455f648095d..2f8c29631fc 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties @@ -1,7 +1,6 @@ - -AdvancedOption_DisplayName_Coordinator=Settings -AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings -CTL_OutlineTopComponent=Outline Window -CTL_SomeAction=test -HINT_OutlineTopComponent=This is a Outline window -OpenIDE-Module-Name=Coordinator +AdvancedOption_DisplayName_Coordinator=Settings +AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings +CTL_OutlineTopComponent=Outline +CTL_SomeAction=test +HINT_OutlineTopComponent=Displays loaded groups of graphs. +OpenIDE-Module-Name=Coordinator diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java index 1b431b3db9d..713d7a1d80f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,13 @@ package com.sun.hotspot.igv.coordinator; import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.data.*; import java.awt.Image; -import java.util.ArrayList; import java.util.List; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; -import org.openide.util.Utilities; +import org.openide.util.ImageUtilities; import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; @@ -45,107 +40,72 @@ import org.openide.util.lookup.InstanceContent; */ public class FolderNode extends AbstractNode { - private GroupOrganizer organizer; private InstanceContent content; - private List>> structure; - private List subFolders; private FolderChildren children; - private static class FolderChildren extends Children.Keys implements ChangedListener { + private static class FolderChildren extends Children.Keys implements ChangedListener { - private FolderNode parent; - private List registeredGroups; + private final Folder folder; - public void setParent(FolderNode parent) { - this.parent = parent; - this.registeredGroups = new ArrayList(); + public FolderChildren(Folder folder) { + this.folder = folder; + folder.getChangedEvent().addListener(this); } @Override - protected Node[] createNodes(Object arg0) { - - for(Group g : registeredGroups) { - g.getChangedEvent().removeListener(this); - } - registeredGroups.clear(); - - Pair> p = (Pair>) arg0; - if (p.getLeft().length() == 0) { - - List curNodes = new ArrayList(); - for (Group g : p.getRight()) { - for (InputGraph graph : g.getGraphs()) { - curNodes.add(new GraphNode(graph)); - } - g.getChangedEvent().addListener(this); - registeredGroups.add(g); - } - - Node[] result = new Node[curNodes.size()]; - for (int i = 0; i < curNodes.size(); i++) { - result[i] = curNodes.get(i); - } - return result; - - } else { - return new Node[]{new FolderNode(p.getLeft(), parent.organizer, parent.subFolders, p.getRight())}; + protected Node[] createNodes(FolderElement e) { + if (e instanceof InputGraph) { + return new Node[]{new GraphNode((InputGraph) e)}; + } else if (e instanceof Folder) { + return new Node[]{new FolderNode((Folder) e)}; + } else { + return null; } } @Override public void addNotify() { - this.setKeys(parent.structure); + this.setKeys(folder.getElements()); } - public void changed(Group source) { - List>> newStructure = new ArrayList>>(); - for(Pair> p : parent.structure) { - refreshKey(p); - } - } - } - - protected InstanceContent getContent() { - return content; + @Override + public void changed(Object source) { + addNotify(); + } } @Override public Image getIcon(int i) { - return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.gif"); + return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png"); } - protected FolderNode(String name, GroupOrganizer organizer, List subFolders, List groups) { - this(name, organizer, subFolders, groups, new FolderChildren(), new InstanceContent()); + protected FolderNode(Folder folder) { + this(folder, new FolderChildren(folder), new InstanceContent()); } - private FolderNode(String name, GroupOrganizer organizer, List oldSubFolders, final List groups, FolderChildren children, InstanceContent content) { + private FolderNode(final Folder folder, FolderChildren children, InstanceContent content) { super(children, new AbstractLookup(content)); - children.setParent(this); this.content = content; this.children = children; - content.add(new RemoveCookie() { - - public void remove() { - for (Group g : groups) { - if (g.getDocument() != null) { - g.getDocument().removeGroup(g); - } + if (folder instanceof FolderElement) { + final FolderElement folderElement = (FolderElement) folder; + this.setDisplayName(folderElement.getName()); + content.add(new RemoveCookie() { + @Override + public void remove() { + folderElement.getParent().removeElement(folderElement); } - } - }); - init(name, organizer, oldSubFolders, groups); + }); + } } - public void init(String name, GroupOrganizer organizer, List oldSubFolders, List groups) { + public void init(String name, List groups) { this.setDisplayName(name); - this.organizer = organizer; - this.subFolders = new ArrayList(oldSubFolders); - if (name.length() > 0) { - this.subFolders.add(name); - } - structure = organizer.organize(subFolders, groups); - assert structure != null; children.addNotify(); + + for (Group g : groups) { + content.add(g); + } } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java deleted file mode 100644 index 065db86da4b..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * - * @author Thomas Wuerthinger - */ -public class GraphCountGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "Graph count structure"; - } - - public List>> organize(List subFolders, List groups) { - - List>> result = new ArrayList>>(); - - if (subFolders.size() == 0) { - Map> map = new HashMap>(); - for (Group g : groups) { - Integer cur = g.getGraphs().size(); - if (!map.containsKey(cur)) { - map.put(cur, new ArrayList()); - } - map.get(cur).add(g); - } - - SortedSet keys = new TreeSet(map.keySet()); - for (Integer i : keys) { - result.add(new Pair>("Graph count " + i, map.get(i))); - } - - } else if (subFolders.size() == 1) { - for (Group g : groups) { - List children = new ArrayList(); - children.add(g); - Pair> p = new Pair>(); - p.setLeft(g.getName()); - p.setRight(children); - result.add(p); - } - } else if (subFolders.size() == 2) { - result.add(new Pair>("", groups)); - } - - return result; - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java index a3da71e25eb..be77609af2b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,23 +23,27 @@ */ package com.sun.hotspot.igv.coordinator; +import com.sun.hotspot.igv.coordinator.actions.CloneGraphAction; import com.sun.hotspot.igv.coordinator.actions.DiffGraphAction; import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie; -import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; +import com.sun.hotspot.igv.coordinator.actions.GraphCloneCookie; +import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie; +import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie; import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.services.GraphViewer; -import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.util.PropertiesSheet; import java.awt.Image; import javax.swing.Action; import org.openide.actions.OpenAction; -import org.openide.cookies.OpenCookie; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; -import org.openide.nodes.Node; +import org.openide.nodes.NodeAdapter; +import org.openide.nodes.NodeEvent; +import org.openide.nodes.NodeMemberEvent; import org.openide.nodes.Sheet; +import org.openide.util.ImageUtilities; import org.openide.util.Lookup; -import org.openide.util.Utilities; import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; @@ -48,7 +52,6 @@ import org.openide.util.lookup.InstanceContent; * @author Thomas Wuerthinger */ public class GraphNode extends AbstractNode { - private InputGraph graph; /** Creates a new instance of GraphNode */ @@ -56,7 +59,7 @@ public class GraphNode extends AbstractNode { this(graph, new InstanceContent()); } - private GraphNode(final InputGraph graph, InstanceContent content) { + private GraphNode(InputGraph graph, InstanceContent content) { super(Children.LEAF, new AbstractLookup(content)); this.graph = graph; this.setDisplayName(graph.getName()); @@ -66,19 +69,22 @@ public class GraphNode extends AbstractNode { if (viewer != null) { // Action for opening the graph - content.add(new OpenCookie() { - - public void open() { - viewer.view(graph); - } - }); + content.add(new GraphOpenCookie(viewer, graph)); } // Action for removing a graph - content.add(new RemoveCookie() { + content.add(new GraphRemoveCookie(graph)); - public void remove() { - graph.getGroup().removeGraph(graph); + // Action for diffing to the current graph + content.add(new DiffGraphCookie(graph)); + + // Action for cloning to the current graph + content.add(new GraphCloneCookie(viewer, graph)); + + this.addNodeListener(new NodeAdapter() { + @Override + public void childrenRemoved(NodeMemberEvent ev) { + GraphNode.this.graph = null; } }); } @@ -86,13 +92,17 @@ public class GraphNode extends AbstractNode { @Override protected Sheet createSheet() { Sheet s = super.createSheet(); - PropertiesSheet.initializeSheet(graph.getProperties(), s); + Properties p = new Properties(); + p.add(graph.getProperties()); + p.setProperty("nodeCount", Integer.toString(graph.getNodes().size())); + p.setProperty("edgeCount", Integer.toString(graph.getEdges().size())); + PropertiesSheet.initializeSheet(p, s); return s; } @Override public Image getIcon(int i) { - return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/graph.gif"); + return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/graph.png"); } @Override @@ -100,31 +110,29 @@ public class GraphNode extends AbstractNode { return getIcon(i); } - @Override - public T getCookie(Class aClass) { - if (aClass == DiffGraphCookie.class) { - InputGraphProvider graphProvider = Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - - InputGraph graphA = null; - if (graphProvider != null) { - graphA = graphProvider.getGraph(); - } - - if (graphA != null && !graphA.isDifferenceGraph()) { - return (T) new DiffGraphCookie(graphA, graph); - } - } - - return super.getCookie(aClass); - } - @Override public Action[] getActions(boolean b) { - return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)}; + return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) CloneGraphAction.findObject(CloneGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)}; } @Override public Action getPreferredAction() { return (Action) OpenAction.findObject(OpenAction.class, true); } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof GraphNode) { + return (graph == ((GraphNode) obj).graph); + } + return false; + } + + @Override + public int hashCode() { + return graph.hashCode(); + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form index 37e033f1989..24ae8179868 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form @@ -3,6 +3,8 @@ + + @@ -14,28 +16,17 @@ - + + + + - - - - - - - - - - - - - - - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java index 77204faf528..292dcd4b6fb 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,37 +23,25 @@ */ package com.sun.hotspot.igv.coordinator; -import com.sun.hotspot.igv.coordinator.actions.ImportAction; -import com.sun.hotspot.igv.coordinator.actions.RemoveAction; -import com.sun.hotspot.igv.coordinator.actions.RemoveAllAction; -import com.sun.hotspot.igv.coordinator.actions.SaveAllAction; -import com.sun.hotspot.igv.coordinator.actions.SaveAsAction; -import com.sun.hotspot.igv.coordinator.actions.StructuredViewAction; +import com.sun.hotspot.igv.connection.Server; +import com.sun.hotspot.igv.coordinator.actions.*; import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.services.GroupCallback; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.services.GroupReceiver; import java.awt.BorderLayout; -import java.awt.Component; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import javax.swing.BoxLayout; -import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.Border; import org.openide.ErrorManager; +import org.openide.actions.GarbageCollectAction; import org.openide.awt.Toolbar; import org.openide.awt.ToolbarPool; import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; import org.openide.explorer.view.BeanTreeView; -import org.openide.util.Lookup; import org.openide.util.LookupEvent; import org.openide.util.LookupListener; import org.openide.util.NbBundle; @@ -72,7 +60,8 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM private ExplorerManager manager; private GraphDocument document; private FolderNode root; - private GroupOrganizer organizer; + private Server server; + private Server binaryServer; private OutlineTopComponent() { initComponents(); @@ -88,17 +77,9 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM private void initListView() { manager = new ExplorerManager(); - organizer = new StandardGroupOrganizer(); - root = new FolderNode("", organizer, new ArrayList(), document.getGroups()); + root = new FolderNode(document); manager.setRootContext(root); - ((BeanTreeView) this.jScrollPane1).setRootVisible(false); - - document.getChangedEvent().addListener(new ChangedListener() { - - public void changed(GraphDocument document) { - updateStructure(); - } - }); + ((BeanTreeView) this.treeView).setRootVisible(false); associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); } @@ -111,61 +92,41 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM this.add(toolbar, BorderLayout.NORTH); toolbar.add(ImportAction.get(ImportAction.class)); - toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup())); - toolbar.add(RemoveAllAction.get(RemoveAllAction.class)); toolbar.add(((NodeAction) SaveAsAction.get(SaveAsAction.class)).createContextAwareInstance(this.getLookup())); toolbar.add(SaveAllAction.get(SaveAllAction.class)); - toolbar.add(StructuredViewAction.get(StructuredViewAction.class).getToolbarPresenter()); + toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup())); + toolbar.add(RemoveAllAction.get(RemoveAllAction.class)); + + toolbar.add(GarbageCollectAction.get(GarbageCollectAction.class).getToolbarPresenter()); for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) { tb.setVisible(false); } - - initOrganizers(); - } - - public void setOrganizer(GroupOrganizer organizer) { - this.organizer = organizer; - updateStructure(); - } - - private void initOrganizers() { - } private void initReceivers() { final GroupCallback callback = new GroupCallback() { + @Override public void started(Group g) { - getDocument().addGroup(g); + synchronized(OutlineTopComponent.this) { + getDocument().addElement(g); + } } }; - Collection receivers = Lookup.getDefault().lookupAll(GroupReceiver.class); - if (receivers.size() > 0) { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); - - for (GroupReceiver r : receivers) { - Component c = r.init(callback); - panel.add(c); - } - - jPanel2.add(panel, BorderLayout.PAGE_START); - } - } - - private void updateStructure() { - root.init("", organizer, new ArrayList(), document.getGroups()); + server = new Server(getDocument(), callback, false); + binaryServer = new Server(getDocument(), callback, true); } public void clear() { document.clear(); } + @Override public ExplorerManager getExplorerManager() { return manager; } @@ -221,6 +182,25 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM return PREFERRED_ID; } + @Override + public void requestActive() { + super.requestActive(); + treeView.requestFocus(); + } + + @Override + public boolean requestFocus(boolean temporary) { + treeView.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + treeView.requestFocus(); + return super.requestFocusInWindow(temporary); + } + + @Override public void resultChanged(LookupEvent lookupEvent) { } @@ -228,7 +208,7 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException { // Not called when user starts application for the first time super.readExternal(objectInput); - ((BeanTreeView) this.jScrollPane1).setRootVisible(false); + ((BeanTreeView) this.treeView).setRootVisible(false); } @Override @@ -253,19 +233,13 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM // //GEN-BEGIN:initComponents private void initComponents() { - jPanel2 = new javax.swing.JPanel(); - jScrollPane1 = new BeanTreeView(); + treeView = new BeanTreeView(); setLayout(new java.awt.BorderLayout()); - - jPanel2.setLayout(new java.awt.BorderLayout()); - jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); - - add(jPanel2, java.awt.BorderLayout.CENTER); + add(treeView, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel jPanel2; - private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane treeView; // End of variables declaration//GEN-END:variables } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml index 1e05bc21edb..ada940d0094 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml @@ -4,7 +4,7 @@ - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java deleted file mode 100644 index ca468a0b5c3..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.Pair; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class StandardGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "-- None --"; - } - - public List>> organize(List subFolders, List groups) { - - List>> result = new ArrayList>>(); - - if (groups.size() == 1 && subFolders.size() > 0) { - result.add(new Pair>("", groups)); - } else { - for (Group g : groups) { - List children = new ArrayList(); - children.add(g); - Pair> p = new Pair>(); - p.setLeft(g.getName()); - p.setRight(children); - result.add(p); - } - } - - return result; - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties index 5b5b93f4773..e765916a8b9 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties @@ -1,18 +1,10 @@ -CTL_EditFilterAction=Edit... CTL_ImportAction=Open... CTL_OpenGraphAction=View graph CTL_DiffGraphAction=Difference to current graph -CTL_RemoveAction=Remove methods -CTL_ApplyFilterAction=Apply -CTL_FilterAction=Open Filter Window -CTL_AppliedFilterAction=Open AppliedFilter Window -CTL_OutlineAction=Open Outline Window -CTL_MoveFilterUpAction=Move upwards -CTL_MoveFilterDownAction=Move downwards -CTL_RemoveFilterAction=Remove -CTL_RemoveFilterSettingsAction=Remove filter setting -CTL_SaveAsAction=Save selected methods... -CTL_SaveAllAction=Save all... -CTL_SaveFilterSettingsAction=Save filter settings... -CTL_PropertiesAction=Open Properties Window +CTL_RemoveAction=Remove selected graphs and groups +CTL_RemoveAllAction=Remove all graphs and groups +CTL_OutlineAction=Outline +CTL_SaveAsAction=Save selected groups... +CTL_SaveAllAction=Save all groups... +CTL_PropertiesAction=Open Properties Window CTL_NewFilterAction=New filter... diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NodeFindAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/CloneGraphAction.java similarity index 54% rename from hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NodeFindAction.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/CloneGraphAction.java index 356b4eb01c7..a54548446eb 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/NodeFindAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/CloneGraphAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,35 +21,62 @@ * questions. * */ -package com.sun.hotspot.igv.view.actions; -import com.sun.hotspot.igv.view.EditorTopComponent; -import javax.swing.Action; +package com.sun.hotspot.igv.coordinator.actions; + +import org.openide.nodes.Node; import org.openide.util.HelpCtx; -import org.openide.util.NbBundle; -import org.openide.util.actions.CallableSystemAction; +import org.openide.util.actions.CookieAction; /** * * @author Thomas Wuerthinger */ -public final class NodeFindAction extends CallableSystemAction { +public final class CloneGraphAction extends CookieAction { - public void performAction() { - EditorTopComponent comp = EditorTopComponent.getActive(); - if (comp != null) { - comp.findNode(); + @Override + protected void performAction(Node[] activatedNodes) { + GraphCloneCookie c = activatedNodes[0].getCookie(GraphCloneCookie.class); + assert c != null; + c.openClone(); + } + + @Override + protected int mode() { + return CookieAction.MODE_EXACTLY_ONE; + } + + @Override + protected boolean enable(Node[] activatedNodes) { + boolean b = super.enable(activatedNodes); + if (b) { + assert activatedNodes.length == 1; + GraphCloneCookie c = activatedNodes[0].getCookie(GraphCloneCookie.class); + assert c != null; + return true; } + + return false; } - public NodeFindAction() { - putValue(Action.SHORT_DESCRIPTION, "Find nodes"); - } - + @Override public String getName() { - return NbBundle.getMessage(NodeFindAction.class, "CTL_NodeFindAction"); + return "Open clone"; } + @Override + protected Class[] cookieClasses() { + return new Class[]{ + GraphCloneCookie.class + }; + } + + @Override + protected String iconResource() { + return "com/sun/hotspot/igv/coordinator/images/graph.png"; + } + + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -58,14 +85,5 @@ public final class NodeFindAction extends CallableSystemAction { protected boolean asynchronous() { return false; } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - protected String iconResource() { - return "com/sun/hotspot/igv/view/images/search.gif"; - } } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java index ffac92113dc..32eb45202cb 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,30 +35,49 @@ import org.openide.util.actions.CookieAction; */ public final class DiffGraphAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class); + assert c != null; c.openDiff(); } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } + @Override + protected boolean enable(Node[] activatedNodes) { + boolean b = super.enable(activatedNodes); + if (b) { + assert activatedNodes.length == 1; + DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class); + assert c != null; + return c.isPossible(); + } + + return false; + } + + @Override public String getName() { return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction"); } - protected Class[] cookieClasses() { - return new Class[]{ + @Override + protected Class[] cookieClasses() { + return new Class[]{ DiffGraphCookie.class }; } @Override protected String iconResource() { - return "com/sun/hotspot/igv/coordinator/images/diff.gif"; + return "com/sun/hotspot/igv/coordinator/images/diff.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -68,3 +87,4 @@ public final class DiffGraphAction extends CookieAction { return false; } } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java index 2bede020431..fe3c28ca783 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,12 +21,13 @@ * questions. * */ - package com.sun.hotspot.igv.coordinator.actions; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.GraphViewer; +import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.difference.Difference; +import com.sun.hotspot.igv.util.LookupHistory; import org.openide.nodes.Node; import org.openide.util.Lookup; @@ -36,21 +37,30 @@ import org.openide.util.Lookup; */ public class DiffGraphCookie implements Node.Cookie { - private InputGraph a; - private InputGraph b; + private InputGraph graph; - public DiffGraphCookie(InputGraph a, InputGraph b) { - this.a = a; - this.b = b; + public DiffGraphCookie(InputGraph graph) { + this.graph = graph; + } + + private InputGraph getCurrentGraph() { + InputGraphProvider graphProvider = LookupHistory.getLast(InputGraphProvider.class); + if (graphProvider != null) { + return graphProvider.getGraph(); + } + return null; + } + + public boolean isPossible() { + return getCurrentGraph() != null; } public void openDiff() { - + InputGraph other = getCurrentGraph(); final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class); - - if(viewer != null) { - InputGraph diffGraph = Difference.createDiffGraph(a, b); - viewer.view(diffGraph); + if (viewer != null) { + InputGraph diffGraph = Difference.createDiffGraph(other, graph); + viewer.view(diffGraph, true); } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphCloneCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphCloneCookie.java new file mode 100644 index 00000000000..63ef347e08c --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphCloneCookie.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.coordinator.actions; + +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.services.GraphViewer; +import org.openide.nodes.Node; + +public class GraphCloneCookie implements Node.Cookie { + + private final GraphViewer viewer; + private final InputGraph graph; + + public GraphCloneCookie(GraphViewer viewer, InputGraph graph) { + this.viewer = viewer; + this.graph = graph; + } + + public void openClone() { + viewer.view(graph, true); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java new file mode 100644 index 00000000000..b3f2e72ad3f --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.coordinator.actions; + +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.services.GraphViewer; +import org.openide.cookies.OpenCookie; + +public class GraphOpenCookie implements OpenCookie { + + private final GraphViewer viewer; + private final InputGraph graph; + + public GraphOpenCookie(GraphViewer viewer, InputGraph graph) { + this.viewer = viewer; + this.graph = graph; + } + + @Override + public void open() { + viewer.view(graph, false); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java new file mode 100644 index 00000000000..d750e7abc19 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.coordinator.actions; + +import com.sun.hotspot.igv.data.InputGraph; + +public class GraphRemoveCookie implements RemoveCookie { + private final InputGraph graph; + + public GraphRemoveCookie(InputGraph graph) { + this.graph = graph; + } + + @Override + public void remove() { + graph.getGroup().removeElement(graph); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java index 82930b4ac1e..5bd6c199bf5 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,51 +26,54 @@ package com.sun.hotspot.igv.coordinator.actions; import com.sun.hotspot.igv.coordinator.OutlineTopComponent; import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.serialization.BinaryParser; +import com.sun.hotspot.igv.data.serialization.GraphParser; +import com.sun.hotspot.igv.data.serialization.ParseMonitor; import com.sun.hotspot.igv.data.serialization.Parser; import com.sun.hotspot.igv.settings.Settings; -import com.sun.hotspot.igv.data.serialization.XMLParser; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.channels.FileChannel; +import java.nio.file.StandardOpenOption; import javax.swing.Action; import javax.swing.JFileChooser; import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; +import org.openide.util.Exceptions; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.util.actions.CallableSystemAction; -import org.openide.xml.XMLUtil; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; /** * * @author Thomas Wuerthinger */ public final class ImportAction extends CallableSystemAction { + private static final int WORKUNITS = 10000; public static FileFilter getFileFilter() { return new FileFilter() { + @Override public boolean accept(File f) { - return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory(); + return f.getName().toLowerCase().endsWith(".xml") || f.getName().toLowerCase().endsWith(".bgv") || f.isDirectory(); } + @Override public String getDescription() { - return "XML files (*.xml)"; + return "Graph files (*.xml, *.bgv)"; } }; } + @Override public void performAction() { JFileChooser fc = new JFileChooser(); @@ -86,84 +89,79 @@ public final class ImportAction extends CallableSystemAction { } Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); - try { - final XMLReader reader = XMLUtil.createXMLReader(); - final FileInputStream inputStream = new FileInputStream(file); - final InputSource is = new InputSource(inputStream); - + final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); - final int basis = 1000; - handle.start(basis); - final int start = inputStream.available(); - - final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() { - - public void setProgress(double d) { + handle.start(WORKUNITS); + final long start = channel.size(); + ParseMonitor monitor = new ParseMonitor() { + @Override + public void updateProgress() { try { - int curAvailable = inputStream.available(); - int prog = (int) (basis * (double) (start - curAvailable) / (double) start); + int prog = (int) (WORKUNITS * (double) channel.position() / (double) start); handle.progress(prog); } catch (IOException ex) { } } - + @Override public void setState(String state) { - setProgress(0.0); + updateProgress(); handle.progress(state); } }; - final Parser parser = new Parser(); + final GraphParser parser; final OutlineTopComponent component = OutlineTopComponent.findInstance(); - - component.requestActive(); - + if (file.getName().endsWith(".xml")) { + parser = new Parser(channel, monitor, null); + } else if (file.getName().endsWith(".bgv")) { + parser = new BinaryParser(channel, monitor, component.getDocument(), null); + } else { + parser = null; + } RequestProcessor.getDefault().post(new Runnable() { - + @Override public void run() { - GraphDocument document = null; try { - document = parser.parse(reader, is, parseMonitor); - parseMonitor.setState("Finishing"); - component.getDocument().addGraphDocument(document); - } catch (SAXException ex) { - String s = "Exception during parsing the XML file, could not load document!"; - if (ex instanceof XMLParser.MissingAttributeException) { - XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex; - s += "\nMissing attribute \"" + e.getAttributeName() + "\""; + final GraphDocument document = parser.parse(); + if (document != null) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + component.requestActive(); + component.getDocument().addGraphDocument(document); + } + }); } - ex.printStackTrace(); - NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notify(d); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); } handle.finish(); } }); - - } catch (SAXException ex) { - ex.printStackTrace(); } catch (FileNotFoundException ex) { - ex.printStackTrace(); + Exceptions.printStackTrace(ex); } catch (IOException ex) { - ex.printStackTrace(); + Exceptions.printStackTrace(ex); } } } + @Override public String getName() { return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction"); } public ImportAction() { - putValue(Action.SHORT_DESCRIPTION, "Open an XML graph document"); + putValue(Action.SHORT_DESCRIPTION, "Open XML graph document..."); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); } @Override protected String iconResource() { - return "com/sun/hotspot/igv/coordinator/images/import.gif"; + return "com/sun/hotspot/igv/coordinator/images/import.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java index e140ce3d840..dda4e7abda4 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/OutlineAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ package com.sun.hotspot.igv.coordinator.actions; -import com.sun.hotspot.igv.coordinator.*; +import com.sun.hotspot.igv.coordinator.OutlineTopComponent; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import org.openide.util.NbBundle; @@ -40,6 +40,7 @@ public class OutlineAction extends AbstractAction { super(NbBundle.getMessage(OutlineAction.class, "CTL_OutlineAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = OutlineTopComponent.findInstance(); win.open(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java index c12e3a55ede..42321f90247 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import org.openide.util.actions.NodeAction; */ public final class RemoveAction extends NodeAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { RemoveCookie removeCookie = n.getCookie(RemoveCookie.class); @@ -46,18 +47,20 @@ public final class RemoveAction extends NodeAction { } public RemoveAction() { - putValue(Action.SHORT_DESCRIPTION, "Remove"); + putValue(Action.SHORT_DESCRIPTION, "Remove selected graphs and groups"); } + @Override public String getName() { return NbBundle.getMessage(RemoveAction.class, "CTL_RemoveAction"); } @Override protected String iconResource() { - return "com/sun/hotspot/igv/coordinator/images/remove.gif"; + return "com/sun/hotspot/igv/coordinator/images/remove.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -67,6 +70,7 @@ public final class RemoveAction extends NodeAction { return false; } + @Override protected boolean enable(Node[] nodes) { return nodes.length > 0; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java index 9ab0531d5c0..e1d68ffefcd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveAllAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,20 +40,22 @@ import org.openide.util.actions.CallableSystemAction; public final class RemoveAllAction extends CallableSystemAction { + @Override public String getName() { - return NbBundle.getMessage(RemoveAllAction.class, "CTL_ImportAction"); + return NbBundle.getMessage(RemoveAllAction.class, "CTL_RemoveAllAction"); } public RemoveAllAction() { - putValue(Action.SHORT_DESCRIPTION, "Remove all methods"); + putValue(Action.SHORT_DESCRIPTION, "Remove all graphs and groups"); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.CTRL_MASK)); } @Override protected String iconResource() { - return "com/sun/hotspot/igv/coordinator/images/removeall.gif"; + return "com/sun/hotspot/igv/coordinator/images/removeall.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java index 5ad8442a7d9..c2620fe0bdd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/RemoveCookie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java index 9db8bb78c65..eb75dd9753a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,17 +39,19 @@ import org.openide.util.actions.CallableSystemAction; */ public final class SaveAllAction extends CallableSystemAction { + @Override public void performAction() { final OutlineTopComponent component = OutlineTopComponent.findInstance(); SaveAsAction.save(component.getDocument()); } + @Override public String getName() { return NbBundle.getMessage(SaveAllAction.class, "CTL_SaveAllAction"); } public SaveAllAction() { - putValue(Action.SHORT_DESCRIPTION, "Save all methods to XML file"); + putValue(Action.SHORT_DESCRIPTION, "Save all groups to XML file..."); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); } @@ -58,6 +60,7 @@ public final class SaveAllAction extends CallableSystemAction { return "com/sun/hotspot/igv/coordinator/images/saveall.gif"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java index e36414ce1e6..a1789093122 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,12 +28,8 @@ import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.serialization.Printer; import com.sun.hotspot.igv.settings.Settings; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; +import java.io.*; +import javax.swing.Action; import javax.swing.JFileChooser; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -47,12 +43,17 @@ import org.openide.util.actions.NodeAction; */ public final class SaveAsAction extends NodeAction { + public SaveAsAction() { + putValue(Action.SHORT_DESCRIPTION, "Save selected groups to XML file..."); + } + + @Override protected void performAction(Node[] activatedNodes) { GraphDocument doc = new GraphDocument(); for (Node n : activatedNodes) { Group group = n.getLookup().lookup(Group.class); - doc.addGroup(group); + doc.addElement(group); } save(doc); @@ -75,10 +76,10 @@ public final class SaveAsAction extends NodeAction { } Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); try { - Writer writer = new OutputStreamWriter(new FileOutputStream(file)); - Printer p = new Printer(); - p.export(writer, doc); - writer.close(); + try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) { + Printer p = new Printer(); + p.export(writer, doc); + } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { @@ -92,15 +93,17 @@ public final class SaveAsAction extends NodeAction { return CookieAction.MODE_SOME; } + @Override public String getName() { return NbBundle.getMessage(SaveAsAction.class, "CTL_SaveAsAction"); } @Override protected String iconResource() { - return "com/sun/hotspot/igv/coordinator/images/save.gif"; + return "com/sun/hotspot/igv/coordinator/images/save.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -110,6 +113,7 @@ public final class SaveAsAction extends NodeAction { return false; } + @Override protected boolean enable(Node[] nodes) { int cnt = 0; diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java deleted file mode 100644 index 53b05984e1f..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.coordinator.actions; - -import com.sun.hotspot.igv.coordinator.OutlineTopComponent; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import java.awt.Component; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import org.openide.awt.DropDownButtonFactory; -import org.openide.util.HelpCtx; -import org.openide.util.Lookup; -import org.openide.util.Utilities; -import org.openide.util.actions.CallableSystemAction; - -public class StructuredViewAction extends CallableSystemAction { - - private static JButton dropDownButton; - private static ButtonGroup buttonGroup; - private static JPopupMenu popup; - private MyMenuItemListener menuItemListener; - private Map map; - - public StructuredViewAction() { - - putValue(Action.SHORT_DESCRIPTION, "Cluster nodes into blocks"); - } - - @Override - public Component getToolbarPresenter() { - - Image iconImage = Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/structure.gif"); - ImageIcon icon = new ImageIcon(iconImage); - - popup = new JPopupMenu(); - - menuItemListener = new MyMenuItemListener(); - - buttonGroup = new ButtonGroup(); - - Collection organizersCollection = Lookup.getDefault().lookupAll(GroupOrganizer.class); - - List organizers = new ArrayList(organizersCollection); - Collections.sort(organizers, new Comparator() { - public int compare(GroupOrganizer a, GroupOrganizer b) { - return a.getName().compareTo(b.getName()); - } - }); - - map = new HashMap(); - - boolean first = true; - for(GroupOrganizer organizer : organizers) { - JCheckBoxMenuItem item = new JCheckBoxMenuItem(organizer.getName()); - map.put(item, organizer); - item.addActionListener(menuItemListener); - buttonGroup.add(item); - popup.add(item); - if(first) { - item.setSelected(true); - first = false; - } - } - - dropDownButton = DropDownButtonFactory.createDropDownButton( - new ImageIcon( - new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)), - popup); - - dropDownButton.setIcon(icon); - - dropDownButton.setToolTipText("Insert Layer Registration"); - - dropDownButton.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - int state = e.getStateChange(); - if (state == ItemEvent.SELECTED) { - performAction(); - } - } - }); - - dropDownButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - performAction(); - } - }); - - popup.addPopupMenuListener(new PopupMenuListener() { - - public void popupMenuCanceled(PopupMenuEvent e) { - dropDownButton.setSelected(false); - } - - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - dropDownButton.setSelected(false); - } - - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - dropDownButton.setSelected(true); - } - }); - - return dropDownButton; - - } - - private class MyMenuItemListener implements ActionListener { - - public void actionPerformed(ActionEvent ev) { - JMenuItem item = (JMenuItem) ev.getSource(); - GroupOrganizer organizer = map.get(item); - assert organizer != null : "Organizer must exist!"; - OutlineTopComponent.findInstance().setOrganizer(organizer); - } - } - - - @Override - public void performAction() { - popup.show(dropDownButton, 0, dropDownButton.getHeight()); - } - - public String getName() { - return "Structured View"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - @Override - protected boolean asynchronous() { - return false; - } - -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml index 2655e46a14b..d3213b31fbc 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/customLeftWsmode.xml @@ -4,12 +4,8 @@ - - - - - - + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.gif deleted file mode 100644 index 6e49c314adf..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.png new file mode 100644 index 00000000000..614e8378470 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/diff.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.gif deleted file mode 100644 index 2d3ca05fb33..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.png new file mode 100644 index 00000000000..9a19c2eaf6d Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/folder.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.gif deleted file mode 100644 index 7a4e5fc8cd7..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.png new file mode 100644 index 00000000000..76039e44911 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/graph.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.gif deleted file mode 100644 index c0b2ca24af5..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.png new file mode 100644 index 00000000000..7e4a6badcb1 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/import.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.gif deleted file mode 100644 index 9dc08247b8f..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.png new file mode 100644 index 00000000000..d89af5b9b38 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/remove.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif deleted file mode 100644 index 9eeab3cad6d..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.png new file mode 100644 index 00000000000..d51f50f16cf Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/removeall.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif deleted file mode 100644 index 954f1accde6..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.png new file mode 100644 index 00000000000..906747dffd1 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/save.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif index 2d31c8b2ccd..655cb1e15a5 100644 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/saveall.gif differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif deleted file mode 100644 index 2be84874874..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.png b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.png new file mode 100644 index 00000000000..de2b8a63605 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/images/structure.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml index 999997db9f6..49fbe2fd330 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml @@ -1,110 +1,194 @@ - + - - - - - - - - - - - - - - - - - - - - - + + + - - - - + + + + + + - + - + - + - + - + - - - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/Data/manifest.mf index 702ae8764a2..117fb84a6f6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/manifest.mf +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/manifest.mf @@ -1,5 +1,5 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.data -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/data/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.data +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/data/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties index 152f44eca60..c5b391f33d3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties @@ -1,2 +1,8 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +src.dir=src +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +test.src.dir=test +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml index dce4d28a7c3..6446f1e3fb1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml @@ -6,6 +6,19 @@ com.sun.hotspot.igv.data + + + unit + + org.netbeans.libs.junit4 + + + + org.openide.util + + + + com.sun.hotspot.igv.data com.sun.hotspot.igv.data.serialization diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java index 40368bc9873..90c87e47dba 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,20 +24,22 @@ package com.sun.hotspot.igv.data; /** - * + * Class representing a generic changed event. * @author Thomas Wuerthinger + * @param */ public class ChangedEvent extends Event> { private T object; - public ChangedEvent() { - } - + /** + * Creates a new event with the specific object as the one for which the event gets fired. + */ public ChangedEvent(T object) { this.object = object; } + @Override protected void fire(ChangedListener l) { l.changed(object); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java index f7b5084b1e4..98384b42462 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,14 @@ package com.sun.hotspot.igv.data; /** - * + * Provides a changed event object. * @author Thomas Wuerthinger + * @param Class for which the changed event fires. */ public interface ChangedEventProvider { - public ChangedEvent getChangedEvent(); + /** + * Returns the changed event object. Should always return the same instance. + */ + ChangedEvent getChangedEvent(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java index 983b493bcf5..c072c6cd6ec 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,15 @@ package com.sun.hotspot.igv.data; /** - * + * Listens to changed events. * @author Thomas Wuerthinger + * @param Class for which the changed event fires. */ public interface ChangedListener { - public void changed(T source); + /** + * This method is called everytime a changed event is fired. + * @param source Object that has changed. + */ + void changed(T source); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java new file mode 100644 index 00000000000..26be59b4bfa --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +/** + * + * @author Thomas Wuerthinger + */ +public abstract class ControllableChangedListener implements ChangedListener{ + + private boolean enabled; + + + public ControllableChangedListener() { + enabled = true; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean b) { + enabled = b; + } + + @Override + public void changed(T source) { + if(enabled) { + filteredChanged(source); + } + } + + public abstract void filteredChanged(T source); +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java index 1287f355d65..25effee7672 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,23 +33,48 @@ import java.util.List; public abstract class Event { private List listener; + private boolean fireEvents; + private boolean eventWasFired; public Event() { - listener = new ArrayList(); + listener = new ArrayList<>(); + fireEvents = true; } public void addListener(L l) { listener.add(l); } - public void removeListener(L l) { + /** + * Remove listener + * @param l + */ + public void removeListener(final L l) { listener.remove(l); } public void fire() { - List tmpList = new ArrayList(listener); - for (L l : tmpList) { - fire(l); + if(fireEvents) { + List tmpList = new ArrayList<>(listener); + for (L l : tmpList) { + fire(l); + } + } else { + eventWasFired = true; + } + } + + public void beginAtomic() { + assert fireEvents : "endAtomic has to be called before another beginAtomic may be called"; + this.fireEvents = false; + this.eventWasFired = false; + } + + public void endAtomic() { + assert !fireEvents : "beginAtomic has to be called first"; + this.fireEvents = true; + if(eventWasFired) { + fire(); } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java similarity index 71% rename from hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java index a3927d39dfb..3f93ba3a710 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,19 +21,13 @@ * questions. * */ -package com.sun.hotspot.igv.data.services; +package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.Pair; import java.util.List; -/** - * - * @author Thomas Wuerthinger - */ -public interface GroupOrganizer { - - public String getName(); - - public List>> organize(List subFolders, List groups); +public interface Folder { + List getElements(); + void removeElement(FolderElement element); + void addElement(FolderElement group); + ChangedEvent getChangedEvent(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java similarity index 78% rename from hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java index b053c117008..696479e3f91 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupReceiver.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,15 +21,11 @@ * questions. * */ -package com.sun.hotspot.igv.data.services; +package com.sun.hotspot.igv.data; -import java.awt.Component; +public interface FolderElement { -/** - * - * @author Thomas Wuerthinger - */ -public interface GroupReceiver { - - public Component init(GroupCallback callback); + Folder getParent(); + String getName(); + void setParent(Folder parent); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java index 7eb5c5edaa7..8c62573b2d4 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,53 +24,36 @@ package com.sun.hotspot.igv.data; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** * * @author Thomas Wuerthinger */ -public class GraphDocument extends Properties.Entity implements ChangedEventProvider { +public class GraphDocument extends Properties.Entity implements ChangedEventProvider, Folder { - private List groups; + private List elements; private ChangedEvent changedEvent; public GraphDocument() { - groups = new ArrayList(); - changedEvent = new ChangedEvent(this); + elements = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public void clear() { - groups.clear(); + elements.clear(); getChangedEvent().fire(); } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } - public List getGroups() { - return Collections.unmodifiableList(groups); - } - - public void addGroup(Group group) { - group.setDocument(this); - groups.add(group); - getChangedEvent().fire(); - } - - public void removeGroup(Group group) { - if (groups.contains(group)) { - group.setDocument(null); - groups.remove(group); - getChangedEvent().fire(); - } - } - public void addGraphDocument(GraphDocument document) { - for (Group g : document.groups) { - this.addGroup(g); + for (FolderElement e : document.elements) { + e.setParent(this); + this.addElement(e); } document.clear(); getChangedEvent().fire(); @@ -80,12 +63,30 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("GraphDocument: " + getProperties().toString() + " \n\n"); - for (Group g : getGroups()) { + sb.append("GraphDocument: ").append(getProperties().toString()).append(" \n\n"); + for (FolderElement g : getElements()) { sb.append(g.toString()); sb.append("\n\n"); } return sb.toString(); } + + @Override + public List getElements() { + return elements; + } + + @Override + public void removeElement(FolderElement element) { + if (elements.remove(element)) { + getChangedEvent().fire(); + } + } + + @Override + public void addElement(FolderElement element) { + elements.add(element); + getChangedEvent().fire(); + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java index dd94891dd98..645ef3c2cfa 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,49 +23,36 @@ */ package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.ChangedEvent; -import com.sun.hotspot.igv.data.ChangedEventProvider; -import com.sun.hotspot.igv.data.Properties; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * * @author Thomas Wuerthinger */ -public class Group extends Properties.Entity implements ChangedEventProvider { +public class Group extends Properties.Entity implements ChangedEventProvider, Folder, FolderElement { + + private final List elements; + private final List graphs; - private List graphs; - private transient ChangedEvent changedEvent; - private GraphDocument document; private InputMethod method; - private String assembly; + private transient ChangedEvent changedEvent; + private Folder parent; - public Group() { - graphs = new ArrayList(); - init(); - } + public Group(Folder parent) { + elements = new ArrayList<>(); + graphs = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); + this.parent = parent; - private void init() { - changedEvent = new ChangedEvent(this); + // Ensure that name and type are never null + getProperties().setProperty("name", ""); + getProperties().setProperty("type", ""); } public void fireChangedEvent() { changedEvent.fire(); } - public void setAssembly(String s) { - this.assembly = s; - } - - public String getAssembly() { - return assembly; - } - public void setMethod(InputMethod method) { this.method = method; } @@ -74,68 +61,120 @@ public class Group extends Properties.Entity implements ChangedEventProvider getChangedEvent() { return changedEvent; } - public List getGraphs() { - return Collections.unmodifiableList(graphs); + @Override + public List getElements() { + return Collections.unmodifiableList(elements); } - public void addGraph(InputGraph g) { - assert g != null; - assert !graphs.contains(g); - graphs.add(g); + public int getGraphsCount() { + return elements.size(); + } + + @Override + public void addElement(FolderElement element) { + elements.add(element); + if (element instanceof InputGraph) { + graphs.add((InputGraph) element); + } else { + + } + element.setParent(this); changedEvent.fire(); } - public void removeGraph(InputGraph g) { - int index = graphs.indexOf(g); - if (index != -1) { - graphs.remove(g); - changedEvent.fire(); - } - } - public Set getAllNodes() { - Set result = new HashSet(); - for (InputGraph g : graphs) { - Set ids = g.getNodesAsSet(); - result.addAll(g.getNodesAsSet()); - for (Integer i : ids) { - result.add(-i); + Set result = new HashSet<>(); + for (FolderElement e : elements) { + if (e instanceof InputGraph) { + InputGraph g = (InputGraph) e; + result.addAll(g.getNodesAsSet()); } } return result; } - public InputGraph getLastAdded() { - if (graphs.size() == 0) { - return null; - } - return graphs.get(graphs.size() - 1); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Group " + getProperties().toString() + "\n"); - for (InputGraph g : graphs) { + sb.append("Group ").append(getProperties()).append("\n"); + for (FolderElement g : elements) { sb.append(g.toString()); - sb.append("\n"); + sb.append('\n'); } return sb.toString(); } + @Override public String getName() { return getProperties().get("name"); } + + public String getType() { + return getProperties().get("type"); + + } + + InputGraph getPrev(InputGraph graph) { + InputGraph lastGraph = null; + for (FolderElement e : elements) { + if (e == graph) { + return lastGraph; + } + if (e instanceof InputGraph) { + lastGraph = (InputGraph) e; + } + } + return null; + } + + InputGraph getNext(InputGraph graph) { + boolean found = false; + for (FolderElement e : elements) { + if (e == graph) { + found = true; + } else if (found && e instanceof InputGraph) { + return (InputGraph) e; + } + } + return null; + } + + public InputGraph getLastGraph() { + InputGraph lastGraph = null; + for (FolderElement e : elements) { + if (e instanceof InputGraph) { + lastGraph = (InputGraph) e; + } + } + return lastGraph; + } + + @Override + public Folder getParent() { + return parent; + } + + @Override + public void removeElement(FolderElement element) { + if (elements.remove(element)) { + if (element instanceof InputGraph) { + graphs.remove((InputGraph) element); + } + changedEvent.fire(); + } + } + + public List getGraphs() { + return graphs; + } + + @Override + public void setParent(Folder parent) { + this.parent = parent; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java index 15dd6e096b7..2626e51e734 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.data; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @@ -37,104 +32,81 @@ import java.util.Set; public class InputBlock { private List nodes; - private List successorNames; private String name; private InputGraph graph; - private Rectangle bounds; private Set successors; - private Set predecessors; - private Set inputs; - private Set outputs; - public InputBlock(InputGraph graph, String name) { - this.graph = graph; - this.name = name; - nodes = new ArrayList(); - successorNames = new ArrayList(); - successors = new HashSet(); - predecessors = new HashSet(); - inputs = new HashSet(); - outputs = new HashSet(); + @Override + public int hashCode() { + return name.hashCode(); } - public void removeSuccessor(InputBlock b) { - if (successors.contains(b)) { - successors.remove(b); - b.predecessors.remove(this); - InputBlockEdge e = new InputBlockEdge(this, b); - assert outputs.contains(e); - outputs.remove(e); - assert b.inputs.contains(e); - b.inputs.remove(e); + @Override + public boolean equals(Object o) { + + if (o == this) { + return true; } + + if (o == null || (!(o instanceof InputBlock))) { + return false; + } + + final InputBlock b = (InputBlock)o; + final boolean result = b.nodes.equals(nodes) && b.name.equals(name) && b.successors.size() == successors.size(); + if (!result) { + return false; + } + + final HashSet s = new HashSet<>(); + for (InputBlock succ : successors) { + s.add(succ.name); + } + + for (InputBlock succ : b.successors) { + if (!s.contains(succ.name)) { + return false; + } + } + + return true; + } + + InputBlock(InputGraph graph, String name) { + this.graph = graph; + this.name = name; + nodes = new ArrayList<>(); + successors = new LinkedHashSet<>(2); } public String getName() { return name; } - public void setName(String s) { - name = s; - } - public List getNodes() { return Collections.unmodifiableList(nodes); } public void addNode(int id) { - InputNode n = graph.getNode(id); - assert n != null; - graph.setBlock(n, this); - addNode(graph.getNode(id)); - } - - public void addNode(InputNode node) { - assert !nodes.contains(node); + InputNode node = graph.getNode(id); + assert node != null; + assert !nodes.contains(node) : "duplicate : " + node; + graph.setBlock(node, this); nodes.add(node); } - public Set getPredecessors() { - return Collections.unmodifiableSet(predecessors); - } - public Set getSuccessors() { return Collections.unmodifiableSet(successors); } - public Set getInputs() { - return Collections.unmodifiableSet(inputs); - } - - public Set getOutputs() { - return Collections.unmodifiableSet(outputs); - } - - // resolveBlockLinks must be called afterwards - public void addSuccessor(String name) { - successorNames.add(name); - } - - public void resolveBlockLinks() { - for (String s : successorNames) { - InputBlock b = graph.getBlock(s); - addSuccessor(b); - } - - successorNames.clear(); - } - - public void addSuccessor(InputBlock b) { - if (!successors.contains(b)) { - successors.add(b); - b.predecessors.add(this); - InputBlockEdge e = new InputBlockEdge(this, b); - outputs.add(e); - b.inputs.add(e); - } - } - @Override public String toString() { - return this.getName(); + return "Block " + this.getName(); + } + + void addSuccessor(InputBlock b) { + if (!successors.contains(b)) { + successors.add(b); + } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java index b8bd38f1833..c93a1549ed2 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,15 @@ package com.sun.hotspot.igv.data; */ public class InputBlockEdge { + public enum State { + SAME, + NEW, + DELETED + } + private InputBlock from; private InputBlock to; + private State state = State.SAME; public InputBlockEdge(InputBlock from, InputBlock to) { assert from != null; @@ -47,13 +54,21 @@ public class InputBlockEdge { return to; } + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + @Override public boolean equals(Object obj) { - if (obj instanceof InputBlockEdge && obj != null) { + if (obj != null && obj instanceof InputBlockEdge) { InputBlockEdge e = (InputBlockEdge) obj; return e.from.equals(from) && e.to.equals(to); } - return super.equals(obj); + return false; } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java index 2d0384a6781..eb4b8438f29 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,11 +31,15 @@ public class InputBytecode { private int bci; private String name; + private String operands; + private String comment; private InputMethod inlined; - public InputBytecode(int bci, String name) { + public InputBytecode(int bci, String name, String operands, String comment) { this.bci = bci; this.name = name; + this.operands = operands; + this.comment = comment; } public InputMethod getInlined() { @@ -53,4 +57,12 @@ public class InputBytecode { public String getName() { return name; } + + public String getOperands() { + return operands; + } + + public String getComment() { + return comment; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java index 8d463c6b5db..846f74f3d1e 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,10 @@ */ package com.sun.hotspot.igv.data; +import java.util.Comparator; +import java.util.WeakHashMap; +import java.lang.ref.WeakReference; + /** * * @author Thomas Wuerthinger @@ -30,21 +34,83 @@ package com.sun.hotspot.igv.data; public class InputEdge { public enum State { - + IMMUTABLE, SAME, NEW, DELETED } - private char toIndex; - private int from; - private int to; + + public static final Comparator OUTGOING_COMPARATOR = new Comparator(){ + + @Override + public int compare(InputEdge o1, InputEdge o2) { + if(o1.getFromIndex() == o2.getFromIndex()) { + return o1.getTo() - o2.getTo(); + } + return o1.getFromIndex() - o2.getFromIndex(); + } + }; + + public static final Comparator INGOING_COMPARATOR = new Comparator(){ + + @Override + public int compare(InputEdge o1, InputEdge o2) { + if(o1.getToIndex() == o2.getToIndex()) { + return o1.getFrom() - o2.getFrom(); + } + return o1.getToIndex() - o2.getToIndex(); + } + }; + + private final char toIndex; + private final char fromIndex; + private final int from; + private final int to; + private final String label; + private final String type; private State state; public InputEdge(char toIndex, int from, int to) { + this((char) 0, toIndex, from, to, null, null); + } + + public InputEdge(char fromIndex, char toIndex, int from, int to) { + this(fromIndex, toIndex, from, to, null, null); + } + + public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) { this.toIndex = toIndex; + this.fromIndex = fromIndex; this.from = from; this.to = to; this.state = State.SAME; + this.label = label; + this.type = type.intern(); + } + + static WeakHashMap> immutableCache = new WeakHashMap<>(); + + public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) { + InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE); + WeakReference result = immutableCache.get(edge); + if (result != null) { + InputEdge edge2 = result.get(); + if (edge2 != null) { + return edge2; + } + } + immutableCache.put(edge, new WeakReference<>(edge)); + return edge; + } + + public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) { + this.toIndex = toIndex; + this.fromIndex = fromIndex; + this.from = from; + this.to = to; + this.state = state; + this.label = label; + this.type = type; } public State getState() { @@ -52,6 +118,9 @@ public class InputEdge { } public void setState(State x) { + if (state == State.IMMUTABLE) { + throw new InternalError("Can't change immutable instances"); + } this.state = x; } @@ -59,6 +128,10 @@ public class InputEdge { return toIndex; } + public char getFromIndex() { + return fromIndex; + } + public String getName() { return "in" + toIndex; } @@ -71,22 +144,35 @@ public class InputEdge { return to; } + public String getLabel() { + return label; + } + + public String getType() { + return type; + } + @Override public boolean equals(Object o) { if (o == null || !(o instanceof InputEdge)) { return false; } InputEdge conn2 = (InputEdge) o; - return conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; + boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; + if (result && (state == State.IMMUTABLE || conn2.state == State.IMMUTABLE)) { + // Immutable instances must be exactly the same + return conn2.label == label && conn2.state == state; + } + return result; } @Override public String toString() { - return "Edge from " + from + " to " + to + "(" + (int) toIndex + ") "; + return "Edge from " + from + " to " + to + "(" + (int) fromIndex + ", " + (int) toIndex + ") "; } @Override public int hashCode() { - return (from << 20 | to << 8 | toIndex); + return (from << 20 | to << 8 | toIndex << 4 | fromIndex); } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java index 52e16e94568..46766c569c4 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,65 +23,141 @@ */ package com.sun.hotspot.igv.data; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.HashMap; -import java.util.List; -import java.util.Set; +import java.util.*; /** * * @author Thomas Wuerthinger */ -public class InputGraph extends Properties.Entity { +public class InputGraph extends Properties.Entity implements FolderElement { - private HashMap nodes; - private ArrayList edges; - private Group parent; - private HashMap blocks; - private HashMap nodeToBlock; - private boolean isDifferenceGraph; + private Map nodes; + private List edges; + private Folder parent; + private Group parentGroup; + private Map blocks; + private List blockEdges; + private Map nodeToBlock; - public InputGraph(Group parent) { - this(parent, null); + public InputGraph(String name) { + setName(name); + nodes = new LinkedHashMap<>(); + edges = new ArrayList<>(); + blocks = new LinkedHashMap<>(); + blockEdges = new ArrayList<>(); + nodeToBlock = new LinkedHashMap<>(); } - public InputGraph(Group parent, InputGraph last) { - this(parent, last, ""); + @Override + public void setParent(Folder parent) { + this.parent = parent; + if (parent instanceof Group) { + assert this.parentGroup == null; + this.parentGroup = (Group) parent; + } } - private void clearBlocks() { + public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) { + InputBlockEdge edge = new InputBlockEdge(left, right); + blockEdges.add(edge); + left.addSuccessor(right); + return edge; + } + + public List findRootNodes() { + List result = new ArrayList<>(); + Set nonRoot = new HashSet<>(); + for(InputEdge curEdges : getEdges()) { + nonRoot.add(curEdges.getTo()); + } + + for(InputNode node : getNodes()) { + if(!nonRoot.contains(node.getId())) { + result.add(node); + } + } + + return result; + } + + public Map> findAllOutgoingEdges() { + Map> result = new HashMap<>(getNodes().size()); + for(InputNode n : this.getNodes()) { + result.put(n, new ArrayList()); + } + + for(InputEdge e : this.edges) { + int from = e.getFrom(); + InputNode fromNode = this.getNode(from); + List fromList = result.get(fromNode); + assert fromList != null; + fromList.add(e); + } + + for(InputNode n : this.getNodes()) { + List list = result.get(n); + Collections.sort(list, InputEdge.OUTGOING_COMPARATOR); + } + + return result; + } + + public Map> findAllIngoingEdges() { + Map> result = new HashMap<>(getNodes().size()); + for(InputNode n : this.getNodes()) { + result.put(n, new ArrayList()); + } + + for(InputEdge e : this.edges) { + int to = e.getTo(); + InputNode toNode = this.getNode(to); + List toList = result.get(toNode); + assert toList != null; + toList.add(e); + } + + for(InputNode n : this.getNodes()) { + List list = result.get(n); + Collections.sort(list, InputEdge.INGOING_COMPARATOR); + } + + return result; + } + + public List findOutgoingEdges(InputNode n) { + List result = new ArrayList<>(); + + for(InputEdge e : this.edges) { + if(e.getFrom() == n.getId()) { + result.add(e); + } + } + + Collections.sort(result, InputEdge.OUTGOING_COMPARATOR); + + return result; + } + + public void clearBlocks() { blocks.clear(); nodeToBlock.clear(); } - public InputGraph(Group parent, InputGraph last, String name) { - this.parent = parent; - setName(name); - nodes = new HashMap(); - edges = new ArrayList(); - blocks = new HashMap(); - nodeToBlock = new HashMap(); - if (last != null) { + public void setEdge(int fromIndex, int toIndex, int from, int to) { + assert fromIndex == ((char)fromIndex) : "Downcast must be safe"; + assert toIndex == ((char)toIndex) : "Downcast must be safe"; - for (InputNode n : last.getNodes()) { - addNode(n); - } - - for (InputEdge c : last.getEdges()) { - addEdge(c); - } + InputEdge edge = new InputEdge((char)fromIndex, (char)toIndex, from, to); + if(!this.getEdges().contains(edge)) { + this.addEdge(edge); } } - public void schedule(Collection newBlocks) { - clearBlocks(); - InputBlock noBlock = new InputBlock(this, "no block"); - Set scheduledNodes = new HashSet(); + public void ensureNodesInBlocks() { + InputBlock noBlock = null; + Set scheduledNodes = new HashSet<>(); - for (InputBlock b : newBlocks) { + for (InputBlock b : getBlocks()) { for (InputNode n : b.getNodes()) { assert !scheduledNodes.contains(n); scheduledNodes.add(n); @@ -91,18 +167,11 @@ public class InputGraph extends Properties.Entity { for (InputNode n : this.getNodes()) { assert nodes.get(n.getId()) == n; if (!scheduledNodes.contains(n)) { + if (noBlock == null) { + noBlock = this.addBlock("(no block)"); + } noBlock.addNode(n.getId()); } - } - - if (noBlock.getNodes().size() != 0) { - newBlocks.add(noBlock); - } - for (InputBlock b : newBlocks) { - addBlock(b); - } - - for (InputNode n : this.getNodes()) { assert this.getBlock(n) != null; } } @@ -116,47 +185,28 @@ public class InputGraph extends Properties.Entity { } public InputBlock getBlock(InputNode node) { + assert nodes.containsKey(node.getId()); + assert nodes.get(node.getId()).equals(node); return getBlock(node.getId()); } public InputGraph getNext() { - List list = parent.getGraphs(); - if (!list.contains(this)) { - return null; - } - int index = list.indexOf(this); - if (index == list.size() - 1) { - return null; - } else { - return list.get(index + 1); - } + return parentGroup.getNext(this); } public InputGraph getPrev() { - List list = parent.getGraphs(); - if (!list.contains(this)) { - return null; - } - int index = list.indexOf(this); - if (index == 0) { - return null; - } else { - return list.get(index - 1); - } + return parentGroup.getPrev(this); } + private void setName(String name) { + this.getProperties().setProperty("name", name); + } + + @Override public String getName() { return getProperties().get("name"); } - public String getAbsoluteName() { - String result = getName(); - if (this.parent != null) { - result = parent.getName() + ": " + result; - } - return result; - } - public Collection getNodes() { return Collections.unmodifiableCollection(nodes.values()); } @@ -186,25 +236,22 @@ public class InputGraph extends Properties.Entity { } public void removeEdge(InputEdge c) { - assert edges.contains(c); - edges.remove(c); - assert !edges.contains(c); + boolean removed = edges.remove(c); + assert removed; } public void addEdge(InputEdge c) { - assert !edges.contains(c); edges.add(c); - assert edges.contains(c); } public Group getGroup() { - return parent; + return parentGroup; } @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Graph " + getName() + " " + getProperties().toString() + "\n"); + sb.append("Graph ").append(getName()).append(" ").append(getProperties().toString()).append("\n"); for (InputNode n : nodes.values()) { sb.append(n.toString()); sb.append("\n"); @@ -214,35 +261,31 @@ public class InputGraph extends Properties.Entity { sb.append(c.toString()); sb.append("\n"); } + + for (InputBlock b : getBlocks()) { + sb.append(b.toString()); + sb.append("\n"); + } + return sb.toString(); } - public void addBlock(InputBlock b) { + public InputBlock addBlock(String name) { + final InputBlock b = new InputBlock(this, name); blocks.put(b.getName(), b); - for (InputNode n : b.getNodes()) { - this.nodeToBlock.put(n.getId(), b); - } - } - - public void resolveBlockLinks() { - for (InputBlock b : blocks.values()) { - b.resolveBlockLinks(); - } - } - - public void setName(String s) { - getProperties().setProperty("name", s); + return b; } public InputBlock getBlock(String s) { return blocks.get(s); } - public boolean isDifferenceGraph() { - return this.isDifferenceGraph; + public Collection getBlockEdges() { + return Collections.unmodifiableList(blockEdges); } - public void setIsDifferenceGraph(boolean b) { - isDifferenceGraph = b; + @Override + public Folder getParent() { + return parent; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java index c9ba3db48c8..9f2cce8aadd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,11 @@ */ package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.Properties; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @@ -42,14 +43,37 @@ public class InputMethod extends Properties.Entity { private Group group; private List bytecodes; + @Override + public int hashCode() { + int result = name.hashCode(); + result = result * 31 + bci; + result = result * 31 + shortName.hashCode(); + result = result * 31 + inlined.hashCode(); + result = result * 31 + bytecodes.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (o == null || (!(o instanceof InputMethod))) { + return false; + } + + final InputMethod im = (InputMethod)o; + return name.equals(im.name) && bci == im.bci && shortName.equals(im.shortName) && + inlined.equals(im.inlined) && bytecodes.equals(im.bytecodes); + } + + + /** Creates a new instance of InputMethod */ public InputMethod(Group parent, String name, String shortName, int bci) { this.group = parent; this.name = name; this.bci = bci; this.shortName = shortName; - inlined = new ArrayList(); - bytecodes = new ArrayList(); + inlined = new ArrayList<>(); + bytecodes = new ArrayList<>(); } public List getBytecodes() { @@ -87,31 +111,42 @@ public class InputMethod extends Properties.Entity { } public void setBytecodes(String text) { - + Pattern instruction = Pattern.compile("\\s*(\\d+)\\s*:?\\s*(\\w+)\\s*(.*)(?://(.*))?"); String[] strings = text.split("\n"); - int oldNumber = -1; + int oldBci = -1; for (String s : strings) { - - if (s.length() > 0 && Character.isDigit(s.charAt(0))) { - s = s.trim(); - int spaceIndex = s.indexOf(' '); - String numberString = s.substring(0, spaceIndex); - String tmpName = s.substring(spaceIndex + 1, s.length()); - - int number = -1; - number = Integer.parseInt(numberString); - - // assert correct order of bytecodes - assert number > oldNumber; - - InputBytecode bc = new InputBytecode(number, tmpName); - bytecodes.add(bc); - - for (InputMethod m : inlined) { - if (m.getBci() == number) { - bc.setInlined(m); - break; + if (s.startsWith(" ")) { + // indented lines are extra textual information + continue; + } + s = s.trim(); + if (s.length() != 0) { + final Matcher matcher = instruction.matcher(s); + if (matcher.matches()) { + String bciString = matcher.group(1); + String opcode = matcher.group(2); + String operands = matcher.group(3).trim(); + String comment = matcher.group(4); + if (comment != null) { + comment = comment.trim(); } + + int bci = Integer.parseInt(bciString); + + // assert correct order of bytecodes + assert bci > oldBci; + + InputBytecode bc = new InputBytecode(bci, opcode, operands, comment); + bytecodes.add(bc); + + for (InputMethod m : inlined) { + if (m.getBci() == bci) { + bc.setInlined(m); + break; + } + } + } else { + System.out.println("no match: " + s); } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java index ee6641d717b..a4b2a97329a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,10 @@ */ package com.sun.hotspot.igv.data; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + /** * * @author Thomas Wuerthinger @@ -30,6 +34,37 @@ package com.sun.hotspot.igv.data; public class InputNode extends Properties.Entity { private int id; + private List subgraphs; + + public static final Comparator COMPARATOR = new Comparator() { + @Override + public int compare(InputNode o1, InputNode o2) { + return o1.getId() - o2.getId(); + } + }; + + public static Comparator getPropertyComparator(final String propertyName) { + return new Comparator() { + + @Override + public int compare(InputNode o1, InputNode o2) { + + int i1 = 0; + try { + i1 = Integer.parseInt(o1.getProperties().get(propertyName)); + } catch(NumberFormatException e) { + } + + int i2 = 0; + try { + i2 = Integer.parseInt(o2.getProperties().get(propertyName)); + } catch(NumberFormatException e) { + } + + return i1 - i2; + } + }; + } public InputNode(InputNode n) { super(n); @@ -49,21 +84,29 @@ public class InputNode extends Properties.Entity { return id; } + public void addSubgraph(InputGraph graph) { + if (subgraphs == null) { + subgraphs = new ArrayList<>(); + } + subgraphs.add(graph); + } + + public List getSubgraphs() { + return subgraphs; + } + @Override public boolean equals(Object o) { if (!(o instanceof InputNode)) { return false; } InputNode n = (InputNode) o; - if (n.id != id) { - return false; - } - return getProperties().equals(n.getProperties()); + return n.id == id; } @Override public int hashCode() { - return id; + return id * 13; } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java index dc261cb1829..8c15c6cf667 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,15 +58,30 @@ public class Pair { @Override public boolean equals(Object o) { - if (!(o instanceof Pair)) { + if (o == null || !(o instanceof Pair)) { return false; } - Pair obj = (Pair) o; - return l.equals(obj.l) && r.equals(obj.r); + Pair obj = (Pair) o; + boolean b1 = (l == obj.l); + if (l != null) { + b1 = l.equals(obj.l); + } + + boolean b2 = (r == obj.r); + if (r != null) { + b2 = r.equals(obj.r); + } + + return b1 && b2; } @Override public int hashCode() { - return l.hashCode() * 71 + r.hashCode(); + return ((l == null) ? 0 : l.hashCode()) * 71 + ((r == null) ? 0 : r.hashCode()); + } + + @Override + public String toString() { + return "[" + l + "/" + r + "]"; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java index 6d85712c840..2646231bfab 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,13 +24,10 @@ package com.sun.hotspot.igv.data; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; - +import java.util.regex.PatternSyntaxException; /** * @@ -58,13 +55,30 @@ public class Properties implements Serializable, Iterable { return false; } } + + for (Property prop : p) { + String value = this.get(prop.getName()); + if (value == null || !value.equals(prop.getValue())) { + return false; + } + } + return true; } @Override public int hashCode() { int hash = 5; - hash = 83 * hash + (this.map != null ? this.map.hashCode() : 0); + + if (map != null) { + for (int i = 0; i < this.map.length; i++) { + if (map[i] == null) { + i++; + } else { + hash = hash * 83 + map[i].hashCode(); + } + } + } return hash; } @@ -85,7 +99,7 @@ public class Properties implements Serializable, Iterable { public Properties(Properties p) { map = new String[p.map.length]; - System.arraycopy(map, 0, p.map, 0, p.map.length); + System.arraycopy(p.map, 0, map, 0, p.map.length); } public static class Entity implements Provider { @@ -100,19 +114,12 @@ public class Properties implements Serializable, Iterable { properties = new Properties(object.getProperties()); } + @Override public Properties getProperties() { return properties; } } - private String getProperty(String key) { - for (int i = 0; i < map.length; i += 2) - if (map[i] != null && map[i].equals(key)) { - return map[i + 1]; - } - return null; - } - public interface PropertyMatcher { String getName(); @@ -128,11 +135,16 @@ public class Properties implements Serializable, Iterable { this.matcher = matcher; } + @Override public String getName() { return matcher.getName(); } + @Override public boolean match(String p) { + if (p == null) { + return false; + } return !matcher.match(p); } } @@ -143,15 +155,26 @@ public class Properties implements Serializable, Iterable { private String value; public StringPropertyMatcher(String name, String value) { + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } + if (value == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } this.name = name; this.value = value; } + @Override public String getName() { return name; } + @Override public boolean match(String p) { + if (p == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } return p.equals(value); } } @@ -162,30 +185,55 @@ public class Properties implements Serializable, Iterable { private Pattern valuePattern; public RegexpPropertyMatcher(String name, String value) { - this.name = name; - valuePattern = Pattern.compile(value); + this(name, value, 0); } + public RegexpPropertyMatcher(String name, String value, int flags) { + + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } + + if (value == null) { + throw new IllegalArgumentException("Property value pattern must not be null!"); + } + + this.name = name; + + try { + valuePattern = Pattern.compile(value, flags); + } catch (PatternSyntaxException e) { + throw new IllegalArgumentException("Bad pattern: " + value); + } + } + + @Override public String getName() { return name; } + @Override public boolean match(String p) { + if (p == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } Matcher m = valuePattern.matcher(p); return m.matches(); } } public Property selectSingle(PropertyMatcher matcher) { + + final String name = matcher.getName(); String value = null; for (int i = 0; i < map.length; i += 2) { - if (map[i] != null && matcher.getName().equals(map[i])) { + if (map[i] != null && name.equals(map[i])) { value = map[i + 1]; break; } } if (value != null && matcher.match(value)) { - return new Property(matcher.getName(), value); + return new Property(name, value); } else { return null; } @@ -198,14 +246,33 @@ public class Properties implements Serializable, Iterable { @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("["); + List pairs = new ArrayList<>(); for (int i = 0; i < map.length; i += 2) { if (map[i + 1] != null) { - String p = map[i + 1]; - sb.append(map[i] + " = " + map[i + 1] + "; "); + pairs.add(new String[]{map[i], map[i + 1]}); } } + + Collections.sort(pairs, new Comparator() { + @Override + public int compare(String[] o1, String[] o2) { + assert o1.length == 2; + assert o2.length == 2; + return o1[0].compareTo(o2[0]); + } + }); + + StringBuilder sb = new StringBuilder(); + sb.append("["); + boolean first = true; + for (String[] p : pairs) { + if (first) { + first = false; + } else { + sb.append(", "); + } + sb.append(p[0]).append("=").append(p[1]); + } return sb.append("]").toString(); } @@ -217,10 +284,6 @@ public class Properties implements Serializable, Iterable { this.objects = objects; } - public T selectSingle(final String name, final String value) { - return selectSingle(new StringPropertyMatcher(name, value)); - } - public T selectSingle(PropertyMatcher matcher) { for (T t : objects) { @@ -233,18 +296,16 @@ public class Properties implements Serializable, Iterable { return null; } - public List selectMultiple(final String name, final String value) { - return selectMultiple(new StringPropertyMatcher(name, value)); - } - public List selectMultiple(PropertyMatcher matcher) { - List result = new ArrayList(); + List result = new ArrayList<>(); + for (T t : objects) { Property p = t.getProperties().selectSingle(matcher); if (p != null) { result.add(t); } } + return result; } } @@ -259,6 +320,10 @@ public class Properties implements Serializable, Iterable { } public void setProperty(String name, String value) { + setPropertyInternal(name.intern(), value != null ? value.intern() : null); + } + private void setPropertyInternal(String name, String value) { + for (int i = 0; i < map.length; i += 2) { if (map[i] != null && map[i].equals(name)) { String p = map[i + 1]; @@ -289,34 +354,26 @@ public class Properties implements Serializable, Iterable { map = newMap; } - public Iterator getProperties() { - return iterator(); - } - public void add(Properties properties) { for (Property p : properties) { - add(p); + // Already interned + setPropertyInternal(p.getName(), p.getValue()); } } - public void add(Property property) { - assert property.getName() != null; - assert property.getValue() != null; - setProperty(property.getName(), property.getValue()); - } - class PropertiesIterator implements Iterator, Iterable { - public Iterator iterator() { - return this; - } + private class PropertiesIterator implements Iterator { int index; + @Override public boolean hasNext() { - while (index < map.length && map[index + 1] == null) + while (index < map.length && map[index + 1] == null) { index += 2; + } return index < map.length; } + @Override public Property next() { if (index < map.length) { index += 2; @@ -325,11 +382,13 @@ public class Properties implements Serializable, Iterable { return null; } + @Override public void remove() { throw new UnsupportedOperationException("Not supported yet."); } - } + + @Override public Iterator iterator() { return new PropertiesIterator(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java index 5c1f2e99ab4..95ec2fe45c3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,25 +32,20 @@ import java.io.Serializable; public class Property implements Serializable { public static final long serialVersionUID = 1L; - private String name; private String value; - private Property() { - this(null, null); - } - - private Property(Property p) { - this(p.getName(), p.getValue()); - } - - private Property(String name) { - this(name, null); - } - - public Property(String name, String value) { + Property(String name, String value) { this.name = name; this.value = value; + + if (value == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } + + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } } public String getName() { @@ -63,17 +58,20 @@ public class Property implements Serializable { @Override public String toString() { - return name + " = " + value + "; "; + return name + "=" + value; } @Override public boolean equals(Object o) { - if (!(o instanceof Property)) return false; - Property p2 = (Property)o; + if (!(o instanceof Property)) { + return false; + } + Property p2 = (Property) o; return name.equals(p2.name) && value.equals(p2.value); } + @Override public int hashCode() { - return name.hashCode() + value == null ? 0 : value.hashCode(); + return name.hashCode() * 13 + value.hashCode(); } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Source.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java similarity index 56% rename from hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Source.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java index bcae73c530b..5a8e83eb973 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Source.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,16 +21,9 @@ * questions. * */ -package com.sun.hotspot.igv.graph; +package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * @@ -42,7 +35,8 @@ public class Source { private Set set; public Source() { - sourceNodes = new ArrayList(1); + sourceNodes = new ArrayList<>(1); + set = new LinkedHashSet<>(1); } public List getSourceNodes() { @@ -50,25 +44,14 @@ public class Source { } public Set getSourceNodesAsSet() { - if (set == null) { - set = new HashSet(); - for (InputNode n : sourceNodes) { - int id = n.getId(); - //if(id < 0) id = -id; - set.add(id); - } - } - return set; + return Collections.unmodifiableSet(set); } public void addSourceNode(InputNode n) { - sourceNodes.add(n); - set = null; - } - - public void removeSourceNode(InputNode n) { - sourceNodes.remove(n); - set = null; + if (!set.contains(n.getId())) { + sourceNodes.add(n); + set.add(n.getId()); + } } public interface Provider { @@ -76,25 +59,9 @@ public class Source { public Source getSource(); } - public void setSourceNodes(List sourceNodes) { - this.sourceNodes = sourceNodes; - set = null; - } - public void addSourceNodes(Source s) { for (InputNode n : s.getSourceNodes()) { - sourceNodes.add(n); + addSourceNode(n); } - set = null; - } - - public boolean isInBlock(InputGraph g, InputBlock blockNode) { - - for (InputNode n : this.getSourceNodes()) { - if (g.getBlock(n) == blockNode) { - return true; - } - } - return false; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java new file mode 100644 index 00000000000..5529701b979 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java @@ -0,0 +1,900 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.hotspot.igv.data.serialization; + +import com.sun.hotspot.igv.data.*; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.services.GroupCallback; +import java.io.EOFException; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.SwingUtilities; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class BinaryParser implements GraphParser { + private static final int BEGIN_GROUP = 0x00; + private static final int BEGIN_GRAPH = 0x01; + private static final int CLOSE_GROUP = 0x02; + + private static final int POOL_NEW = 0x00; + private static final int POOL_STRING = 0x01; + private static final int POOL_ENUM = 0x02; + private static final int POOL_CLASS = 0x03; + private static final int POOL_METHOD = 0x04; + private static final int POOL_NULL = 0x05; + private static final int POOL_NODE_CLASS = 0x06; + private static final int POOL_FIELD = 0x07; + private static final int POOL_SIGNATURE = 0x08; + + private static final int KLASS = 0x00; + private static final int ENUM_KLASS = 0x01; + + private static final int PROPERTY_POOL = 0x00; + private static final int PROPERTY_INT = 0x01; + private static final int PROPERTY_LONG = 0x02; + private static final int PROPERTY_DOUBLE = 0x03; + private static final int PROPERTY_FLOAT = 0x04; + private static final int PROPERTY_TRUE = 0x05; + private static final int PROPERTY_FALSE = 0x06; + private static final int PROPERTY_ARRAY = 0x07; + private static final int PROPERTY_SUBGRAPH = 0x08; + + private static final String NO_BLOCK = "noBlock"; + + private final GroupCallback callback; + private final List constantPool; + private final ByteBuffer buffer; + private final ReadableByteChannel channel; + private final GraphDocument rootDocument; + private final Deque folderStack; + private final Deque hashStack; + private final ParseMonitor monitor; + + private MessageDigest digest; + + private enum Length { + S, + M, + L + } + + private interface LengthToString { + String toString(Length l); + } + + private static abstract class Member implements LengthToString { + public final Klass holder; + public final int accessFlags; + public final String name; + public Member(Klass holder, String name, int accessFlags) { + this.holder = holder; + this.accessFlags = accessFlags; + this.name = name; + } + } + + private static class Method extends Member { + public final Signature signature; + public final byte[] code; + public Method(String name, Signature signature, byte[] code, Klass holder, int accessFlags) { + super(holder, name, accessFlags); + this.signature = signature; + this.code = code; + } + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(holder).append('.').append(name).append('('); + for (int i = 0; i < signature.argTypes.length; i++) { + if (i > 0) { + sb.append(", "); + } + sb.append(signature.argTypes[i]); + } + sb.append(')'); + return sb.toString(); + } + @Override + public String toString(Length l) { + switch(l) { + case M: + return holder.toString(Length.L) + "." + name; + case S: + return holder.toString(Length.S) + "." + name; + default: + case L: + return toString(); + } + } + } + + private static class Signature { + public final String returnType; + public final String[] argTypes; + public Signature(String returnType, String[] argTypes) { + this.returnType = returnType; + this.argTypes = argTypes; + } + } + + private static class Field extends Member { + public final String type; + public Field(String type, Klass holder, String name, int accessFlags) { + super(holder, name, accessFlags); + this.type = type; + } + @Override + public String toString() { + return holder + "." + name; + } + @Override + public String toString(Length l) { + switch(l) { + case M: + return holder.toString(Length.L) + "." + name; + case S: + return holder.toString(Length.S) + "." + name; + default: + case L: + return toString(); + } + } + } + + private static class Klass implements LengthToString { + public final String name; + public final String simpleName; + public Klass(String name) { + this.name = name; + String simple; + try { + simple = name.substring(name.lastIndexOf('.') + 1); + } catch (IndexOutOfBoundsException ioobe) { + simple = name; + } + this.simpleName = simple; + } + @Override + public String toString() { + return name; + } + @Override + public String toString(Length l) { + switch(l) { + case S: + return simpleName; + default: + case L: + case M: + return toString(); + } + } + } + + private static class EnumKlass extends Klass { + public final String[] values; + public EnumKlass(String name, String[] values) { + super(name); + this.values = values; + } + } + + private static class Port { + public final boolean isList; + public final String name; + private Port(boolean isList, String name) { + this.isList = isList; + this.name = name; + } + } + + private static class TypedPort extends Port { + public final EnumValue type; + private TypedPort(boolean isList, String name, EnumValue type) { + super(isList, name); + this.type = type; + } + } + + private static class NodeClass { + public final String className; + public final String nameTemplate; + public final List inputs; + public final List sux; + private NodeClass(String className, String nameTemplate, List inputs, List sux) { + this.className = className; + this.nameTemplate = nameTemplate; + this.inputs = inputs; + this.sux = sux; + } + @Override + public String toString() { + return className; + } + } + + private static class EnumValue implements LengthToString { + public EnumKlass enumKlass; + public int ordinal; + public EnumValue(EnumKlass enumKlass, int ordinal) { + this.enumKlass = enumKlass; + this.ordinal = ordinal; + } + @Override + public String toString() { + return enumKlass.simpleName + "." + enumKlass.values[ordinal]; + } + @Override + public String toString(Length l) { + switch(l) { + case S: + return enumKlass.values[ordinal]; + default: + case M: + case L: + return toString(); + } + } + } + + public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GraphDocument rootDocument, GroupCallback callback) { + this.callback = callback; + constantPool = new ArrayList<>(); + buffer = ByteBuffer.allocateDirect(256 * 1024); + buffer.flip(); + this.channel = channel; + this.rootDocument = rootDocument; + folderStack = new LinkedList<>(); + hashStack = new LinkedList<>(); + this.monitor = monitor; + try { + this.digest = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + } + } + + private void fill() throws IOException { + buffer.compact(); + if (channel.read(buffer) < 0) { + throw new EOFException(); + } + buffer.flip(); + } + + private void ensureAvailable(int i) throws IOException { + while (buffer.remaining() < i) { + fill(); + } + buffer.mark(); + byte[] result = new byte[i]; + buffer.get(result); + digest.update(result); + buffer.reset(); + } + + private int readByte() throws IOException { + ensureAvailable(1); + return ((int)buffer.get()) & 0xff; + } + + private int readInt() throws IOException { + ensureAvailable(4); + return buffer.getInt(); + } + + private char readShort() throws IOException { + ensureAvailable(2); + return buffer.getChar(); + } + + private long readLong() throws IOException { + ensureAvailable(8); + return buffer.getLong(); + } + + private double readDouble() throws IOException { + ensureAvailable(8); + return buffer.getDouble(); + } + + private float readFloat() throws IOException { + ensureAvailable(4); + return buffer.getFloat(); + } + + private String readString() throws IOException { + int len = readInt(); + ensureAvailable(len * 2); + char[] chars = new char[len]; + buffer.asCharBuffer().get(chars); + buffer.position(buffer.position() + len * 2); + return new String(chars).intern(); + } + + private byte[] readBytes() throws IOException { + int len = readInt(); + if (len < 0) { + return null; + } + ensureAvailable(len); + byte[] data = new byte[len]; + buffer.get(data); + return data; + } + + private String readIntsToString() throws IOException { + int len = readInt(); + if (len < 0) { + return "null"; + } + ensureAvailable(len * 4); + StringBuilder sb = new StringBuilder().append('['); + for (int i = 0; i < len; i++) { + sb.append(buffer.getInt()); + if (i < len - 1) { + sb.append(", "); + } + } + sb.append(']'); + return sb.toString().intern(); + } + + private String readDoublesToString() throws IOException { + int len = readInt(); + if (len < 0) { + return "null"; + } + ensureAvailable(len * 8); + StringBuilder sb = new StringBuilder().append('['); + for (int i = 0; i < len; i++) { + sb.append(buffer.getDouble()); + if (i < len - 1) { + sb.append(", "); + } + } + sb.append(']'); + return sb.toString().intern(); + } + + private String readPoolObjectsToString() throws IOException { + int len = readInt(); + if (len < 0) { + return "null"; + } + StringBuilder sb = new StringBuilder().append('['); + for (int i = 0; i < len; i++) { + sb.append(readPoolObject(Object.class)); + if (i < len - 1) { + sb.append(", "); + } + } + sb.append(']'); + return sb.toString().intern(); + } + + private T readPoolObject(Class klass) throws IOException { + int type = readByte(); + if (type == POOL_NULL) { + return null; + } + if (type == POOL_NEW) { + return (T) addPoolEntry(klass); + } + assert assertObjectType(klass, type); + char index = readShort(); + if (index < 0 || index >= constantPool.size()) { + throw new IOException("Invalid constant pool index : " + index); + } + Object obj = constantPool.get(index); + return (T) obj; + } + + private boolean assertObjectType(Class klass, int type) { + switch(type) { + case POOL_CLASS: + return klass.isAssignableFrom(EnumKlass.class); + case POOL_ENUM: + return klass.isAssignableFrom(EnumValue.class); + case POOL_METHOD: + return klass.isAssignableFrom(Method.class); + case POOL_STRING: + return klass.isAssignableFrom(String.class); + case POOL_NODE_CLASS: + return klass.isAssignableFrom(NodeClass.class); + case POOL_FIELD: + return klass.isAssignableFrom(Field.class); + case POOL_SIGNATURE: + return klass.isAssignableFrom(Signature.class); + case POOL_NULL: + return true; + default: + return false; + } + } + + private Object addPoolEntry(Class klass) throws IOException { + char index = readShort(); + int type = readByte(); + assert assertObjectType(klass, type) : "Wrong object type : " + klass + " != " + type; + Object obj; + switch(type) { + case POOL_CLASS: { + String name = readString(); + int klasstype = readByte(); + if (klasstype == ENUM_KLASS) { + int len = readInt(); + String[] values = new String[len]; + for (int i = 0; i < len; i++) { + values[i] = readPoolObject(String.class); + } + obj = new EnumKlass(name, values); + } else if (klasstype == KLASS) { + obj = new Klass(name); + } else { + throw new IOException("unknown klass type : " + klasstype); + } + break; + } + case POOL_ENUM: { + EnumKlass enumClass = readPoolObject(EnumKlass.class); + int ordinal = readInt(); + obj = new EnumValue(enumClass, ordinal); + break; + } + case POOL_NODE_CLASS: { + String className = readString(); + String nameTemplate = readString(); + int inputCount = readShort(); + List inputs = new ArrayList<>(inputCount); + for (int i = 0; i < inputCount; i++) { + boolean isList = readByte() != 0; + String name = readPoolObject(String.class); + EnumValue inputType = readPoolObject(EnumValue.class); + inputs.add(new TypedPort(isList, name, inputType)); + } + int suxCount = readShort(); + List sux = new ArrayList<>(suxCount); + for (int i = 0; i < suxCount; i++) { + boolean isList = readByte() != 0; + String name = readPoolObject(String.class); + sux.add(new Port(isList, name)); + } + obj = new NodeClass(className, nameTemplate, inputs, sux); + break; + } + case POOL_METHOD: { + Klass holder = readPoolObject(Klass.class); + String name = readPoolObject(String.class); + Signature sign = readPoolObject(Signature.class); + int flags = readInt(); + byte[] code = readBytes(); + obj = new Method(name, sign, code, holder, flags); + break; + } + case POOL_FIELD: { + Klass holder = readPoolObject(Klass.class); + String name = readPoolObject(String.class); + String fType = readPoolObject(String.class); + int flags = readInt(); + obj = new Field(fType, holder, name, flags); + break; + } + case POOL_SIGNATURE: { + int argc = readShort(); + String[] args = new String[argc]; + for (int i = 0; i < argc; i++) { + args[i] = readPoolObject(String.class); + } + String returnType = readPoolObject(String.class); + obj = new Signature(returnType, args); + break; + } + case POOL_STRING: { + obj = readString(); + break; + } + default: + throw new IOException("unknown pool type"); + } + while (constantPool.size() <= index) { + constantPool.add(null); + } + constantPool.set(index, obj); + return obj; + } + + private Object readPropertyObject() throws IOException { + int type = readByte(); + switch (type) { + case PROPERTY_INT: + return readInt(); + case PROPERTY_LONG: + return readLong(); + case PROPERTY_FLOAT: + return readFloat(); + case PROPERTY_DOUBLE: + return readDouble(); + case PROPERTY_TRUE: + return Boolean.TRUE; + case PROPERTY_FALSE: + return Boolean.FALSE; + case PROPERTY_POOL: + return readPoolObject(Object.class); + case PROPERTY_ARRAY: + int subType = readByte(); + switch(subType) { + case PROPERTY_INT: + return readIntsToString(); + case PROPERTY_DOUBLE: + return readDoublesToString(); + case PROPERTY_POOL: + return readPoolObjectsToString(); + default: + throw new IOException("Unknown type"); + } + case PROPERTY_SUBGRAPH: + InputGraph graph = parseGraph(""); + new Group(null).addElement(graph); + return graph; + default: + throw new IOException("Unknown type"); + } + } + + @Override + public GraphDocument parse() throws IOException { + folderStack.push(rootDocument); + hashStack.push(null); + if (monitor != null) { + monitor.setState("Starting parsing"); + } + try { + while(true) { + parseRoot(); + } + } catch (EOFException e) { + + } + if (monitor != null) { + monitor.setState("Finished parsing"); + } + return rootDocument; + } + + private void parseRoot() throws IOException { + int type = readByte(); + switch(type) { + case BEGIN_GRAPH: { + final Folder parent = folderStack.peek(); + final InputGraph graph = parseGraph(); + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + parent.addElement(graph); + } + }); + break; + } + case BEGIN_GROUP: { + final Folder parent = folderStack.peek(); + final Group group = parseGroup(parent); + if (callback == null || parent instanceof Group) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + parent.addElement(group); + } + }); + } + folderStack.push(group); + hashStack.push(null); + if (callback != null && parent instanceof GraphDocument) { + callback.started(group); + } + break; + } + case CLOSE_GROUP: { + if (folderStack.isEmpty()) { + throw new IOException("Unbalanced groups"); + } + folderStack.pop(); + hashStack.pop(); + break; + } + default: + throw new IOException("unknown root : " + type); + } + } + + private Group parseGroup(Folder parent) throws IOException { + String name = readPoolObject(String.class); + String shortName = readPoolObject(String.class); + if (monitor != null) { + monitor.setState(shortName); + } + Method method = readPoolObject(Method.class); + int bci = readInt(); + Group group = new Group(parent); + group.getProperties().setProperty("name", name); + if (method != null) { + InputMethod inMethod = new InputMethod(group, method.name, shortName, bci); + inMethod.setBytecodes("TODO"); + group.setMethod(inMethod); + } + return group; + } + + private InputGraph parseGraph() throws IOException { + if (monitor != null) { + monitor.updateProgress(); + } + String title = readPoolObject(String.class); + digest.reset(); + InputGraph graph = parseGraph(title); + byte[] d = digest.digest(); + byte[] hash = hashStack.peek(); + if (hash != null && Arrays.equals(hash, d)) { + graph.getProperties().setProperty("_isDuplicate", "true"); + } else { + hashStack.pop(); + hashStack.push(d); + } + return graph; + } + + private InputGraph parseGraph(String title) throws IOException { + InputGraph graph = new InputGraph(title); + parseNodes(graph); + parseBlocks(graph); + graph.ensureNodesInBlocks(); + return graph; + } + + private void parseBlocks(InputGraph graph) throws IOException { + int blockCount = readInt(); + List edges = new LinkedList<>(); + for (int i = 0; i < blockCount; i++) { + int id = readInt(); + String name = id >= 0 ? Integer.toString(id) : NO_BLOCK; + InputBlock block = graph.addBlock(name); + int nodeCount = readInt(); + for (int j = 0; j < nodeCount; j++) { + int nodeId = readInt(); + if (nodeId < 0) { + continue; + } + final Properties properties = graph.getNode(nodeId).getProperties(); + final String oldBlock = properties.get("block"); + if(oldBlock != null) { + properties.setProperty("block", oldBlock + ", " + name); + } else { + block.addNode(nodeId); + properties.setProperty("block", name); + } + } + int edgeCount = readInt(); + for (int j = 0; j < edgeCount; j++) { + int to = readInt(); + edges.add(new Edge(id, to)); + } + } + for (Edge e : edges) { + String fromName = e.from >= 0 ? Integer.toString(e.from) : NO_BLOCK; + String toName = e.to >= 0 ? Integer.toString(e.to) : NO_BLOCK; + graph.addBlockEdge(graph.getBlock(fromName), graph.getBlock(toName)); + } + } + + private void parseNodes(InputGraph graph) throws IOException { + int count = readInt(); + Map props = new HashMap<>(); + List inputEdges = new ArrayList<>(count); + List succEdges = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + int id = readInt(); + InputNode node = new InputNode(id); + final Properties properties = node.getProperties(); + NodeClass nodeClass = readPoolObject(NodeClass.class); + int preds = readByte(); + if (preds > 0) { + properties.setProperty("hasPredecessor", "true"); + } + properties.setProperty("idx", Integer.toString(id)); + int propCount = readShort(); + for (int j = 0; j < propCount; j++) { + String key = readPoolObject(String.class); + if (key.equals("hasPredecessor") || key.equals("name") || key.equals("class") || key.equals("id") || key.equals("idx")) { + key = "!data." + key; + } + Object value = readPropertyObject(); + if (value instanceof InputGraph) { + InputGraph subgraph = (InputGraph) value; + subgraph.getProperties().setProperty("name", node.getId() + ":" + key); + node.addSubgraph((InputGraph) value); + } else { + properties.setProperty(key, value != null ? value.toString() : "null"); + props.put(key, value); + } + } + ArrayList currentEdges = new ArrayList<>(); + int portNum = 0; + for (TypedPort p : nodeClass.inputs) { + if (p.isList) { + int size = readShort(); + for (int j = 0; j < size; j++) { + int in = readInt(); + if (in >= 0) { + Edge e = new Edge(in, id, (char) (preds + portNum), p.name + "[" + j + "]", p.type.toString(Length.S), true); + currentEdges.add(e); + inputEdges.add(e); + portNum++; + } + } + } else { + int in = readInt(); + if (in >= 0) { + Edge e = new Edge(in, id, (char) (preds + portNum), p.name, p.type.toString(Length.S), true); + currentEdges.add(e); + inputEdges.add(e); + portNum++; + } + } + + } + portNum = 0; + for (Port p : nodeClass.sux) { + if (p.isList) { + int size = readShort(); + for (int j = 0; j < size; j++) { + int sux = readInt(); + if (sux >= 0) { + Edge e = new Edge(id, sux, (char) portNum, p.name + "[" + j + "]", "Successor", false); + currentEdges.add(e); + succEdges.add(e); + portNum++; + } + } + } else { + int sux = readInt(); + if (sux >= 0) { + Edge e = new Edge(id, sux, (char) portNum, p.name, "Successor", false); + currentEdges.add(e); + succEdges.add(e); + portNum++; + } + } + } + properties.setProperty("name", createName(currentEdges, props, nodeClass.nameTemplate)); + properties.setProperty("class", nodeClass.className); + switch (nodeClass.className) { + case "BeginNode": + properties.setProperty("shortName", "B"); + break; + case "EndNode": + properties.setProperty("shortName", "E"); + break; + } + graph.addNode(node); + props.clear(); + } + + Set nodesWithSuccessor = new HashSet<>(); + + for (Edge e : succEdges) { + assert !e.input; + char fromIndex = e.num; + nodesWithSuccessor.add(graph.getNode(e.from)); + char toIndex = 0; + graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + } + for (Edge e : inputEdges) { + assert e.input; + char fromIndex = (char) (nodesWithSuccessor.contains(graph.getNode(e.from)) ? 1 : 0); + char toIndex = e.num; + graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label, e.type)); + } + } + + private String createName(List edges, Map properties, String template) { + Pattern p = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}"); + Matcher m = p.matcher(template); + StringBuffer sb = new StringBuffer(); + while (m.find()) { + String name = m.group(2); + String type = m.group(1); + String result; + switch (type) { + case "i": + StringBuilder inputString = new StringBuilder(); + for(Edge edge : edges) { + if (edge.label.startsWith(name) && (name.length() == edge.label.length() || edge.label.charAt(name.length()) == '[')) { + if (inputString.length() > 0) { + inputString.append(", "); + } + inputString.append(edge.from); + } + } + result = inputString.toString(); + break; + case "p": + Object prop = properties.get(name); + String length = m.group(4); + if (prop == null) { + result = "?"; + } else if (length != null && prop instanceof LengthToString) { + LengthToString lengthProp = (LengthToString) prop; + switch(length) { + default: + case "l": + result = lengthProp.toString(Length.L); + break; + case "m": + result = lengthProp.toString(Length.M); + break; + case "s": + result = lengthProp.toString(Length.S); + break; + } + } else { + result = prop.toString(); + } + break; + default: + result = "#?#"; + break; + } + result = result.replace("\\", "\\\\"); + result = result.replace("$", "\\$"); + m.appendReplacement(sb, result); + } + m.appendTail(sb); + return sb.toString().intern(); + } + + private static class Edge { + final int from; + final int to; + final char num; + final String label; + final String type; + final boolean input; + public Edge(int from, int to) { + this(from, to, (char) 0, null, null, false); + } + public Edge(int from, int to, char num, String label, String type, boolean input) { + this.from = from; + this.to = to; + this.label = label != null ? label.intern() : label; + this.type = type != null ? type.intern() : type; + this.num = num; + this.input = input; + } + } +} diff --git a/jdk/src/jdk.dev/share/classes/com/sun/tools/hat/internal/oql/ObjectVisitor.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/GraphParser.java similarity index 69% rename from jdk/src/jdk.dev/share/classes/com/sun/tools/hat/internal/oql/ObjectVisitor.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/GraphParser.java index c3b4d341067..a517ce8e9bd 100644 --- a/jdk/src/jdk.dev/share/classes/com/sun/tools/hat/internal/oql/ObjectVisitor.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/GraphParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,22 +22,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ +package com.sun.hotspot.igv.data.serialization; +import com.sun.hotspot.igv.data.GraphDocument; +import java.io.IOException; -/* - * The Original Code is HAT. The Initial Developer of the - * Original Code is Bill Foote, with contributions from others - * at JavaSoft/Sun. - */ - -package com.sun.tools.hat.internal.oql; - -/** - * This visitor is supplied to OQLEngine.executeQuery - * to receive result set objects one by one. - * - */ -public interface ObjectVisitor { - // return true to terminate the result set callback earlier - public boolean visit(Object o); +public interface GraphParser { + public GraphDocument parse() throws IOException; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/ParseMonitor.java similarity index 77% rename from hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/ParseMonitor.java index c31add80705..ebf86ffbc9e 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ScriptEngineAbstraction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/ParseMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,17 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.sun.hotspot.igv.filter; +package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.graph.Diagram; +public interface ParseMonitor { -/** - * - * @author Thomas Wuerthinger - */ -public interface ScriptEngineAbstraction { + public void updateProgress(); - public boolean initialize(String jsHelperText); + public void setState(String state); - public void execute(Diagram d, String code); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java index 5ec3e0f2891..afd470ae078 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,31 +23,34 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Property; -import com.sun.hotspot.igv.data.services.GroupCallback; +import com.sun.hotspot.igv.data.*; import com.sun.hotspot.igv.data.serialization.XMLParser.ElementHandler; import com.sun.hotspot.igv.data.serialization.XMLParser.HandoverElementHandler; -import com.sun.hotspot.igv.data.serialization.XMLParser.ParseMonitor; import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler; +import com.sun.hotspot.igv.data.services.GroupCallback; import java.io.IOException; +import java.io.InputStream; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; +import javax.swing.SwingUtilities; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.SchemaFactory; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; /** * * @author Thomas Wuerthinger */ -public class Parser { +public class Parser implements GraphParser { public static final String INDENT = " "; public static final String TOP_ELEMENT = "graphDocument"; @@ -63,6 +66,7 @@ public class Parser { public static final String REMOVE_EDGE_ELEMENT = "removeEdge"; public static final String REMOVE_NODE_ELEMENT = "removeNode"; public static final String METHOD_NAME_PROPERTY = "name"; + public static final String GROUP_NAME_PROPERTY = "name"; public static final String METHOD_IS_PUBLIC_PROPERTY = "public"; public static final String METHOD_IS_STATIC_PROPERTY = "static"; public static final String TRUE_VALUE = "true"; @@ -71,9 +75,13 @@ public class Parser { public static final String NODE_ID_PROPERTY = "id"; public static final String FROM_PROPERTY = "from"; public static final String TO_PROPERTY = "to"; + public static final String TYPE_PROPERTY = "type"; public static final String PROPERTY_NAME_PROPERTY = "name"; public static final String GRAPH_NAME_PROPERTY = "name"; - public static final String TO_INDEX_PROPERTY = "index"; + public static final String FROM_INDEX_PROPERTY = "fromIndex"; + public static final String TO_INDEX_PROPERTY = "toIndex"; + public static final String TO_INDEX_ALT_PROPERTY = "index"; + public static final String LABEL_PROPERTY = "label"; public static final String METHOD_ELEMENT = "method"; public static final String INLINE_ELEMENT = "inline"; public static final String BYTECODES_ELEMENT = "bytecodes"; @@ -86,13 +94,23 @@ public class Parser { public static final String SUCCESSOR_ELEMENT = "successor"; public static final String ASSEMBLY_ELEMENT = "assembly"; public static final String DIFFERENCE_PROPERTY = "difference"; - private TopElementHandler xmlDocument = new TopElementHandler(); - private boolean difference; + private TopElementHandler xmlDocument = new TopElementHandler<>(); + private Map differenceEncoding = new HashMap<>(); + private Map lastParsedGraph = new HashMap<>(); private GroupCallback groupCallback; - private HashMap idCache = new HashMap(); + private HashMap idCache = new HashMap<>(); + private ArrayList> blockConnections = new ArrayList<>(); private int maxId = 0; + private GraphDocument graphDocument; + private final ParseMonitor monitor; + private final ReadableByteChannel channel; private int lookupID(String i) { + try { + return Integer.parseInt(i); + } catch (NumberFormatException nfe) { + // ignore + } Integer id = idCache.get(i); if (id == null) { id = maxId++; @@ -106,41 +124,40 @@ public class Parser { @Override protected GraphDocument start() throws SAXException { - return new GraphDocument(); + graphDocument = new GraphDocument(); + return graphDocument; } }; // - private ElementHandler groupHandler = new XMLParser.ElementHandler(GROUP_ELEMENT) { + private ElementHandler groupHandler = new XMLParser.ElementHandler(GROUP_ELEMENT) { @Override protected Group start() throws SAXException { - Group group = new Group(); - Parser.this.difference = false; + final Group group = new Group(this.getParentObject()); + String differenceProperty = this.readAttribute(DIFFERENCE_PROPERTY); - if (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true"))) { - Parser.this.difference = true; - } + Parser.this.differenceEncoding.put(group, (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true")))); ParseMonitor monitor = getMonitor(); if (monitor != null) { monitor.setState(group.getName()); } + final Folder parent = getParentObject(); + if (groupCallback == null || parent instanceof Group) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + parent.addElement(group); + } + }); + } + return group; } @Override protected void end(String text) throws SAXException { - if (groupCallback == null) { - getParentObject().addGroup(getObject()); - } - } - }; - private HandoverElementHandler assemblyHandler = new XMLParser.HandoverElementHandler(ASSEMBLY_ELEMENT, true) { - - @Override - protected void end(String text) throws SAXException { - getParentObject().setAssembly(text); } }; // @@ -155,7 +172,7 @@ public class Parser { } }; - private InputMethod parseMethod(XMLParser.ElementHandler handler, Group group) throws SAXException { + private InputMethod parseMethod(XMLParser.ElementHandler handler, Group group) throws SAXException { String s = handler.readRequiredAttribute(METHOD_BCI_PROPERTY); int bci = 0; try { @@ -175,7 +192,7 @@ public class Parser { } }; // - private HandoverElementHandler inlinedHandler = new XMLParser.HandoverElementHandler(INLINE_ELEMENT); + private HandoverElementHandler inlinedHandler = new XMLParser.HandoverElementHandler<>(INLINE_ELEMENT); // private ElementHandler inlinedMethodHandler = new XMLParser.ElementHandler(METHOD_ELEMENT) { @@ -189,45 +206,110 @@ public class Parser { // private ElementHandler graphHandler = new XMLParser.ElementHandler(GRAPH_ELEMENT) { - private InputGraph graph; - @Override protected InputGraph start() throws SAXException { - String name = readAttribute(GRAPH_NAME_PROPERTY); - InputGraph previous = getParentObject().getLastAdded(); - if (!difference) { - previous = null; + InputGraph curGraph = new InputGraph(name); + if (differenceEncoding.get(getParentObject())) { + InputGraph previous = lastParsedGraph.get(getParentObject()); + lastParsedGraph.put(getParentObject(), curGraph); + if (previous != null) { + for (InputNode n : previous.getNodes()) { + curGraph.addNode(n); + } + for (InputEdge e : previous.getEdges()) { + curGraph.addEdge(e); + } + } + } + ParseMonitor monitor = getMonitor(); + if (monitor != null) { + monitor.updateProgress(); } - InputGraph curGraph = new InputGraph(getParentObject(), previous, name); - this.graph = curGraph; return curGraph; } @Override protected void end(String text) throws SAXException { - getParentObject().addGraph(graph); - graph.resolveBlockLinks(); + // NOTE: Some graphs intentionally don't provide blocks. Instead + // they later generate the blocks from other information such + // as node properties (example: ServerCompilerScheduler). + // Thus, we shouldn't assign nodes that don't belong to any + // block to some artificial block below unless blocks are + // defined and nodes are assigned to them. + + final InputGraph graph = getObject(); + final Group parent = getParentObject(); + if (graph.getBlocks().size() > 0) { + boolean blocksContainNodes = false; + for (InputBlock b : graph.getBlocks()) { + if (b.getNodes().size() > 0) { + blocksContainNodes = true; + break; + } + } + + if (!blocksContainNodes) { + graph.clearBlocks(); + blockConnections.clear(); + } else { + // Blocks and their nodes defined: add other nodes to an + // artificial "no block" block + InputBlock noBlock = null; + for (InputNode n : graph.getNodes()) { + if (graph.getBlock(n) == null) { + if (noBlock == null) { + noBlock = graph.addBlock("(no block)"); + } + + noBlock.addNode(n.getId()); + } + + assert graph.getBlock(n) != null; + } + } + } + + // Resolve block successors + for (Pair p : blockConnections) { + final InputBlock left = graph.getBlock(p.getLeft()); + assert left != null; + final InputBlock right = graph.getBlock(p.getRight()); + assert right != null; + graph.addBlockEdge(left, right); + } + blockConnections.clear(); + + SwingUtilities.invokeLater(new Runnable(){ + + @Override + public void run() { + // Add to group + parent.addElement(graph); + } + }); } }; // - private HandoverElementHandler nodesHandler = new HandoverElementHandler(NODES_ELEMENT); + private HandoverElementHandler nodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // - private HandoverElementHandler controlFlowHandler = new HandoverElementHandler(CONTROL_FLOW_ELEMENT); + private HandoverElementHandler controlFlowHandler = new HandoverElementHandler<>(CONTROL_FLOW_ELEMENT); // private ElementHandler blockHandler = new ElementHandler(BLOCK_ELEMENT) { @Override protected InputBlock start() throws SAXException { InputGraph graph = getParentObject(); - String name = readRequiredAttribute(BLOCK_NAME_PROPERTY).intern(); - InputBlock b = new InputBlock(getParentObject(), name); - graph.addBlock(b); + String name = readRequiredAttribute(BLOCK_NAME_PROPERTY); + InputBlock b = graph.addBlock(name); + for (InputNode n : b.getNodes()) { + assert graph.getBlock(n).equals(b); + } return b; } }; // - private HandoverElementHandler blockNodesHandler = new HandoverElementHandler(NODES_ELEMENT); + private HandoverElementHandler blockNodesHandler = new HandoverElementHandler<>(NODES_ELEMENT); // private ElementHandler blockNodeHandler = new ElementHandler(NODE_ELEMENT) { @@ -246,14 +328,14 @@ public class Parser { } }; // - private HandoverElementHandler successorsHandler = new HandoverElementHandler(SUCCESSORS_ELEMENT); + private HandoverElementHandler successorsHandler = new HandoverElementHandler<>(SUCCESSORS_ELEMENT); // private ElementHandler successorHandler = new ElementHandler(SUCCESSOR_ELEMENT) { @Override protected InputBlock start() throws SAXException { String name = readRequiredAttribute(BLOCK_NAME_PROPERTY); - getParentObject().addSuccessor(name); + blockConnections.add(new Pair<>(getParentObject().getName(), name)); return getParentObject(); } }; @@ -290,7 +372,7 @@ public class Parser { } }; // - private HandoverElementHandler edgesHandler = new HandoverElementHandler(EDGES_ELEMENT); + private HandoverElementHandler edgesHandler = new HandoverElementHandler<>(EDGES_ELEMENT); // Local class for edge elements private class EdgeElementHandler extends ElementHandler { @@ -301,24 +383,37 @@ public class Parser { @Override protected InputEdge start() throws SAXException { + int fromIndex = 0; int toIndex = 0; int from = -1; int to = -1; + String label = null; + String type = null; try { + String fromIndexString = readAttribute(FROM_INDEX_PROPERTY); + if (fromIndexString != null) { + fromIndex = Integer.parseInt(fromIndexString); + } + String toIndexString = readAttribute(TO_INDEX_PROPERTY); + if (toIndexString == null) { + toIndexString = readAttribute(TO_INDEX_ALT_PROPERTY); + } if (toIndexString != null) { toIndex = Integer.parseInt(toIndexString); } + label = readAttribute(LABEL_PROPERTY); + type = readAttribute(TYPE_PROPERTY); + from = lookupID(readRequiredAttribute(FROM_PROPERTY)); to = lookupID(readRequiredAttribute(TO_PROPERTY)); } catch (NumberFormatException e) { throw new SAXException(e); } - - InputEdge conn = new InputEdge((char) toIndex, from, to); + InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to, label, type == null ? "" : type); return start(conn); } @@ -345,14 +440,20 @@ public class Parser { } }; // - private HandoverElementHandler propertiesHandler = new HandoverElementHandler(PROPERTIES_ELEMENT); + private HandoverElementHandler propertiesHandler = new HandoverElementHandler<>(PROPERTIES_ELEMENT); // private HandoverElementHandler groupPropertiesHandler = new HandoverElementHandler(PROPERTIES_ELEMENT) { @Override public void end(String text) throws SAXException { - if (groupCallback != null) { - groupCallback.started(getParentObject()); + if (groupCallback != null && getParentObject().getParent() instanceof GraphDocument) { + final Group group = getParentObject(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + groupCallback.started(group); + } + }); } } }; @@ -361,30 +462,32 @@ public class Parser { @Override public String start() throws SAXException { - return readRequiredAttribute(PROPERTY_NAME_PROPERTY).intern(); - } + return readRequiredAttribute(PROPERTY_NAME_PROPERTY); + } @Override public void end(String text) { - getParentObject().getProperties().setProperty(getObject(), text.trim().intern()); + getParentObject().getProperties().setProperty(getObject(), text.trim()); } }; - public Parser() { - this(null); + public Parser(ReadableByteChannel channel) { + this(channel, null, null); } - public Parser(GroupCallback groupCallback) { + public Parser(ReadableByteChannel channel, ParseMonitor monitor, GroupCallback groupCallback) { this.groupCallback = groupCallback; + this.monitor = monitor; + this.channel = channel; // Initialize dependencies xmlDocument.addChild(topHandler); topHandler.addChild(groupHandler); groupHandler.addChild(methodHandler); - groupHandler.addChild(assemblyHandler); groupHandler.addChild(graphHandler); + groupHandler.addChild(groupHandler); methodHandler.addChild(inlinedHandler); methodHandler.addChild(bytecodesHandler); @@ -420,14 +523,40 @@ public class Parser { } // Returns a new GraphDocument object deserialized from an XML input source. - public GraphDocument parse(XMLReader reader, InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { - reader.setContentHandler(new XMLParser(xmlDocument, monitor)); + @Override + public GraphDocument parse() throws IOException { + if (monitor != null) { + monitor.setState("Starting parsing"); + } try { - reader.parse(source); - } catch (IOException ex) { + XMLReader reader = createReader(); + reader.setContentHandler(new XMLParser(xmlDocument, monitor)); + reader.parse(new InputSource(Channels.newInputStream(channel))); + } catch (SAXException ex) { + if (!(ex instanceof SAXParseException) || !"XML document structures must start and end within the same entity.".equals(ex.getMessage())) { + throw new IOException(ex); + } + } + if (monitor != null) { + monitor.setState("Finished parsing"); + } + return graphDocument; + } + + private XMLReader createReader() throws SAXException { + try { + SAXParserFactory pfactory = SAXParserFactory.newInstance(); + pfactory.setValidating(true); + pfactory.setNamespaceAware(true); + + // Enable schema validation + SchemaFactory sfactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + InputStream stream = Parser.class.getResourceAsStream("graphdocument.xsd"); + pfactory.setSchema(sfactory.newSchema(new Source[]{new StreamSource(stream)})); + + return pfactory.newSAXParser().getXMLReader(); + } catch (ParserConfigurationException ex) { throw new SAXException(ex); } - - return topHandler.getObject(); } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java index 14d17d66a52..8cf190869df 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,9 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputBytecode; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Property; +import com.sun.hotspot.igv.data.*; import java.io.IOException; +import java.io.InputStream; import java.io.Writer; import java.util.HashSet; import java.util.Set; @@ -44,6 +36,16 @@ import java.util.Set; */ public class Printer { + private InputStream in; + + public Printer() { + this(null); + } + + public Printer(InputStream inputStream) { + this.in = inputStream; + } + public void export(Writer writer, GraphDocument document) { XMLWriter xmlWriter = new XMLWriter(writer); @@ -57,8 +59,12 @@ public class Printer { private void export(XMLWriter xmlWriter, GraphDocument document) throws IOException { xmlWriter.startTag(Parser.ROOT_ELEMENT); xmlWriter.writeProperties(document.getProperties()); - for (Group g : document.getGroups()) { - export(xmlWriter, g); + for (FolderElement e : document.getElements()) { + if (e instanceof Group) { + export(xmlWriter, (Group) e); + } else if (e instanceof InputGraph) { + export(xmlWriter, (InputGraph)e, null, false); + } } xmlWriter.endTag(); @@ -71,14 +77,29 @@ public class Printer { writer.startTag(Parser.GROUP_ELEMENT, attributes); writer.writeProperties(g.getProperties()); - if (g.getMethod() != null) { - export(writer, g.getMethod()); + boolean shouldExport = true; + if (in != null) { + char c = (char) in.read(); + if (c != 'y') { + shouldExport = false; + } } - InputGraph previous = null; - for (InputGraph graph : g.getGraphs()) { - export(writer, graph, previous, true); - previous = graph; + if (shouldExport) { + if (g.getMethod() != null) { + export(writer, g.getMethod()); + } + + InputGraph previous = null; + for (FolderElement e : g.getElements()) { + if (e instanceof InputGraph) { + InputGraph graph = (InputGraph) e; + export(writer, graph, previous, true); + previous = graph; + } else if (e instanceof Group) { + export(writer, (Group) e); + } + } } writer.endTag(); @@ -90,8 +111,8 @@ public class Printer { writer.writeProperties(graph.getProperties()); writer.startTag(Parser.NODES_ELEMENT); - Set removed = new HashSet(); - Set equal = new HashSet(); + Set removed = new HashSet<>(); + Set equal = new HashSet<>(); if (previous != null) { for (InputNode n : previous.getNodes()) { @@ -122,8 +143,8 @@ public class Printer { writer.endTag(); writer.startTag(Parser.EDGES_ELEMENT); - Set removedEdges = new HashSet(); - Set equalEdges = new HashSet(); + Set removedEdges = new HashSet<>(); + Set equalEdges = new HashSet<>(); if (previous != null) { for (InputEdge e : previous.getEdges()) { @@ -153,23 +174,25 @@ public class Printer { writer.startTag(Parser.CONTROL_FLOW_ELEMENT); for (InputBlock b : graph.getBlocks()) { - writer.startTag(Parser.BLOCK_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, b.getName())); - writer.startTag(Parser.SUCCESSORS_ELEMENT); - for (InputBlock s : b.getSuccessors()) { - writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName())); + if (b.getSuccessors().size() > 0) { + writer.startTag(Parser.SUCCESSORS_ELEMENT); + for (InputBlock s : b.getSuccessors()) { + writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName())); + } + writer.endTag(); } - writer.endTag(); + if (b.getNodes().size() > 0) { writer.startTag(Parser.NODES_ELEMENT); - for (InputNode n : b.getNodes()) { - writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + "")); + for (InputNode n : b.getNodes()) { + writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + "")); + } + writer.endTag(); } - writer.endTag(); writer.endTag(); - } writer.endTag(); @@ -199,8 +222,8 @@ public class Printer { b.append(" "); b.append(code.getName()); b.append("\n"); - } + b.append("]]>"); w.write(b.toString()); w.endTag(); @@ -209,9 +232,15 @@ public class Printer { private Properties createProperties(InputEdge edge) { Properties p = new Properties(); - p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex())); + if (edge.getToIndex() != 0) { + p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex())); + } + if (edge.getFromIndex() != 0) { + p.setProperty(Parser.FROM_INDEX_PROPERTY, Integer.toString(edge.getFromIndex())); + } p.setProperty(Parser.TO_PROPERTY, Integer.toString(edge.getTo())); p.setProperty(Parser.FROM_PROPERTY, Integer.toString(edge.getFrom())); + p.setProperty(Parser.TYPE_PROPERTY, edge.getType()); return p; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java index cc2743844bc..c65d34f7516 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.Property; import com.sun.hotspot.igv.data.Properties; import java.util.HashMap; import java.util.Stack; @@ -38,13 +37,6 @@ import org.xml.sax.SAXException; */ public class XMLParser implements ContentHandler { - public static interface ParseMonitor { - - public void setProgress(double d); - - public void setState(String state); - } - public static class MissingAttributeException extends SAXException { private String name; @@ -85,24 +77,25 @@ public class XMLParser implements ContentHandler { public static class ElementHandler { private String name; - private T object; + private Stack object = new Stack<>(); private Attributes attr; private StringBuilder currentText; private ParseMonitor monitor; private HashMap> hashtable; private boolean needsText; - private ElementHandler parentElement; + private Stack> parentElement = new Stack<>(); + private Stack

parentObject = new Stack<>(); public ElementHandler(String name) { this(name, false); } public ElementHandler getParentElement() { - return parentElement; + return parentElement.peek(); } public P getParentObject() { - return getParentElement().getObject(); + return parentObject.peek(); } protected boolean needsText() { @@ -110,7 +103,7 @@ public class XMLParser implements ContentHandler { } public ElementHandler(String name, boolean needsText) { - this.hashtable = new HashMap>(); + this.hashtable = new HashMap<>(); this.name = name; this.needsText = needsText; } @@ -133,7 +126,7 @@ public class XMLParser implements ContentHandler { } public T getObject() { - return object; + return object.size() == 0 ? null : object.peek(); } public String readAttribute(String name) { @@ -151,8 +144,8 @@ public class XMLParser implements ContentHandler { public void processAttributesAsProperties(Properties p) { int length = attr.getLength(); for (int i = 0; i < length; i++) { - String val = attr.getValue(i).intern(); - String localName = attr.getLocalName(i).intern(); + String val = attr.getValue(i); + String localName = attr.getLocalName(i); p.setProperty(val, localName); } } @@ -161,8 +154,9 @@ public class XMLParser implements ContentHandler { this.currentText = new StringBuilder(); this.attr = attr; this.monitor = monitor; - this.parentElement = parentElement; - object = start(); + this.parentElement.push(parentElement); + parentObject.push(parentElement.getObject()); + object.push(start()); } protected T start() throws SAXException { @@ -175,6 +169,9 @@ public class XMLParser implements ContentHandler { public void endElement() throws SAXException { end(currentText.toString()); + object.pop(); + parentElement.pop(); + parentObject.pop(); } protected void text(char[] c, int start, int length) { @@ -186,32 +183,37 @@ public class XMLParser implements ContentHandler { private ParseMonitor monitor; public XMLParser(TopElementHandler rootHandler, ParseMonitor monitor) { - this.stack = new Stack(); + this.stack = new Stack<>(); this.monitor = monitor; this.stack.push(rootHandler); } + @Override public void setDocumentLocator(Locator locator) { - if (monitor != null) { - monitor.setState("Starting parsing"); - } + } + @Override public void startDocument() throws SAXException { } + @Override public void endDocument() throws SAXException { } + @Override public void startPrefixMapping(String prefix, String uri) throws SAXException { } + @Override public void endPrefixMapping(String prefix) throws SAXException { } + @SuppressWarnings("unchecked") + @Override public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { - assert !stack.isEmpty(); + ElementHandler parent = stack.peek(); if (parent != null) { ElementHandler child = parent.getChild(qName); @@ -225,6 +227,7 @@ public class XMLParser implements ContentHandler { stack.push(null); } + @Override public void endElement(String uri, String localName, String qName) throws SAXException { ElementHandler handler = stack.pop(); if (handler != null) { @@ -232,6 +235,7 @@ public class XMLParser implements ContentHandler { } } + @Override public void characters(char[] ch, int start, int length) throws SAXException { assert !stack.isEmpty(); @@ -243,12 +247,15 @@ public class XMLParser implements ContentHandler { } } + @Override public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { } + @Override public void processingInstruction(String target, String data) throws SAXException { } + @Override public void skippedEntity(String name) throws SAXException { } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java index 0f431427851..b9408d992b8 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class XMLWriter extends Writer { public XMLWriter(Writer inner) { this.inner = inner; - elementStack = new Stack(); + elementStack = new Stack<>(); } @Override @@ -49,6 +49,7 @@ public class XMLWriter extends Writer { write(arr, 0, arr.length); } + @Override public void write(char[] cbuf, int off, int len) throws IOException { for (int i = off; i < off + len; i++) { char c = cbuf[i]; @@ -64,10 +65,12 @@ public class XMLWriter extends Writer { } } + @Override public void flush() throws IOException { inner.flush(); } + @Override public void close() throws IOException { inner.close(); } @@ -111,7 +114,7 @@ public class XMLWriter extends Writer { } public void writeProperties(Properties props) throws IOException { - if (props.getProperties().hasNext() == false) { + if (props.iterator().hasNext() == false) { return; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd new file mode 100644 index 00000000000..be576142ed4 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/graphdocument.xsd @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java index 949525dd59a..0d14711fd03 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GraphViewer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,5 +31,5 @@ import com.sun.hotspot.igv.data.InputGraph; */ public interface GraphViewer { - public void view(InputGraph graph); + public void view(InputGraph graph, boolean clone); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java index 032d5233819..b35f3eabf89 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java index b08930f09e7..638a065c40b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java index 262197362a1..1fe6ac3342a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/Scheduler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java new file mode 100644 index 00000000000..89d22f2ce6e --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.assertEquals; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class ChangedEventTest { + + public ChangedEventTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of addListener method, of class Event. + */ + @Test + public void testBase() { + + ChangedEvent e = new ChangedEvent<>(5); + final int[] fireCount = new int[1]; + + e.addListener(new ChangedListener() { + @Override + public void changed(Integer s) { + assertEquals(s.intValue(), 5); + fireCount[0]++; + } + }); + + e.fire(); + assertEquals(1, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.beginAtomic(); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.endAtomic(); + assertEquals(3, fireCount[0]); + + } + + +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java new file mode 100644 index 00000000000..999475ce95b --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.*; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class ControllableChangedListenerTest { + + public ControllableChangedListenerTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of isEnabled method, of class ControllableChangedListener. + */ + @Test + public void testBase() { + + final boolean[] hasFired = new boolean[1]; + final boolean[] shouldFire = new boolean[1]; + final Integer[] valueToFire = new Integer[1]; + ControllableChangedListener l = new ControllableChangedListener() { + + @Override + public void filteredChanged(Integer value) { + assertTrue(shouldFire[0]); + assertEquals(valueToFire[0], value); + hasFired[0] = true; + } + }; + + shouldFire[0] = true; + valueToFire[0] = 1; + hasFired[0] = false; + l.changed(1); + assertTrue(hasFired[0]); + + shouldFire[0] = false; + hasFired[0] = false; + l.setEnabled(false); + l.changed(1); + assertFalse(hasFired[0]); + + shouldFire[0] = true; + valueToFire[0] = 1; + hasFired[0] = false; + l.setEnabled(true); + l.changed(1); + assertTrue(hasFired[0]); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java new file mode 100644 index 00000000000..9c6616b6df6 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.util.Arrays; +import java.util.HashSet; +import static org.junit.Assert.assertEquals; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class GroupTest { + + public GroupTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getAllNodes method, of class Group. + */ + @Test + public void testGetAllNodes() { + final Group g = new Group(null); + final InputGraph graph1 = new InputGraph("1"); + final InputGraph graph2 = new InputGraph("2"); + g.addElement(graph1); + g.addElement(graph2); + graph1.addNode(new InputNode(1)); + graph1.addNode(new InputNode(2)); + graph2.addNode(new InputNode(2)); + graph2.addNode(new InputNode(3)); + assertEquals(g.getAllNodes(), new HashSet(Arrays.asList(1, 2, 3))); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java new file mode 100644 index 00000000000..7ae20ca6c36 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class InputGraphTest { + + /** + * 1 + * / \ + * 2 3 + * \ | 5 + * \ | / + * 4 + */ + private static InputGraph referenceGraph; + + private static InputGraph emptyGraph; + + private static final InputNode N1 = new InputNode(1); + private static final InputNode N2 = new InputNode(2); + private static final InputNode N3 = new InputNode(3); + private static final InputNode N4 = new InputNode(4); + private static final InputNode N5 = new InputNode(5); + private static final InputEdge E12 = new InputEdge((char)0, 1, 2); + private static final InputEdge E13 = new InputEdge((char)0, 1, 3); + private static final InputEdge E24 = new InputEdge((char)0, 2, 4); + private static final InputEdge E34 = new InputEdge((char)0, 3, 4); + private static final InputEdge E54 = new InputEdge((char)0, 5, 4); + + public InputGraphTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + Group group = new Group(null); + + emptyGraph = new InputGraph("emptyGraph"); + group.addElement(emptyGraph); + + referenceGraph = new InputGraph("referenceGraph"); + group.addElement(referenceGraph); + referenceGraph.addNode(N1); + referenceGraph.addNode(N2); + referenceGraph.addNode(N3); + referenceGraph.addNode(N4); + referenceGraph.addNode(N5); + + referenceGraph.addEdge(E12); + referenceGraph.addEdge(E13); + referenceGraph.addEdge(E24); + referenceGraph.addEdge(E34); + referenceGraph.addEdge(E54); + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of equals method, of class InputGraph. + */ + @Test + public void testEquals() { + + Group parentA = new Group(null); + InputGraph a = new InputGraph("graph"); + parentA.addElement(a); + + Group parentB = new Group(null); + InputGraph b = new InputGraph("graph"); + parentB.addElement(b); + + InputGraph c = new InputGraph("graph"); + parentB.addElement(b); + + Util.assertGraphEquals(a, b); + Util.assertGraphEquals(b, c); + + a.addNode(new InputNode(1)); + Util.assertGraphNotEquals(a, b); + + b.addNode(new InputNode(1)); + Util.assertGraphEquals(a, b); + } + + /** + * Test of findRootNodes method, of class InputGraph. + */ + @Test + public void testFindRootNodes() { + assertTrue(emptyGraph.findRootNodes().isEmpty()); + + List result = referenceGraph.findRootNodes(); + assertTrue(result.size() == 2); + assertTrue(result.contains(N1)); + assertTrue(result.contains(N5)); + } + + /** + * Test of findAllOutgoingEdges method, of class InputGraph. + */ + @Test + public void testFindAllOutgoingEdges() { + assertTrue(emptyGraph.findAllOutgoingEdges().isEmpty()); + + Map> result = referenceGraph.findAllOutgoingEdges(); + assertTrue(result.size() == 5); + assertEquals(result.get(N1), Arrays.asList(E12, E13)); + assertEquals(result.get(N2), Arrays.asList(E24)); + assertEquals(result.get(N3), Arrays.asList(E34)); + assertEquals(result.get(N4), Arrays.asList()); + assertEquals(result.get(N5), Arrays.asList(E54)); + } + + /** + * Test of findAllIngoingEdges method, of class InputGraph. + */ + @Test + public void testFindAllIngoingEdges() { + assertTrue(emptyGraph.findAllIngoingEdges().isEmpty()); + + Map> result = referenceGraph.findAllIngoingEdges(); + assertTrue(result.size() == 5); + assertEquals(result.get(N1), Arrays.asList()); + assertEquals(result.get(N2), Arrays.asList(E12)); + assertEquals(result.get(N3), Arrays.asList(E13)); + assertEquals(result.get(N4), Arrays.asList(E24, E34, E54)); + assertEquals(result.get(N5), Arrays.asList()); + } + + /** + * Test of findOutgoingEdges method, of class InputGraph. + */ + @Test + public void testFindOutgoingEdges() { + assertTrue(emptyGraph.findOutgoingEdges(new InputNode(1)).isEmpty()); + + assertEquals(referenceGraph.findOutgoingEdges(N1), Arrays.asList(E12, E13)); + assertEquals(referenceGraph.findOutgoingEdges(N2), Arrays.asList(E24)); + assertEquals(referenceGraph.findOutgoingEdges(N3), Arrays.asList(E34)); + assertEquals(referenceGraph.findOutgoingEdges(N4), Arrays.asList()); + assertEquals(referenceGraph.findOutgoingEdges(N5), Arrays.asList(E54)); + } + + /** + * Test of getNext method, of class InputGraph. + */ + @Test + public void testGetNextPrev() { + final Group group = new Group(null); + + final InputGraph a = new InputGraph("a"); + + final InputGraph b = new InputGraph("b"); + + final InputGraph c = new InputGraph("c"); + group.addElement(a); + group.addElement(b); + group.addElement(c); + + assertEquals(null, a.getPrev()); + assertEquals(b, a.getNext()); + + assertEquals(a, b.getPrev()); + assertEquals(c, b.getNext()); + + assertEquals(b, c.getPrev()); + assertEquals(null, c.getNext()); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java new file mode 100644 index 00000000000..b7c9cddc5fc --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; +import org.junit.*; + +/** + * + * @author Thomas + */ +public class InputMethodTest { + + public InputMethodTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + + /** + * Test of getBytecodes method, of class InputMethod. + */ + @Test + public void testGetSetBytecodes() { + + final String input = "0 iload_0\n" + + "1 iconst_1\n" + + "2 if_icmpne 7\n" + + "5 iconst_1\n" + + "6 ireturn\n" + + "7 iconst_0\n" + + "8 ireturn"; + + final Group g = new Group(null); + InputMethod m = new InputMethod(g, "name", "shortName", -1); + m.setBytecodes(input); + + assertThat(m.getBytecodes().size(), is(7)); + + assertThat(m.getBytecodes().get(0).getBci(), is(0)); + assertThat(m.getBytecodes().get(1).getBci(), is(1)); + assertThat(m.getBytecodes().get(2).getBci(), is(2)); + assertThat(m.getBytecodes().get(3).getBci(), is(5)); + + assertThat(m.getBytecodes().get(0).getName(), is("iload_0")); + assertThat(m.getBytecodes().get(1).getName(), is("iconst_1")); + assertThat(m.getBytecodes().get(2).getName(), is("if_icmpne 7")); + assertThat(m.getBytecodes().get(6).getName(), is("ireturn")); + + assertThat(m.getBytecodes().get(2).getInlined(), nullValue()); + assertThat(m.getBytecodes().get(6).getInlined(), nullValue()); + } + + +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java new file mode 100644 index 00000000000..6b615c62785 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.*; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class PairTest { + + public PairTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getLeft method, of class Pair. + */ + @Test + public void testBase() { + Pair p = new Pair(); + assertTrue(p.getLeft() == null); + assertTrue(p.getRight() == null); + assertEquals("[null/null]", p.toString()); + assertFalse(p.equals(null)); + + Pair p2 = new Pair(1, 2); + assertTrue(p2.getLeft().intValue() == 1); + assertTrue(p2.getRight().intValue() == 2); + assertFalse(p.equals(p2)); + assertFalse(p2.equals(p)); + assertFalse(p.hashCode() == p2.hashCode()); + assertEquals("[1/2]", p2.toString()); + + Pair p3 = new Pair(1, 2); + assertTrue(p2.equals(p3)); + assertTrue(p2.hashCode() == p3.hashCode()); + + p2.setLeft(2); + assertFalse(p2.equals(p3)); + assertTrue(p2.getLeft().intValue() == 2); + assertTrue(p2.getRight().intValue() == 2); + assertFalse(p2.hashCode() == p3.hashCode()); + assertEquals("[2/2]", p2.toString()); + + p2.setRight(1); + assertFalse(p2.equals(p3)); + assertTrue(p2.getLeft().intValue() == 2); + assertTrue(p2.getRight().intValue() == 1); + assertFalse(p2.hashCode() == p3.hashCode()); + assertEquals("[2/1]", p2.toString()); + + p3.setLeft(2); + p3.setRight(1); + assertTrue(p2.hashCode() == p3.hashCode()); + assertTrue(p2.equals(p3)); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java new file mode 100644 index 00000000000..0310dd4d8a2 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java @@ -0,0 +1,401 @@ +/* + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import com.sun.hotspot.igv.data.Properties.InvertPropertyMatcher; +import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.data.Properties.PropertySelector; +import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; +import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import junit.framework.TestCase; + +/** + * + * @author Thomas Wuerthinger + */ +public class PropertiesTest extends TestCase { + + + + public PropertiesTest(String testName) { + super(testName); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Test of equals method, of class Properties. + */ + public void testEquals() { + Properties a = new Properties(); + assertFalse(a.equals(null)); + assertTrue(a.equals(a)); + + Properties b = new Properties(); + assertTrue(a.equals(b)); + assertTrue(a.hashCode() == b.hashCode()); + + a.setProperty("p1", "1"); + assertFalse(a.equals(b)); + assertFalse(b.equals(a)); + assertFalse(a.hashCode() == b.hashCode()); + + b.setProperty("p1", "1"); + assertTrue(a.equals(b)); + assertTrue(a.hashCode() == b.hashCode()); + + Properties c = new Properties(a); + assertTrue(c.equals(a)); + assertTrue(c.equals(b)); + + c.setProperty("p1", "2"); + assertFalse(c.equals(b)); + assertFalse(c.hashCode() == b.hashCode()); + assertFalse(c.equals(a)); + assertFalse(c.hashCode() == a.hashCode()); + + a.setProperty("p2", "2"); + Properties d = new Properties(); + d.setProperty("p2", "2"); + d.setProperty("p1", "1"); + assertTrue(d.equals(a)); + } + + /** + * Test of selectSingle method, of class Properties. + */ + public void testSelectSingle() { + + final boolean[] called = new boolean[1]; + final String v = "2"; + final String n = "p2"; + + PropertyMatcher matcher = new PropertyMatcher() { + + @Override + public String getName() { + assertFalse(called[0]); + called[0] = true; + return n; + } + + @Override + public boolean match(String value) { + assertTrue(v.equals(value)); + return true; + } + }; + + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + instance.setProperty(n, v); + instance.setProperty("p3", "3"); + Property result = instance.selectSingle(matcher); + assertEquals(result, new Property(n, v)); + + + called[0] = false; + PropertyMatcher matcher2 = new PropertyMatcher() { + + @Override + public String getName() { + assertFalse(called[0]); + called[0] = true; + return n; + } + + @Override + public boolean match(String value) { + return false; + } + }; + + + Property result2 = instance.selectSingle(matcher2); + assertTrue(result2 == null); + } + + /** + * Test of get method, of class Properties. + */ + public void testGet() { + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + assertEquals("1", instance.get("p1")); + assertEquals(null, instance.get("p2")); + } + + /** + * Test of getProperties method, of class Properties. + */ + public void testIterator() { + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + instance.setProperty("p2", "2"); + Iterator result = instance.iterator(); + assertTrue(result.hasNext()); + assertEquals(new Property("p1", "1"), result.next()); + assertTrue(result.hasNext()); + assertEquals(new Property("p2", "2"), result.next()); + assertFalse(result.hasNext()); + assertTrue(result.next() == null); + + try { + result.remove(); + fail(); + } catch(UnsupportedOperationException e) {} + } + + /** + * Test of add method, of class Properties. + */ + public void testAdd() { + Properties a = new Properties(); + a.setProperty("p1", "1"); + a.setProperty("p2", "2"); + + Properties b = new Properties(); + b.setProperty("p1", "1"); + + Properties c = new Properties(); + c.setProperty("p2", "2"); + + assertFalse(a.equals(b)); + b.add(c); + + assertTrue(a.equals(b)); + + b.setProperty("p3", null); + assertTrue(a.equals(b)); + + Properties empty = new Properties(); + b.add(empty); + assertTrue(a.equals(b)); + + empty.add(b); + assertTrue(a.equals(empty)); + } + + + /** + * Test the multiple argument constructors. + */ + public void testConstructors() { + Properties a = new Properties("p1", "1", "p2", "2", "p3", "3"); + Properties b = new Properties("p1", "1", "p2", "2"); + Properties c = new Properties("p1", "1"); + + assertTrue(a.get("p3").equals("3")); + assertTrue(b.get("p2").equals("2")); + assertTrue(b.get("p1").equals("1")); + + b.setProperty("p3", "3"); + c.setProperty("p2", "2"); + c.setProperty("p3", "3"); + + assertTrue(a.equals(b)); + assertTrue(a.equals(c)); + } + + /** + * Test Entity class + */ + public void testEntity() { + + Properties p = new Properties(); + + Properties.Entity entity = new Properties.Entity(); + assertEquals(entity.getProperties(), p); + + entity.getProperties().setProperty("p1", "1"); + Properties.Entity entity2 = new Properties.Entity(entity); + assertEquals(entity.getProperties(), entity2.getProperties()); + } + + /** + * Test property selector + */ + public void testPropertySelector() { + final Collection c = new ArrayList<>(); + + final Properties.Entity e1 = new Properties.Entity(); + e1.getProperties().setProperty("p1", "1"); + e1.getProperties().setProperty("p2", "2"); + c.add(e1); + + final Properties.Entity e2 = new Properties.Entity(); + e2.getProperties().setProperty("p2", "2"); + e2.getProperties().setProperty("p1", "1"); + e2.getProperties().setProperty("p3", "3"); + c.add(e2); + + final Properties.Entity e3 = new Properties.Entity(); + e3.getProperties().setProperty("p3", "3"); + e3.getProperties().setProperty("p4", "4"); + c.add(e3); + + final PropertySelector sel = new PropertySelector<>(c); + + final StringPropertyMatcher matcher1 = new StringPropertyMatcher("p2", "2"); + assertTrue(sel.selectMultiple(matcher1).size() == 2); + assertTrue(sel.selectMultiple(matcher1).contains(e1)); + assertTrue(sel.selectMultiple(matcher1).contains(e2)); + assertTrue(sel.selectSingle(matcher1).equals(e1) || sel.selectSingle(matcher1).equals(e2)); + + final StringPropertyMatcher matcher2 = new StringPropertyMatcher("p3", "3"); + assertTrue(sel.selectMultiple(matcher2).size() == 2); + assertTrue(sel.selectMultiple(matcher2).contains(e2)); + assertTrue(sel.selectMultiple(matcher2).contains(e3)); + assertTrue(sel.selectSingle(matcher2).equals(e2) || sel.selectSingle(matcher2).equals(e3)); + + final StringPropertyMatcher matcher3 = new StringPropertyMatcher("p4", "4"); + assertTrue(sel.selectMultiple(matcher3).size() == 1); + assertTrue(sel.selectMultiple(matcher3).contains(e3)); + assertTrue(sel.selectSingle(matcher3).equals(e3)); + + final StringPropertyMatcher matcher4 = new StringPropertyMatcher("p5", "5"); + assertTrue(sel.selectMultiple(matcher4).size() == 0); + assertTrue(sel.selectSingle(matcher4) == null); + } + + public void testRemoveProperty() { + final Properties p = new Properties(); + p.setProperty("p1", "1"); + p.setProperty("p2", "2"); + + assertTrue(p.get("p1").equals("1")); + assertTrue(p.get("p2").equals("2")); + + p.setProperty("p1", null); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2").equals("2")); + + p.setProperty("p2", null); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2") == null); + + p.setProperty("p3", "3"); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2") == null); + assertTrue(p.get("p3").equals("3")); + } + + /** + * Test property matchers + */ + public void testPropertyMatchers() { + final StringPropertyMatcher matcher = new StringPropertyMatcher("p1", "1"); + assertTrue(matcher.getName().equals("p1")); + assertTrue(matcher.match("1")); + assertFalse(matcher.match("2")); + try { + matcher.match(null); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new StringPropertyMatcher(null, "**"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new StringPropertyMatcher("p1", null); + fail(); + } catch(IllegalArgumentException e) {} + + final RegexpPropertyMatcher matcher2 = new RegexpPropertyMatcher("p1", "C.*"); + assertTrue(matcher2.getName().equals("p1")); + assertTrue(matcher2.match("C")); + assertTrue(matcher2.match("Casdf")); + assertFalse(matcher2.match(" C")); + assertFalse(matcher2.match("c")); + assertFalse(matcher2.match("asdfC")); + + try { + matcher2.match(null); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher("p1", "**"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher(null, "1"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher("p1", null); + fail(); + } catch(IllegalArgumentException e) {} + + final InvertPropertyMatcher matcher3 = new InvertPropertyMatcher(matcher); + assertTrue(matcher3.getName().equals("p1")); + assertFalse(matcher3.match("1")); + assertTrue(matcher3.match("2")); + assertFalse(matcher3.match(null)); + } + + public void testToString() { + Properties p = new Properties(); + assertEquals(p.toString(), "[]"); + + p.setProperty("p1", "1"); + assertEquals(p.toString(), "[p1=1]"); + + Properties p2 = new Properties(); + p2.setProperty("p1", "1"); + p2.setProperty("p2", "2"); + assertEquals(p2.toString(), "[p1=1, p2=2]"); + + Properties p3 = new Properties(); + p3.setProperty("p2", "2"); + p3.setProperty("p1", "1"); + assertEquals(p3.toString(), "[p1=1, p2=2]"); + + p3.setProperty("p0", "0"); + assertEquals(p3.toString(), "[p0=0, p1=1, p2=2]"); + + p2.setProperty("p1", null); + assertEquals(p2.toString(), "[p2=2]"); + + p2.setProperty("p2", null); + assertEquals(p2.toString(), "[]"); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java new file mode 100644 index 00000000000..ab90788433d --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.*; +import org.junit.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class PropertyTest { + + public PropertyTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getName method, of class Property. + */ + @Test + public void testGetNameAndValue() { + final Property p = new Property("name", "value"); + assertEquals(p.getName(), "name"); + assertEquals(p.getValue(), "value"); + + try { + new Property(null, "value"); + fail(); + } catch(IllegalArgumentException e) { + } + + + try { + new Property("name", null); + fail(); + } catch(IllegalArgumentException e) { + } + } + + /** + * Test of toString method, of class Property. + */ + @Test + public void testToString() { + final Property p = new Property("name", "value"); + assertEquals(p.toString(), "name=value"); + } + + /** + * Test of equals method, of class Property. + */ + @Test + public void testEquals() { + final Property p = new Property("name", "value"); + final Object o = new Object(); + assertFalse(p.equals(o)); + assertFalse(p.equals(null)); + assertTrue(p.equals(p)); + + final Property p2 = new Property("name", "value1"); + assertFalse(p.equals(p2)); + assertTrue(p.hashCode() != p2.hashCode()); + + final Property p3 = new Property("name2", "value"); + assertFalse(p.equals(p3)); + assertTrue(p.hashCode() != p3.hashCode()); + assertTrue(p2.hashCode() != p3.hashCode()); + + final Property p4 = new Property("name", "value"); + assertEquals(p, p4); + assertEquals(p.hashCode(), p4.hashCode()); + + final Property p5 = new Property("value", "name"); + assertFalse(p.equals(p5)); + assertTrue(p.hashCode() != p5.hashCode()); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java new file mode 100644 index 00000000000..7c525017ceb --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import static org.junit.Assert.assertEquals; +import org.junit.*; + +/** + * + * @author Thomas + */ +public class SourceTest { + + public SourceTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getSourceNodes method, of class Source. + */ + @Test + public void testBase() { + final Source s = new Source(); + + final InputNode N1 = new InputNode(1); + final InputNode N2 = new InputNode(2); + + s.addSourceNode(N1); + assertEquals(s.getSourceNodes(), Arrays.asList(N1)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1))); + + s.addSourceNode(N2); + assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); + + s.addSourceNode(N1); + assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet<>(Arrays.asList(1, 2))); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java new file mode 100644 index 00000000000..8ad4977e46d --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class Util { + + public static void assertGraphDocumentNotEquals(GraphDocument a, GraphDocument b) { + try { + assertGraphDocumentEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Graphs documents are equal!"); + } + + public static void assertGraphDocumentEquals(GraphDocument a, GraphDocument b) { + + if (a.getElements().size() != b.getElements().size()) { + fail(); + } + + int z = 0; + for (FolderElement e : b.getElements()) { + + if (e instanceof Group) { + Group g = (Group) e; + Group thisG = (Group) a.getElements().get(z); + assertGroupEquals(thisG, g); + z++; + } + } + } + + public static void assertGroupNotEquals(Group a, Group b) { + try { + assertGroupEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Groups are equal!"); + } + + public static void assertGroupEquals(Group a, Group b) { + + if (a.getGraphsCount() != b.getGraphsCount()) { + fail(); + } + + int z = 0; + for (InputGraph graph : a.getGraphs()) { + InputGraph otherGraph = b.getGraphs().get(z); + assertGraphEquals(graph, otherGraph); + z++; + } + + if (a.getMethod() == null || b.getMethod() == null) { + if (a.getMethod() != b.getMethod()) { + fail(); + } + } else { + if (!a.getMethod().equals(b.getMethod())) { + fail(); + } + } + } + + public static void assertGraphNotEquals(InputGraph a, InputGraph b) { + try { + assertGraphEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Graphs are equal!"); + } + + public static void assertGraphEquals(InputGraph a, InputGraph b) { + + if(!a.getNodesAsSet().equals(b.getNodesAsSet())) { + fail(); + } + + if (!a.getEdges().equals(b.getEdges())) { + fail(); + } + + if (a.getBlocks().equals(b.getBlocks())) { + fail(); + } + + for (InputNode n : a.getNodes()) { + assertEquals(a.getBlock(n), b.getBlock(n)); + } + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java new file mode 100644 index 00000000000..f375441dfdf --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data.serialization; + +import com.sun.hotspot.igv.data.*; +import java.io.*; +import java.nio.channels.Channels; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import org.junit.*; +import org.openide.util.Exceptions; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * + * @author Thomas Wuerthinger + */ +public class ParserTest { + + public ParserTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + private void test(GraphDocument document) { + final Printer printer = new Printer(); + final CharArrayWriter writer = new CharArrayWriter(); + printer.export(writer, document); + test(document, writer.toString()); + } + + private void test(GraphDocument document, String xmlString) { + try { + InputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8")); + try { + Parser parser = new Parser(Channels.newChannel(in)); + final GraphDocument parsedDocument = parser.parse(); + Util.assertGraphDocumentEquals(document, parsedDocument); + } catch (SAXException ex) { + fail(ex.toString()); + } + } catch (UnsupportedEncodingException ex) { + Exceptions.printStackTrace(ex); + } + } + + private void testBoth(GraphDocument document, String xmlString) { + test(document); + test(document, xmlString); + } + + /** + * Test of graph document serialization + */ + @Test + public void testSerialization() { + final GraphDocument doc = new GraphDocument(); + + test(doc); + + final Group group1 = new Group(doc); + doc.addElement(group1); + test(doc); + + final Group group2 = new Group(doc); + doc.addElement(group2); + test(doc); + + final InputGraph graph = new InputGraph(""); + group1.addElement(graph); + test(doc); + + graph.addNode(new InputNode(0)); + test(doc); + + graph.addNode(new InputNode(1)); + test(doc); + + graph.addNode(new InputNode(2)); + test(doc); + + graph.addNode(new InputNode(3)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 0, 1)); + test(doc); + + graph.addEdge(new InputEdge((char)1, (char)1, 0, 1)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 1, 2)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 2, 3)); + test(doc); + + group1.setMethod(new InputMethod(group1, "testMethod", "tM", 1)); + test(doc); + + final InputBlock b1 = graph.addBlock("1"); + b1.addNode(0); + b1.addNode(1); + + final InputBlock b2 = graph.addBlock("2"); + b2.addNode(2); + b2.addNode(3); + test(doc); + + final GraphDocument document2 = new GraphDocument(); + doc.addGraphDocument(document2); + test(doc); + assertTrue(doc.getElements().size() == 2); + + final Group group3 = new Group(document2); + document2.addElement(group3); + doc.addGraphDocument(document2); + assertTrue(doc.getElements().size() == 3); + assertTrue(document2.getElements().size() == 0); + + doc.clear(); + test(doc); + Util.assertGraphDocumentEquals(doc, new GraphDocument()); + } + + @Test + public void testSimpleExport() { + GraphDocument document = new GraphDocument(); + Group g = new Group(document); + document.addElement(g); + + InputGraph graph = new InputGraph("TestGraph"); + g.addElement(graph); + graph.getProperties().setProperty("testName", "testValue"); + + InputNode n1 = new InputNode(0); + InputNode n2 = new InputNode(1); + InputEdge e1 = new InputEdge((char)0, 0, 1); + InputEdge e2 = new InputEdge((char)1, 0, 1); + graph.addNode(n1); + graph.addNode(n2); + graph.addEdge(e1); + graph.addEdge(e2); + + test(document); + } + + @Test + public void testComplexExport() { + + GraphDocument document = new GraphDocument(); + Group g = new Group(document); + document.addElement(g); + + InputGraph graph = new InputGraph("TestGraph"); + g.addElement(graph); + graph.getProperties().setProperty("testName", "testValue"); + + InputNode n1 = new InputNode(0); + InputNode n2 = new InputNode(1); + InputEdge e1 = new InputEdge((char)0, 0, 0); + InputEdge e2 = new InputEdge((char)1, 1, 1); + graph.addNode(n1); + graph.addNode(n2); + graph.addEdge(e1); + graph.addEdge(e2); + + InputGraph graph2 = new InputGraph("TestGraph2"); + g.addElement(graph2); + graph2.addNode(n1); + InputNode n3 = new InputNode(2); + graph2.addNode(n3); + InputEdge e3 = new InputEdge((char)0, 0, 2); + graph2.addEdge(e3); + + test(document); + } + + + /** + * Test of parse method, of class Parser. + */ + @Test + public void testParse() { + testBoth(new GraphDocument(), ""); + } + +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml index 1225db62971..7260e5d2a3a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml @@ -14,6 +14,14 @@ 1.0 + + org.openide.util.lookup + + + + 8.6.1 + + com.sun.hotspot.igv.difference diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java index f1a6fdadc8c..0b2f01c47e8 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,16 +24,11 @@ */ package com.sun.hotspot.igv.difference; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Property; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.*; +import com.sun.hotspot.igv.data.services.Scheduler; +import java.util.*; +import org.openide.util.Lookup; /** * @@ -46,7 +41,7 @@ public class Difference { public static final String VALUE_CHANGED = "changed"; public static final String VALUE_SAME = "same"; public static final String VALUE_DELETED = "deleted"; - public static final String OLD_PREFIX = "OLD_"; + public static final String NEW_PREFIX = "NEW_"; public static final String MAIN_PROPERTY = "name"; public static final double LIMIT = 100.0; public static final String[] IGNORE_PROPERTIES = new String[]{"idx", "debug_idx"}; @@ -60,14 +55,14 @@ public class Difference { } private static InputGraph createDiffSameGroup(InputGraph a, InputGraph b) { - Map keyMapB = new HashMap(); + Map keyMapB = new HashMap<>(b.getNodes().size()); for (InputNode n : b.getNodes()) { Integer key = n.getId(); assert !keyMapB.containsKey(key); keyMapB.put(key, n); } - Set pairs = new HashSet(); + Set pairs = new HashSet<>(); for (InputNode n : a.getNodes()) { Integer key = n.getId(); @@ -75,30 +70,92 @@ public class Difference { if (keyMapB.containsKey(key)) { InputNode nB = keyMapB.get(key); - pairs.add(new Pair(n, nB)); + pairs.add(new NodePair(n, nB)); } } return createDiff(a, b, pairs); } - private static InputGraph createDiff(InputGraph a, InputGraph b, Set pairs) { - Group g = new Group(); + private static void ensureScheduled(InputGraph a) { + if (a.getBlocks().isEmpty()) { + Scheduler s = Lookup.getDefault().lookup(Scheduler.class); + a.clearBlocks(); + s.schedule(a); + a.ensureNodesInBlocks(); + } + } + + private static InputGraph createDiff(InputGraph a, InputGraph b, Set pairs) { + ensureScheduled(a); + ensureScheduled(b); + + Group g = new Group(null); g.setMethod(a.getGroup().getMethod()); - g.setAssembly(a.getGroup().getAssembly()); + if (a.getGroup() == b.getGroup()) { + g.getProperties().add(a.getGroup().getProperties()); + } else { + // copy properties that have the same value in both groups + Properties bps = b.getGroup().getProperties(); + for (Property p : a.getGroup().getProperties()) { + String value = p.getValue(); + if (value != null && value.equals(bps.get(p.getName()))) { + g.getProperties().setProperty(p.getName(), value); + } + } + } g.getProperties().setProperty("name", "Difference"); - InputGraph graph = new InputGraph(g, null); - graph.setName(a.getName() + ", " + b.getName()); - graph.setIsDifferenceGraph(true); + InputGraph graph = new InputGraph(a.getName() + ", " + b.getName()); + g.addElement(graph); - Set nodesA = new HashSet(a.getNodes()); - Set nodesB = new HashSet(b.getNodes()); + Map blocksMap = new HashMap<>(); + for (InputBlock blk : a.getBlocks()) { + InputBlock diffblk = graph.addBlock(blk.getName()); + blocksMap.put(blk, diffblk); + } + for (InputBlock blk : b.getBlocks()) { + InputBlock diffblk = graph.getBlock(blk.getName()); + if (diffblk == null) { + diffblk = graph.addBlock(blk.getName()); + } + blocksMap.put(blk, diffblk); + } - Map inputNodeMap = new HashMap(); - for (Pair p : pairs) { - InputNode n = p.getN1(); + // Difference between block edges + Set> aEdges = new HashSet<>(); + for (InputBlockEdge edge : a.getBlockEdges()) { + aEdges.add(new Pair<>(edge.getFrom().getName(), edge.getTo().getName())); + } + for (InputBlockEdge bEdge : b.getBlockEdges()) { + InputBlock from = bEdge.getFrom(); + InputBlock to = bEdge.getTo(); + Pair pair = new Pair<>(from.getName(), to.getName()); + if (aEdges.contains(pair)) { + // same + graph.addBlockEdge(blocksMap.get(from), blocksMap.get(to)); + aEdges.remove(pair); + } else { + // added + InputBlockEdge edge = graph.addBlockEdge(blocksMap.get(from), blocksMap.get(to)); + edge.setState(InputBlockEdge.State.NEW); + } + } + for (Pair deleted : aEdges) { + // removed + InputBlock from = graph.getBlock(deleted.getLeft()); + InputBlock to = graph.getBlock(deleted.getRight()); + InputBlockEdge edge = graph.addBlockEdge(from, to); + edge.setState(InputBlockEdge.State.DELETED); + } + + Set nodesA = new HashSet<>(a.getNodes()); + Set nodesB = new HashSet<>(b.getNodes()); + + Map inputNodeMap = new HashMap<>(pairs.size()); + for (NodePair p : pairs) { + InputNode n = p.getLeft(); assert nodesA.contains(n); - InputNode nB = p.getN2(); + InputNode nB = p.getRight(); assert nodesB.contains(nB); nodesA.remove(n); @@ -107,41 +164,59 @@ public class Difference { inputNodeMap.put(n, n2); inputNodeMap.put(nB, n2); graph.addNode(n2); + InputBlock block = blocksMap.get(a.getBlock(n)); + block.addNode(n2.getId()); markAsChanged(n2, n, nB); } for (InputNode n : nodesA) { InputNode n2 = new InputNode(n); graph.addNode(n2); - markAsNew(n2); + InputBlock block = blocksMap.get(a.getBlock(n)); + block.addNode(n2.getId()); + markAsDeleted(n2); inputNodeMap.put(n, n2); } + int curIndex = 0; for (InputNode n : nodesB) { InputNode n2 = new InputNode(n); - n2.setId(-n2.getId()); + + // Find new ID for node of b, does not change the id property + while (graph.getNode(curIndex) != null) { + curIndex++; + } + + n2.setId(curIndex); graph.addNode(n2); - markAsDeleted(n2); + InputBlock block = blocksMap.get(b.getBlock(n)); + block.addNode(n2.getId()); + markAsNew(n2); inputNodeMap.put(n, n2); } Collection edgesA = a.getEdges(); Collection edgesB = b.getEdges(); - Set newEdges = new HashSet(); + Set newEdges = new HashSet<>(); for (InputEdge e : edgesA) { int from = e.getFrom(); int to = e.getTo(); InputNode nodeFrom = inputNodeMap.get(a.getNode(from)); InputNode nodeTo = inputNodeMap.get(a.getNode(to)); - char index = e.getToIndex(); + char fromIndex = e.getFromIndex(); + char toIndex = e.getToIndex(); - InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId()); - if (!newEdges.contains(newEdge)) { - markAsNew(newEdge); - newEdges.add(newEdge); - graph.addEdge(newEdge); + if (nodeFrom == null || nodeTo == null) { + System.out.println("Unexpected edge : " + from + " -> " + to); + } else { + InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType()); + if (!newEdges.contains(newEdge)) { + markAsDeleted(newEdge); + newEdges.add(newEdge); + graph.addEdge(newEdge); + } } } @@ -150,40 +225,41 @@ public class Difference { int to = e.getTo(); InputNode nodeFrom = inputNodeMap.get(b.getNode(from)); InputNode nodeTo = inputNodeMap.get(b.getNode(to)); - char index = e.getToIndex(); + char fromIndex = e.getFromIndex(); + char toIndex = e.getToIndex(); - InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId()); - if (!newEdges.contains(newEdge)) { - markAsDeleted(newEdge); - newEdges.add(newEdge); - graph.addEdge(newEdge); + if (nodeFrom == null || nodeTo == null) { + System.out.println("Unexpected edge : " + from + " -> " + to); } else { - newEdges.remove(newEdge); - graph.removeEdge(newEdge); - markAsSame(newEdge); - newEdges.add(newEdge); - graph.addEdge(newEdge); + InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType()); + if (!newEdges.contains(newEdge)) { + markAsNew(newEdge); + newEdges.add(newEdge); + graph.addEdge(newEdge); + } else { + newEdges.remove(newEdge); + graph.removeEdge(newEdge); + markAsSame(newEdge); + newEdges.add(newEdge); + graph.addEdge(newEdge); + } } } - g.addGraph(graph); return graph; } - private static class Pair { + private static class NodePair extends Pair { - private InputNode n1; - private InputNode n2; - public Pair(InputNode n1, InputNode n2) { - this.n1 = n1; - this.n2 = n2; + public NodePair(InputNode n1, InputNode n2) { + super(n1, n2); } public double getValue() { double result = 0.0; - for (Property p : n1.getProperties()) { + for (Property p : getLeft().getProperties()) { double faktor = 1.0; for (String forbidden : IGNORE_PROPERTIES) { if (p.getName().equals(forbidden)) { @@ -191,7 +267,7 @@ public class Difference { break; } } - String p2 = n2.getProperties().get(p.getName()); + String p2 = getRight().getProperties().get(p.getName()); result += evaluate(p.getValue(), p2) * faktor; } @@ -208,21 +284,13 @@ public class Difference { return (double) (Math.abs(p.length() - p2.length())) / p.length() + 0.5; } } - - public InputNode getN1() { - return n1; - } - - public InputNode getN2() { - return n2; - } } private static InputGraph createDiff(InputGraph a, InputGraph b) { - Set matched = new HashSet(); + Set matched = new HashSet<>(); - Set pairs = new HashSet(); + Set pairs = new HashSet<>(); for (InputNode n : a.getNodes()) { String s = n.getProperties().get(MAIN_PROPERTY); if (s == null) { @@ -235,18 +303,18 @@ public class Difference { } if (s.equals(s2)) { - Pair p = new Pair(n, n2); + NodePair p = new NodePair(n, n2); pairs.add(p); } } } - Set selectedPairs = new HashSet(); + Set selectedPairs = new HashSet<>(); while (pairs.size() > 0) { double min = Double.MAX_VALUE; - Pair minPair = null; - for (Pair p : pairs) { + NodePair minPair = null; + for (NodePair p : pairs) { double cur = p.getValue(); if (cur < min) { minPair = p; @@ -259,9 +327,9 @@ public class Difference { } else { selectedPairs.add(minPair); - Set toRemove = new HashSet(); - for (Pair p : pairs) { - if (p.getN1() == minPair.getN1() || p.getN2() == minPair.getN2()) { + Set toRemove = new HashSet<>(); + for (NodePair p : pairs) { + if (p.getLeft() == minPair.getLeft() || p.getRight() == minPair.getRight()) { toRemove.add(p); } } @@ -292,7 +360,7 @@ public class Difference { String s = firstNode.getProperties().get(p.getName()); if (!p.getValue().equals(s)) { difference = true; - n.getProperties().setProperty(OLD_PREFIX + p.getName(), p.getValue()); + n.getProperties().setProperty(NEW_PREFIX + p.getName(), p.getValue()); } } @@ -300,7 +368,7 @@ public class Difference { String s = otherNode.getProperties().get(p.getName()); if (s == null && p.getValue().length() > 0) { difference = true; - n.getProperties().setProperty(OLD_PREFIX + p.getName(), ""); + n.getProperties().setProperty(NEW_PREFIX + p.getName(), ""); } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml index 31414d5503e..626e1cdd621 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/nbproject/project.xml @@ -22,13 +22,29 @@ 1.0 + + com.sun.hotspot.igv.layout + + + + 1.0 + + org.jdesktop.layout 1 - 1.4.1 + 1.16.1 + + + + org.openide.awt + + + + 7.30.1 @@ -36,7 +52,7 @@ - 7.5.1 + 7.18.1 @@ -44,7 +60,7 @@ - 7.3 + 7.46.1 @@ -52,7 +68,7 @@ - 7.2.0.1 + 7.20.1 @@ -60,7 +76,15 @@ - 7.9.0.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 @@ -68,7 +92,7 @@ - 6.16 + 6.39.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction deleted file mode 100644 index 4ebfb455217..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction +++ /dev/null @@ -1 +0,0 @@ -com.sun.hotspot.igv.filter.JavaSE6ScriptEngine \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java index 526674ad1e3..f0cff78f1c2 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/AbstractFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,14 +42,17 @@ public abstract class AbstractFilter implements Filter { properties = new Properties(); } + @Override public Properties getProperties() { return properties; } + @Override public OpenCookie getEditor() { return null; } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java index daaeee14edf..8a6bf7b5134 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ColorFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,9 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; +import com.sun.hotspot.igv.graph.*; import java.awt.Color; import java.util.ArrayList; import java.util.List; @@ -45,16 +41,18 @@ public class ColorFilter extends AbstractFilter { public ColorFilter(String name) { this.name = name; - colorRules = new ArrayList(); + colorRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector

selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ColorRule rule : colorRules) { if (rule.getSelector() != null) { List
figures = rule.getSelector().selected(diagram); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java index d82ddbe203f..058e9892aa6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,9 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -46,23 +42,25 @@ public class CombineFilter extends AbstractFilter { public CombineFilter(String name) { this.name = name; - rules = new ArrayList(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (CombineRule r : rules) { List
list = selector.selectMultiple(r.getFirstMatcher()); - Set
figuresToRemove = new HashSet
(); + Set
figuresToRemove = new HashSet<>(); for (Figure f : list) { - List
successors = new ArrayList
(f.getSuccessors()); + List
successors = new ArrayList<>(f.getSuccessors()); if (r.isReversed()) { if (successors.size() == 1) { Figure succ = successors.get(0); @@ -76,21 +74,30 @@ public class CombineFilter extends AbstractFilter { } } - assert slot != null; - slot.setName(f.getProperties().get("dump_spec")); - if (f.getProperties().get("short_name") != null) { - slot.setShortName(f.getProperties().get("short_name")); - } else { - String s = f.getProperties().get("dump_spec"); - if (s != null && s.length() <= 5) { + slot.getSource().addSourceNodes(f.getSource()); + if (r.getShortProperty() != null) { + String s = f.getProperties().get(r.getShortProperty()); + if (s != null && s.length() > 0) { slot.setShortName(s); + slot.setText(s); + slot.setColor(f.getColor()); + } + } else { + assert slot != null; + slot.setText(f.getProperties().get("dump_spec")); + if (f.getProperties().get("short_name") != null) { + slot.setShortName(f.getProperties().get("short_name")); + } else { + String s = f.getProperties().get("dump_spec"); + if (s != null && s.length() <= 5) { + slot.setShortName(s); + } } - } for (InputSlot s : f.getInputSlots()) { for (Connection c : s.getConnections()) { - Connection newConn = diagram.createConnection(slot, c.getOutputSlot()); + Connection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel(), c.getType()); newConn.setColor(c.getColor()); newConn.setStyle(c.getStyle()); } @@ -101,7 +108,7 @@ public class CombineFilter extends AbstractFilter { } else { for (Figure succ : successors) { - if (succ.getPredecessors().size() == 1) { + if (succ.getPredecessors().size() == 1 && succ.getInputSlots().size() == 1) { if (succ.getProperties().selectSingle(r.getSecondMatcher()) != null && succ.getOutputSlots().size() == 1) { @@ -122,22 +129,32 @@ public class CombineFilter extends AbstractFilter { pos = Integer.parseInt(succ.getProperties().get("con")); } OutputSlot slot = f.createOutputSlot(pos); - slot.setName(succ.getProperties().get("dump_spec")); - if (succ.getProperties().get("short_name") != null) { - slot.setShortName(succ.getProperties().get("short_name")); - } else { - String s = succ.getProperties().get("dump_spec"); - if (s != null && s.length() <= 2) { + slot.getSource().addSourceNodes(succ.getSource()); + if (r.getShortProperty() != null) { + String s = succ.getProperties().get(r.getShortProperty()); + if (s != null && s.length() > 0) { slot.setShortName(s); + slot.setText(s); + slot.setColor(succ.getColor()); + } + } else { + slot.setText(succ.getProperties().get("dump_spec")); + if (succ.getProperties().get("short_name") != null) { + slot.setShortName(succ.getProperties().get("short_name")); } else { - String tmpName = succ.getProperties().get("name"); - if (tmpName != null && tmpName.length() > 0) { - slot.setShortName(tmpName.substring(0, 1)); + String s = succ.getProperties().get("dump_spec"); + if (s != null && s.length() <= 2) { + slot.setShortName(s); + } else { + String tmpName = succ.getProperties().get("name"); + if (tmpName != null && tmpName.length() > 0) { + slot.setShortName(tmpName.substring(0, 1)); + } } } } for (Connection c : nextSlot.getConnections()) { - Connection newConn = diagram.createConnection(c.getInputSlot(), slot); + Connection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel(), c.getType()); newConn.setColor(c.getColor()); newConn.setStyle(c.getStyle()); } @@ -167,6 +184,7 @@ public class CombineFilter extends AbstractFilter { private PropertyMatcher first; private PropertyMatcher second; private boolean reversed; + private String shortProperty; public CombineRule(PropertyMatcher first, PropertyMatcher second) { this(first, second, false); @@ -174,9 +192,14 @@ public class CombineFilter extends AbstractFilter { } public CombineRule(PropertyMatcher first, PropertyMatcher second, boolean reversed) { + this(first, second, reversed, null); + } + + public CombineRule(PropertyMatcher first, PropertyMatcher second, boolean reversed, String shortProperty) { this.first = first; this.second = second; this.reversed = reversed; + this.shortProperty = shortProperty; } public boolean isReversed() { @@ -190,5 +213,9 @@ public class CombineFilter extends AbstractFilter { public PropertyMatcher getSecondMatcher() { return second; } + + public String getShortProperty() { + return shortProperty; + } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java index 9a9624ccb01..6a77ba6e078 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/ConnectionFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,8 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.graph.*; import java.awt.Color; import java.util.ArrayList; import java.util.List; @@ -44,16 +40,18 @@ public class ConnectionFilter extends AbstractFilter { public ConnectionFilter(String name) { this.name = name; - connectionStyleRules = new ArrayList(); + connectionStyleRules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(diagram.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(diagram.getFigures()); for (ConnectionStyleRule rule : connectionStyleRules) { List
figures = null; if (rule.getSelector() != null) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java index 9c1c32ecbf9..d54b9b8a495 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,17 +29,13 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; +import javax.script.*; import org.openide.cookies.OpenCookie; -import org.openide.filesystems.Repository; -import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; -import org.openide.util.Lookup; /** * @@ -48,7 +44,6 @@ import org.openide.util.Lookup; public class CustomFilter extends AbstractFilter { public static final String JAVASCRIPT_HELPER_ID = "JavaScriptHelper"; - private static ScriptEngineAbstraction engine; private String code; private String name; @@ -58,6 +53,7 @@ public class CustomFilter extends AbstractFilter { getProperties().setProperty("name", name); } + @Override public String getName() { return name; } @@ -80,6 +76,7 @@ public class CustomFilter extends AbstractFilter { public OpenCookie getEditor() { return new OpenCookie() { + @Override public void open() { openInEditor(); } @@ -89,7 +86,9 @@ public class CustomFilter extends AbstractFilter { public boolean openInEditor() { EditFilterDialog dialog = new EditFilterDialog(CustomFilter.this); dialog.setVisible(true); - return dialog.wasAccepted(); + boolean result = dialog.wasAccepted(); + this.getChangedEvent().fire(); + return result; } @Override @@ -97,41 +96,16 @@ public class CustomFilter extends AbstractFilter { return getName(); } - public static ScriptEngineAbstraction getEngine() { - if (engine == null) { - - ScriptEngineAbstraction chosen = null; - try { - Collection list = Lookup.getDefault().lookupAll(ScriptEngineAbstraction.class); - for (ScriptEngineAbstraction s : list) { - if (s.initialize(getJsHelperText())) { - if (chosen == null || !(chosen instanceof JavaSE6ScriptEngine)) { - chosen = s; - } - } - } - } catch (NoClassDefFoundError ncdfe) { - Logger.getLogger("global").log(Level.SEVERE, null, ncdfe); - } - - if (chosen == null) { - NotifyDescriptor message = new NotifyDescriptor.Message("Could not find a scripting engine. Please make sure that the Rhino scripting engine is available. Otherwise filter cannot be used.", NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(message); - chosen = new NullScriptEngine(); - } - - engine = chosen; - } - - return engine; - } - private static String getJsHelperText() { InputStream is = null; - StringBuilder sb = new StringBuilder("importPackage(Packages.com.sun.hotspot.igv.filter);importPackage(Packages.com.sun.hotspot.igv.graph);importPackage(Packages.com.sun.hotspot.igv.data);importPackage(Packages.com.sun.hotspot.igv.util);importPackage(java.awt);"); + StringBuilder sb = new StringBuilder("if (typeof importPackage === 'undefined') { try { load('nashorn:mozilla_compat.js'); } catch (e) {} }" + + "importPackage(Packages.com.sun.hotspot.igv.filter);" + + "importPackage(Packages.com.sun.hotspot.igv.graph);" + + "importPackage(Packages.com.sun.hotspot.igv.data);" + + "importPackage(Packages.com.sun.hotspot.igv.util);" + + "importPackage(java.awt);"); try { - FileSystem fs = Repository.getDefault().getDefaultFileSystem(); - FileObject fo = fs.getRoot().getFileObject(JAVASCRIPT_HELPER_ID); + FileObject fo = FileUtil.getConfigRoot().getFileObject(JAVASCRIPT_HELPER_ID); is = fo.getInputStream(); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String s; @@ -152,7 +126,18 @@ public class CustomFilter extends AbstractFilter { return sb.toString(); } + @Override public void apply(Diagram d) { - getEngine().execute(d, code); + try { + ScriptEngineManager sem = new ScriptEngineManager(); + ScriptEngine e = sem.getEngineByName("ECMAScript"); + e.eval(getJsHelperText()); + Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); + b.put("graph", d); + b.put("IO", System.out); + e.eval(code, b); + } catch (ScriptException ex) { + Exceptions.printStackTrace(ex); + } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java new file mode 100644 index 00000000000..4a1919101be --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EdgeColorIndexFilter.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.filter; + +import com.sun.hotspot.igv.graph.*; +import java.awt.Color; +import java.util.List; + +public class EdgeColorIndexFilter extends AbstractFilter { + + public static final String INPUTS = "INPUTS"; + public static final String OUTPUTS = "OUTPUTS"; + private final String applyTo; + private final Color[] colors; + + public EdgeColorIndexFilter(String applyTo, Color... color) { + if (!applyTo.equals(INPUTS) && !applyTo.equals(OUTPUTS)) { + throw new IllegalArgumentException("applyTo"); + } + + this.applyTo = applyTo; + this.colors = color; + } + + @Override + public String getName() { + return "Edge Color Index Filter"; + } + + @Override + public void apply(Diagram d) { + List
figures = d.getFigures(); + for (Figure f : figures) { + Slot[] slots; + if (applyTo.equals(INPUTS)) { + List inputSlots = f.getInputSlots(); + slots = inputSlots.toArray(new Slot[inputSlots.size()]); + } else { + List outputSlots = f.getOutputSlots(); + slots = outputSlots.toArray(new Slot[outputSlots.size()]); + } + int index = 0; + for (Slot slot : slots) { + if (index < colors.length && colors[index] != null) { + slot.setColor(colors[index]); + for (Connection c : slot.getConnections()) { + + c.setColor(colors[index]); + } + } + index++; + } + + } + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java index 85365cbeb74..1fb82ff9cbc 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,14 +137,14 @@ public class EditFilterDialog extends javax.swing.JDialog { }// //GEN-END:initComponents private void okButtonClicked(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonClicked - this.customFilter.setName(this.nameTextField.getText()); - this.customFilter.setCode(this.sourceTextArea.getText()); - accepted = true; - setVisible(false); + this.customFilter.setName(this.nameTextField.getText()); + this.customFilter.setCode(this.sourceTextArea.getText()); + accepted = true; + setVisible(false); }//GEN-LAST:event_okButtonClicked private void cancelButtonClicked(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonClicked - setVisible(false); + setVisible(false); }//GEN-LAST:event_cancelButtonClicked diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java index 7122fcebd20..c14443086df 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/Filter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,5 +41,6 @@ public interface Filter extends Properties.Provider, ChangedEventProvider getChangedEvent(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java index 30c96d65023..dcfff410779 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,9 +23,10 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.data.ChangedEvent; import com.sun.hotspot.igv.data.ChangedEventProvider; +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.graph.Diagram; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -38,20 +39,25 @@ public class FilterChain implements ChangedEventProvider { private List filters; private transient ChangedEvent changedEvent; - private boolean fireEvents; + + private ChangedListener changedListener = new ChangedListener() { + @Override + public void changed(Filter source) { + changedEvent.fire(); + } + }; public FilterChain() { - filters = new ArrayList(); - changedEvent = new ChangedEvent(this); - this.fireEvents = true; + filters = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); } public FilterChain(FilterChain f) { - this.filters = new ArrayList(f.filters); - changedEvent = new ChangedEvent(this); - this.fireEvents = true; + this.filters = new ArrayList<>(f.filters); + changedEvent = new ChangedEvent<>(this); } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } @@ -68,7 +74,7 @@ public class FilterChain implements ChangedEventProvider { } public void apply(Diagram d, FilterChain sequence) { - List applied = new ArrayList(); + List applied = new ArrayList<>(); for (Filter f : sequence.getFilters()) { if (filters.contains(f)) { f.apply(d); @@ -84,29 +90,12 @@ public class FilterChain implements ChangedEventProvider { } } - public void beginAtomic() { - this.fireEvents = false; - } - - public void endAtomic() { - this.fireEvents = true; - changedEvent.fire(); - } public void addFilter(Filter filter) { assert filter != null; filters.add(filter); - if (fireEvents) { - changedEvent.fire(); - } - } - - public void addFilterSameSequence(Filter filter) { - assert filter != null; - filters.add(filter); - if (fireEvents) { - changedEvent.fire(); - } + filter.getChangedEvent().addListener(changedListener); + changedEvent.fire(); } public boolean containsFilter(Filter filter) { @@ -116,9 +105,8 @@ public class FilterChain implements ChangedEventProvider { public void removeFilter(Filter filter) { assert filters.contains(filter); filters.remove(filter); - if (fireEvents) { - changedEvent.fire(); - } + filter.getChangedEvent().removeListener(changedListener); + changedEvent.fire(); } public void moveFilterUp(Filter filter) { @@ -128,9 +116,7 @@ public class FilterChain implements ChangedEventProvider { filters.remove(index); filters.add(index - 1, filter); } - if (fireEvents) { - changedEvent.fire(); - } + changedEvent.fire(); } public void moveFilterDown(Filter filter) { @@ -140,16 +126,10 @@ public class FilterChain implements ChangedEventProvider { filters.remove(index); filters.add(index + 1, filter); } - if (fireEvents) { - changedEvent.fire(); - } + changedEvent.fire(); } public List getFilters() { return Collections.unmodifiableList(filters); } - - public void clear() { - filters.clear(); - } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChainProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChainProvider.java index 5ff4c9e3f39..29ae9abc40e 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChainProvider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChainProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java index f86b7c6861a..b0fa5ab2ff7 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterSetting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class FilterSetting { public FilterSetting(String name) { this.name = name; - filters = new HashSet(); + filters = new HashSet<>(); } public Set getFilters() { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java new file mode 100644 index 00000000000..c4ab94179d2 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/GradientColorFilter.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.filter; + +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.image.Raster; +import java.util.List; + +/** + * Filter that colors nodes using a customizable color gradient, based on how + * a numeric property is located in a specified interval. + * + * @author Peter Hofer + */ +public class GradientColorFilter extends AbstractFilter { + + public static final String LINEAR = "LINEAR"; + public static final String LOGARITHMIC = "LOGARITHMIC"; + + private String propertyName = "probability"; + private float minValue = 0; + private float maxValue = 500; + private float[] fractions = {0, 0.5f, 1}; + private Color[] colors = {Color.BLUE, Color.YELLOW, Color.RED}; + private int shadeCount = 8; + private String mode = LINEAR; + + @Override + public String getName() { + return "Gradient Color Filter"; + } + + @Override + public void apply(Diagram d) { + boolean logarithmic = mode.equalsIgnoreCase(LOGARITHMIC); + if (!logarithmic && !mode.equalsIgnoreCase(LINEAR)) { + throw new RuntimeException("Unknown mode: " + mode); + } + + Rectangle bounds = new Rectangle(shadeCount, 1); + LinearGradientPaint lgp = new LinearGradientPaint(bounds.x, bounds.y, bounds.width, bounds.y, fractions, colors); + PaintContext context = lgp.createContext(null, bounds, bounds.getBounds2D(), AffineTransform.getTranslateInstance(0, 0), new RenderingHints(null)); + Raster raster = context.getRaster(bounds.x, bounds.y, bounds.width, bounds.height); + int[] rgb = raster.getPixels(bounds.x, bounds.y, bounds.width, bounds.height, (int[]) null); + Color[] shades = new Color[rgb.length / 3]; + for (int i = 0; i < shades.length; ++i) { + shades[i] = new Color(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]); + } + + List
figures = d.getFigures(); + for (Figure f : figures) { + String property = f.getProperties().get(propertyName); + if (property != null) { + try { + float value = Float.parseFloat(property); + + Color nodeColor; + if (value <= minValue) { + nodeColor = colors[0]; + } else if (value >= maxValue) { + nodeColor = colors[colors.length - 1]; + } else { + double normalized = value - minValue; + double interval = maxValue - minValue; + int index; + // Use Math.ceil() to make values above zero distinguishable from zero + if (logarithmic) { + index = (int) Math.ceil(shades.length * Math.log(1 + normalized) / Math.log(1 + interval)); + } else { + index = (int) Math.ceil(shades.length * normalized / interval); + } + nodeColor = shades[index]; + } + f.setColor(nodeColor); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + public String getPropertyName() { + return propertyName; + } + + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + public float getMinValue() { + return minValue; + } + + public void setMinValue(float minValue) { + this.minValue = minValue; + } + + public float getMaxValue() { + return maxValue; + } + + public void setMaxValue(float maxValue) { + this.maxValue = maxValue; + } + + public float[] getFractions() { + return fractions; + } + + public void setFractions(float[] fractions) { + this.fractions = fractions; + } + + public Color[] getColors() { + return colors; + } + + public void setColors(Color[] colors) { + this.colors = colors; + } + + public int getShadeCount() { + return shadeCount; + } + + public void setShadeCount(int shadeCount) { + this.shadeCount = shadeCount; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/JavaSE6ScriptEngine.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/JavaSE6ScriptEngine.java deleted file mode 100644 index cea6c48588e..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/JavaSE6ScriptEngine.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.filter; - -import com.sun.hotspot.igv.graph.Diagram; -import javax.script.Bindings; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import org.openide.util.Exceptions; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaSE6ScriptEngine implements ScriptEngineAbstraction { - - private ScriptEngine engine; - private Bindings bindings; - - public boolean initialize(String jsHelperText) { - try { - ScriptEngineManager sem = new ScriptEngineManager(); - ScriptEngine e = sem.getEngineByName("ECMAScript"); - engine = e; - e.eval(jsHelperText); - Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); - b.put("IO", System.out); - bindings = b; - return true; - } catch (Exception e) { - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Bindings b = bindings; - b.put("graph", d); - engine.eval(code, b); - } catch (ScriptException ex) { - Exceptions.printStackTrace(ex); - } - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java index 5ea7b67586b..b08e91e1d45 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,7 @@ package com.sun.hotspot.igv.filter; import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; import com.sun.hotspot.igv.graph.Selector; -import com.sun.hotspot.igv.data.Properties; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -44,56 +42,36 @@ public class RemoveFilter extends AbstractFilter { public RemoveFilter(String name) { this.name = name; - rules = new ArrayList(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { - for (RemoveRule r : rules) { + List
selected = r.getSelector().selected(diagram); + Set
toRemove = new HashSet<>(selected); - List
list = r.getSelector().selected(diagram); - Set
figuresToRemove = new HashSet
(); - - List
protectedFigures = null; - if (r.getRemoveAllWithoutPredecessor()) { - protectedFigures = diagram.getRootFigures(); - } - - for (Figure f : list) { - if (r.getRemoveOnlyInputs()) { - List inputSlots = new ArrayList(); - for (InputSlot is : f.getInputSlots()) { - inputSlots.add(is); - } - for (InputSlot is : inputSlots) { - f.removeSlot(is); - } - - f.createInputSlot(); - } else { - figuresToRemove.add(f); - } - } - - if (r.getRemoveAllWithoutPredecessor()) { - boolean progress = true; - while (progress) { - List
rootFigures = diagram.getRootFigures(); - progress = false; - for (Figure f : rootFigures) { - if (!protectedFigures.contains(f)) { - figuresToRemove.add(f); - progress = true; + if (r.getRemoveOrphans()) { + boolean changed; + do { + changed = false; + for (Figure f : diagram.getFigures()) { + if (!toRemove.contains(f)) { + if (toRemove.containsAll(f.getPredecessors()) && toRemove.containsAll(f.getSuccessors())) { + toRemove.add(f); + changed = true; + } } } - } + } while (changed); } - diagram.removeAllFigures(figuresToRemove); + diagram.removeAllFigures(toRemove); } } @@ -104,29 +82,23 @@ public class RemoveFilter extends AbstractFilter { public static class RemoveRule { private Selector selector; - private boolean removeAllWithoutPredecessor; - private boolean removeOnlyInputs; + private boolean removeOrphans; - public RemoveRule(Selector selector, boolean b) { - this(selector, b, false); + public RemoveRule(Selector selector) { + this(selector, false); } - public RemoveRule(Selector selector, boolean removeAllWithoutPredecessor, boolean removeOnlyInputs) { + public RemoveRule(Selector selector, boolean removeOrphans) { this.selector = selector; - this.removeOnlyInputs = removeOnlyInputs; - this.removeAllWithoutPredecessor = removeAllWithoutPredecessor; + this.removeOrphans = removeOrphans; } public Selector getSelector() { return selector; } - public boolean getRemoveOnlyInputs() { - return removeOnlyInputs; - } - - public boolean getRemoveAllWithoutPredecessor() { - return removeAllWithoutPredecessor; + public boolean getRemoveOrphans() { + return removeOrphans; } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java index 75631fba9cd..073abf23d5b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.List; @@ -43,13 +38,15 @@ public class RemoveInputsFilter extends AbstractFilter { public RemoveInputsFilter(String name) { this.name = name; - rules = new ArrayList(); + rules = new ArrayList<>(); } + @Override public String getName() { return name; } + @Override public void apply(Diagram diagram) { for (RemoveInputsRule r : rules) { @@ -57,7 +54,7 @@ public class RemoveInputsFilter extends AbstractFilter { List
list = r.getSelector().selected(diagram); for (Figure f : list) { int z = 0; - List last = new ArrayList(); + List last = new ArrayList<>(); for (InputSlot is : f.getInputSlots()) { if (z >= r.getStartingIndex() && z <= r.getEndIndex() && is.getConnections().size() > 0) { StringBuilder sb = new StringBuilder(); @@ -73,7 +70,7 @@ public class RemoveInputsFilter extends AbstractFilter { } is.removeAllConnections(); is.setShortName("X"); - is.setName(sb.toString()); + is.setText(sb.toString()); last.add(is); } else { last.clear(); @@ -91,10 +88,10 @@ public class RemoveInputsFilter extends AbstractFilter { if (i != 0) { sb.append("
"); } - sb.append(is2.getName()); + sb.append(is2.getText()); } - first.setName(sb.toString()); + first.setText(sb.toString()); for (int i = 1; i < last.size(); i++) { f.removeSlot(last.get(i)); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java index 41e6e8a1edb..edbb88f9de4 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; +import com.sun.hotspot.igv.graph.*; import java.util.ArrayList; import java.util.List; @@ -44,17 +40,19 @@ public class RemoveSelfLoopsFilter extends AbstractFilter { this.name = name; } + @Override public String getName() { return name; } + @Override public void apply(Diagram d) { for (Figure f : d.getFigures()) { for (InputSlot is : f.getInputSlots()) { - List toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); for (Connection c : is.getConnections()) { if (c.getOutputSlot().getFigure() == f) { @@ -72,7 +70,7 @@ public class RemoveSelfLoopsFilter extends AbstractFilter { } c.getInputSlot().setShortName("O"); - c.getInputSlot().setName("Self Loop"); + c.getInputSlot().setText("Self Loop"); } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java index aeb0233af4a..171bf16a972 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,7 @@ */ package com.sun.hotspot.igv.filter; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Selector; +import com.sun.hotspot.igv.graph.*; import java.util.List; /** @@ -39,25 +34,52 @@ public class SplitFilter extends AbstractFilter { private String name; private Selector selector; + private String propertyName; - public SplitFilter(String name, Selector selector) { + public SplitFilter(String name, Selector selector, String propertyName) { this.name = name; this.selector = selector; + this.propertyName = propertyName; } + @Override public String getName() { return name; } + @Override public void apply(Diagram d) { List
list = selector.selected(d); for (Figure f : list) { + + for (InputSlot is : f.getInputSlots()) { + for (Connection c : is.getConnections()) { + OutputSlot os = c.getOutputSlot(); + if (f.getSource().getSourceNodes().size() > 0) { + os.getSource().addSourceNodes(f.getSource()); + os.setAssociatedNode(f.getSource().getSourceNodes().get(0)); + os.setColor(f.getColor()); + } + + + String s = Figure.resolveString(propertyName, f.getProperties()); + if (s != null) { + os.setShortName(s); + } + + } + } for (OutputSlot os : f.getOutputSlots()) { for (Connection c : os.getConnections()) { InputSlot is = c.getInputSlot(); - is.setName(f.getProperties().get("dump_spec")); - String s = f.getProperties().get("short_name"); + if (f.getSource().getSourceNodes().size() > 0) { + is.getSource().addSourceNodes(f.getSource()); + is.setAssociatedNode(f.getSource().getSourceNodes().get(0)); + is.setColor(f.getColor()); + } + + String s = Figure.resolveString(propertyName, f.getProperties()); if (s != null) { is.setShortName(s); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java new file mode 100644 index 00000000000..d07f319e2e5 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/UnconnectedSlotFilter.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.filter; + +import com.sun.hotspot.igv.graph.*; +import java.util.ArrayList; +import java.util.List; + +/** + * Filter that hides slots with no connections. + */ +public class UnconnectedSlotFilter extends AbstractFilter { + + private final boolean removeInputs; + private final boolean removeOutputs; + + public UnconnectedSlotFilter(boolean inputs, boolean outputs) { + this.removeInputs = inputs; + this.removeOutputs = outputs; + } + + @Override + public String getName() { + return "Unconnected Slot Filter"; + } + + @Override + public void apply(Diagram d) { + if (!removeInputs && !removeOutputs) { + return; + } + + List
figures = d.getFigures(); + for (Figure f : figures) { + List remove = new ArrayList<>(); + if (removeInputs) { + for (InputSlot is : f.getInputSlots()) { + if (is.getConnections().isEmpty()) { + remove.add(is); + } + } + } + if (removeOutputs) { + for (OutputSlot os : f.getOutputSlots()) { + if (os.getConnections().isEmpty()) { + remove.add(os); + } + } + } + for (Slot s : remove) { + f.removeSlot(s); + } + } + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js index d608887dbd2..5f286eb8af7 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js @@ -21,26 +21,35 @@ * questions. * */ - + /** * * @author Thomas Wuerthinger */ - + function colorize(property, regexp, color) { var f = new ColorFilter(""); f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), color)); - f.apply(graph); + f.apply(graph); } function remove(property, regexp) { var f = new RemoveFilter(""); - f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), false, false)); + f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)))); f.apply(graph); } -function split(property, regexp) { - var f = new SplitFilter("", new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp))); +function removeIncludingOrphans(property, regexp) { + var f = new RemoveFilter(""); + f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), true)); + f.apply(graph); +} + +function split(property, regexp, propertyName) { + if (propertyName == undefined) { + propertyName = graph.getNodeText(); + } + var f = new SplitFilter("", new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), propertyName); f.apply(graph); } @@ -56,6 +65,40 @@ function removeInputs(property, regexp, from, to) { f.apply(graph); } +function removeUnconnectedSlots(inputs, outputs) { + var f = new UnconnectedSlotFilter(inputs, outputs); + f.apply(graph); +} + +function colorizeGradient(property, min, max) { + var f = new GradientColorFilter(); + f.setPropertyName(property); + f.setMinValue(min); + f.setMaxValue(max); + f.apply(graph); +} + +function colorizeGradientWithMode(property, min, max, mode) { + var f = new GradientColorFilter(); + f.setPropertyName(property); + f.setMinValue(min); + f.setMaxValue(max); + f.setMode(mode); + f.apply(graph); +} + +function colorizeGradientCustom(property, min, max, mode, colors, fractions, nshades) { + var f = new GradientColorFilter(); + f.setPropertyName(property); + f.setMinValue(min); + f.setMaxValue(max); + f.setMode(mode); + f.setColors(colors); + f.setFractions(fractions); + f.setShadeCount(nshades); + f.apply(graph); +} + var black = Color.black; var blue = Color.blue; var cyan = Color.cyan; @@ -68,4 +111,4 @@ var orange = Color.orange; var pink = Color.pink var red = Color.red; var yellow = Color.yellow; -var white = Color.white; +var white = Color.white; \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/build-impl.xml b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/build-impl.xml index 01265560daa..f769a829911 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/build-impl.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/build-impl.xml @@ -4,6 +4,13 @@ *** EDIT ../build.xml INSTEAD *** --> + + + + + + + You must set 'suite.dir' to point to your containing module suite @@ -16,13 +23,21 @@ + + + + + + + - - + + + - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties index b9832d5e596..10dcb4dd2e5 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties @@ -1,8 +1,5 @@ -build.xml.data.CRC32=401b2654 -build.xml.script.CRC32=9c158403 -build.xml.stylesheet.CRC32=79c3b980 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=401b2654 -nbproject/build-impl.xml.script.CRC32=19fb08e0 -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65 +nbproject/build-impl.xml.data.CRC32=5b8e8a60 +nbproject/build-impl.xml.script.CRC32=e4293f0e +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.xml index 7740f12aef9..d6a7375c5b9 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/project.xml @@ -43,7 +43,15 @@ - 6.6.1.1 + 6.21.1 + + + + org.openide.awt + + + + 7.39.1 @@ -51,7 +59,7 @@ - 7.5.1 + 7.18.1 @@ -59,7 +67,7 @@ - 6.12.1 + 6.34.1 @@ -67,7 +75,7 @@ - 7.3.1 + 7.46.1 @@ -75,7 +83,7 @@ - 6.7.1 + 7.20.1 @@ -83,7 +91,7 @@ - 7.2.1.1 + 7.20.1 @@ -91,7 +99,15 @@ - 7.10.1.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 @@ -99,7 +115,7 @@ - 6.18.1 + 6.39.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/Bundle.properties index c7f2ba7357f..ed4f723de2d 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/Bundle.properties @@ -1,3 +1,3 @@ OpenIDE-Module-Name=FilterWindow -CTL_FilterTopComponent=Filter Window -HINT_FilterTopComponent=This is a Filter window +CTL_FilterTopComponent=Filters +HINT_FilterTopComponent=Allows to choose active filters and modify them. diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java index 529ed09b639..d8526aafe30 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,8 +44,8 @@ public class CheckListView extends ListView { } @Override - protected JList createList() { - JList tmpList = super.createList(); + protected JList createList() { + JList tmpList = super.createList(); tmpList.setCellRenderer(new CheckRenderer(tmpList)); return tmpList; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java index 37174064ebb..a1745d6ef23 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class CheckNode extends AbstractNode { public CheckNode(Children c, Lookup lookup) { super(c, lookup); - selectionChangedEvent = new ChangedEvent(this); + selectionChangedEvent = new ChangedEvent<>(this); selected = false; enabled = true; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNodeListModel.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNodeListModel.java index 2471a864b61..ec555ef584d 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNodeListModel.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckNodeListModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ package com.sun.hotspot.igv.filterwindow; import org.openide.explorer.view.NodeListModel; -import org.openide.nodes.Node; +import org.openide.explorer.view.Visualizer; /** * @@ -32,15 +32,11 @@ import org.openide.nodes.Node; */ public class CheckNodeListModel extends NodeListModel { - private Node rootNode; - - @Override - public void setNode(Node rootNode) { - this.rootNode = rootNode; - super.setNode(rootNode); - } - public CheckNode getCheckNodeAt(int index) { - return (CheckNode) rootNode.getChildren().getNodes()[index]; + Object item = getElementAt(index); + if (item != null) { + return (CheckNode) Visualizer.findNode(item); + } + return null; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java index f8795db6b6d..dcef4e66022 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.filterwindow; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; +import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JCheckBox; @@ -37,12 +33,12 @@ import javax.swing.ListCellRenderer; /** * @author Thomas Wuerthinger */ -public class CheckRenderer extends JCheckBox implements ListCellRenderer { +public class CheckRenderer extends JCheckBox implements ListCellRenderer { - private JList list; + private JList list; private Color startBackground; - public CheckRenderer(final JList list) { + public CheckRenderer(final JList list) { this.list = list; list.addMouseListener( new MouseAdapter() { @@ -65,7 +61,8 @@ public class CheckRenderer extends JCheckBox implements ListCellRenderer { startBackground = this.getBackground(); } - public Component getListCellRendererComponent(final JList list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { + @Override + public Component getListCellRendererComponent(final JList list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index); this.setSelected(node.isSelected()); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java index f884d7a87b7..e0a049253b2 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterChainProviderImplementation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,10 +32,12 @@ import com.sun.hotspot.igv.filter.FilterChainProvider; */ public class FilterChainProviderImplementation implements FilterChainProvider { + @Override public FilterChain getFilterChain() { return FilterTopComponent.findInstance().getFilterChain(); } + @Override public FilterChain getSequence() { return FilterTopComponent.findInstance().getSequence(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java index 3cdeb4cc4c2..501b6a32b93 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,12 @@ */ package com.sun.hotspot.igv.filterwindow; +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.filter.Filter; +import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.filterwindow.actions.MoveFilterDownAction; import com.sun.hotspot.igv.filterwindow.actions.MoveFilterUpAction; import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterAction; -import com.sun.hotspot.igv.filter.Filter; -import com.sun.hotspot.igv.filter.FilterChain; -import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.util.PropertiesSheet; import javax.swing.Action; import org.openide.actions.OpenAction; @@ -48,7 +48,7 @@ import org.openide.util.lookup.InstanceContent; public class FilterNode extends CheckNode implements LookupListener, ChangedListener { private Filter filter; - private Lookup.Result result; + private Lookup.Result result; public FilterNode(Filter filter) { this(filter, new InstanceContent()); @@ -62,6 +62,7 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedList this.filter = filter; filter.getChangedEvent().addListener(new ChangedListener() { + @Override public void changed(Filter source) { update(); } @@ -69,12 +70,14 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedList update(); - Lookup.Template tpl = new Lookup.Template(FilterChain.class); + Lookup.Template tpl = new Lookup.Template<>(FilterChain.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this); resultChanged(null); + + setShortDescription("Double-click to open filter"); } private void update() { @@ -102,10 +105,12 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedList return OpenAction.get(OpenAction.class).createContextAwareInstance(Utilities.actionsGlobalContext()); } + @Override public void resultChanged(LookupEvent lookupEvent) { changed(FilterTopComponent.findInstance()); } + @Override public void changed(FilterTopComponent source) { setSelected(source.getFilterChain().containsFilter(filter)); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form index f3fc524ebe3..f6925396092 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form @@ -3,6 +3,8 @@
+ + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java index 9d374862545..d3645f8a59a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,65 +23,38 @@ */ package com.sun.hotspot.igv.filterwindow; -import com.sun.hotspot.igv.filterwindow.actions.MoveFilterDownAction; -import com.sun.hotspot.igv.filterwindow.actions.MoveFilterUpAction; -import com.sun.hotspot.igv.filterwindow.actions.NewFilterAction; -import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterAction; -import com.sun.hotspot.igv.filterwindow.actions.RemoveFilterSettingsAction; -import com.sun.hotspot.igv.filterwindow.actions.SaveFilterSettingsAction; +import com.sun.hotspot.igv.data.ChangedEvent; +import com.sun.hotspot.igv.data.ChangedListener; import com.sun.hotspot.igv.filter.CustomFilter; import com.sun.hotspot.igv.filter.Filter; import com.sun.hotspot.igv.filter.FilterChain; import com.sun.hotspot.igv.filter.FilterSetting; -import com.sun.hotspot.igv.data.ChangedEvent; -import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.filterwindow.actions.*; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.io.*; +import java.util.*; import javax.swing.JComboBox; import javax.swing.UIManager; import javax.swing.border.Border; import org.openide.DialogDisplayer; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; +import org.openide.awt.Toolbar; import org.openide.awt.ToolbarPool; import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerUtils; +import org.openide.filesystems.FileLock; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; -import org.openide.util.Exceptions; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.awt.Toolbar; -import org.openide.filesystems.FileLock; +import org.openide.util.*; import org.openide.util.actions.SystemAction; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; -import org.openide.filesystems.Repository; -import org.openide.filesystems.FileSystem; -import org.openide.filesystems.FileObject; /** * @@ -98,13 +71,14 @@ public final class FilterTopComponent extends TopComponent implements LookupList private ExplorerManager manager; private FilterChain filterChain; private FilterChain sequence; - private Lookup.Result result; + private Lookup.Result result; private JComboBox comboBox; private List filterSettings; private FilterSetting customFilterSetting = new FilterSetting("-- Custom --"); private ChangedEvent filterSettingsChangedEvent; private ActionListener comboBoxActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { comboBoxSelectionChanged(); } @@ -139,8 +113,8 @@ public final class FilterTopComponent extends TopComponent implements LookupList if (s != customFilterSetting) { FilterChain chain = getFilterChain(); - chain.beginAtomic(); - List toRemove = new ArrayList(); + chain.getChangedEvent().beginAtomic(); + List toRemove = new ArrayList<>(); for (Filter f : chain.getFilters()) { if (!s.containsFilter(f)) { toRemove.add(f); @@ -156,7 +130,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList } } - chain.endAtomic(); + chain.getChangedEvent().endAtomic(); filterSettingsChangedEvent.fire(); } else { this.updateComboBoxSelection(); @@ -177,14 +151,14 @@ public final class FilterTopComponent extends TopComponent implements LookupList } public void addFilterSetting() { - NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter"); + NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Name of the new profile:", "Filter Profile"); if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) { String name = l.getInputText(); FilterSetting toRemove = null; for (FilterSetting s : filterSettings) { if (s.getName().equals(name)) { - NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter"); + NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter profile \"" + name + "\" already exists, do you want to replace it?", "Filter"); if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) { toRemove = s; break; @@ -203,6 +177,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList // Sort alphabetically Collections.sort(filterSettings, new Comparator() { + @Override public int compare(FilterSetting o1, FilterSetting o2) { return o1.getName().compareTo(o2.getName()); } @@ -223,7 +198,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList FilterSetting f = (FilterSetting) o; assert f != customFilterSetting; assert filterSettings.contains(f); - NotifyDescriptor.Confirmation l = new NotifyDescriptor.Confirmation("Do you really want to remove filter \"" + f + "\"?", "Filter"); + NotifyDescriptor.Confirmation l = new NotifyDescriptor.Confirmation("Do you really want to remove filter profile \"" + f + "\"?", "Filter Profile"); if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.YES_OPTION) { filterSettings.remove(f); updateComboBox(); @@ -267,28 +242,26 @@ public final class FilterTopComponent extends TopComponent implements LookupList } } - private class FilterChildren extends Children.Keys implements ChangedListener { + private class FilterChildren extends Children.Keys implements ChangedListener { - //private Node[] oldSelection; - //private ArrayList newSelection; - private HashMap nodeHash = new HashMap(); + private HashMap nodeHash = new HashMap<>(); - protected Node[] createNodes(Object object) { - if (nodeHash.containsKey(object)) { - return new Node[]{nodeHash.get(object)}; + @Override + protected Node[] createNodes(Filter filter) { + if (nodeHash.containsKey(filter)) { + return new Node[]{nodeHash.get(filter)}; } - assert object instanceof Filter; - Filter filter = (Filter) object; - com.sun.hotspot.igv.filterwindow.FilterNode node = new com.sun.hotspot.igv.filterwindow.FilterNode(filter); + FilterNode node = new FilterNode(filter); node.getSelectionChangedEvent().addListener(this); - nodeHash.put(object, node); + nodeHash.put(filter, node); return new Node[]{node}; } public FilterChildren() { sequence.getChangedEvent().addListener(new ChangedListener() { + @Override public void changed(FilterChain source) { addNotify(); } @@ -297,11 +270,13 @@ public final class FilterTopComponent extends TopComponent implements LookupList setBefore(false); } + @Override protected void addNotify() { setKeys(sequence.getFilters()); updateSelection(); } + @Override public void changed(CheckNode source) { FilterNode node = (FilterNode) source; Filter f = node.getFilter(); @@ -322,16 +297,11 @@ public final class FilterTopComponent extends TopComponent implements LookupList } public FilterChain getFilterChain() { - return filterChain;/* - EditorTopComponent tc = EditorTopComponent.getActive(); - if (tc == null) { - return filterChain; - } - return tc.getFilterChain();*/ + return filterChain; } private FilterTopComponent() { - filterSettingsChangedEvent = new ChangedEvent(this); + filterSettingsChangedEvent = new ChangedEvent<>(this); initComponents(); setName(NbBundle.getMessage(FilterTopComponent.class, "CTL_FilterTopComponent")); setToolTipText(NbBundle.getMessage(FilterTopComponent.class, "HINT_FilterTopComponent")); @@ -355,13 +325,13 @@ public final class FilterTopComponent extends TopComponent implements LookupList toolBar.add(SaveFilterSettingsAction.get(SaveFilterSettingsAction.class)); toolBar.add(RemoveFilterSettingsAction.get(RemoveFilterSettingsAction.class)); toolBar.addSeparator(); + toolBar.add(NewFilterAction.get(NewFilterAction.class)); + toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup())); toolBar.add(MoveFilterUpAction.get(MoveFilterUpAction.class).createContextAwareInstance(this.getLookup())); toolBar.add(MoveFilterDownAction.get(MoveFilterDownAction.class).createContextAwareInstance(this.getLookup())); - toolBar.add(RemoveFilterAction.get(RemoveFilterAction.class).createContextAwareInstance(this.getLookup())); - toolBar.add(NewFilterAction.get(NewFilterAction.class)); this.add(view, BorderLayout.CENTER); - filterSettings = new ArrayList(); + filterSettings = new ArrayList<>(); updateComboBox(); comboBox.addActionListener(comboBoxActionListener); @@ -401,6 +371,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList filter = cf; } + @Override public void changed(Filter source) { try { if (!fileObject.getName().equals(filter.getName())) { @@ -409,15 +380,14 @@ public final class FilterTopComponent extends TopComponent implements LookupList lock.releaseLock(); FileObject newFileObject = fileObject.getParent().getFileObject(filter.getName()); fileObject = newFileObject; - } FileLock lock = fileObject.lock(); OutputStream os = fileObject.getOutputStream(lock); - Writer w = new OutputStreamWriter(os); - String s = filter.getCode(); - w.write(s); - w.close(); + try (Writer w = new OutputStreamWriter(os)) { + String s = filter.getCode(); + w.write(s); + } lock.releaseLock(); } catch (IOException ex) { @@ -427,15 +397,13 @@ public final class FilterTopComponent extends TopComponent implements LookupList } public void initFilters() { - - FileSystem fs = Repository.getDefault().getDefaultFileSystem(); - FileObject folder = fs.getRoot().getFileObject(FOLDER_ID); + FileObject folder = FileUtil.getConfigRoot().getFileObject(FOLDER_ID); FileObject[] children = folder.getChildren(); - List customFilters = new ArrayList(); - HashMap afterMap = new HashMap(); - Set enabledSet = new HashSet(); - HashMap map = new HashMap(); + List customFilters = new ArrayList<>(); + HashMap afterMap = new HashMap<>(); + Set enabledSet = new HashSet<>(); + HashMap map = new HashMap<>(); for (final FileObject fo : children) { InputStream is = null; @@ -447,13 +415,12 @@ public final class FilterTopComponent extends TopComponent implements LookupList is = fo.getInputStream(); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String s; - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); while ((s = r.readLine()) != null) { sb.append(s); sb.append("\n"); } code = sb.toString(); - } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { @@ -488,7 +455,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList for (int j = 0; j < customFilters.size(); j++) { for (int i = 0; i < customFilters.size(); i++) { - List copiedList = new ArrayList(customFilters); + List copiedList = new ArrayList<>(customFilters); for (CustomFilter cf : copiedList) { String after = afterMap.get(cf); @@ -573,7 +540,7 @@ public final class FilterTopComponent extends TopComponent implements LookupList @Override public void componentOpened() { - Lookup.Template tpl = new Lookup.Template(FilterChain.class); + Lookup.Template tpl = new Lookup.Template<>(FilterChain.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -584,13 +551,9 @@ public final class FilterTopComponent extends TopComponent implements LookupList result = null; } + @Override public void resultChanged(LookupEvent lookupEvent) { setChain(Utilities.actionsGlobalContext().lookup(FilterChain.class)); - /* - EditorTopComponent tc = EditorTopComponent.getActive(); - if (tc != null) { - setChain(tc.getFilterChain()); - }*/ } public void setChain(FilterChain chain) { @@ -598,10 +561,10 @@ public final class FilterTopComponent extends TopComponent implements LookupList } private FileObject getFileObject(CustomFilter cf) { - FileObject fo = Repository.getDefault().getDefaultFileSystem().getRoot().getFileObject(FOLDER_ID + "/" + cf.getName()); + FileObject fo = FileUtil.getConfigRoot().getFileObject(FOLDER_ID + "/" + cf.getName()); if (fo == null) { try { - fo = org.openide.filesystems.Repository.getDefault().getDefaultFileSystem().getRoot().getFileObject(FOLDER_ID).createData(cf.getName()); + fo = FileUtil.getConfigRoot().getFileObject(FOLDER_ID).createData(cf.getName()); } catch (IOException ex) { Exceptions.printStackTrace(ex); } @@ -609,6 +572,24 @@ public final class FilterTopComponent extends TopComponent implements LookupList return fo; } + @Override + public boolean requestFocus(boolean temporary) { + view.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + view.requestFocus(); + return super.requestFocusInWindow(temporary); + } + + @Override + public void requestActive() { + super.requestActive(); + view.requestFocus(); + } + @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties index 8cf238dc8c3..5a24e74e2f6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties @@ -1,10 +1,7 @@ -# To change this template, choose Tools | Templates -# and open the template in the editor. - -CTL_FilterAction=Open Filter Window -CTL_MoveFilterDownAction=Move downwards +CTL_FilterAction=Filters CTL_MoveFilterUpAction=Move upwards -CTL_NewFilterAction=New filter... +CTL_MoveFilterDownAction=Move downwards CTL_RemoveFilterAction=Remove CTL_RemoveFilterSettingsAction=Remove filter setting -CTL_SaveFilterSettingsAction=Save filter settings... +CTL_SaveFilterSettingsAction=Create filter profile... +CTL_NewFilterAction=New filter... diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java index ce71c34d7d6..41561050aa6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/FilterAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ */ package com.sun.hotspot.igv.filterwindow.actions; -import com.sun.hotspot.igv.filterwindow.*; +import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import org.openide.util.NbBundle; @@ -39,6 +39,7 @@ public class FilterAction extends AbstractAction { super(NbBundle.getMessage(FilterAction.class, "CTL_FilterAction")); } + @Override public void actionPerformed(ActionEvent evt) { TopComponent win = FilterTopComponent.findInstance(); win.open(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java index 5659b9b7d68..df994346e27 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterDownAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; -import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import com.sun.hotspot.igv.filter.Filter; +import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -37,6 +37,7 @@ import org.openide.util.actions.CookieAction; */ public final class MoveFilterDownAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { Filter c = n.getLookup().lookup(Filter.class); @@ -44,19 +45,22 @@ public final class MoveFilterDownAction extends CookieAction { } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } public MoveFilterDownAction() { - putValue(Action.SHORT_DESCRIPTION, "Move filter downwards"); + putValue(Action.SHORT_DESCRIPTION, "Move selected filter downwards"); } + @Override public String getName() { return NbBundle.getMessage(MoveFilterUpAction.class, "CTL_MoveFilterDownAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -65,7 +69,7 @@ public final class MoveFilterDownAction extends CookieAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/down.gif"; + return "com/sun/hotspot/igv/filterwindow/images/down.png"; } @Override @@ -74,6 +78,7 @@ public final class MoveFilterDownAction extends CookieAction { putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java index 6be45cab0e0..ce5c5e71181 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/MoveFilterUpAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; -import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import com.sun.hotspot.igv.filter.Filter; +import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import javax.swing.Action; import org.openide.nodes.Node; import org.openide.util.HelpCtx; @@ -37,6 +37,7 @@ import org.openide.util.actions.CookieAction; */ public final class MoveFilterUpAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { for (Node n : activatedNodes) { Filter c = n.getLookup().lookup(Filter.class); @@ -44,18 +45,21 @@ public final class MoveFilterUpAction extends CookieAction { } } + @Override protected int mode() { return CookieAction.MODE_EXACTLY_ONE; } public MoveFilterUpAction() { - putValue(Action.SHORT_DESCRIPTION, "Move filter upwards"); + putValue(Action.SHORT_DESCRIPTION, "Move selected filter upwards"); } + @Override public String getName() { return NbBundle.getMessage(MoveFilterUpAction.class, "CTL_MoveFilterUpAction"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -64,7 +68,7 @@ public final class MoveFilterUpAction extends CookieAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/up.gif"; + return "com/sun/hotspot/igv/filterwindow/images/up.png"; } @Override @@ -73,6 +77,7 @@ public final class MoveFilterUpAction extends CookieAction { putValue("noIconInMenu", Boolean.TRUE); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java index 751eade98ff..17b0cdc0bc1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/NewFilterAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,10 +39,12 @@ public final class NewFilterAction extends CallableSystemAction { putValue(Action.SHORT_DESCRIPTION, "Create new filter"); } + @Override public void performAction() { FilterTopComponent.findInstance().newFilter(); } + @Override public String getName() { return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_NewFilterAction"); } @@ -52,6 +54,7 @@ public final class NewFilterAction extends CallableSystemAction { super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -63,6 +66,6 @@ public final class NewFilterAction extends CallableSystemAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/plus.gif"; + return "com/sun/hotspot/igv/filterwindow/images/plus.png"; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java index 85f5990a0bb..42d569b5342 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ */ package com.sun.hotspot.igv.filterwindow.actions; -import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import com.sun.hotspot.igv.filter.Filter; +import com.sun.hotspot.igv.filterwindow.FilterTopComponent; import javax.swing.Action; import javax.swing.JOptionPane; import org.openide.nodes.Node; @@ -39,13 +39,14 @@ import org.openide.windows.WindowManager; */ public final class RemoveFilterAction extends CookieAction { + @Override protected void performAction(Node[] activatedNodes) { Object[] options = {"Yes", "No", "Cancel" }; int n = JOptionPane.showOptionDialog(WindowManager.getDefault().getMainWindow(), - "Do you really want to delete " + activatedNodes.length + " filter/s?", "Delete?", + "Do you really want to delete " + activatedNodes.length + " filter(s)?", "Delete Filters", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, @@ -59,18 +60,21 @@ public final class RemoveFilterAction extends CookieAction { } } + @Override protected int mode() { return CookieAction.MODE_ALL; } + @Override public String getName() { return NbBundle.getMessage(RemoveFilterAction.class, "CTL_RemoveFilterAction"); } public RemoveFilterAction() { - putValue(Action.SHORT_DESCRIPTION, "Remove filter"); + putValue(Action.SHORT_DESCRIPTION, "Remove selected filter"); } + @Override protected Class[] cookieClasses() { return new Class[]{ Filter.class @@ -85,9 +89,10 @@ public final class RemoveFilterAction extends CookieAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/minus.gif"; + return "com/sun/hotspot/igv/filterwindow/images/minus.png"; } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java index 953848a9630..9f7f2ae86ef 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/RemoveFilterSettingsAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,16 +35,18 @@ import org.openide.util.actions.CallableSystemAction; */ public final class RemoveFilterSettingsAction extends CallableSystemAction { + @Override public void performAction() { FilterTopComponent.findInstance().removeFilterSetting(); } + @Override public String getName() { return NbBundle.getMessage(RemoveFilterSettingsAction.class, "CTL_RemoveFilterSettingsAction"); } public RemoveFilterSettingsAction() { - putValue(Action.SHORT_DESCRIPTION, "Remove filter profile"); + putValue(Action.SHORT_DESCRIPTION, "Delete current filter profile"); } @Override @@ -52,6 +54,7 @@ public final class RemoveFilterSettingsAction extends CallableSystemAction { super.initialize(); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -63,6 +66,6 @@ public final class RemoveFilterSettingsAction extends CallableSystemAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/delete.gif"; + return "com/sun/hotspot/igv/filterwindow/images/delete.png"; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java index 18dc5c8cbab..054802f3a70 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/SaveFilterSettingsAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,10 +35,12 @@ import org.openide.util.actions.CallableSystemAction; */ public final class SaveFilterSettingsAction extends CallableSystemAction { + @Override public void performAction() { FilterTopComponent.findInstance().addFilterSetting(); } + @Override public String getName() { return NbBundle.getMessage(SaveFilterSettingsAction.class, "CTL_SaveFilterSettingsAction"); } @@ -49,9 +51,10 @@ public final class SaveFilterSettingsAction extends CallableSystemAction { } public SaveFilterSettingsAction() { - putValue(Action.SHORT_DESCRIPTION, "Create new filter profile"); + putValue(Action.SHORT_DESCRIPTION, "Save filter configuration as profile..."); } + @Override public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } @@ -63,6 +66,6 @@ public final class SaveFilterSettingsAction extends CallableSystemAction { @Override protected String iconResource() { - return "com/sun/hotspot/igv/filterwindow/images/add.gif"; + return "com/sun/hotspot/igv/filterwindow/images/add.png"; } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/customRightTopWsmode.xml b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/customRightTopWsmode.xml index ca1b2772e89..b63c1d5d5d7 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/customRightTopWsmode.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/customRightTopWsmode.xml @@ -4,8 +4,8 @@ - - + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.gif deleted file mode 100644 index 0fc47e193cf..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.png new file mode 100644 index 00000000000..802bd6cde02 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/add.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.gif deleted file mode 100644 index 3f83fce4b9a..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.png new file mode 100644 index 00000000000..cce652e845c Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/delete.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.gif deleted file mode 100644 index 6123422ddde..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.png new file mode 100644 index 00000000000..6c24e0092c2 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/down.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.gif deleted file mode 100644 index ba0d281cf90..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.png new file mode 100644 index 00000000000..9e980e4de3d Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/minus.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.gif deleted file mode 100644 index 5e2274da3fc..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.png new file mode 100644 index 00000000000..0cdcfaccacb Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/plus.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.gif b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.gif deleted file mode 100644 index 277f5bb492b..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.png b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.png new file mode 100644 index 00000000000..365ebd5e347 Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/images/up.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml index 8d1367e773a..319376b4d5b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml @@ -18,8 +18,11 @@ - - + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/build.xml similarity index 81% rename from hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml rename to hotspot/src/share/tools/IdealGraphVisualizer/Graal/build.xml index dfdd0922316..8011dca6c8f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/build.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/build.xml @@ -2,7 +2,7 @@ - - Builds, tests, and runs the project com.sun.hotspot.igv.rhino. + + Builds, tests, and runs the project com.sun.hotspot.igv.graal. diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/manifest.mf new file mode 100644 index 00000000000..2dcb25e6cc3 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.graal +OpenIDE-Module-Layer: com/sun/hotspot/igv/graal/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graal/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml similarity index 51% rename from hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml rename to hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml index d627b3a01c1..3f27701c7ae 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/build-impl.xml @@ -3,7 +3,14 @@ *** GENERATED FROM project.xml - DO NOT EDIT *** *** EDIT ../build.xml INSTEAD *** --> - + + + + + + + + You must set 'suite.dir' to point to your containing module suite @@ -16,13 +23,21 @@ + + + + + + + - - + + + - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties new file mode 100644 index 00000000000..3ae068e841f --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=92ea213f +build.xml.script.CRC32=3534d355 +build.xml.stylesheet.CRC32=a56c6a5b@2.67.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=92ea213f +nbproject/build-impl.xml.script.CRC32=2867f2d5 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties similarity index 68% rename from hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties rename to hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml similarity index 56% rename from hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml rename to hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml index 1f9e5814f48..b082f586940 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/project.xml @@ -1,31 +1,45 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.rhino - - - - com.sun.hotspot.igv.filter - - - - 1.0 - - - - com.sun.hotspot.igv.graph - - - - 1.0 - - - - - com.sun.hotspot.igv.rhino - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.graal + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.filter + + + + 1.0 + + + + com.sun.hotspot.igv.layout + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/suite.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/suite.properties similarity index 100% rename from hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/suite.properties rename to hotspot/src/share/tools/IdealGraphVisualizer/Graal/nbproject/suite.properties diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/Bundle.properties new file mode 100644 index 00000000000..e66b3a18bd2 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=Graal Compiler Support diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java new file mode 100644 index 00000000000..b691e31c3df --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalCFGFilter.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.graal.filters; + +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.filter.AbstractFilter; +import com.sun.hotspot.igv.graph.Connection; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import com.sun.hotspot.igv.graph.InputSlot; +import com.sun.hotspot.igv.graph.OutputSlot; +import java.util.HashSet; +import java.util.Set; + +public class GraalCFGFilter extends AbstractFilter { + + @Override + public String getName() { + return "Graal CFG Filter"; + } + + @Override + public void apply(Diagram d) { + Set connectionsToRemove = new HashSet<>(); + + for (Figure f : d.getFigures()) { + Properties p = f.getProperties(); + int predCount; + String predCountString = p.get("predecessorCount"); + if (predCountString != null) { + predCount = Integer.parseInt(predCountString); + } else if (Boolean.parseBoolean(p.get("hasPredecessor"))) { + predCount = 1; + } else { + predCount = 0; + } + for (InputSlot is : f.getInputSlots()) { + if (is.getPosition() >= predCount && !"EndNode".equals(is.getProperties().get("class"))) { + for (Connection c : is.getConnections()) { + if (!"EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class"))) { + connectionsToRemove.add(c); + } + } + } + } + } + + for (Connection c : connectionsToRemove) { + c.remove(); + } + + Set
figuresToRemove = new HashSet<>(); + next: for (Figure f : d.getFigures()) { + for (InputSlot is : f.getInputSlots()) { + if (!is.getConnections().isEmpty()) { + continue next; + } + } + for (OutputSlot os : f.getOutputSlots()) { + if (!os.getConnections().isEmpty()) { + continue next; + } + } + figuresToRemove.add(f); + } + d.removeAllFigures(figuresToRemove); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java new file mode 100644 index 00000000000..0d5966b6441 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalColoringFilter.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.graal.filters; + +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.filter.AbstractFilter; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import java.awt.Color; +import java.util.List; + +public class GraalColoringFilter extends AbstractFilter { + + private String colorName; + + public GraalColoringFilter(String colorName) { + this.colorName = colorName; + } + + @Override + public String getName() { + return "Graal Coloring Filter (" + colorName + ")"; + } + + @Override + public void apply(Diagram d) { + List
figures = d.getFigures(); + int colors = 0; + for (Figure f : figures) { + Properties p = f.getProperties(); + final String prop = p.get(colorName + "Color"); + if (prop == null) { + continue; + } + try { + int color = Integer.parseInt(prop); + if (color > colors) { + colors = color; + } + } catch (NumberFormatException nfe) { + // nothing to do + } + } + colors++; + for (Figure f : figures) { + Properties p = f.getProperties(); + final String prop = p.get(colorName + "Color"); + if (prop == null) { + continue; + } + try { + int color = Integer.parseInt(prop); + Color c = Color.getHSBColor((float) color / colors, 1.0f, 0.7f); + f.setColor(c); + } catch (NumberFormatException nfe) { + // nothing to do + } + } + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java new file mode 100644 index 00000000000..1693a3ec57e --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.graal.filters; + +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.filter.AbstractFilter; +import com.sun.hotspot.igv.graph.Connection; +import com.sun.hotspot.igv.graph.Connection.ConnectionStyle; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import com.sun.hotspot.igv.graph.InputSlot; +import java.awt.Color; +import java.util.HashMap; +import java.util.List; + +/** + * Filter that colors usage and successor edges differently. + * + * @author Peter Hofer + */ +public class GraalEdgeColorFilter extends AbstractFilter { + + private final HashMap usageColor = new HashMap<>(); + private Color otherUsageColor = Color.BLACK; + + public GraalEdgeColorFilter() { + } + + @Override + public String getName() { + return "Graal Edge Color Filter"; + } + + @Override + public void apply(Diagram d) { + List
figures = d.getFigures(); + for (Figure f : figures) { + for (InputSlot is : f.getInputSlots()) { + for (Connection c : is.getConnections()) { + String type = c.getType(); + if (type == "Association" && "EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class"))) { + type = "Successor"; + } + + if (type != null) { + Color typeColor = usageColor.get(type); + if (typeColor == null) { + c.setColor(otherUsageColor); + } else { + c.setColor(typeColor); + } + if (c.getStyle() != ConnectionStyle.DASHED && type == "Successor") { + c.setStyle(ConnectionStyle.BOLD); + } + } + } + } + } + } + + public Color getUsageColor(String type) { + return usageColor.get(type); + } + + public void setUsageColor(String type, Color usageColor) { + this.usageColor.put(type, usageColor); + } + + public Color getOtherUsageColor() { + return otherUsageColor; + } + + public void setOtherUsageColor(Color otherUsageColor) { + this.otherUsageColor = otherUsageColor; + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/callgraph.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/callgraph.filter new file mode 100644 index 00000000000..5ae00a29881 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/callgraph.filter @@ -0,0 +1,4 @@ +colorize("name", ".*", yellow); +colorize("name", ".*", pink); +colorize("leaf", "1", lightGray); +colorize("cutoff", "1", red); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/color.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/color.filter new file mode 100644 index 00000000000..90f16bee24b --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/color.filter @@ -0,0 +1,31 @@ +var red = new java.awt.Color(240, 59, 32); +var orange = new java.awt.Color(254, 178, 76); +var yellow = new java.awt.Color(255, 237, 160); +var middleBlue = new java.awt.Color(100, 147, 224); +var lightGreen = new java.awt.Color(173, 221, 142); +var lightBlue = new java.awt.Color(200, 200, 250); +var gray = new java.awt.Color(220, 220, 220); +var violet = new java.awt.Color(201, 148, 199); +var black = new java.awt.Color(0, 0, 0); + +colorize("category", "controlSink", red); +colorize("category", "controlSplit", red); +colorize("category", "merge", red); +colorize("category", "begin", orange); +colorize("category", "end", orange); +colorize("category", "fixed", yellow); +colorize("category", "state", lightGreen); +colorize("category", "phi", middleBlue); +colorize("category", "proxy", middleBlue); +colorize("category", "floating", lightBlue); +colorize("class", "ConstantLocationNode", gray); +colorize("class", "ParameterNode", gray); +colorize("class", "ConstantNode", gray); +colorize("class", "GuardNode", violet); +colorize("class", "BlackholeNode", black); + +var f = new com.sun.hotspot.igv.graal.filters.GraalEdgeColorFilter(); +f.setUsageColor("Successor", red); +f.setUsageColor("Value", blue); +f.setUsageColor("Memory", new Color(0.0, 0.5, 0.0)); +f.apply(graph); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/probability.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/probability.filter new file mode 100644 index 00000000000..72ec0a306bc --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/probability.filter @@ -0,0 +1,3 @@ +colorizeGradientWithMode("probability", 0, 500, "logarithmic"); + +// more parameters: colorizeGradientCustom("probability", 0, 500, "logarithmic", [blue, yellow, red], [0, 0.5, 1], 16); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/reduceEdges.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/reduceEdges.filter new file mode 100644 index 00000000000..59a1f8f6f62 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/reduceEdges.filter @@ -0,0 +1,3 @@ +split("class", "ConstantLocationNode"); +split("class", "ParameterNode"); +split("class", "ConstantNode"); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeFloating.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeFloating.filter new file mode 100644 index 00000000000..253befbeef4 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeFloating.filter @@ -0,0 +1,4 @@ +remove("category", "floating"); +remove("category", "state"); +remove("category", "phi"); +remove("category", "proxy"); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeState.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeState.filter new file mode 100644 index 00000000000..5990b13b19f --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/removeState.filter @@ -0,0 +1 @@ +remove("category", "state"); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/stampColor.filter b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/stampColor.filter new file mode 100644 index 00000000000..462eeb8d6e4 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/stampColor.filter @@ -0,0 +1,16 @@ +var red = new java.awt.Color(240, 59, 32); +var orange = new java.awt.Color(254, 178, 76); +var yellow = new java.awt.Color(255, 237, 160); +var middleBlue = new java.awt.Color(100, 147, 224); +var lightGreen = new java.awt.Color(173, 221, 142); +var lightBlue = new java.awt.Color(200, 200, 250); +var gray = new java.awt.Color(220, 220, 220); +var violet = new java.awt.Color(201, 148, 199); + +colorize("stamp", ".*", white); +colorize("stamp", "void", gray); +colorize("stamp", "a.*", yellow); +colorize("stamp", "a#.*", orange); +colorize("stamp", "a!.*", red); +colorize("stamp", "i.*", middleBlue); +colorize("stamp", "f.*", lightGreen); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/layer.xml new file mode 100644 index 00000000000..714e4884007 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/layer.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml index c8fbe3c294f..7e3f062052b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml @@ -25,6 +25,7 @@ com.sun.hotspot.igv.graph + com.sun.hotspot.igv.graph.services diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java index fcb1b47b090..eba645e11ce 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/AndSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,10 +40,11 @@ public class AndSelector implements Selector { this.selector2 = s2; } + @Override public List
selected(Diagram d) { List
l1 = selector1.selected(d); List
l2 = selector2.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : l2) { if (l1.contains(f)) { result.add(f); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java index 058fef4e316..a853f5854fd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,14 +60,6 @@ public class Block implements Cluster { return succs; } - public Set getPredecessors() { - Set succs = new HashSet(); - for (InputBlock b : inputBlock.getPredecessors()) { - succs.add(diagram.getBlock(b)); - } - return succs; - } - public void setBounds(Rectangle r) { this.bounds = r; } @@ -79,4 +71,10 @@ public class Block implements Cluster { public int compareTo(Cluster o) { return toString().compareTo(o.toString()); } + + @Override + public String toString() { + return inputBlock.getName(); + } } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java index 887059af2a0..3a7498f74c1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Link; import com.sun.hotspot.igv.layout.Port; import java.awt.Color; @@ -36,6 +37,11 @@ import java.util.List; */ public class Connection implements Source.Provider, Link { + @Override + public boolean isVIP() { + return style == ConnectionStyle.BOLD; + } + public enum ConnectionStyle { NORMAL, @@ -48,13 +54,17 @@ public class Connection implements Source.Provider, Link { private Color color; private ConnectionStyle style; private List controlPoints; + private String label; + private String type; - protected Connection(InputSlot inputSlot, OutputSlot outputSlot) { + protected Connection(InputSlot inputSlot, OutputSlot outputSlot, String label, String type) { this.inputSlot = inputSlot; this.outputSlot = outputSlot; + this.label = label; + this.type = type; this.inputSlot.connections.add(this); this.outputSlot.connections.add(this); - controlPoints = new ArrayList(); + controlPoints = new ArrayList<>(); Figure sourceFigure = this.outputSlot.getFigure(); Figure destFigure = this.inputSlot.getFigure(); sourceFigure.addSuccessor(destFigure); @@ -89,10 +99,19 @@ public class Connection implements Source.Provider, Link { style = s; } + @Override public Source getSource() { return source; } + public String getLabel() { + return label; + } + + public String getType() { + return type; + } + public void remove() { inputSlot.getFigure().removePredecessor(outputSlot.getFigure()); inputSlot.connections.remove(this); @@ -100,24 +119,44 @@ public class Connection implements Source.Provider, Link { outputSlot.connections.remove(this); } - @Override - public String toString() { - return "Connection(" + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; + public String getToolTipText() { + StringBuilder builder = new StringBuilder(); + if (label != null) { + builder.append(label).append(": "); + } + if (type != null) { + builder.append(type).append(" "); + } + builder.append("from "); + builder.append(getOutputSlot().getFigure().getSource().getSourceNodes().get(0).getId()); + builder.append(" to "); + builder.append(getInputSlot().getFigure().getSource().getSourceNodes().get(0).getId()); + return builder.toString(); } + @Override + public String toString() { + return "Connection('" + label + "', " + getFrom().getVertex() + " to " + getTo().getVertex() + ")"; + } + + @Override public Port getFrom() { return outputSlot; } + @Override public Port getTo() { return inputSlot; } + @Override public List getControlPoints() { return controlPoints; } + @Override public void setControlPoints(List list) { controlPoints = list; } } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java index 8d47b88eb57..eb1e8702051 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,17 +28,9 @@ import com.sun.hotspot.igv.data.InputEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; import java.awt.Font; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @@ -51,20 +43,33 @@ public class Diagram { private InputGraph graph; private int curId; private String nodeText; - private Font font; + private final Font font; + private final Font slotFont; + private final Font boldFont; public Font getFont() { return font; } + public Font getSlotFont() { + return slotFont; + } + + public Font getBoldFont() { + return boldFont; + } + private Diagram() { - figures = new ArrayList
(); - blocks = new HashMap(); + figures = new ArrayList<>(); + blocks = new LinkedHashMap<>(8); this.nodeText = ""; - this.font = new Font("Serif", Font.PLAIN, 14); + this.font = new Font("Arial", Font.PLAIN, 12); + this.slotFont = new Font("Arial", Font.PLAIN, 10); + this.boldFont = this.font.deriveFont(Font.BOLD); } public Block getBlock(InputBlock b) { + assert blocks.containsKey(b); return blocks.get(b); } @@ -72,12 +77,7 @@ public class Diagram { return nodeText; } - public void schedule(Collection newBlocks) { - graph.schedule(newBlocks); - updateBlocks(); - } - - private void updateBlocks() { + public void updateBlocks() { blocks.clear(); for (InputBlock b : graph.getBlocks()) { Block curBlock = new Block(b, this); @@ -108,10 +108,26 @@ public class Diagram { return f; } - public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot) { + public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot, String label, String type) { assert inputSlot.getFigure().getDiagram() == this; assert outputSlot.getFigure().getDiagram() == this; - return new Connection(inputSlot, outputSlot); + return new Connection(inputSlot, outputSlot, label, type); + } + + public Map> calcSourceToFigureRelation() { + Map> map = new HashMap<>(); + + for(InputNode node : this.getGraph().getNodes()) { + map.put(node, new HashSet
()); + } + + for(Figure f : this.getFigures()) { + for(InputNode node : f.getSource().getSourceNodes()) { + map.get(node).add(f); + } + } + + return map; } public static Diagram createDiagram(InputGraph graph, String nodeText) { @@ -126,11 +142,12 @@ public class Diagram { d.updateBlocks(); Collection nodes = graph.getNodes(); - HashMap figureHash = new HashMap(); + Hashtable figureHash = new Hashtable<>(); for (InputNode n : nodes) { Figure f = d.createFigure(); f.getSource().addSourceNode(n); f.getProperties().add(n.getProperties()); + f.setSubgraphs(n.getSubgraphs()); figureHash.put(n.getId(), f); } @@ -140,23 +157,23 @@ public class Diagram { int to = e.getTo(); Figure fromFigure = figureHash.get(from); Figure toFigure = figureHash.get(to); + + if(fromFigure == null || toFigure == null) continue; assert fromFigure != null && toFigure != null; - int toIndex = e.getToIndex(); - - while (fromFigure.getOutputSlots().size() <= 0) { + int fromIndex = e.getFromIndex(); + while (fromFigure.getOutputSlots().size() <= fromIndex) { fromFigure.createOutputSlot(); } + OutputSlot outputSlot = fromFigure.getOutputSlots().get(fromIndex); - OutputSlot outputSlot = fromFigure.getOutputSlots().get(0); - + int toIndex = e.getToIndex(); while (toFigure.getInputSlots().size() <= toIndex) { toFigure.createInputSlot(); } - InputSlot inputSlot = toFigure.getInputSlots().get(toIndex); - Connection c = d.createConnection(inputSlot, outputSlot); + Connection c = d.createConnection(inputSlot, outputSlot, e.getLabel(), e.getType()); if (e.getState() == InputEdge.State.NEW) { c.setStyle(Connection.ConnectionStyle.BOLD); @@ -174,7 +191,7 @@ public class Diagram { freeFigure(f); } - ArrayList
newFigures = new ArrayList
(); + ArrayList
newFigures = new ArrayList<>(); for (Figure f : this.figures) { if (!figuresToRemove.contains(f)) { newFigures.add(f); @@ -185,12 +202,12 @@ public class Diagram { private void freeFigure(Figure succ) { - List inputSlots = new ArrayList(succ.getInputSlots()); + List inputSlots = new ArrayList<>(succ.getInputSlots()); for (InputSlot s : inputSlots) { succ.removeInputSlot(s); } - List outputSlots = new ArrayList(succ.getOutputSlots()); + List outputSlots = new ArrayList<>(succ.getOutputSlots()); for (OutputSlot s : outputSlots) { succ.removeOutputSlot(s); } @@ -219,7 +236,7 @@ public class Diagram { public Set getConnections() { - Set connections = new HashSet(); + Set connections = new HashSet<>(); for (Figure f : figures) { for (InputSlot s : f.getInputSlots()) { @@ -231,10 +248,10 @@ public class Diagram { } public Figure getRootFigure() { - Properties.PropertySelector
selector = new Properties.PropertySelector
(figures); - Figure root = selector.selectSingle("name", "Root"); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(figures); + Figure root = selector.selectSingle(new StringPropertyMatcher("name", "Root")); if (root == null) { - root = selector.selectSingle("name", "Start"); + root = selector.selectSingle(new StringPropertyMatcher("name", "Start")); } if (root == null) { List
rootFigures = getRootFigures(); @@ -258,9 +275,10 @@ public class Diagram { System.out.println("Number of figures: " + tmpFigures.size()); System.out.println("Number of connections: " + connections.size()); - List
figuresSorted = new ArrayList
(tmpFigures); + List
figuresSorted = new ArrayList<>(tmpFigures); Collections.sort(figuresSorted, new Comparator
() { + @Override public int compare(Figure a, Figure b) { return b.getPredecessors().size() + b.getSuccessors().size() - a.getPredecessors().size() - a.getSuccessors().size(); } @@ -283,7 +301,7 @@ public class Diagram { } public List
getRootFigures() { - ArrayList
rootFigures = new ArrayList
(); + ArrayList
rootFigures = new ArrayList<>(); for (Figure f : figures) { if (f.getPredecessors().size() == 0) { rootFigures.add(f); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java index a8c9fb2e7bd..1f1f735318c 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,30 +23,25 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.InputBlock; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Cluster; import com.sun.hotspot.igv.layout.Vertex; -import com.sun.hotspot.igv.data.Properties; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Point; +import java.awt.*; import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.*; -/** - * - * @author Thomas Wuerthinger - */ public class Figure extends Properties.Entity implements Source.Provider, Vertex { - public static final int INSET = 6; - public static final int SLOT_WIDTH = 10; - public static final int SLOT_START = 3; + public static final int INSET = 8; + public static int SLOT_WIDTH = 10; + public static final int OVERLAPPING = 6; + public static final int SLOT_START = 4; + public static final int SLOT_OFFSET = 8; public static final boolean VERTICAL_LAYOUT = true; protected List inputSlots; protected List outputSlots; @@ -55,6 +50,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex private Point position; private List
predecessors; private List
successors; + private List subgraphs; private Color color; private int id; private String idString; @@ -66,7 +62,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex if (heightCash == -1) { BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); - g.setFont(diagram.getFont()); + g.setFont(diagram.getFont().deriveFont(Font.BOLD)); FontMetrics metrics = g.getFontMetrics(); String nodeText = diagram.getNodeText(); heightCash = nodeText.split("\n").length * metrics.getHeight() + INSET; @@ -74,20 +70,41 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex return heightCash; } + public static List getAllBefore(List inputList, T tIn) { + List result = new ArrayList<>(); + for(T t : inputList) { + if(t.equals(tIn)) { + break; + } + result.add(t); + } + return result; + } + + public static int getSlotsWidth(Collection slots) { + int result = Figure.SLOT_OFFSET; + for(Slot s : slots) { + result += s.getWidth() + Figure.SLOT_OFFSET; + } + return result; + } + public int getWidth() { if (widthCash == -1) { int max = 0; BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); - g.setFont(diagram.getFont()); + g.setFont(diagram.getFont().deriveFont(Font.BOLD)); FontMetrics metrics = g.getFontMetrics(); - for (String s : lines) { + for (String s : getLines()) { int cur = metrics.stringWidth(s); if (cur > max) { max = cur; } } widthCash = max + INSET; + widthCash = Math.max(widthCash, Figure.getSlotsWidth(inputSlots)); + widthCash = Math.max(widthCash, Figure.getSlotsWidth(outputSlots)); } return widthCash; } @@ -95,10 +112,10 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex protected Figure(Diagram diagram, int id) { this.diagram = diagram; this.source = new Source(); - inputSlots = new ArrayList(5); - outputSlots = new ArrayList(1); - predecessors = new ArrayList
(6); - successors = new ArrayList
(6); + inputSlots = new ArrayList<>(5); + outputSlots = new ArrayList<>(1); + predecessors = new ArrayList<>(6); + successors = new ArrayList<>(6); this.id = id; idString = Integer.toString(id); @@ -123,7 +140,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex } public Set
getPredecessorSet() { - Set
result = new HashSet
(); + Set
result = new HashSet<>(); for (Figure f : getPredecessors()) { result.add(f); } @@ -131,7 +148,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex } public Set
getSuccessorSet() { - Set
result = new HashSet
(); + Set
result = new HashSet<>(); for (Figure f : getSuccessors()) { result.add(f); } @@ -160,10 +177,20 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex successors.remove(f); } + public List getSubgraphs() { + return subgraphs; + } + + public void setSubgraphs(List subgraphs) { + this.subgraphs = subgraphs; + } + + @Override public void setPosition(Point p) { this.position = p; } + @Override public Point getPosition() { return position; } @@ -172,6 +199,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex return diagram; } + @Override public Source getSource() { return source; } @@ -193,7 +221,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex assert inputSlots.contains(s) || outputSlots.contains(s); - List connections = new ArrayList(s.getConnections()); + List connections = new ArrayList<>(s.getConnections()); for (Connection c : connections) { c.remove(); } @@ -222,6 +250,13 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex return Collections.unmodifiableList(inputSlots); } + public Set getSlots() { + Set result = new HashSet<>(); + result.addAll(getInputSlots()); + result.addAll(getOutputSlots()); + return result; + } + public List getOutputSlots() { return Collections.unmodifiableList(outputSlots); } @@ -248,13 +283,13 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex String[] result = new String[strings.length]; for (int i = 0; i < strings.length; i++) { - result[i] = resolveString(strings[i]); + result[i] = resolveString(strings[i], getProperties()); } lines = result; } - private String resolveString(String string) { + public static final String resolveString(String string, Properties properties) { StringBuilder sb = new StringBuilder(); boolean inBrackets = false; @@ -264,7 +299,7 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex char c = string.charAt(i); if (inBrackets) { if (c == ']') { - String value = getProperties().get(curIdent.toString()); + String value = properties.get(curIdent.toString()); if (value == null) { value = ""; } @@ -286,13 +321,16 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex return sb.toString(); } + @Override public Dimension getSize() { if (VERTICAL_LAYOUT) { int width = Math.max(getWidth(), Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1)); - int height = getHeight() + 2 * Figure.SLOT_WIDTH; + int height = getHeight() + 2 * Figure.SLOT_WIDTH - 2 * Figure.OVERLAPPING; + + return new Dimension(width, height); } else { - int width = getWidth() + 2 * Figure.SLOT_WIDTH; + int width = getWidth() + 2 * Figure.SLOT_WIDTH - 2*Figure.OVERLAPPING; int height = Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1); return new Dimension(width, height); } @@ -308,21 +346,31 @@ public class Figure extends Properties.Entity implements Source.Provider, Vertex assert false : "Should never reach here, every figure must have at least one source node!"; return null; } else { - Cluster result = diagram.getBlock(diagram.getGraph().getBlock(getSource().getSourceNodes().get(0))); + final InputBlock inputBlock = diagram.getGraph().getBlock(getSource().getSourceNodes().get(0)); + assert inputBlock != null; + Cluster result = diagram.getBlock(inputBlock); assert result != null; return result; } } + @Override public boolean isRoot() { - if (source.getSourceNodes().size() > 0 && source.getSourceNodes().get(0).getProperties().get("name").equals("Root")) { - return true; + + List sourceNodes = source.getSourceNodes(); + if (sourceNodes.size() > 0 && sourceNodes.get(0).getProperties().get("name") != null) { + return source.getSourceNodes().get(0).getProperties().get("name").equals("Root"); } else { return false; } } + @Override public int compareTo(Vertex f) { return toString().compareTo(f.toString()); } + + public Rectangle getBounds() { + return new Rectangle(this.getPosition(), new Dimension(this.getWidth(), this.getHeight())); + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java index 5a4e21a86d7..cb1f3a5b5fd 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,18 +36,24 @@ public class InputSlot extends Slot { super(figure, wantedIndex); } + @Override public int getPosition() { return getFigure().getInputSlots().indexOf(this); } + @Override public void setPosition(int position) { List inputSlots = getFigure().inputSlots; InputSlot s = inputSlots.remove(position); inputSlots.add(position, s); } - + @Override public Point getRelativePosition() { - return new Point(getFigure().getWidth() * (getPosition() + 1) / (getFigure().getInputSlots().size() + 1), Figure.SLOT_WIDTH - Figure.SLOT_START); + int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getInputSlots()); + double gapRatio = (double)gap / (double)(getFigure().getInputSlots().size() + 1); + int gapAmount = (int)((getPosition() + 1)*gapRatio); + return new Point(gapAmount + Figure.getSlotsWidth(Figure.getAllBefore(getFigure().getInputSlots(), this)) + getWidth()/2, -Figure.SLOT_START); + //return new Point((getFigure().getWidth() / (getFigure().getInputSlots().size() * 2)) * (getPosition() * 2 + 1), -Figure.SLOT_START); } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java index 21093cbc969..d6e95d132ba 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InvertSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,10 @@ public class InvertSelector implements Selector { this.selector = selector; } + @Override public List
selected(Diagram d) { - List
result = new ArrayList
(); + List
result = new ArrayList<>(); List
otherResult = selector.selected(d); for (Figure f : d.getFigures()) { if (!otherResult.contains(f)) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java index a506673a152..15fffaaa049 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/MatcherSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,9 @@ public class MatcherSelector implements Selector { this.matcher = matcher; } + @Override public List
selected(Diagram d) { - Properties.PropertySelector
selector = new Properties.PropertySelector
(d.getFigures()); + Properties.PropertySelector
selector = new Properties.PropertySelector<>(d.getFigures()); List
list = selector.selectMultiple(matcher); return list; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java index c0c158fbab8..1e7cb2446df 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OrSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ public class OrSelector implements Selector { this.selector2 = s2; } + @Override public List
selected(Diagram d) { List
l1 = selector1.selected(d); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java index 206a8cb84b1..7b1f9cd1a64 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,17 +35,26 @@ public class OutputSlot extends Slot { super(figure, wantedIndex); } + @Override public int getPosition() { return getFigure().getOutputSlots().indexOf(this); } + @Override public void setPosition(int position) { OutputSlot s = getFigure().outputSlots.remove(position); getFigure().outputSlots.add(position, s); } + @Override public Point getRelativePosition() { - return new Point(getFigure().getWidth() * (getPosition() + 1) / (getFigure().getOutputSlots().size() + 1), getFigure().getSize().height - Figure.SLOT_WIDTH + Figure.SLOT_START); + int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getOutputSlots()); + if(gap < 0) { + gap = 0; + } + double gapRatio = (double)gap / (double)(getFigure().getOutputSlots().size() + 1); + int gapAmount = (int)((getPosition() + 1)*gapRatio); + return new Point(gapAmount + Figure.getSlotsWidth(Figure.getAllBefore(getFigure().getOutputSlots(), this)) + getWidth()/2, Figure.SLOT_START); } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java index eac6d3afd35..97846e21c69 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/PredecessorSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,10 @@ public class PredecessorSelector implements Selector { this.innerSelector = innerSelector; } + @Override public List
selected(Diagram d) { List
inner = innerSelector.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getSuccessors()) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Selector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Selector.java index e0dbe8e1e0f..189a494819b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Selector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Selector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java index a350db0976c..da101bf7341 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,63 +23,111 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Port; import com.sun.hotspot.igv.layout.Vertex; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; -import java.util.List; import java.util.Comparator; +import java.util.List; /** * * @author Thomas Wuerthinger */ -public abstract class Slot implements Port, Source.Provider { +public abstract class Slot implements Port, Source.Provider, Properties.Provider { private int wantedIndex; - private String name; - private String shortName; // 1 - 2 characters private Source source; protected List connections; + private InputNode associatedNode; + private Color color; + private String text; + private String shortName; private Figure figure; protected Slot(Figure figure, int wantedIndex) { this.figure = figure; - connections = new ArrayList(2); + connections = new ArrayList<>(2); source = new Source(); this.wantedIndex = wantedIndex; - name = ""; + text = ""; shortName = ""; assert figure != null; } + + @Override + public Properties getProperties() { + Properties p = new Properties(); + if (source.getSourceNodes().size() > 0) { + for (InputNode n : source.getSourceNodes()) { + p.add(n.getProperties()); + } + } else { + p.setProperty("name", "Slot"); + p.setProperty("figure", figure.getProperties().get("name")); + p.setProperty("connectionCount", Integer.toString(connections.size())); + } + return p; + } public static final Comparator slotIndexComparator = new Comparator() { + @Override public int compare(Slot o1, Slot o2) { return o1.wantedIndex - o2.wantedIndex; } }; public static final Comparator slotFigureComparator = new Comparator() { + @Override public int compare(Slot o1, Slot o2) { return o1.figure.getId() - o2.figure.getId(); } }; + public InputNode getAssociatedNode() { + return associatedNode; + } + + public void setAssociatedNode(InputNode node) { + associatedNode = node; + } + + public int getWidth() { + if (shortName == null || shortName.length() <= 1) { + return Figure.SLOT_WIDTH; + } else { + BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + g.setFont(figure.getDiagram().getSlotFont().deriveFont(Font.BOLD)); + FontMetrics metrics = g.getFontMetrics(); + return Math.max(Figure.SLOT_WIDTH, metrics.stringWidth(shortName) + 6); + } + } + public int getWantedIndex() { return wantedIndex; } + @Override public Source getSource() { return source; } - public String getName() { - return name; + public String getText() { + return text; } public void setShortName(String s) { assert s != null; - assert s.length() <= 2; +// assert s.length() <= 2; this.shortName = s; } @@ -88,15 +136,27 @@ public abstract class Slot implements Port, Source.Provider { return shortName; } - public boolean getShowName() { + public String getToolTipText() { + StringBuilder sb = new StringBuilder(); + sb.append(text); + + for (InputNode n : getSource().getSourceNodes()) { + sb.append("Node (ID=" + n.getId() + "): " + n.getProperties().get("name")); + sb.append("
"); + } + + return sb.toString(); + } + + public boolean shouldShowName() { return getShortName() != null && getShortName().length() > 0; } - public void setName(String s) { + public void setText(String s) { if (s == null) { s = ""; } - this.name = s; + this.text = s; } public Figure getFigure() { @@ -104,17 +164,26 @@ public abstract class Slot implements Port, Source.Provider { return figure; } + public Color getColor() { + return this.color; + } + + public void setColor(Color c) { + color = c; + } + public List getConnections() { return Collections.unmodifiableList(connections); } public void removeAllConnections() { - List connectionsCopy = new ArrayList(this.connections); + List connectionsCopy = new ArrayList<>(this.connections); for (Connection c : connectionsCopy) { c.remove(); } } + @Override public Vertex getVertex() { return figure; } @@ -123,3 +192,4 @@ public abstract class Slot implements Port, Source.Provider { public abstract void setPosition(int position); } + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java index 59aa07ebd3b..0a2289e3cfe 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/SuccessorSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,9 +38,10 @@ public class SuccessorSelector implements Selector { this.innerSelector = innerSelector; } + @Override public List
selected(Diagram d) { List
inner = innerSelector.selected(d); - List
result = new ArrayList
(); + List
result = new ArrayList<>(); for (Figure f : d.getFigures()) { boolean saved = false; for (Figure f2 : f.getPredecessors()) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/services/DiagramProvider.java similarity index 77% rename from hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java rename to hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/services/DiagramProvider.java index e17dda4be38..319825f2a65 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/NullScriptEngine.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/services/DiagramProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,20 +21,18 @@ * questions. * */ -package com.sun.hotspot.igv.filter; +package com.sun.hotspot.igv.graph.services; + +import com.sun.hotspot.igv.data.ChangedEvent; import com.sun.hotspot.igv.graph.Diagram; /** * * @author Thomas Wuerthinger */ -public class NullScriptEngine implements ScriptEngineAbstraction { +public interface DiagramProvider { + Diagram getDiagram(); + ChangedEvent getChangedEvent(); - public boolean initialize(String jsHelperText) { - return true; - } - - public void execute(Diagram d, String code) { - } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java index cc66a80c061..474cef1ddca 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterEdge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,4 +60,8 @@ public class ClusterEdge implements Link { public List getControlPoints() { return points; } + + public boolean isVIP() { + return false; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java index d6600b8b847..e181c669118 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterIngoingConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,4 +73,8 @@ public class ClusterIngoingConnection implements Link { public List getControlPoints() { return controlPoints; } + + public boolean isVIP() { + return false; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java index ff38dda871a..aae46cb629e 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterInputSlotNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java index d42d2fa9917..36937e0622b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ public class ClusterNode implements Vertex { outputSlot = new Port() { public Point getRelativePosition() { - return new Point(size.width / 2, size.height); + return new Point(size.width / 2, 0);//size.height); } public Vertex getVertex() { @@ -183,7 +183,7 @@ public class ClusterNode implements Vertex { for (Link e : subEdges) { List arr = e.getControlPoints(); - ArrayList newArr = new ArrayList(); + ArrayList newArr = new ArrayList(arr.size()); for (Point p : arr) { if (p != null) { Point p2 = new Point(p); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java index 97590916c3c..2f5bce16883 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutgoingConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,4 +65,8 @@ public class ClusterOutgoingConnection implements Link { public List getControlPoints() { return intermediatePoints; } + + public boolean isVIP() { + return false; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java index 1672bb632f3..d0240ce5cd5 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,7 +88,7 @@ public class ClusterOutputSlotNode implements Vertex { public Point getRelativePosition() { Point p = new Point(thisNode.getPosition()); p.x += ClusterNode.BORDER; - p.y = thisBlockNode.getSize().height; + p.y = 0;//thisBlockNode.getSize().height; return p; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java index d789f8112a9..6f990b545a6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Edge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,6 +83,7 @@ public class Edge { dest.addInEdge(this); } + @Override public String toString() { return "Edge (" + source + " -- " + dest + "): " + data; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java index f0b2374306c..e19d3ebf5b8 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Graph.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,7 @@ */ package com.sun.hotspot.igv.hierarchicallayout; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; +import java.util.*; /** * @@ -42,13 +36,13 @@ public class Graph { private List> nodeList; public Graph() { - nodes = new HashMap>(); - edges = new HashMap>(); - nodeList = new ArrayList>(); + nodes = new HashMap<>(); + edges = new HashMap<>(); + nodeList = new ArrayList<>(); } public Node createNode(N data, Object key) { - Node n = new Node(this, data); + Node n = new Node<>(this, data); assert key == null || !nodes.containsKey(key); if (key != null) { nodes.put(key, n); @@ -58,7 +52,7 @@ public class Graph { } public Edge createEdge(Node source, Node dest, E data, Object key) { - Edge e = new Edge(this, source, dest, data); + Edge e = new Edge<>(this, source, dest, data); source.addOutEdge(e); dest.addInEdge(e); if (key != null) { @@ -114,7 +108,7 @@ public class Graph { public List> getNodesWithInDegree(int x, boolean countSelfLoops) { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); for (Node n : getNodes()) { if (n.getInDegree(countSelfLoops) == x) { result.add(n); @@ -126,7 +120,7 @@ public class Graph { } private void markReachable(Node startingNode) { - ArrayList> arr = new ArrayList>(); + ArrayList> arr = new ArrayList<>(); arr.add(startingNode); for (Node n : getNodes()) { n.setReachable(false); @@ -151,7 +145,7 @@ public class Graph { n.setActive(false); } - Queue> queue = new LinkedList>(); + Queue> queue = new LinkedList<>(); queue.add(startingNode); startingNode.setVisited(true); int layer = 0; diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java index 089f03d1ac2..fac6b94e010 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,12 +44,12 @@ import com.sun.hotspot.igv.layout.Vertex; */ public class HierarchicalClusterLayoutManager implements LayoutManager { - private OldHierarchicalLayoutManager.Combine combine; - private LayoutManager subManager = new OldHierarchicalLayoutManager(combine); - private LayoutManager manager = new OldHierarchicalLayoutManager(combine, 150); + private HierarchicalLayoutManager.Combine combine; + private LayoutManager subManager = new HierarchicalLayoutManager(combine); + private LayoutManager manager = new HierarchicalLayoutManager(combine); private static final boolean TRACE = false; - public HierarchicalClusterLayoutManager(OldHierarchicalLayoutManager.Combine combine) { + public HierarchicalClusterLayoutManager(HierarchicalLayoutManager.Combine combine) { this.combine = combine; } @@ -57,6 +57,10 @@ public class HierarchicalClusterLayoutManager implements LayoutManager { doLayout(graph, new HashSet(), new HashSet(), new HashSet()); } + public void doLayout(LayoutGraph graph, Set importantLinks) { + doLayout(graph); + } + public void setSubManager(LayoutManager manager) { this.subManager = manager; } @@ -116,7 +120,7 @@ public class HierarchicalClusterLayoutManager implements LayoutManager { for (Vertex v : graph.getVertices()) { Cluster c = v.getCluster(); - assert c != null; + assert c != null : "Cluster of vertex " + v + " is null!"; clusterNodes.get(c).addSubNode(v); } @@ -130,9 +134,9 @@ public class HierarchicalClusterLayoutManager implements LayoutManager { Cluster toCluster = toVertex.getCluster(); Port samePort = null; - if (combine == OldHierarchicalLayoutManager.Combine.SAME_INPUTS) { + if (combine == HierarchicalLayoutManager.Combine.SAME_INPUTS) { samePort = toPort; - } else if (combine == OldHierarchicalLayoutManager.Combine.SAME_OUTPUTS) { + } else if (combine == HierarchicalLayoutManager.Combine.SAME_OUTPUTS) { samePort = fromPort; } @@ -196,7 +200,7 @@ public class HierarchicalClusterLayoutManager implements LayoutManager { for (Cluster c : cluster) { ClusterNode n = clusterNodes.get(c); - subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), clusterInputSlotSet.get(c), clusterOutputSlotSet.get(c), new HashSet()); + subManager.doLayout(new LayoutGraph(n.getSubEdges(), n.getSubNodes()), new HashSet()); n.updateSize(); } @@ -206,7 +210,7 @@ public class HierarchicalClusterLayoutManager implements LayoutManager { ((ClusterNode) v).setRoot(true); } - manager.doLayout(new LayoutGraph(clusterEdges, clusterNodeSet), new HashSet(), new HashSet(), interClusterEdges); + manager.doLayout(new LayoutGraph(clusterEdges, clusterNodeSet), interClusterEdges); for (Cluster c : cluster) { ClusterNode n = clusterNodes.get(c); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java index dbde2c58b20..cb6b02ed573 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,18 +29,7 @@ import com.sun.hotspot.igv.layout.Link; import com.sun.hotspot.igv.layout.Vertex; import java.awt.Dimension; import java.awt.Point; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.Stack; -import java.util.TreeSet; +import java.util.*; /** * @@ -54,10 +43,11 @@ public class HierarchicalLayoutManager implements LayoutManager { public static final int CROSSING_ITERATIONS = 2; public static final int DUMMY_HEIGHT = 1; public static final int DUMMY_WIDTH = 1; - public static final int X_OFFSET = 9; - public static final int LAYER_OFFSET = 30; + public static final int X_OFFSET = 8; + public static final int LAYER_OFFSET = 8; public static final int MAX_LAYER_LENGTH = -1; public static final int MIN_LAYER_DIFFERENCE = 1; + public static final int VIP_BONUS = 10; public enum Combine { @@ -85,8 +75,6 @@ public class HierarchicalLayoutManager implements LayoutManager { private LayoutGraph graph; private List[] layers; private int layerCount; - private Set firstLayerHint; - private Set lastLayerHint; private Set importantLinks; private Set linksToFollow; @@ -101,11 +89,13 @@ public class HierarchicalLayoutManager implements LayoutManager { public int yOffset; public int bottomYOffset; public Vertex vertex; // Only used for non-dummy nodes, otherwise null - public List preds = new ArrayList(); - public List succs = new ArrayList(); - public HashMap outOffsets = new HashMap(); - public HashMap inOffsets = new HashMap(); + + public List preds = new ArrayList<>(); + public List succs = new ArrayList<>(); + public HashMap outOffsets = new HashMap<>(); + public HashMap inOffsets = new HashMap<>(); public int pos = -1; // Position within layer + public int crossingNumber; @Override @@ -121,6 +111,7 @@ public class HierarchicalLayoutManager implements LayoutManager { public int relativeFrom; public int relativeTo; public Link link; + public boolean vip; } private abstract class AlgorithmPart { @@ -171,7 +162,7 @@ public class HierarchicalLayoutManager implements LayoutManager { this.layerOffset = LAYER_OFFSET; this.maxLayerLength = MAX_LAYER_LENGTH; this.minLayerDifference = MIN_LAYER_DIFFERENCE; - this.linksToFollow = new HashSet(); + this.linksToFollow = new HashSet<>(); } public int getMaxLayerLength() { @@ -186,26 +177,26 @@ public class HierarchicalLayoutManager implements LayoutManager { minLayerDifference = v; } + @Override public void doLayout(LayoutGraph graph) { - doLayout(graph, new HashSet(), new HashSet(), new HashSet()); + doLayout(graph, new HashSet()); } - public void doLayout(LayoutGraph graph, Set firstLayerHint, Set lastLayerHint, Set importantLinks) { + @Override + public void doLayout(LayoutGraph graph, Set importantLinks) { this.importantLinks = importantLinks; this.graph = graph; - this.firstLayerHint = firstLayerHint; - this.lastLayerHint = lastLayerHint; - vertexToLayoutNode = new HashMap(); - reversedLinks = new HashSet(); - reversedLinkStartPoints = new HashMap>(); - reversedLinkEndPoints = new HashMap>(); - bottomEdgeHash = new HashMap(); - nodes = new ArrayList(); - splitStartPoints = new HashMap>(); - splitEndPoints = new HashMap>(); + vertexToLayoutNode = new HashMap<>(); + reversedLinks = new HashSet<>(); + reversedLinkStartPoints = new HashMap<>(); + reversedLinkEndPoints = new HashMap<>(); + bottomEdgeHash = new HashMap<>(); + nodes = new ArrayList<>(); + splitStartPoints = new HashMap<>(); + splitEndPoints = new HashMap<>(); // ############################################################# // Step 1: Build up data structure @@ -216,7 +207,7 @@ public class HierarchicalLayoutManager implements LayoutManager { new ReverseEdges().start(); for (LayoutNode n : nodes) { - ArrayList tmpArr = new ArrayList(); + ArrayList tmpArr = new ArrayList<>(); for (LayoutEdge e : n.succs) { if (importantLinks.contains(e.link)) { tmpArr.add(e); @@ -224,7 +215,6 @@ public class HierarchicalLayoutManager implements LayoutManager { } for (LayoutEdge e : tmpArr) { - //System.out.println("Removed " + e); e.from.succs.remove(e); e.to.preds.remove(e); } @@ -244,8 +234,7 @@ public class HierarchicalLayoutManager implements LayoutManager { // ############################################################# // STEP 7: Assign X coordinates - //new AssignXCoordinates().start(); - new AssignXCoordinates2().start(); + new AssignXCoordinates().start(); // ############################################################# // STEP 6: Assign Y coordinates @@ -260,10 +249,11 @@ public class HierarchicalLayoutManager implements LayoutManager { private int pointCount; + @Override protected void run() { - HashMap vertexPositions = new HashMap(); - HashMap> linkPositions = new HashMap>(); + HashMap vertexPositions = new HashMap<>(); + HashMap> linkPositions = new HashMap<>(); for (Vertex v : graph.getVertices()) { LayoutNode n = vertexToLayoutNode.get(v); assert !vertexPositions.containsKey(v); @@ -274,12 +264,12 @@ public class HierarchicalLayoutManager implements LayoutManager { for (LayoutEdge e : n.preds) { if (e.link != null) { - ArrayList points = new ArrayList(); + ArrayList points = new ArrayList<>(); - Point p = new Point(e.to.x + e.relativeTo, e.to.y + e.to.yOffset); + Point p = new Point(e.to.x + e.relativeTo, e.to.y + e.to.yOffset + e.link.getTo().getRelativePosition().y); points.add(p); if (e.to.inOffsets.containsKey(e.relativeTo)) { - points.add(new Point(p.x, p.y + e.to.inOffsets.get(e.relativeTo))); + points.add(new Point(p.x, p.y + e.to.inOffsets.get(e.relativeTo) + e.link.getTo().getRelativePosition().y)); } LayoutNode cur = e.from; @@ -299,16 +289,14 @@ public class HierarchicalLayoutManager implements LayoutManager { cur = curEdge.from; } - p = new Point(cur.x + curEdge.relativeFrom, cur.y + cur.height - cur.bottomYOffset); + p = new Point(cur.x + curEdge.relativeFrom, cur.y + cur.height - cur.bottomYOffset + (curEdge.link == null ? 0 : curEdge.link.getFrom().getRelativePosition().y)); if (curEdge.from.outOffsets.containsKey(curEdge.relativeFrom)) { - points.add(new Point(p.x, p.y + curEdge.from.outOffsets.get(curEdge.relativeFrom))); + points.add(new Point(p.x, p.y + curEdge.from.outOffsets.get(curEdge.relativeFrom) + (curEdge.link == null ? 0 : curEdge.link.getFrom().getRelativePosition().y))); } points.add(p); Collections.reverse(points); - - if (cur.vertex == null && cur.preds.size() == 0) { if (reversedLinkEndPoints.containsKey(e.link)) { @@ -359,17 +347,17 @@ public class HierarchicalLayoutManager implements LayoutManager { for (LayoutEdge e : n.succs) { if (e.link != null) { - ArrayList points = new ArrayList(); - Point p = new Point(e.from.x + e.relativeFrom, e.from.y + e.from.height - e.from.bottomYOffset); + ArrayList points = new ArrayList<>(); + Point p = new Point(e.from.x + e.relativeFrom, e.from.y + e.from.height - e.from.bottomYOffset + e.link.getFrom().getRelativePosition().y); points.add(p); if (e.from.outOffsets.containsKey(e.relativeFrom)) { - points.add(new Point(p.x, p.y + e.from.outOffsets.get(e.relativeFrom))); + points.add(new Point(p.x, p.y + e.from.outOffsets.get(e.relativeFrom) + e.link.getFrom().getRelativePosition().y)); } LayoutNode cur = e.to; LayoutNode other = e.from; LayoutEdge curEdge = e; - while (cur.vertex == null && cur.succs.size() != 0) { + while (cur.vertex == null && !cur.succs.isEmpty()) { if (points.size() > 1 && points.get(points.size() - 1).x == cur.x + cur.width / 2 && points.get(points.size() - 2).x == cur.x + cur.width / 2) { points.remove(points.size() - 1); } @@ -378,7 +366,7 @@ public class HierarchicalLayoutManager implements LayoutManager { points.remove(points.size() - 1); } points.add(new Point(cur.x + cur.width / 2, cur.y + cur.height)); - if (cur.succs.size() == 0) { + if (cur.succs.isEmpty()) { break; } assert cur.succs.size() == 1; @@ -386,15 +374,13 @@ public class HierarchicalLayoutManager implements LayoutManager { cur = curEdge.to; } - - p = new Point(cur.x + curEdge.relativeTo, cur.y + cur.yOffset); + p = new Point(cur.x + curEdge.relativeTo, cur.y + cur.yOffset + ((curEdge.link == null) ? 0 : curEdge.link.getTo().getRelativePosition().y)); points.add(p); if (curEdge.to.inOffsets.containsKey(curEdge.relativeTo)) { - points.add(new Point(p.x, p.y + curEdge.to.inOffsets.get(curEdge.relativeTo))); + points.add(new Point(p.x, p.y + curEdge.to.inOffsets.get(curEdge.relativeTo) + ((curEdge.link == null) ? 0 : curEdge.link.getTo().getRelativePosition().y))); } - - if (cur.succs.size() == 0 && cur.vertex == null) { + if (cur.succs.isEmpty() && cur.vertex == null) { if (reversedLinkStartPoints.containsKey(e.link)) { for (Point p1 : reversedLinkStartPoints.get(e.link)) { points.add(0, new Point(p1.x + other.x, p1.y + other.y)); @@ -495,13 +481,14 @@ public class HierarchicalLayoutManager implements LayoutManager { public float d; public int orderNumber = -1; - public ArrayList nodes = new ArrayList(); - public HashSet succs = new HashSet(); - public HashSet preds = new HashSet(); + public ArrayList nodes = new ArrayList<>(); + public HashSet succs = new HashSet<>(); + public HashSet preds = new HashSet<>(); public Region region; } private static final Comparator segmentComparator = new Comparator() { + @Override public int compare(Segment s1, Segment s2) { return s1.orderNumber - s2.orderNumber; } @@ -511,26 +498,46 @@ public class HierarchicalLayoutManager implements LayoutManager { public float d; public int minOrderNumber; - public SortedSet segments = new TreeSet(segmentComparator); - public HashSet succs = new HashSet(4); - public HashSet preds = new HashSet(4); + public SortedSet segments = new TreeSet<>(segmentComparator); + public HashSet succs = new HashSet<>(4); + public HashSet preds = new HashSet<>(4); } private static final Comparator regionComparator = new Comparator() { + @Override public int compare(Region r1, Region r2) { return r1.minOrderNumber - r2.minOrderNumber; } }; private static final Comparator nodePositionComparator = new Comparator() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { return n1.pos - n2.pos; } }; private static final Comparator nodeProcessingDownComparator = new Comparator() { - + @Override public int compare(LayoutNode n1, LayoutNode n2) { + int n1VIP = 0; + for (LayoutEdge e : n1.preds) { + if (e.vip) { + n1VIP++; + } + } + int n2VIP = 0; + for (LayoutEdge e : n2.preds) { + if (e.vip) { + n2VIP++; + } + } + if (n1VIP != n2VIP) { + return n2VIP - n1VIP; + } if (n1.vertex == null) { + if (n2.vertex == null) { + return 0; + } return -1; } if (n2.vertex == null) { @@ -541,8 +548,27 @@ public class HierarchicalLayoutManager implements LayoutManager { }; private static final Comparator nodeProcessingUpComparator = new Comparator() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { + int n1VIP = 0; + for (LayoutEdge e : n1.succs) { + if (e.vip) { + n1VIP++; + } + } + int n2VIP = 0; + for (LayoutEdge e : n2.succs) { + if (e.vip) { + n2VIP++; + } + } + if (n1VIP != n2VIP) { + return n2VIP - n1VIP; + } if (n1.vertex == null) { + if (n2.vertex == null) { + return 0; + } return -1; } if (n2.vertex == null) { @@ -552,7 +578,7 @@ public class HierarchicalLayoutManager implements LayoutManager { } }; - private class AssignXCoordinates2 extends AlgorithmPart { + private class AssignXCoordinates extends AlgorithmPart { private ArrayList[] space; private ArrayList[] downProcessingOrder; @@ -564,16 +590,21 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - protected void run() { - + @SuppressWarnings("unchecked") + private void createArrays() { space = new ArrayList[layers.length]; downProcessingOrder = new ArrayList[layers.length]; upProcessingOrder = new ArrayList[layers.length]; + } + + @Override + protected void run() { + createArrays(); for (int i = 0; i < layers.length; i++) { - space[i] = new ArrayList(); - downProcessingOrder[i] = new ArrayList(); - upProcessingOrder[i] = new ArrayList(); + space[i] = new ArrayList<>(); + downProcessingOrder[i] = new ArrayList<>(); + upProcessingOrder[i] = new ArrayList<>(); int curX = 0; for (LayoutNode n : layers[i]) { @@ -590,72 +621,106 @@ public class HierarchicalLayoutManager implements LayoutManager { initialPositions(); for (int i = 0; i < SWEEP_ITERATIONS; i++) { sweepDown(); - sweepUp(); + adjustSpace(); + sweepUp(false); + adjustSpace(); } - for (int i = 0; i < SWEEP_ITERATIONS; i++) { - doubleSweep(); + sweepDown(); + adjustSpace(); + sweepUp(true); + } + + private void adjustSpace() { + for (int i = 0; i < layers.length; i++) { + // space[i] = new ArrayList<>(); + int curX = 0; + for (LayoutNode n : layers[i]) { + space[i].add(n.x); +// curX += n.width + xOffset; + } } } private int calculateOptimalDown(LayoutNode n) { - - List values = new ArrayList(); - if (n.preds.size() == 0) { + int size = n.preds.size(); + if (size == 0) { return n.x; } + int vipCount = 0; for (LayoutEdge e : n.preds) { - int cur = e.from.x + e.relativeFrom - e.relativeTo; - values.add(cur); + if (e.vip) { + vipCount++; + } + } + + if (vipCount == 0) { + int[] values = new int[size]; + for (int i = 0; i < size; i++) { + LayoutEdge e = n.preds.get(i); + values[i] = e.from.x + e.relativeFrom - e.relativeTo; + } + return median(values); + } else { + int z = 0; + int[] values = new int[vipCount]; + for (int i = 0; i < size; i++) { + LayoutEdge e = n.preds.get(i); + if (e.vip) { + values[z++] = e.from.x + e.relativeFrom - e.relativeTo; + } + } + return median(values); } - return median(values); } private int calculateOptimalBoth(LayoutNode n) { - - List values = new ArrayList(); - if (n.preds.size() == 0 + n.succs.size()) { + if (n.preds.size() == n.succs.size()) { return n.x; } + + int[] values = new int[n.preds.size() + n.succs.size()]; + int i = 0; + for (LayoutEdge e : n.preds) { - int cur = e.from.x + e.relativeFrom - e.relativeTo; - values.add(cur); + values[i] = e.from.x + e.relativeFrom - e.relativeTo; + i++; } for (LayoutEdge e : n.succs) { - int cur = e.to.x + e.relativeTo - e.relativeFrom; - values.add(cur); + values[i] = e.to.x + e.relativeTo - e.relativeFrom; + i++; } return median(values); } private int calculateOptimalUp(LayoutNode n) { - - //List values = new ArrayList(); int size = n.succs.size(); if (size == 0) { return n.x; - } else { - int result = 0; - for (LayoutEdge e : n.succs) { - int cur = e.to.x + e.relativeTo - e.relativeFrom; - result += cur; + } + int[] values = new int[size]; + for (int i = 0; i < size; i++) { + LayoutEdge e = n.succs.get(i); + values[i] = e.to.x + e.relativeTo - e.relativeFrom; + if (e.vip) { + return values[i]; } - return result / size; //median(values); } + return median(values); } - private int median(List values) { - Collections.sort(values); - if (values.size() % 2 == 0) { - return (values.get(values.size() / 2 - 1) + values.get(values.size() / 2)) / 2; + private int median(int[] values) { + Arrays.sort(values); + if (values.length % 2 == 0) { + return (values[values.length / 2 - 1] + values[values.length / 2]) / 2; } else { - return values.get(values.size() / 2); + return values[values.length / 2]; } } - private void sweepUp() { + private void sweepUp(boolean onlyDummies) { for (int i = layers.length - 1; i >= 0; i--) { NodeRow r = new NodeRow(space[i]); for (LayoutNode n : upProcessingOrder[i]) { @@ -663,14 +728,6 @@ public class HierarchicalLayoutManager implements LayoutManager { r.insert(n, optimal); } } - /* - for(int i=0; i space; public NodeRow(ArrayList space) { - treeSet = new TreeSet(nodePositionComparator); + treeSet = new TreeSet<>(nodePositionComparator); this.space = space; } @@ -739,357 +796,15 @@ public class HierarchicalLayoutManager implements LayoutManager { n.x = pos; } - assert minX <= maxX; + assert minX <= maxX : minX + " vs " + maxX; } treeSet.add(n); } } - - private class AssignXCoordinates extends AlgorithmPart { - - HashMap hashMap = new HashMap(); - ArrayList segments = new ArrayList(); - - private void generateSegments() { - - for (int i = 0; i < layerCount; i++) { - for (LayoutNode n : layers[i]) { - if (!hashMap.containsKey(n)) { - Segment s = new Segment(); - segments.add(s); - LayoutNode curNode = n; - - int maxLength = 0; - while (curNode.succs.size() == 1 && curNode.preds.size() == 1) { - s.nodes.add(curNode); - assert !hashMap.containsKey(curNode); - hashMap.put(curNode, s); - curNode = curNode.succs.get(0).to; - maxLength++; - //if(maxLength > 10) break; - } - - if (s.nodes.size() > 0 && curNode.preds.size() == 1 && curNode.vertex == null) { - s.nodes.add(curNode); - assert !hashMap.containsKey(curNode); - hashMap.put(curNode, s); - } - - if (s.nodes.size() == 0) { - // Simple segment with a single node - s.nodes.add(n); - hashMap.put(n, s); - } - } - } - } - } - - private void addEdges() { - - for (int i = 0; i < layerCount; i++) { - LayoutNode prev = null; - for (LayoutNode n : layers[i]) { - - if (prev != null) { - Segment s1 = hashMap.get(prev); - Segment s2 = hashMap.get(n); - - if (s1 != s2) { - s1.succs.add(s2); - s2.preds.add(s1); - } - } - prev = n; - - } - } - } - - private void topologicalSorting() { - - Queue queue = new LinkedList(); - - int index = 0; - ArrayList newList = new ArrayList(); - for (Segment s : segments) { - if (s.preds.size() == 0) { - s.orderNumber = index; - newList.add(s); - index++; - queue.add(s); - } - } - - while (!queue.isEmpty()) { - Segment s = queue.remove(); - - for (Segment succ : s.succs) { - succ.preds.remove(s); - if (succ.preds.size() == 0) { - queue.add(succ); - succ.orderNumber = index; - newList.add(succ); - index++; - } - } - } - - segments = newList; - } - - private void initialPositions() { - - int[] minPos = new int[layers.length]; - - for (Segment s : segments) { - int max = 0; - for (LayoutNode n : s.nodes) { - int x = minPos[n.layer]; - if (x > max) { - max = x; - } - } - - for (LayoutNode n : s.nodes) { - minPos[n.layer] = max + n.width + xOffset; - n.x = max; - } - } - } - - private int predSum(LayoutNode n) { - int sum = 0; - for (LayoutEdge e : n.preds) { - assert e.to == n; - //sum += (e.from.x + e.relativeFrom + (int)hashMap.get(e.from).d) - (e.to.x + e.relativeTo + (int)hashMap.get(e.to).d); - sum += (e.from.x + e.relativeFrom) - (e.to.x + e.relativeTo); - } - - return sum; - } - - private int succSum(LayoutNode n) { - int sum = 0; - for (LayoutEdge e : n.succs) { - - assert e.from == n; - sum += (e.to.x + e.relativeTo) - (e.from.x + e.relativeFrom); - //sum += (e.to.x + e.relativeTo + (int)hashMap.get(e.to).d) - (e.from.x + e.relativeFrom + (int)hashMap.get(e.from).d); - } - - return sum; - - } - - private void downValues() { - - for (Segment s : segments) { - downValues(s); - - } - - } - - private void downValues(Segment s) { - LayoutNode n = s.nodes.get(0); // Only first node needed, all other have same coordinate - - if (n.preds.size() == 0) { - // Value is 0.0; - if (n.succs.size() == 0) { - s.d = 0.0f; - } else { - s.d = (((float) succSum(n) / (float) n.succs.size())) / 2; - } - } else { - s.d = (float) predSum(n) / (float) n.preds.size(); - } - } - - private void upValues() { - for (Segment s : segments) { - upValues(s); - } - } - - private void upValues(Segment s) { - LayoutNode n = s.nodes.get(0); // Only first node needed, all other have same coordinate - - if (n.succs.size() == 0) { - // Value is 0.0; - if (n.preds.size() == 0) { - s.d = 0.0f; - } else { - s.d = (float) predSum(n) / (float) n.preds.size(); - } - } else { - s.d = ((float) succSum(n) / (float) n.succs.size()) / 2; - } - } - - private void sweep(boolean down) { - - if (down) { - downValues(); - } else { - upValues(); - } - - SortedSet regions = new TreeSet(regionComparator); - for (Segment s : segments) { - s.region = new Region(); - s.region.minOrderNumber = s.orderNumber; - s.region.segments.add(s); - s.region.d = s.d; - regions.add(s.region); - } - - for (Segment s : segments) { - for (LayoutNode n : s.nodes) { - if (n.pos != 0) { - LayoutNode prevNode = layers[n.layer].get(n.pos - 1); - if (prevNode.x + prevNode.width + xOffset == n.x) { - Segment other = hashMap.get(prevNode); - Region r1 = s.region; - Region r2 = other.region; - // They are close together - if (r1 != r2 && r2.d >= r1.d) { - - if (r2.segments.size() < r1.segments.size()) { - - r1.d = (r1.d * r1.segments.size() + r2.d * r2.segments.size()) / (r1.segments.size() + r2.segments.size()); - - for (Segment tempS : r2.segments) { - r1.segments.add(tempS); - tempS.region = r1; - r1.minOrderNumber = Math.min(r1.minOrderNumber, tempS.orderNumber); - } - - regions.remove(r2); - } else { - - r2.d = (r1.d * r1.segments.size() + r2.d * r2.segments.size()) / (r1.segments.size() + r2.segments.size()); - - for (Segment tempS : r1.segments) { - r2.segments.add(tempS); - tempS.region = r2; - r2.minOrderNumber = Math.min(r2.minOrderNumber, tempS.orderNumber); - } - - regions.remove(r1); - } - } - } - } - } - } - - - - ArrayList reversedRegions = new ArrayList(); - for (Region r : regions) { - if (r.d < 0) { - processRegion(r, down); - } else { - reversedRegions.add(0, r); - } - } - - for (Region r : reversedRegions) { - processRegion(r, down); - } - - } - - private void processRegion(Region r, boolean down) { - - // Do not move - if ((int) r.d == 0) { - return; - } - - ArrayList arr = new ArrayList(); - for (Segment s : r.segments) { - arr.add(s); - } - - if (r.d > 0) { - Collections.reverse(arr); - } - - for (Segment s : arr) { - - - int min = (int) r.d; - if (min < 0) { - min = -min; - } - - for (LayoutNode n : s.nodes) { - - int layer = n.layer; - int pos = n.pos; - - - if (r.d > 0) { - - if (pos != layers[layer].size() - 1) { - - int off = layers[layer].get(pos + 1).x - n.x - xOffset - n.width; - assert off >= 0; - if (off < min) { - min = off; - } - } - - } else { - - if (pos != 0) { - - int off = n.x - xOffset - layers[layer].get(pos - 1).x - layers[layer].get(pos - 1).width; - assert off >= 0; - if (off < min) { - min = off; - } - } - } - } - - assert min >= 0; - if (min != 0) { - for (LayoutNode n : s.nodes) { - if (r.d > 0) { - n.x += min; - } else { - n.x -= min; - } - - } - } - } - } - - protected void run() { - - generateSegments(); - addEdges(); - topologicalSorting(); - initialPositions(); - for (int i = 0; i < SWEEP_ITERATIONS; i++) { - - sweep(true); - sweep(true); - sweep(false); - sweep(false); - } - - sweep(true); - sweep(true); - } - } private static Comparator crossingNodeComparator = new Comparator() { + @Override public int compare(LayoutNode n1, LayoutNode n2) { return n1.crossingNumber - n2.crossingNumber; } @@ -1104,22 +819,26 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - protected void run() { - + @SuppressWarnings("unchecked") + private void createLayers() { layers = new List[layerCount]; for (int i = 0; i < layerCount; i++) { - layers[i] = new ArrayList(); + layers[i] = new ArrayList<>(); } + } + @Override + protected void run() { + createLayers(); // Generate initial ordering - HashSet visited = new HashSet(); + HashSet visited = new HashSet<>(); for (LayoutNode n : nodes) { if (n.layer == 0) { layers[0].add(n); visited.add(n); - } else if (n.preds.size() == 0) { + } else if (n.preds.isEmpty()) { layers[n.layer].add(n); visited.add(n); } @@ -1136,7 +855,6 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - updatePositions(); initX(); @@ -1146,10 +864,7 @@ public class HierarchicalLayoutManager implements LayoutManager { downSweep(); upSweep(); } - - /*for(int i=0; i 0) { - sum /= n.preds.size(); + if (count > 0) { + sum /= count; n.crossingNumber = sum; - //if(n.vertex == null) n.crossingNumber += layers[i].size(); } } - updateCrossingNumbers(i, true); Collections.sort(layers[i], crossingNodeComparator); updateXOfLayer(i); @@ -1234,9 +947,9 @@ public class HierarchicalLayoutManager implements LayoutManager { next = layers[index].get(i + 1); } - boolean cond = (n.succs.size() == 0); + boolean cond = n.succs.isEmpty(); if (down) { - cond = (n.preds.size() == 0); + cond = n.preds.isEmpty(); } if (cond) { @@ -1251,44 +964,6 @@ public class HierarchicalLayoutManager implements LayoutManager { } } } - /* - private void doubleSweep() { - // Downsweep - for(int i=0; i= layerCount) { - index = 2*layerCount - i - 1; - } - for(LayoutNode n : layers[index]) { - float sum = 0.0f; - for(LayoutEdge e : n.preds) { - float cur = e.from.pos; - if(e.from.width != 0 && e.relativeFrom != 0) { - cur += (float)e.relativeFrom / (float)(e.from.width); - } - sum += cur; - } - for(LayoutEdge e : n.succs) { - float cur = e.to.pos; - if(e.to.width != 0 && e.relativeTo != 0) { - cur += (float)e.relativeTo / (float)(e.to.width); - } - sum += cur; - } - if(n.preds.size() + n.succs.size() > 0) { - sum /= n.preds.size() + n.succs.size(); - n.crossingNumber = sum; - } - } - Collections.sort(layers[index], crossingNodeComparator); - updateXOfLayer(index); - int z = 0; - for(LayoutNode n : layers[index]) { - n.pos = z; - z++; - } - } - }*/ private void upSweep() { // Upsweep @@ -1300,21 +975,21 @@ public class HierarchicalLayoutManager implements LayoutManager { for (LayoutNode n : layers[i]) { + int count = 0; int sum = 0; for (LayoutEdge e : n.succs) { - int cur = e.to.x + e.relativeTo;//pos; - /* - if(e.to.width != 0 && e.relativeTo != 0) { - cur += (float)e.relativeTo / (float)(e.to.width); - }*/ - - sum += cur; + int cur = e.to.x + e.relativeTo; + int factor = 1; + if (e.vip) { + factor = VIP_BONUS; + } + sum += cur * factor; + count += factor; } - if (n.succs.size() > 0) { - sum /= n.succs.size(); + if (count > 0) { + sum /= count; n.crossingNumber = sum; - //if(n.vertex == null) n.crossingNumber += layers[i].size(); } } @@ -1331,15 +1006,10 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - private int evaluate() { - // TODO: Implement efficient evaluate / crossing min - return 0; - } - @Override public void postCheck() { - HashSet visited = new HashSet(); + HashSet visited = new HashSet<>(); for (int i = 0; i < layers.length; i++) { for (LayoutNode n : layers[i]) { assert !visited.contains(n); @@ -1353,9 +1023,10 @@ public class HierarchicalLayoutManager implements LayoutManager { private class AssignYCoordinates extends AlgorithmPart { + @Override protected void run() { int curY = 0; - //maxLayerHeight = new int[layers.length]; + for (int i = 0; i < layers.length; i++) { int maxHeight = 0; int baseLine = 0; @@ -1383,10 +1054,8 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - //maxLayerHeight[i] = maxHeight + baseLine + bottomBaseLine; - curY += maxHeight + baseLine + bottomBaseLine; - curY += layerOffset + (int) Math.sqrt(maxXOffset); + curY += layerOffset + ((int) (Math.sqrt(maxXOffset) * 1.5)); } } } @@ -1411,26 +1080,27 @@ public class HierarchicalLayoutManager implements LayoutManager { } } + @Override protected void run() { oldNodeCount = nodes.size(); - if (combine == Combine.SAME_OUTPUTS) { Comparator comparator = new Comparator() { + @Override public int compare(LayoutEdge e1, LayoutEdge e2) { return e1.to.layer - e2.to.layer; } }; - HashMap> portHash = new HashMap>(); - ArrayList currentNodes = new ArrayList(nodes); + HashMap> portHash = new HashMap<>(); + ArrayList currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { portHash.clear(); - ArrayList succs = new ArrayList(n.succs); - HashMap topNodeHash = new HashMap(); - HashMap> bottomNodeHash = new HashMap>(); + ArrayList succs = new ArrayList<>(n.succs); + HashMap topNodeHash = new HashMap<>(); + HashMap> bottomNodeHash = new HashMap<>(); for (LayoutEdge e : succs) { assert e.from.layer < e.to.layer; if (e.from.layer != e.to.layer - 1) { @@ -1449,6 +1119,7 @@ public class HierarchicalLayoutManager implements LayoutManager { topEdge.relativeTo = topNode.width / 2; topEdge.to = topNode; topEdge.link = e.link; + topEdge.vip = e.vip; e.from.succs.add(topEdge); topNode.preds.add(topEdge); } else { @@ -1464,6 +1135,7 @@ public class HierarchicalLayoutManager implements LayoutManager { topEdge.relativeTo = topNode.width / 2; topEdge.to = topNode; topEdge.link = e.link; + topEdge.vip = e.vip; e.from.succs.add(topEdge); topNode.preds.add(topEdge); topNodeHash.put(e.relativeFrom, topNode); @@ -1491,6 +1163,7 @@ public class HierarchicalLayoutManager implements LayoutManager { bottomEdge.relativeFrom = bottomNode.width / 2; bottomEdge.from = bottomNode; bottomEdge.link = e.link; + bottomEdge.vip = e.vip; e.to.preds.add(bottomEdge); bottomEdgeHash.put(topEdge, bottomEdge); bottomNode.succs.add(bottomEdge); @@ -1500,17 +1173,12 @@ public class HierarchicalLayoutManager implements LayoutManager { if (!portHash.containsKey(i)) { portHash.put(i, new ArrayList()); } - - if (n.vertex.toString().equals("1012 CastPP")) { - int x = 0; - } - portHash.get(i).add(e); } } } - succs = new ArrayList(n.succs); + succs = new ArrayList<>(n.succs); for (LayoutEdge e : succs) { Integer i = e.relativeFrom; @@ -1528,13 +1196,13 @@ public class HierarchicalLayoutManager implements LayoutManager { maxLayer = Math.max(maxLayer, curEdge.to.layer); } - int cnt = maxLayer - n.layer - 1; LayoutEdge[] edges = new LayoutEdge[cnt]; LayoutNode[] nodes = new LayoutNode[cnt]; edges[0] = new LayoutEdge(); edges[0].from = n; edges[0].relativeFrom = i; + edges[0].vip = e.vip; n.succs.add(edges[0]); nodes[0] = new LayoutNode(); @@ -1546,6 +1214,7 @@ public class HierarchicalLayoutManager implements LayoutManager { edges[0].relativeTo = nodes[0].width / 2; for (int j = 1; j < cnt; j++) { edges[j] = new LayoutEdge(); + edges[j].vip = e.vip; edges[j].from = nodes[j - 1]; edges[j].relativeFrom = nodes[j - 1].width / 2; nodes[j - 1].succs.add(edges[j]); @@ -1577,7 +1246,7 @@ public class HierarchicalLayoutManager implements LayoutManager { } else if (combine == Combine.SAME_INPUTS) { throw new UnsupportedOperationException("Currently not supported"); } else { - ArrayList currentNodes = new ArrayList(nodes); + ArrayList currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { for (LayoutEdge e : n.succs) { processSingleEdge(e); @@ -1604,6 +1273,7 @@ public class HierarchicalLayoutManager implements LayoutManager { n.preds.add(e); nodes.add(n); LayoutEdge result = new LayoutEdge(); + result.vip = e.vip; n.succs.add(result); result.from = n; result.relativeFrom = n.width / 2; @@ -1623,7 +1293,7 @@ public class HierarchicalLayoutManager implements LayoutManager { @Override public void postCheck() { - ArrayList currentNodes = new ArrayList(nodes); + ArrayList currentNodes = new ArrayList<>(nodes); for (LayoutNode n : currentNodes) { for (LayoutEdge e : n.succs) { assert e.from.layer == e.to.layer - 1; @@ -1648,89 +1318,112 @@ public class HierarchicalLayoutManager implements LayoutManager { } } + @Override protected void run() { - HashSet set = new HashSet(); + assignLayerDownwards(); + assignLayerUpwards(); + } + + private void assignLayerDownwards() { + ArrayList hull = new ArrayList<>(); for (LayoutNode n : nodes) { - if (n.preds.size() == 0) { - set.add(n); + if (n.preds.isEmpty()) { + hull.add(n); n.layer = 0; } } int z = minLayerDifference; - HashSet newSet = new HashSet(); - HashSet failed = new HashSet(); - while (!set.isEmpty()) { - - newSet.clear(); - failed.clear(); - - for (LayoutNode n : set) { - + while (!hull.isEmpty()) { + ArrayList newSet = new ArrayList<>(); + for (LayoutNode n : hull) { for (LayoutEdge se : n.succs) { LayoutNode s = se.to; - if (!newSet.contains(s) && !failed.contains(s)) { - boolean ok = true; + if (s.layer != -1) { + // This node was assigned before. + } else { + boolean unassignedPred = false; for (LayoutEdge pe : s.preds) { LayoutNode p = pe.from; - if (p.layer == -1) { - ok = false; + if (p.layer == -1 || p.layer >= z) { + // This now has an unscheduled successor or a successor that was scheduled only in this round. + unassignedPred = true; break; } } - if (ok) { - newSet.add(s); + if (unassignedPred) { + // This successor node can not yet be assigned. } else { - failed.add(s); + s.layer = z; + newSet.add(s); } } } - } - for (LayoutNode n : newSet) { - n.layer = z; - } - - // Swap sets - HashSet tmp = set; - set = newSet; - newSet = tmp; + hull = newSet; z += minLayerDifference; } - optimize(set); - layerCount = z - minLayerDifference; - - for (Vertex v : lastLayerHint) { - - LayoutNode n = vertexToLayoutNode.get(v); - assert n.succs.size() == 0; - n.layer = layerCount - 1; - } - - for (Vertex v : firstLayerHint) { - LayoutNode n = vertexToLayoutNode.get(v); - assert n.preds.size() == 0; - assert n.layer == 0; + for (LayoutNode n : nodes) { + n.layer = (layerCount - 1 - n.layer); } } - public void optimize(HashSet set) { - - for (LayoutNode n : set) { - if (n.preds.size() == 0 && n.succs.size() > 0) { - int minLayer = n.succs.get(0).to.layer; - for (LayoutEdge e : n.succs) { - minLayer = Math.min(minLayer, e.to.layer); - } - - n.layer = minLayer - 1; + private void assignLayerUpwards() { + ArrayList hull = new ArrayList<>(); + for (LayoutNode n : nodes) { + if (n.succs.isEmpty()) { + hull.add(n); + } else { + n.layer = -1; } } + int z = minLayerDifference; + while (!hull.isEmpty()) { + ArrayList newSet = new ArrayList<>(); + for (LayoutNode n : hull) { + if (n.layer < z) { + for (LayoutEdge se : n.preds) { + LayoutNode s = se.from; + if (s.layer != -1) { + // This node was assigned before. + } else { + boolean unassignedSucc = false; + for (LayoutEdge pe : s.succs) { + LayoutNode p = pe.to; + if (p.layer == -1 || p.layer >= z) { + // This now has an unscheduled successor or a successor that was scheduled only in this round. + unassignedSucc = true; + break; + } + } + + if (unassignedSucc) { + // This predecessor node can not yet be assigned. + } else { + s.layer = z; + newSet.add(s); + } + } + } + } else { + newSet.add(n); + } + } + + hull = newSet; + z += minLayerDifference; + } + + layerCount = z - minLayerDifference; + + for (LayoutNode n : nodes) { + n.layer = (layerCount - 1 - n.layer); + } } @Override @@ -1750,11 +1443,12 @@ public class HierarchicalLayoutManager implements LayoutManager { private HashSet visited; private HashSet active; + @Override protected void run() { - // Remove self-edges, TODO: Special treatment + // Remove self-edges for (LayoutNode node : nodes) { - ArrayList succs = new ArrayList(node.succs); + ArrayList succs = new ArrayList<>(node.succs); for (LayoutEdge e : succs) { assert e.from == node; if (e.to == node) { @@ -1780,18 +1474,16 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - // Start DFS and reverse back edges - visited = new HashSet(); - active = new HashSet(); + visited = new HashSet<>(); + active = new HashSet<>(); for (LayoutNode node : nodes) { DFS(node); } - for (LayoutNode node : nodes) { - SortedSet reversedDown = new TreeSet(); + SortedSet reversedDown = new TreeSet<>(); for (LayoutEdge e : node.succs) { if (reversedLinks.contains(e.link)) { @@ -1799,12 +1491,11 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - SortedSet reversedUp = null; if (reversedDown.size() == 0) { - reversedUp = new TreeSet(Collections.reverseOrder()); + reversedUp = new TreeSet<>(Collections.reverseOrder()); } else { - reversedUp = new TreeSet(); + reversedUp = new TreeSet<>(); } for (LayoutEdge e : node.preds) { @@ -1818,7 +1509,7 @@ public class HierarchicalLayoutManager implements LayoutManager { int curX = 0; int curWidth = node.width + reversedDown.size() * offset; for (int pos : reversedDown) { - ArrayList reversedSuccs = new ArrayList(); + ArrayList reversedSuccs = new ArrayList<>(); for (LayoutEdge e : node.succs) { if (e.relativeFrom == pos && reversedLinks.contains(e.link)) { reversedSuccs.add(e); @@ -1826,7 +1517,7 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - ArrayList startPoints = new ArrayList(); + ArrayList startPoints = new ArrayList<>(); startPoints.add(new Point(curWidth, curX)); startPoints.add(new Point(pos, curX)); startPoints.add(new Point(pos, reversedDown.size() * offset)); @@ -1856,7 +1547,7 @@ public class HierarchicalLayoutManager implements LayoutManager { int oldNodeHeight = node.height; for (int pos : reversedUp) { - ArrayList reversedPreds = new ArrayList(); + ArrayList reversedPreds = new ArrayList<>(); for (LayoutEdge e : node.preds) { if (e.relativeTo == pos && reversedLinks.contains(e.link)) { if (reversedDown.size() == 0) { @@ -1869,7 +1560,7 @@ public class HierarchicalLayoutManager implements LayoutManager { } } node.height += offset; - ArrayList endPoints = new ArrayList(); + ArrayList endPoints = new ArrayList<>(); if (reversedDown.size() == 0) { @@ -1887,7 +1578,6 @@ public class HierarchicalLayoutManager implements LayoutManager { curX += offset; node.bottomYOffset += offset; - endPoints.add(new Point(pos, node.height)); endPoints.add(new Point(pos, oldNodeHeight)); for (LayoutEdge e : reversedPreds) { @@ -1895,7 +1585,6 @@ public class HierarchicalLayoutManager implements LayoutManager { } } - if (minX < 0) { for (LayoutEdge e : node.preds) { e.relativeTo -= minX; @@ -1917,7 +1606,7 @@ public class HierarchicalLayoutManager implements LayoutManager { return; } - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(startNode); while (!stack.empty()) { @@ -1934,7 +1623,7 @@ public class HierarchicalLayoutManager implements LayoutManager { visited.add(node); active.add(node); - ArrayList succs = new ArrayList(node.succs); + ArrayList succs = new ArrayList<>(node.succs); for (LayoutEdge e : succs) { if (active.contains(e.to)) { assert visited.contains(e.to); @@ -1989,8 +1678,8 @@ public class HierarchicalLayoutManager implements LayoutManager { for (LayoutNode n : nodes) { - HashSet curVisited = new HashSet(); - Queue queue = new LinkedList(); + HashSet curVisited = new HashSet<>(); + Queue queue = new LinkedList<>(); for (LayoutEdge e : n.succs) { LayoutNode s = e.to; queue.add(s); @@ -2013,7 +1702,15 @@ public class HierarchicalLayoutManager implements LayoutManager { } private Comparator linkComparator = new Comparator() { + @Override public int compare(Link l1, Link l2) { + if (l1.isVIP() && !l2.isVIP()) { + return -1; + } + + if (!l1.isVIP() && l2.isVIP()) { + return 1; + } int result = l1.getFrom().getVertex().compareTo(l2.getFrom().getVertex()); if (result != 0) { @@ -2034,9 +1731,10 @@ public class HierarchicalLayoutManager implements LayoutManager { private class BuildDatastructure extends AlgorithmPart { + @Override protected void run() { // Set up nodes - List vertices = new ArrayList(graph.getVertices()); + List vertices = new ArrayList<>(graph.getVertices()); Collections.sort(vertices); for (Vertex v : vertices) { @@ -2050,7 +1748,7 @@ public class HierarchicalLayoutManager implements LayoutManager { } // Set up edges - List links = new ArrayList(graph.getLinks()); + List links = new ArrayList<>(graph.getLinks()); Collections.sort(links, linkComparator); for (Link l : links) { LayoutEdge edge = new LayoutEdge(); @@ -2061,14 +1759,15 @@ public class HierarchicalLayoutManager implements LayoutManager { edge.relativeFrom = l.getFrom().getRelativePosition().x; edge.relativeTo = l.getTo().getRelativePosition().x; edge.link = l; + edge.vip = l.isVIP(); edge.from.succs.add(edge); edge.to.preds.add(edge); - //assert edge.from != edge.to; // No self-loops allowed + //assert edge.from != edge.to; // No self-loops allowed } for (Link l : importantLinks) { - if (!vertexToLayoutNode.containsKey(l.getFrom().getVertex()) || - vertexToLayoutNode.containsKey(l.getTo().getVertex())) { + if (!vertexToLayoutNode.containsKey(l.getFrom().getVertex()) + || vertexToLayoutNode.containsKey(l.getTo().getVertex())) { continue; } LayoutNode from = vertexToLayoutNode.get(l.getFrom().getVertex()); @@ -2104,7 +1803,8 @@ public class HierarchicalLayoutManager implements LayoutManager { } } + @Override public void doRouting(LayoutGraph graph) { - // Do nothing for now + // Do nothing for now } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java index 43b78fa4bbc..3599434217a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/InterClusterConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,4 +73,8 @@ public class InterClusterConnection implements Link { public String toString() { return "InterClusterConnection[from=" + getFrom() + ", to=" + getTo() + "]"; } + + public boolean isVIP() { + return false; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java index bb288188241..f98b1598002 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Node.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,8 +90,8 @@ public class Node { protected Node(Graph graph, N data) { setData(data); this.graph = graph; - inEdges = new ArrayList>(); - outEdges = new ArrayList>(); + inEdges = new ArrayList<>(); + outEdges = new ArrayList<>(); } protected void addInEdge(Edge e) { @@ -125,7 +125,7 @@ public class Node { } public List> getSuccessors() { - ArrayList> succ = new ArrayList>(); + ArrayList> succ = new ArrayList<>(); for (Edge e : getOutEdges()) { Node n = e.getDest(); if (!succ.contains(n)) { @@ -136,7 +136,7 @@ public class Node { } public List> getPredecessors() { - ArrayList> pred = new ArrayList>(); + ArrayList> pred = new ArrayList<>(); for (Edge e : getInEdges()) { Node n = e.getSource(); if (!pred.contains(n)) { diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java deleted file mode 100644 index 33b33d3825e..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java +++ /dev/null @@ -1,1222 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.hierarchicallayout; - -import java.awt.Point; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.layout.LayoutManager; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; - -/** - * - * @author Thomas Wuerthinger - */ -public class OldHierarchicalLayoutManager implements LayoutManager { - - public static final int DUMMY_WIDTH = 0; - public static final int DUMMY_HEIGHT = 0; - public static final int LAYER_OFFSET = 50; - public static final int OFFSET = 8; - public static final boolean VERTICAL_LAYOUT = true; - public static final boolean ASSERT = false; - public static final boolean TRACE = false; - public static final Timing initTiming = new Timing("init"); - public static final Timing removeCyclesTiming = new Timing("removeCycles"); - public static final Timing reversedEdgesTiming = new Timing("reversedEdges"); - public static final Timing assignLayersTiming = new Timing("assignLayers"); - public static final Timing dummyNodesTiming = new Timing("dummyNodes"); - public static final Timing crossingReductionTiming = new Timing("crossingReduction"); - public static final Timing assignCoordinatesTiming = new Timing("assignCoordinates"); - public static final Timing assignRealTiming = new Timing("assignReal"); - public static final Timing rootVertexTiming = new Timing("rootVertex"); - public static final Timing createEdgesTiming = new Timing("createEdges"); - public static final Timing optimizeMedianTiming = new Timing("optimizeMedian"); - private Combine combine; - - public enum Combine { - - NONE, - SAME_INPUTS, - SAME_OUTPUTS - } - - private class NodeData { - - private Map reversePositions; - private Vertex node; - private Link edge; - private int layer; - private int x; - private int y; - private int width; - - public NodeData(Vertex node) { - reversePositions = new HashMap(); - layer = -1; - this.node = node; - assert node != null; - - if (VERTICAL_LAYOUT) { - width = node.getSize().width; - } else { - width = node.getSize().height; - } - } - - public NodeData(Link edge) { - layer = -1; - this.edge = edge; - assert edge != null; - - if (VERTICAL_LAYOUT) { - width = DUMMY_WIDTH; - } else { - width = DUMMY_HEIGHT; - } - } - - public Vertex getNode() { - return node; - } - - public Link getEdge() { - return edge; - } - - public int getCoordinate() { - return x; - } - - public void setCoordinate(int x) { - this.x = x; - } - - public int getX() { - if (VERTICAL_LAYOUT) { - return x; - } else { - return y; - } - } - - public int getY() { - if (VERTICAL_LAYOUT) { - return y; - } else { - return x; - } - } - - public void setLayerCoordinate(int y) { - this.y = y; - } - - public void setLayer(int x) { - layer = x; - } - - public int getLayer() { - return layer; - } - - public boolean isDummy() { - return edge != null; - } - - public int getWidth() { - return width; - } - - public void addReversedStartEdge(Edge e) { - assert e.getData().isReversed(); - Port port = e.getData().getEdge().getTo(); - int pos = addReversedPort(port); - Point start = e.getData().getRelativeStart(); - e.getData().addStartPoint(start); - int yCoord = node.getSize().height + width - node.getSize().width; - e.getData().addStartPoint(new Point(start.x, yCoord)); - e.getData().addStartPoint(new Point(pos, yCoord)); - e.getData().setRelativeStart(new Point(pos, 0)); - } - - private int addReversedPort(Port p) { - if (reversePositions.containsKey(p)) { - return reversePositions.get(p); - } else { - width += OFFSET; - reversePositions.put(p, width); - return width; - } - } - - public void addReversedEndEdge(Edge e) { - assert e.getData().isReversed(); - int pos = addReversedPort(e.getData().getEdge().getFrom()); - Point end = e.getData().getRelativeEnd(); - e.getData().setRelativeEnd(new Point(pos, node.getSize().height)); - int yCoord = 0 - width + node.getSize().width; - e.getData().addEndPoint(new Point(pos, yCoord)); - e.getData().addEndPoint(new Point(end.x, yCoord)); - e.getData().addEndPoint(end); - } - - public int getHeight() { - if (isDummy()) { - if (VERTICAL_LAYOUT) { - return DUMMY_HEIGHT; - } else { - return DUMMY_WIDTH; - } - - } else { - if (VERTICAL_LAYOUT) { - return node.getSize().height; - } else { - return node.getSize().width; - } - } - } - - @Override - public String toString() { - if (isDummy()) { - return edge.toString() + "(layer=" + layer + ")"; - } else { - return node.toString() + "(layer=" + layer + ")"; - } - } - } - - private class EdgeData { - - private Point relativeEnd; - private Point relativeStart; - private List startPoints; - private List endPoints; - private boolean important; - private boolean reversed; - private Link edge; - - public EdgeData(Link edge) { - this(edge, false); - } - - public EdgeData(Link edge, boolean rev) { - this.edge = edge; - reversed = rev; - relativeStart = edge.getFrom().getRelativePosition(); - relativeEnd = edge.getTo().getRelativePosition(); - assert relativeStart.x >= 0 && relativeStart.x <= edge.getFrom().getVertex().getSize().width; - assert relativeStart.y >= 0 && relativeStart.y <= edge.getFrom().getVertex().getSize().height; - assert relativeEnd.x >= 0 && relativeEnd.x <= edge.getTo().getVertex().getSize().width; - assert relativeEnd.y >= 0 && relativeEnd.y <= edge.getTo().getVertex().getSize().height; - startPoints = new ArrayList(); - endPoints = new ArrayList(); - this.important = true; - } - - public boolean isImportant() { - return important; - } - - public void setImportant(boolean b) { - this.important = b; - } - - public List getStartPoints() { - return startPoints; - } - - public List getEndPoints() { - return endPoints; - } - - public List getAbsoluteEndPoints() { - if (endPoints.size() == 0) { - return endPoints; - } - - List result = new ArrayList(); - Point point = edge.getTo().getVertex().getPosition(); - for (Point p : endPoints) { - Point p2 = new Point(p.x + point.x, p.y + point.y); - result.add(p2); - } - - return result; - } - - public List getAbsoluteStartPoints() { - if (startPoints.size() == 0) { - return startPoints; - } - - List result = new ArrayList(); - Point point = edge.getFrom().getVertex().getPosition(); - for (Point p : startPoints) { - Point p2 = new Point(p.x + point.x, p.y + point.y); - result.add(p2); - } - - return result; - } - - public void addEndPoint(Point p) { - endPoints.add(p); - } - - public void addStartPoint(Point p) { - startPoints.add(p); - } - - public Link getEdge() { - return edge; - } - - public void setRelativeEnd(Point p) { - relativeEnd = p; - } - - public void setRelativeStart(Point p) { - relativeStart = p; - } - - public Point getRelativeEnd() { - return relativeEnd; - } - - public Point getRelativeStart() { - return relativeStart; - } - - public boolean isReversed() { - return reversed; - } - - public void setReversed(boolean b) { - reversed = b; - } - - @Override - public String toString() { - return "EdgeData[reversed=" + reversed + "]"; - } - } - private Graph graph; - private Map> nodeMap; - private int layerOffset; - - /** Creates a new instance of HierarchicalPositionManager */ - public OldHierarchicalLayoutManager(Combine combine) { - this(combine, LAYER_OFFSET); - } - - public OldHierarchicalLayoutManager(Combine combine, int layerOffset) { - this.combine = combine; - this.layerOffset = layerOffset; - } - - public void doRouting(LayoutGraph graph) { - } - - //public void setPositions(PositionedNode rootNode, List nodes, List edges) { - public void doLayout(LayoutGraph layoutGraph) { - doLayout(layoutGraph, new HashSet(), new HashSet()); - } - - public void doLayout(LayoutGraph layoutGraph, Set firstLayerHint, Set lastLayerHint) { - doLayout(layoutGraph, firstLayerHint, lastLayerHint, new HashSet()); - } - - public void doLayout(LayoutGraph layoutGraph, Set firstLayerHint, Set lastLayerHint, Set importantLinksHint) { - - if (TRACE) { - System.out.println("HierarchicalPositionManager.doLayout called"); - System.out.println("Vertex count = " + layoutGraph.getVertices().size() + " Link count = " + layoutGraph.getLinks().size()); - } - - // Nothing to do => quit immediately - if (layoutGraph.getVertices().size() == 0) { - return; - } - - initTiming.start(); - - // Mapping vertex to Node in graph - nodeMap = new HashMap>(); - - graph = new Graph(); - - Set> rootNodes = new HashSet>(); - Set startRootVertices = new HashSet(); - - for (Vertex v : layoutGraph.getVertices()) { - if (v.isRoot()) { - startRootVertices.add(v); - } - } - - rootVertexTiming.start(); - Set rootVertices = layoutGraph.findRootVertices(startRootVertices); - rootVertexTiming.stop(); - - - for (Vertex node : layoutGraph.getVertices()) { - - NodeData data = new NodeData(node); - Node n = graph.createNode(data, node); - nodeMap.put(node, n); - - if (rootVertices.contains(node)) { - rootNodes.add(n); - } - } - - Set links = layoutGraph.getLinks(); - Link[] linkArr = new Link[links.size()]; - links.toArray(linkArr); - - List linkList = new ArrayList(); - for (Link l : linkArr) { - linkList.add(l); - } - - createEdgesTiming.start(); - Collections.sort(linkList, new Comparator() { - - public int compare(Link o1, Link o2) { - int result = o1.getFrom().getVertex().compareTo(o2.getFrom().getVertex()); - if (result == 0) { - return o1.getTo().getVertex().compareTo(o2.getTo().getVertex()); - } else { - return result; - } - } - }); - - for (Link edge : linkList) { - EdgeData data = new EdgeData(edge); - graph.createEdge(graph.getNode(edge.getFrom().getVertex()), graph.getNode(edge.getTo().getVertex()), data, data); - if (importantLinksHint.size() > 0 && !importantLinksHint.contains(edge)) { - data.setImportant(false); - } - } - createEdgesTiming.stop(); - - initTiming.stop(); - - removeCyclesTiming.start(); - - // STEP 1: Remove cycles! - removeCycles(rootNodes); - if (ASSERT) { - assert checkRemoveCycles(); - } - - removeCyclesTiming.stop(); - - reversedEdgesTiming.start(); - - for (Node n : graph.getNodes()) { - List> edges = new ArrayList>(n.getOutEdges()); - Collections.sort(edges, new Comparator>() { - - public int compare(Edge o1, Edge o2) { - return o2.getData().getRelativeEnd().x - o1.getData().getRelativeEnd().x; - } - }); - - - for (Edge e : edges) { - - if (e.getData().isReversed()) { - e.getSource().getData().addReversedEndEdge(e); - } - } - } - - for (Node n : graph.getNodes()) { - List> edges = new ArrayList>(n.getInEdges()); - Collections.sort(edges, new Comparator>() { - - public int compare(Edge o1, Edge o2) { - return o2.getData().getRelativeStart().x - o1.getData().getRelativeStart().x; - } - }); - - - for (Edge e : edges) { - if (e.getData().isReversed()) { - e.getDest().getData().addReversedStartEdge(e); - } - } - } - - reversedEdgesTiming.stop(); - - assignLayersTiming.start(); - // STEP 2: Assign layers! - int maxLayer = assignLayers(rootNodes, firstLayerHint, lastLayerHint); - if (ASSERT) { - assert checkAssignLayers(); - } - - // Put into layer array - //int maxLayer = 0; - //for(Node n : graph.getNodes()) { - // maxLayer = Math.max(maxLayer, n.getData().getLayer()); - //} - - - ArrayList> layers[] = new ArrayList[maxLayer + 1]; - int layerSizes[] = new int[maxLayer + 1]; - for (int i = 0; i < maxLayer + 1; i++) { - layers[i] = new ArrayList>(); - } - - for (Node n : graph.getNodes()) { - int curLayer = n.getData().getLayer(); - layers[curLayer].add(n); - } - - assignLayersTiming.stop(); - - // STEP 3: Insert dummy nodes! - dummyNodesTiming.start(); - insertDummyNodes(layers); - if (ASSERT) { - assert checkDummyNodes(); - } - dummyNodesTiming.stop(); - - crossingReductionTiming.start(); - // STEP 4: Assign Y coordinates - assignLayerCoordinates(layers, layerSizes); - - // STEP 5: Crossing reduction - crossingReduction(layers); - crossingReductionTiming.stop(); - - // STEP 6: Assign Y coordinates - assignCoordinatesTiming.start(); - assignCoordinates(layers); - assignCoordinatesTiming.stop(); - - assignRealTiming.start(); - - // Assign coordinates of nodes to real objects - for (Node n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - node.setPosition(new Point(n.getData().getX(), n.getData().getY())); - } - } - - for (Node n : graph.getNodes()) { - if (!n.getData().isDummy()) { - - Vertex node = n.getData().getNode(); - - List> outEdges = n.getOutEdges(); - for (Edge e : outEdges) { - Node succ = e.getDest(); - if (succ.getData().isDummy()) { - //PositionedEdge edge = succ.getData().getEdge(); - List points = new ArrayList(); - assignToRealObjects(layerSizes, succ, points); - } else { - List points = new ArrayList(); - - EdgeData otherEdgeData = e.getData(); - points.addAll(otherEdgeData.getAbsoluteStartPoints()); - Link otherEdge = otherEdgeData.getEdge(); - Point relFrom = new Point(otherEdgeData.getRelativeStart()); - Point from = otherEdge.getFrom().getVertex().getPosition(); - relFrom.move(relFrom.x + from.x, relFrom.y + from.y); - points.add(relFrom); - - Point relTo = new Point(otherEdgeData.getRelativeEnd()); - Point to = otherEdge.getTo().getVertex().getPosition(); - relTo.move(relTo.x + to.x, relTo.y + to.y); - assert from != null; - assert to != null; - points.add(relTo); - points.addAll(otherEdgeData.getAbsoluteEndPoints()); - e.getData().getEdge().setControlPoints(points); - } - } - } - } - - assignRealTiming.stop(); - - initTiming.print(); - removeCyclesTiming.print(); - reversedEdgesTiming.print(); - assignLayersTiming.print(); - dummyNodesTiming.print(); - crossingReductionTiming.print(); - assignCoordinatesTiming.print(); - assignRealTiming.print(); - rootVertexTiming.print(); - createEdgesTiming.print(); - optimizeMedianTiming.print(); - } - - public boolean onOneLine(Point p1, Point p2, Point p3) { - int xoff1 = p1.x - p2.x; - int yoff1 = p1.y - p2.y; - int xoff2 = p3.x - p2.x; - int yoff2 = p3.y - p2.x; - - return (xoff1 * yoff2 - yoff1 * xoff2 == 0); - } - - private void assignToRealObjects(int layerSizes[], Node cur, List points) { - assert cur.getData().isDummy(); - - ArrayList otherPoints = new ArrayList(points); - - int size = layerSizes[cur.getData().getLayer()]; - otherPoints.add(new Point(cur.getData().getX(), cur.getData().getY() - size / 2)); - if (otherPoints.size() >= 3 && onOneLine(otherPoints.get(otherPoints.size() - 1), otherPoints.get(otherPoints.size() - 2), otherPoints.get(otherPoints.size() - 3))) { - otherPoints.remove(otherPoints.size() - 2); - } - otherPoints.add(new Point(cur.getData().getX(), cur.getData().getY() + size / 2)); - if (otherPoints.size() >= 3 && onOneLine(otherPoints.get(otherPoints.size() - 1), otherPoints.get(otherPoints.size() - 2), otherPoints.get(otherPoints.size() - 3))) { - otherPoints.remove(otherPoints.size() - 2); - } - - for (int i = 0; i < cur.getOutEdges().size(); i++) { - Node otherSucc = cur.getOutEdges().get(i).getDest(); - - if (otherSucc.getData().isDummy()) { - assignToRealObjects(layerSizes, otherSucc, otherPoints); - } else { - EdgeData otherEdgeData = cur.getOutEdges().get(i).getData(); - Link otherEdge = otherEdgeData.getEdge(); - - List middlePoints = new ArrayList(otherPoints); - if (cur.getOutEdges().get(i).getData().isReversed()) { - Collections.reverse(middlePoints); - } - - ArrayList copy = new ArrayList(); - Point relFrom = new Point(otherEdgeData.getRelativeStart()); - Point from = otherEdge.getFrom().getVertex().getPosition(); - //int moveUp = (size - otherEdge.getFrom().getVertex().getSize().height) / 2; - relFrom.move(relFrom.x + from.x, relFrom.y + from.y); - copy.addAll(otherEdgeData.getAbsoluteStartPoints()); - copy.add(relFrom); - copy.addAll(middlePoints); - - Point relTo = new Point(otherEdgeData.getRelativeEnd()); - Point to = otherEdge.getTo().getVertex().getPosition(); - relTo.move(relTo.x + to.x, relTo.y + to.y); - copy.add(relTo); - - copy.addAll(otherEdgeData.getAbsoluteEndPoints()); - - - otherEdge.setControlPoints(copy); - } - } - } - - private boolean checkDummyNodes() { - for (Edge e : graph.getEdges()) { - if (e.getSource().getData().getLayer() != e.getDest().getData().getLayer() - 1) { - return false; - } - } - - return true; - } - - private void insertDummyNodes(ArrayList> layers[]) { - - int sum = 0; - List> nodes = new ArrayList>(graph.getNodes()); - int edgeCount = 0; - int innerMostLoop = 0; - - for (Node n : nodes) { - List> edges = new ArrayList>(n.getOutEdges()); - for (Edge e : edges) { - - edgeCount++; - Link edge = e.getData().getEdge(); - Node destNode = e.getDest(); - Node lastNode = n; - Edge lastEdge = e; - - boolean searchForNode = (combine != Combine.NONE); - for (int i = n.getData().getLayer() + 1; i < destNode.getData().getLayer(); i++) { - - Node foundNode = null; - if (searchForNode) { - for (Node sameLayerNode : layers[i]) { - innerMostLoop++; - - if (combine == Combine.SAME_OUTPUTS) { - if (sameLayerNode.getData().isDummy() && sameLayerNode.getData().getEdge().getFrom() == edge.getFrom()) { - foundNode = sameLayerNode; - break; - } - } else if (combine == Combine.SAME_INPUTS) { - if (sameLayerNode.getData().isDummy() && sameLayerNode.getData().getEdge().getTo() == edge.getTo()) { - foundNode = sameLayerNode; - break; - } - } - } - } - - if (foundNode == null) { - searchForNode = false; - NodeData intermediateData = new NodeData(edge); - Node curNode = graph.createNode(intermediateData, null); - curNode.getData().setLayer(i); - layers[i].add(0, curNode); - sum++; - lastEdge.remove(); - graph.createEdge(lastNode, curNode, e.getData(), null); - assert lastNode.getData().getLayer() == curNode.getData().getLayer() - 1; - lastEdge = graph.createEdge(curNode, destNode, e.getData(), null); - lastNode = curNode; - } else { - lastEdge.remove(); - lastEdge = graph.createEdge(foundNode, destNode, e.getData(), null); - lastNode = foundNode; - } - - } - } - } - - if (TRACE) { - System.out.println("Number of edges: " + edgeCount); - } - if (TRACE) { - System.out.println("Dummy nodes inserted: " + sum); - } - } - - private void assignLayerCoordinates(ArrayList> layers[], int layerSizes[]) { - int cur = 0; - for (int i = 0; i < layers.length; i++) { - int maxHeight = 0; - for (Node n : layers[i]) { - maxHeight = Math.max(maxHeight, n.getData().getHeight()); - } - - layerSizes[i] = maxHeight; - for (Node n : layers[i]) { - int curCoordinate = cur + (maxHeight - n.getData().getHeight()) / 2; - n.getData().setLayerCoordinate(curCoordinate); - } - cur += maxHeight + layerOffset; - - } - } - - private void assignCoordinates(ArrayList> layers[]) { - - // TODO: change this - for (int i = 0; i < layers.length; i++) { - ArrayList> curArray = layers[i]; - int curY = 0; - for (Node n : curArray) { - - n.getData().setCoordinate(curY); - if (!n.getData().isDummy()) { - curY += n.getData().getWidth(); - } - curY += OFFSET; - - } - } - - int curSol = evaluateSolution(); - if (TRACE) { - System.out.println("First coordinate solution found: " + curSol); - } - - // Sort to correct order - for (int i = 0; i < layers.length; i++) { - Collections.sort(layers[i], new Comparator>() { - - public int compare(Node o1, Node o2) { - if (o2.getData().isDummy()) { - return 1; - } else if (o1.getData().isDummy()) { - return -1; - } - return o2.getInEdges().size() + o2.getOutEdges().size() - o1.getInEdges().size() - o1.getOutEdges().size(); - } - }); - } - - - optimizeMedianTiming.start(); - for (int i = 0; i < 2; i++) { - optimizeMedian(layers); - curSol = evaluateSolution(); - if (TRACE) { - System.out.println("Current coordinate solution found: " + curSol); - } - } - optimizeMedianTiming.stop(); - normalizeCoordinate(); - - } - - private void normalizeCoordinate() { - - int min = Integer.MAX_VALUE; - for (Node n : graph.getNodes()) { - min = Math.min(min, n.getData().getCoordinate()); - } - - for (Node n : graph.getNodes()) { - n.getData().setCoordinate(n.getData().getCoordinate() - min); - } - - } - - private void optimizeMedian(ArrayList> layers[]) { - - // Downsweep - for (int i = 1; i < layers.length; i++) { - - ArrayList> processingList = layers[i]; - ArrayList> alreadyAssigned = new ArrayList>(); - for (Node n : processingList) { - - - ArrayList> preds = new ArrayList>(n.getPredecessors()); - int pos = n.getData().getCoordinate(); - if (preds.size() > 0) { - - Collections.sort(preds, new Comparator>() { - - public int compare(Node o1, Node o2) { - return o1.getData().getCoordinate() - o2.getData().getCoordinate(); - } - }); - - if (preds.size() % 2 == 0) { - assert preds.size() >= 2; - pos = (preds.get(preds.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2), n) + preds.get(preds.size() / 2 - 1).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2 - 1), n)) / 2; - } else { - assert preds.size() >= 1; - pos = preds.get(preds.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(preds.get(preds.size() / 2), n); - } - } - - tryAdding(alreadyAssigned, n, pos); - } - } - // Upsweep - for (int i = layers.length - 2; i >= 0; i--) { - ArrayList> processingList = layers[i]; - ArrayList> alreadyAssigned = new ArrayList>(); - for (Node n : processingList) { - - ArrayList> succs = new ArrayList>(n.getSuccessors()); - int pos = n.getData().getCoordinate(); - if (succs.size() > 0) { - - Collections.sort(succs, new Comparator>() { - - public int compare(Node o1, Node o2) { - return o1.getData().getCoordinate() - o2.getData().getCoordinate(); - } - }); - - if (succs.size() % 2 == 0) { - assert succs.size() >= 2; - pos = (succs.get(succs.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2)) + succs.get(succs.size() / 2 - 1).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2 - 1))) / 2; - } else { - assert succs.size() >= 1; - pos = succs.get(succs.size() / 2).getData().getCoordinate() - calcRelativeCoordinate(n, succs.get(succs.size() / 2)); - } - } - - tryAdding(alreadyAssigned, n, pos); - } - } - } - - private int median(ArrayList arr) { - assert arr.size() > 0; - Collections.sort(arr); - if (arr.size() % 2 == 0) { - return (arr.get(arr.size() / 2) + arr.get(arr.size() / 2 - 1)) / 2; - } else { - return arr.get(arr.size() / 2); - } - } - - private int calcRelativeCoordinate(Node n, Node succ) { - - if (n.getData().isDummy() && succ.getData().isDummy()) { - return 0; - } - - int pos = 0; - int pos2 = 0; - ArrayList coords2 = new ArrayList(); - ArrayList coords = new ArrayList(); - /*if(!n.getData().isDummy())*/ { - for (Edge e : n.getOutEdges()) { - - //System.out.println("reversed: " + e.getData().isReversed()); - if (e.getDest() == succ) { - - if (e.getData().isReversed()) { - if (!n.getData().isDummy()) { - coords.add(e.getData().getRelativeEnd().x); - } - - if (!succ.getData().isDummy()) { - coords2.add(e.getData().getRelativeStart().x); - } - } else { - if (!n.getData().isDummy()) { - coords.add(e.getData().getRelativeStart().x); - } - - if (!succ.getData().isDummy()) { - coords2.add(e.getData().getRelativeEnd().x); - } - } - } - } - - // assert coords.size() > 0; - if (!n.getData().isDummy()) { - pos = median(coords); - } - - if (!succ.getData().isDummy()) { - pos2 = median(coords2); - } - } - //System.out.println("coords=" + coords); - //System.out.println("coords2=" + coords2); - - return pos - pos2; - } - - private boolean intersect(int v1, int w1, int v2, int w2) { - if (v1 >= v2 && v1 < v2 + w2) { - return true; - } - if (v1 + w1 > v2 && v1 + w1 < v2 + w2) { - return true; - } - if (v1 < v2 && v1 + w1 > v2) { - return true; - } - return false; - } - - private boolean intersect(Node n1, Node n2) { - return intersect(n1.getData().getCoordinate(), n1.getData().getWidth() + OFFSET, n2.getData().getCoordinate(), n2.getData().getWidth() + OFFSET); - } - - private void tryAdding(List> alreadyAssigned, Node node, int pos) { - - boolean doesIntersect = false; - node.getData().setCoordinate(pos); - for (Node n : alreadyAssigned) { - if (n.getData().getCoordinate() + n.getData().getWidth() < pos) { - break; - } else if (intersect(node, n)) { - doesIntersect = true; - break; - } - - } - - if (!doesIntersect) { - - // Everything fine, just place the node - int z = 0; - for (Node n : alreadyAssigned) { - if (pos > n.getData().getCoordinate()) { - break; - } - z++; - } - - if (z == -1) { - z = alreadyAssigned.size(); - } - - - if (ASSERT) { - assert !findOverlap(alreadyAssigned, node); - } - alreadyAssigned.add(z, node); - - } else { - - assert alreadyAssigned.size() > 0; - - // Search for alternative location - int minOffset = Integer.MAX_VALUE; - int minIndex = -1; - int minPos = 0; - int w = node.getData().getWidth() + OFFSET; - - // Try top-most - minIndex = 0; - minPos = alreadyAssigned.get(0).getData().getCoordinate() + alreadyAssigned.get(0).getData().getWidth() + OFFSET; - minOffset = Math.abs(minPos - pos); - - // Try bottom-most - Node lastNode = alreadyAssigned.get(alreadyAssigned.size() - 1); - int lastPos = lastNode.getData().getCoordinate() - w; - int lastOffset = Math.abs(lastPos - pos); - if (lastOffset < minOffset) { - minPos = lastPos; - minOffset = lastOffset; - minIndex = alreadyAssigned.size(); - } - - // Try between - for (int i = 0; i < alreadyAssigned.size() - 1; i++) { - Node curNode = alreadyAssigned.get(i); - Node nextNode = alreadyAssigned.get(i + 1); - - int start = nextNode.getData().getCoordinate() + nextNode.getData().getWidth() + OFFSET; - int end = curNode.getData().getCoordinate() - OFFSET; - - int bestPoss = end - node.getData().getWidth(); - if (bestPoss < pos && pos - bestPoss > minOffset) { - // No better solution possible => break - break; - } - - if (end - start >= node.getData().getWidth()) { - // Node could fit here - int cand1 = start; - int cand2 = end - node.getData().getWidth(); - int off1 = Math.abs(cand1 - pos); - int off2 = Math.abs(cand2 - pos); - if (off1 < minOffset) { - minPos = cand1; - minOffset = off1; - minIndex = i + 1; - } - - if (off2 < minOffset) { - minPos = cand2; - minOffset = off2; - minIndex = i + 1; - } - } - } - - assert minIndex != -1; - node.getData().setCoordinate(minPos); - if (ASSERT) { - assert !findOverlap(alreadyAssigned, node); - } - alreadyAssigned.add(minIndex, node); - } - - } - - private boolean findOverlap(List> nodes, Node node) { - - for (Node n1 : nodes) { - if (intersect(n1, node)) { - return true; - } - } - - return false; - } - - private int evaluateSolution() { - - int sum = 0; - for (Edge e : graph.getEdges()) { - Node source = e.getSource(); - Node dest = e.getDest(); - int offset = 0; - offset = Math.abs(source.getData().getCoordinate() - dest.getData().getCoordinate()); - sum += offset; - } - - return sum; - } - - private void crossingReduction(ArrayList> layers[]) { - - for (int i = 0; i < layers.length - 1; i++) { - - ArrayList> curNodes = layers[i]; - ArrayList> nextNodes = layers[i + 1]; - for (Node n : curNodes) { - for (Node succ : n.getSuccessors()) { - if (ASSERT) { - assert nextNodes.contains(succ); - } - nextNodes.remove(succ); - nextNodes.add(succ); - } - } - - } - - } - - private void removeCycles(Set> rootNodes) { - final List> reversedEdges = new ArrayList>(); - - - int removedCount = 0; - int reversedCount = 0; - - Graph.DFSTraversalVisitor visitor = graph.new DFSTraversalVisitor() { - - @Override - public boolean visitEdge(Edge e, boolean backEdge) { - if (backEdge) { - if (ASSERT) { - assert !reversedEdges.contains(e); - } - reversedEdges.add(e); - e.getData().setReversed(!e.getData().isReversed()); - } - - return e.getData().isImportant(); - } - }; - Set> nodes = new HashSet>(); - nodes.addAll(rootNodes); - - assert nodes.size() > 0; - - this.graph.traverseDFS(nodes, visitor); - - for (Edge e : reversedEdges) { - if (e.isSelfLoop()) { - e.remove(); - removedCount++; - } else { - e.reverse(); - reversedCount++; - } - } - } - - private boolean checkRemoveCycles() { - return !graph.hasCycles(); - } - // Only used by assignLayers - private int maxLayerTemp; - - private int assignLayers(Set> rootNodes, Set firstLayerHints, - Set lastLayerHints) { - this.maxLayerTemp = -1; - for (Node n : graph.getNodes()) { - n.getData().setLayer(-1); - } - - Graph.BFSTraversalVisitor traverser = graph.new BFSTraversalVisitor() { - - @Override - public void visitNode(Node n, int depth) { - if (depth > n.getData().getLayer()) { - n.getData().setLayer(depth); - maxLayerTemp = Math.max(maxLayerTemp, depth); - } - } - }; - - for (Node n : rootNodes) { - if (n.getData().getLayer() == -1) { - this.graph.traverseBFS(n, traverser, true); - } - } - - for (Vertex v : firstLayerHints) { - assert nodeMap.containsKey(v); - nodeMap.get(v).getData().setLayer(0); - } - - for (Vertex v : lastLayerHints) { - assert nodeMap.containsKey(v); - nodeMap.get(v).getData().setLayer(maxLayerTemp); - } - - return maxLayerTemp; - } - - private boolean checkAssignLayers() { - - for (Edge e : graph.getEdges()) { - Node source = e.getSource(); - Node dest = e.getDest(); - - - if (source.getData().getLayer() >= dest.getData().getLayer()) { - return false; - } - } - int maxLayer = 0; - for (Node n : graph.getNodes()) { - assert n.getData().getLayer() >= 0; - if (n.getData().getLayer() > maxLayer) { - maxLayer = n.getData().getLayer(); - } - } - - int countPerLayer[] = new int[maxLayer + 1]; - for (Node n : graph.getNodes()) { - countPerLayer[n.getData().getLayer()]++; - } - - if (TRACE) { - System.out.println("Number of layers: " + maxLayer); - } - return true; - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Timing.java b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Timing.java index 43881d5be8e..7272e80d761 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Timing.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/Timing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java index dc8128b14c6..31ac1a6a1c2 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,4 @@ public interface Cluster extends Comparable { public void setBounds(Rectangle r); public Set getSuccessors(); - - public Set getPredecessors(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java index 933b8a69ba9..3a8da0d649c 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,7 @@ */ package com.sun.hotspot.igv.layout; -import java.util.HashSet; -import java.util.HashMap; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.*; /** * @@ -49,10 +45,10 @@ public class LayoutGraph { this.links = links; assert verify(); - vertices = new TreeSet(); - portLinks = new HashMap>(); - inputPorts = new HashMap>(); - outputPorts = new HashMap>(); + vertices = new TreeSet<>(); + portLinks = new HashMap<>(links.size()); + inputPorts = new HashMap<>(links.size()); + outputPorts = new HashMap<>(links.size()); for (Link l : links) { Port p = l.getFrom(); @@ -76,7 +72,7 @@ public class LayoutGraph { } if (!portLinks.containsKey(p)) { - HashSet hashSet = new HashSet(3); + HashSet hashSet = new HashSet<>(3); portLinks.put(p, hashSet); } @@ -152,7 +148,7 @@ public class LayoutGraph { // whole graph is visited. public Set findRootVertices(Set startingRoots) { - Set notRootSet = new HashSet(); + Set notRootSet = new HashSet<>(); for (Vertex v : startingRoots) { if (!notRootSet.contains(v)) { markNotRoot(notRootSet, v, v); @@ -174,7 +170,7 @@ public class LayoutGraph { } } - Set result = new HashSet(); + Set result = new HashSet<>(); for (Vertex v : tmpVertices) { if (!notRootSet.contains(v)) { result.add(v); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutManager.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutManager.java index 6a3fc0c1c7c..cca19fa28b6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutManager.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ public interface LayoutManager { public void doLayout(LayoutGraph graph); - public void doLayout(LayoutGraph graph, Set firstLayerHint, Set lastLayerHint, Set importantLinks); + public void doLayout(LayoutGraph graph, Set importantLinks); public void doRouting(LayoutGraph graph); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java index 208015b92f9..7f58b607f43 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Link.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ public interface Link { public Port getTo(); + public boolean isVIP(); + public List getControlPoints(); public void setControlPoints(List list); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Port.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Port.java index 128834b9792..f2776b5050f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Port.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Port.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java index f92d0c4cb76..6350e52faef 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Vertex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,8 +32,6 @@ import java.awt.Point; */ public interface Vertex extends Comparable { - public Cluster getCluster(); - public Dimension getSize(); public Point getPosition(); @@ -41,4 +39,6 @@ public interface Vertex extends Comparable { public void setPosition(Point p); public boolean isRoot(); + + public Cluster getCluster(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties index 0897ad916a4..68c04ba5e2b 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties @@ -1,8 +1,5 @@ -build.xml.data.CRC32=f8e21cb6 -build.xml.script.CRC32=a265137e -build.xml.stylesheet.CRC32=79c3b980 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=f8e21cb6 -nbproject/build-impl.xml.script.CRC32=36f3138c -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65 +nbproject/build-impl.xml.data.CRC32=5a0e591e +nbproject/build-impl.xml.script.CRC32=4c38ce23 +nbproject/build-impl.xml.stylesheet.CRC32=e50cf570@2.62.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml index 5edaba9763b..7623eb30fca 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/project.xml @@ -27,7 +27,7 @@ - 6.11.1.1 + 7.30.1 @@ -35,7 +35,7 @@ - 7.5.1 + 7.18.1 @@ -43,7 +43,15 @@ - 7.10.1.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver deleted file mode 100644 index 62561a6709f..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupReceiver +++ /dev/null @@ -1 +0,0 @@ -com.sun.hotspot.igv.connection.Server \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java index 59bad5a57d4..5bba5c4fb6d 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,73 +24,48 @@ */ package com.sun.hotspot.igv.connection; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupCallback; +import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.serialization.BinaryParser; import com.sun.hotspot.igv.data.serialization.Parser; -import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; +import com.sun.hotspot.igv.data.services.GroupCallback; import java.io.IOException; -import java.io.InputStream; -import java.net.Socket; -import javax.swing.JTextField; +import java.nio.channels.SocketChannel; import org.openide.util.Exceptions; -import org.openide.xml.XMLUtil; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -/** - * - * @author Thomas Wuerthinger - */ -public class Client implements Runnable, GroupCallback { +public class Client implements Runnable { + private final boolean binary; + private final SocketChannel socket; + private final GraphDocument rootDocument; + private final GroupCallback callback; - private Socket socket; - private JTextField networkTextField; - private GroupCallback callback; - - public Client(Socket socket, JTextField networkTextField, GroupCallback callback) { + public Client(SocketChannel socket, GraphDocument rootDocument, GroupCallback callback, boolean binary) { this.callback = callback; this.socket = socket; - this.networkTextField = networkTextField; + this.binary = binary; + this.rootDocument = rootDocument; } + @Override public void run() { try { - InputStream inputStream = socket.getInputStream(); - - if (networkTextField.isEnabled()) { - - socket.getOutputStream().write('y'); - InputSource is = new InputSource(inputStream); - - try { - XMLReader reader = XMLUtil.createXMLReader(); - Parser parser = new Parser(this); - parser.parse(reader, is, null); - } catch (SAXException ex) { - ex.printStackTrace(); - } + final SocketChannel channel = socket; + channel.configureBlocking(true); + if (binary) { + new BinaryParser(channel, null, rootDocument, callback).parse(); } else { - socket.getOutputStream().write('n'); + // signal readiness to client VM (old protocol) + channel.socket().getOutputStream().write('y'); + new Parser(channel, null, callback).parse(); } - - socket.close(); } catch (IOException ex) { Exceptions.printStackTrace(ex); - } - } - - public void started(final Group g) { - try { - RegexpPropertyMatcher matcher = new RegexpPropertyMatcher("name", ".*" + networkTextField.getText() + ".*"); - if (g.getProperties().selectSingle(matcher) != null && networkTextField.isEnabled()) { - socket.getOutputStream().write('y'); - callback.started(g); - } else { - socket.getOutputStream().write('n'); + } finally { + try { + socket.close(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); } - } catch (IOException e) { } } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java index 9ea5cfe8930..c755e2cdb35 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,17 +24,15 @@ */ package com.sun.hotspot.igv.connection; -import com.sun.hotspot.igv.data.Group; +import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.services.GroupCallback; -import com.sun.hotspot.igv.data.services.GroupReceiver; import com.sun.hotspot.igv.settings.Settings; -import java.awt.Component; import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; +import java.net.InetSocketAddress; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; import java.util.prefs.PreferenceChangeEvent; import java.util.prefs.PreferenceChangeListener; -import javax.swing.SwingUtilities; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.util.RequestProcessor; @@ -43,54 +41,26 @@ import org.openide.util.RequestProcessor; * * @author Thomas Wuerthinger */ -public class Server implements GroupCallback, GroupReceiver, PreferenceChangeListener { - - private javax.swing.JPanel jPanel1; - private javax.swing.JCheckBox networkCheckBox; - private javax.swing.JTextField networkTextField; - private ServerSocket serverSocket; - private GroupCallback callback; +public class Server implements PreferenceChangeListener { + private final boolean binary; + private ServerSocketChannel serverSocket; + private final GraphDocument rootDocument; + private final GroupCallback callback; private int port; private Runnable serverRunnable; - public Component init(GroupCallback callback) { - + public Server(GraphDocument rootDocument, GroupCallback callback, boolean binary) { + this.binary = binary; + this.rootDocument = rootDocument; this.callback = callback; - - jPanel1 = new javax.swing.JPanel(); - networkTextField = new javax.swing.JTextField(); - networkCheckBox = new javax.swing.JCheckBox(); - - - jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); - jPanel1.setLayout(new java.awt.BorderLayout(10, 10)); - jPanel1.add(networkTextField, java.awt.BorderLayout.CENTER); - - networkCheckBox.setSelected(true); - org.openide.awt.Mnemonics.setLocalizedText(networkCheckBox, "Receive when name contains"); - networkCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); - networkCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); - networkCheckBox.addChangeListener(new javax.swing.event.ChangeListener() { - - public void stateChanged(javax.swing.event.ChangeEvent evt) { - networkCheckBoxChanged(evt); - } - }); - jPanel1.add(networkCheckBox, java.awt.BorderLayout.WEST); - networkCheckBox.getAccessibleContext().setAccessibleName("Read from network when name contains"); - initializeNetwork(); Settings.get().addPreferenceChangeListener(this); - return jPanel1; - } - - private void networkCheckBoxChanged(javax.swing.event.ChangeEvent evt) { - networkTextField.setEnabled(networkCheckBox.isSelected()); } + @Override public void preferenceChange(PreferenceChangeEvent e) { - int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT)); + int curPort = Integer.parseInt(Settings.get().get(binary ? Settings.PORT_BINARY : Settings.PORT, binary ? Settings.PORT_BINARY_DEFAULT : Settings.PORT_DEFAULT)); if (curPort != port) { initializeNetwork(); } @@ -98,30 +68,32 @@ public class Server implements GroupCallback, GroupReceiver, PreferenceChangeLis private void initializeNetwork() { - int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT)); + int curPort = Integer.parseInt(Settings.get().get(binary ? Settings.PORT_BINARY : Settings.PORT, binary ? Settings.PORT_BINARY_DEFAULT : Settings.PORT_DEFAULT)); this.port = curPort; try { - serverSocket = new java.net.ServerSocket(curPort); - } catch (IOException ex) { - NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); + serverSocket = ServerSocketChannel.open(); + serverSocket.bind(new InetSocketAddress(curPort)); + } catch (Throwable ex) { + NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(message); return; } Runnable runnable = new Runnable() { + @Override public void run() { while (true) { try { - Socket clientSocket = serverSocket.accept(); + SocketChannel clientSocket = serverSocket.accept(); if (serverRunnable != this) { clientSocket.close(); return; } - RequestProcessor.getDefault().post(new Client(clientSocket, networkTextField, Server.this), 0, Thread.MAX_PRIORITY); + RequestProcessor.getDefault().post(new Client(clientSocket, rootDocument, callback, binary), 0, Thread.MAX_PRIORITY); } catch (IOException ex) { serverSocket = null; - NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); + NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(message); return; } @@ -133,13 +105,4 @@ public class Server implements GroupCallback, GroupReceiver, PreferenceChangeLis RequestProcessor.getDefault().post(runnable, 0, Thread.MAX_PRIORITY); } - - public void started(final Group g) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - callback.started(g); - } - }); - } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/README b/hotspot/src/share/tools/IdealGraphVisualizer/README deleted file mode 100644 index 5c9a16601bc..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/README +++ /dev/null @@ -1,40 +0,0 @@ -The Ideal Graph Visualizer is a tool developed to help examine the -intermediate representation of C2 which is commonly referred to as the -"ideal graph". It was developed in collaboration with the University -of Linz in Austria and has been included as part of hotspot since that -was the primary target of the tool. The tool itself is fairly general -with only a few modules that contain C2 specific elements. - -The tool is built on top of the NetBeans 6.1 rich client -infrastructure and so requires NetBeans to build. It currently -requires Java 6 to run as it needs support for JavaScript for its -filtering mechanism and assumes it's built into the platform. It -should build out of the box with NetBeans 6.1 and Java 6 or later. -It's possible to run it on 1.5 by including Rhino on the classpath -though that currently isn't working correctly. Support for exporting -graphs as SVG can be enabled by adding batik to the classpath which -isn't included by default. It can be built on top of NetBeans 6.0 if -you change the required modules to be platform7 instead of platform8. - -The JVM support is controlled by the flag -XX:PrintIdealGraphLevel=# -where # is: - - 0: no output, the default - 1: dumps graph after parsing, before matching, and final code. - also dumps graph for failed compiles, if available - 2: more detail, including after loop opts - 3: even more detail - 4: prints graph after parsing every bytecode (very slow) - -By default the JVM expects that it will connect to a visualizer on the -local host on port 4444. This can be configured using the options --XX:PrintIdealGraphAddress= and -XX:PrintIdealGraphPort=. -PrintIdealGraphAddress can actually be a hostname. - -Alternatively the output can be sent to a file using --XX:PrintIdealGraphFile=filename. Each compiler thread will get it's -own file with unique names being generated by adding a number onto the -provided file name. - -More information about the tool is available at -http://wikis.sun.com/display/HotSpotInternals/IdealGraphVisualizer. diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/README.md b/hotspot/src/share/tools/IdealGraphVisualizer/README.md new file mode 100644 index 00000000000..fd3bed1aa34 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/README.md @@ -0,0 +1,50 @@ +# Overview + +The Ideal Graph Visualizer is a tool developed to help examine the intermediate +representation of C2 which is commonly referred to as the "ideal graph". It was +developed in collaboration with the University of Linz in Austria and has been +included as part of hotspot since that was the primary target of the tool. The +tool itself is fairly general with only a few modules that contain C2 specific +elements. + +The tool is built on top of the NetBeans 7 rich client infrastructure and so +requires NetBeans to build. It currently requires at least Java 6 to run as it +needs support for JavaScript for its filtering mechanism and assumes it's built +into the platform. It should build out of the box with NetBeans 7.0 and Java 6 +or later. + +# Building and Running + +The build system used for IGV is ant. To download all required libraries and +build IGV, issue `ant build`. To run IGV, use the `igv.sh` command; it will put +all log messages generated by the run to the file `.igv.log`. To see all log +messages generated during an IGV run, use `ant run`. + +# Usage + +The JVM support is controlled by the flag `-XX:PrintIdealGraphLevel=#` where `#` +is: + +* 0: no output, the default +* 1: dumps graph after parsing, before matching, and final code (also dumps + graphs for failed compilations, if available) +* 2: more detail, including after loop opts +* 3: even more detail +* 4: prints graph after parsing every bytecode (very slow) + +By default the JVM expects that it will connect to a visualizer on the local +host on port 4444. This can be configured using the options +`-XX:PrintIdealGraphAddress=` and `-XX:PrintIdealGraphPort=`. +`PrintIdealGraphAddress` can actually be a hostname. + +It is advisable to run the JVM with background compilation disabled (-Xbatch). +Compilations going on in the background may be cancelled when the VM terminates, +which can lead to incomplete dumps being sent to IGV. + +Alternatively the output can be sent to a file using +`-XX:PrintIdealGraphFile=filename`. Each compiler thread will get it's own file +with unique names being generated by adding a number onto the provided file +name. + +More information about the tool is available at +https://wikis.oracle.com/display/HotSpotInternals/IdealGraphVisualizer. diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf deleted file mode 100644 index 18ba3a45614..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.sun.hotspot.igv.rhino -OpenIDE-Module-Layer: com/sun/hotspot/igv/rhino/layer.xml -OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/rhino/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties deleted file mode 100644 index e21cae5f34b..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=0c3e7912 -build.xml.script.CRC32=44d0050c -build.xml.stylesheet.CRC32=79c3b980 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0c3e7912 -nbproject/build-impl.xml.script.CRC32=7aab3f52 -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction deleted file mode 100644 index 11a13a78ee0..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction +++ /dev/null @@ -1 +0,0 @@ -com.sun.hotspot.igv.rhino.RhinoScriptEngine \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties deleted file mode 100644 index e389254eb05..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties +++ /dev/null @@ -1 +0,0 @@ -OpenIDE-Module-Name=RhinoScriptEngineProxy diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java deleted file mode 100644 index e1aee9145dc..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.rhino; - -import com.sun.hotspot.igv.filter.ScriptEngineAbstraction; -import com.sun.hotspot.igv.graph.Diagram; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * - * @author Thomas Wuerthinger - */ -public class RhinoScriptEngine implements ScriptEngineAbstraction { - - private String jsHelperText; - private Constructor importer; - private Method scope_put; - private Method cx_evaluateString; - private Method context_enter; - private Method context_exit; - - public boolean initialize(String s) { - this.jsHelperText = s; - Class importerTopLevel = null; - try { - ClassLoader cl = RhinoScriptEngine.class.getClassLoader(); - Class context = cl.loadClass("org.mozilla.javascript.Context"); - Class scriptable = cl.loadClass("org.mozilla.javascript.Scriptable"); - importerTopLevel = cl.loadClass("org.mozilla.javascript.ImporterTopLevel"); - importer = importerTopLevel.getDeclaredConstructor(context); - scope_put = importerTopLevel.getMethod("put", new Class[]{String.class, scriptable, Object.class}); - cx_evaluateString = context.getDeclaredMethod("evaluateString", new Class[]{scriptable, String.class, String.class, Integer.TYPE, Object.class}); - context_enter = context.getDeclaredMethod("enter", new Class[0]); - context_exit = context.getDeclaredMethod("exit", new Class[0]); - return true; - } catch (NoSuchMethodException nsme) { - return false; - } catch (ClassNotFoundException cnfe) { - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Object cx = context_enter.invoke(null, (Object[]) null); - try { - Object scope = importer.newInstance(cx); - scope_put.invoke(scope, "IO", scope, System.out); - scope_put.invoke(scope, "graph", scope, d); - cx_evaluateString.invoke(cx, scope, jsHelperText, "jsHelper.js", 1, null); - cx_evaluateString.invoke(cx, scope, code, "", 1, null); - } finally { - // Exit from the context. - context_exit.invoke(null, (Object[]) null); - } - } catch (InvocationTargetException iae) { - } catch (IllegalAccessException iae) { - } catch (InstantiationException iae) { - } - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml deleted file mode 100644 index c16a8a0fed6..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/build.xml b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/build.xml new file mode 100644 index 00000000000..ddb36768ed5 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/build.xml @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.selectioncoordinator. + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/manifest.mf b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/manifest.mf new file mode 100644 index 00000000000..3dd06663268 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/manifest.mf @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.selectioncoordinator +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/selectioncoordinator/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/build-impl.xml b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/build-impl.xml new file mode 100644 index 00000000000..7b681fb1397 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/build-impl.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/genfiles.properties b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/genfiles.properties new file mode 100644 index 00000000000..0cf9e674992 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/genfiles.properties @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=13553862 +nbproject/build-impl.xml.script.CRC32=3db87c68 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.67.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/platform.properties b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/platform.properties new file mode 100644 index 00000000000..4e58e5a3b1e --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/platform.properties @@ -0,0 +1,129 @@ +# Deprecated since 5.0u1; for compatibility with 5.0: +disabled.clusters=\ + apisupport1,\ + gsf1,\ + harness,\ + java2,\ + nb6.1,\ + profiler3 +disabled.modules=\ + org.apache.xml.resolver,\ + org.netbeans.api.debugger,\ + org.netbeans.api.xml,\ + org.netbeans.core.execution,\ + org.netbeans.core.ide,\ + org.netbeans.core.multiview,\ + org.netbeans.core.nativeaccess,\ + org.netbeans.core.output2,\ + org.netbeans.insane,\ + org.netbeans.lib.cvsclient,\ + org.netbeans.libs.commons_logging,\ + org.netbeans.libs.freemarker,\ + org.netbeans.libs.ini4j,\ + org.netbeans.libs.jna,\ + org.netbeans.libs.jsch,\ + org.netbeans.libs.jsr223,\ + org.netbeans.libs.lucene,\ + org.netbeans.libs.svnClientAdapter,\ + org.netbeans.libs.xerces,\ + org.netbeans.modules.applemenu,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.classfile,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.db,\ + org.netbeans.modules.db.core,\ + org.netbeans.modules.db.drivers,\ + org.netbeans.modules.db.kit,\ + org.netbeans.modules.db.mysql,\ + org.netbeans.modules.db.sql.editor,\ + org.netbeans.modules.db.sql.visualeditor,\ + org.netbeans.modules.dbapi,\ + org.netbeans.modules.defaults,\ + org.netbeans.modules.diff,\ + org.netbeans.modules.editor.bookmarks,\ + org.netbeans.modules.editor.bracesmatching,\ + org.netbeans.modules.editor.codetemplates,\ + org.netbeans.modules.editor.completion,\ + org.netbeans.modules.editor.errorstripe,\ + org.netbeans.modules.editor.errorstripe.api,\ + org.netbeans.modules.editor.guards,\ + org.netbeans.modules.editor.highlights,\ + org.netbeans.modules.editor.macros,\ + org.netbeans.modules.editor.plain,\ + org.netbeans.modules.editor.plain.lib,\ + org.netbeans.modules.editor.structure,\ + org.netbeans.modules.extbrowser,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.gototest,\ + org.netbeans.modules.httpserver,\ + org.netbeans.modules.ide.kit,\ + org.netbeans.modules.image,\ + org.netbeans.modules.javahelp,\ + org.netbeans.modules.jumpto,\ + org.netbeans.modules.languages,\ + org.netbeans.modules.languages.bat,\ + org.netbeans.modules.languages.diff,\ + org.netbeans.modules.languages.manifest,\ + org.netbeans.modules.languages.sh,\ + org.netbeans.modules.lexer.editorbridge,\ + org.netbeans.modules.lexer.nbbridge,\ + org.netbeans.modules.localhistory,\ + org.netbeans.modules.masterfs,\ + org.netbeans.modules.mercurial,\ + org.netbeans.modules.progress.ui,\ + org.netbeans.modules.project.ant,\ + org.netbeans.modules.project.libraries,\ + org.netbeans.modules.projectui,\ + org.netbeans.modules.projectuiapi,\ + org.netbeans.modules.properties,\ + org.netbeans.modules.properties.syntax,\ + org.netbeans.modules.refactoring.api,\ + org.netbeans.modules.schema2beans,\ + org.netbeans.modules.sendopts,\ + org.netbeans.modules.server,\ + org.netbeans.modules.servletapi,\ + org.netbeans.modules.subversion,\ + org.netbeans.modules.tasklist.kit,\ + org.netbeans.modules.tasklist.projectint,\ + org.netbeans.modules.tasklist.todo,\ + org.netbeans.modules.tasklist.ui,\ + org.netbeans.modules.templates,\ + org.netbeans.modules.timers,\ + org.netbeans.modules.usersguide,\ + org.netbeans.modules.utilities,\ + org.netbeans.modules.utilities.project,\ + org.netbeans.modules.versioning,\ + org.netbeans.modules.versioning.system.cvss,\ + org.netbeans.modules.versioning.util,\ + org.netbeans.modules.web.flyingsaucer,\ + org.netbeans.modules.xml,\ + org.netbeans.modules.xml.axi,\ + org.netbeans.modules.xml.catalog,\ + org.netbeans.modules.xml.core,\ + org.netbeans.modules.xml.lexer,\ + org.netbeans.modules.xml.multiview,\ + org.netbeans.modules.xml.retriever,\ + org.netbeans.modules.xml.schema.completion,\ + org.netbeans.modules.xml.schema.model,\ + org.netbeans.modules.xml.tax,\ + org.netbeans.modules.xml.text,\ + org.netbeans.modules.xml.tools,\ + org.netbeans.modules.xml.wsdl.model,\ + org.netbeans.modules.xml.xam,\ + org.netbeans.modules.xml.xdm,\ + org.netbeans.modules.xsl,\ + org.netbeans.spi.debugger.ui,\ + org.netbeans.spi.editor.hints,\ + org.netbeans.spi.navigator,\ + org.netbeans.spi.palette,\ + org.netbeans.spi.tasklist,\ + org.netbeans.spi.viewmodel,\ + org.netbeans.swing.dirchooser,\ + org.openide.compat,\ + org.openide.util.enumerations +enabled.clusters=\ + ide9,\ + platform8 +nbjdk.active=default +nbplatform.active=default diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties new file mode 100644 index 00000000000..b0194c49776 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties @@ -0,0 +1,2 @@ +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.xml new file mode 100644 index 00000000000..fa24812c85d --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.xml @@ -0,0 +1,23 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.selectioncoordinator + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + + com.sun.hotspot.igv.selectioncoordinator + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/suite.properties b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/suite.properties new file mode 100644 index 00000000000..29d7cc9bd6f --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/suite.properties @@ -0,0 +1 @@ +suite.dir=${basedir}/.. diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/Bundle.properties new file mode 100644 index 00000000000..a6120f43283 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/Bundle.properties @@ -0,0 +1 @@ +OpenIDE-Module-Name=SelectionCoordinator diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java new file mode 100644 index 00000000000..a62cf5d187e --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.selectioncoordinator; + +import com.sun.hotspot.igv.data.ChangedEvent; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author Thomas + */ +public class SelectionCoordinator { + + private static SelectionCoordinator singleInstance = new SelectionCoordinator(); + private Set selectedObjects; + private Set highlightedObjects; + private ChangedEvent selectedChangedEvent; + private ChangedEvent highlightedChangedEvent; + + public static SelectionCoordinator getInstance() { + return singleInstance; + } + + private SelectionCoordinator() { + selectedChangedEvent = new ChangedEvent<>(this); + highlightedChangedEvent = new ChangedEvent<>(this); + selectedObjects = new HashSet<>(); + highlightedObjects = new HashSet<>(); + } + + public Set getSelectedObjects() { + return Collections.unmodifiableSet(selectedObjects); + } + + public Set getHighlightedObjects() { + return Collections.unmodifiableSet(highlightedObjects); + } + + public ChangedEvent getHighlightedChangedEvent() { + return highlightedChangedEvent; + } + + public ChangedEvent getSelectedChangedEvent() { + return selectedChangedEvent; + } + + public void addHighlighted(Object o) { + if (!highlightedObjects.contains(o)) { + highlightedObjects.add(o); + highlightedObjectsChanged(); + } + } + + public void removeHighlighted(Object o) { + if (highlightedObjects.contains(o)) { + highlightedObjects.remove(o); + highlightedObjectsChanged(); + } + } + + public void addAllHighlighted(Set s) { + int oldSize = highlightedObjects.size(); + highlightedObjects.addAll(s); + if (oldSize != highlightedObjects.size()) { + highlightedObjectsChanged(); + } + } + + public void removeAllHighlighted(Set s) { + int oldSize = highlightedObjects.size(); + highlightedObjects.removeAll(s); + if (oldSize != highlightedObjects.size()) { + highlightedObjectsChanged(); + } + } + + private void highlightedObjectsChanged() { + highlightedChangedEvent.fire(); + + } + + public void addAllSelected(Set s) { + int oldSize = selectedObjects.size(); + selectedObjects.addAll(s); + if (oldSize != selectedObjects.size()) { + selectedObjectsChanged(); + } + } + + public void removeAllSelected(Set s) { + int oldSize = selectedObjects.size(); + selectedObjects.removeAll(s); + if (oldSize != selectedObjects.size()) { + selectedObjectsChanged(); + } + } + + public void setSelectedObjects(Set s) { + assert s != null; + selectedObjects.clear(); + selectedObjects.addAll(s); + selectedObjectsChanged(); + } + + private void selectedObjectsChanged() { + selectedChangedEvent.fire(); + } + + public void setHighlightedObjects(Set s) { + assert s != null; + this.highlightedObjects.clear(); + this.highlightedObjects.addAll(s); + highlightedObjectsChanged(); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml index 56151ed37c8..a886ad39018 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml @@ -1,21 +1,29 @@ - - - org.netbeans.modules.apisupport.project - - - com.sun.hotspot.igv.servercompiler - - - - com.sun.hotspot.igv.data - - - - 1.0 - - - - - - - + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.servercompiler + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer deleted file mode 100644 index 9da82d4ca10..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer +++ /dev/null @@ -1 +0,0 @@ -com.sun.hotspot.igv.servercompiler.JavaGroupOrganizer \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java deleted file mode 100644 index 26a7f27e6fc..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.servercompiler; - -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.services.GroupOrganizer; -import com.sun.hotspot.igv.data.Pair; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "Java structure"; - } - - public List>> organize(List subFolders, List groups) { - - List>> result = new ArrayList>>(); - - if (subFolders.size() == 0) { - buildResult(result, groups, packageNameProvider); - } else if (subFolders.size() == 1) { - buildResult(result, groups, classNameProvider); - } else if (subFolders.size() == 2) { - for (Group g : groups) { - List children = new ArrayList(); - children.add(g); - Pair> p = new Pair>(); - p.setLeft(reducedNameProvider.getName(g)); - p.setRight(children); - result.add(p); - } - } else { - result.add(new Pair>("", groups)); - } - - return result; - } - - private void buildResult(List>> result, List groups, NameProvider provider) { - HashMap> map = new HashMap>(); - for (Group g : groups) { - String s = provider.getName(g); - - if (!map.containsKey(s)) { - List list = new ArrayList(); - Pair> pair = new Pair>(s, list); - result.add(pair); - map.put(s, list); - } - - List curList = map.get(s); - curList.add(g); - } - - Collections.sort(result, new Comparator>>() { - - public int compare(Pair> a, Pair> b) { - return a.getLeft().compareTo(b.getLeft()); - } - }); - } - - private static interface NameProvider { - - public String getName(Group g); - } - private NameProvider reducedNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noReducedName = name; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noReducedName; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noReducedName; - } - - int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { - current--; - } - - String tmp = name.substring(0, firstParenthese); - int lastPoint = tmp.lastIndexOf("."); - if (lastPoint == -1) { - return noReducedName; - } - - name = name.substring(0, current + 1) + name.substring(lastPoint + 1); - return name; - } - }; - private NameProvider packageNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noPackage = ""; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noPackage; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noPackage; - } - - int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noPackage; - } - lastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - if (lastPoint == -1) { - return noPackage; - } - - String packageName = fullClassName.substring(0, lastPoint); - return packageName; - } - }; - private NameProvider classNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - - final String noClass = ""; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noClass; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noClass; - } - - int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noClass; - } - int lastlastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - - String className = fullClassName.substring(lastlastPoint + 1, lastPoint); - return className; - } - }; -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java index e86ffe8bd0a..29ec19ca1e6 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,17 +29,7 @@ import com.sun.hotspot.igv.data.InputEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.services.Scheduler; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.Vector; +import java.util.*; /** * @@ -50,8 +40,8 @@ public class ServerCompilerScheduler implements Scheduler { private static class Node { public InputNode inputNode; - public Set succs = new HashSet(); - public List preds = new ArrayList(); + public Set succs = new HashSet<>(); + public List preds = new ArrayList<>(); public InputBlock block; public boolean isBlockProjection; public boolean isBlockStart; @@ -65,6 +55,7 @@ public class ServerCompilerScheduler implements Scheduler { private InputBlock[][] commonDominator; private static final Comparator edgeComparator = new Comparator() { + @Override public int compare(InputEdge o1, InputEdge o2) { return o1.getToIndex() - o2.getToIndex(); } @@ -72,13 +63,13 @@ public class ServerCompilerScheduler implements Scheduler { public void buildBlocks() { - blocks = new Vector(); + blocks = new Vector<>(); Node root = findRoot(); if (root == null) { return; } - Stack stack = new Stack(); - Set visited = new HashSet(); + Stack stack = new Stack<>(); + Set visited = new HashSet<>(); stack.add(root); int blockCount = 0; InputBlock rootBlock = null; @@ -93,7 +84,7 @@ public class ServerCompilerScheduler implements Scheduler { if (!visited.contains(parent)) { visited.add(parent); - InputBlock block = new InputBlock(graph, "" + blockCount); + InputBlock block = graph.addBlock(Integer.toString(blockCount)); blocks.add(block); if (parent == root) { rootBlock = block; @@ -111,7 +102,12 @@ public class ServerCompilerScheduler implements Scheduler { p = parent; break; } + p = p.preds.get(0); + if (p == proj) { + // Cycle, stop + break; + } if (p.block == null) { p.block = block; @@ -125,7 +121,7 @@ public class ServerCompilerScheduler implements Scheduler { n = n.preds.get(0); } if (n.block != null) { - n.block.addSuccessor(block); + graph.addBlockEdge(n.block, block); } } } @@ -136,12 +132,12 @@ public class ServerCompilerScheduler implements Scheduler { for (Node n2 : n.succs) { if (n2 != parent && n2.block != null && n2.block != rootBlock) { - block.addSuccessor(n2.block); + graph.addBlockEdge(block, n2.block); } } } else { if (n != parent && n.block != null && n.block != rootBlock) { - block.addSuccessor(n.block); + graph.addBlockEdge(block, n.block); } } } @@ -161,7 +157,7 @@ public class ServerCompilerScheduler implements Scheduler { } if (pushed == 0 && p == root) { - // TODO: special handling when root backedges are not built yet + // TODO: special handling when root backedges are not built yet } } } @@ -174,7 +170,7 @@ public class ServerCompilerScheduler implements Scheduler { } int z = 0; - blockIndex = new HashMap(); + blockIndex = new HashMap<>(blocks.size()); for (InputBlock b : blocks) { blockIndex.put(b, z); z++; @@ -185,20 +181,25 @@ public class ServerCompilerScheduler implements Scheduler { return n.getProperties().get("block"); } + @Override public Collection schedule(InputGraph graph) { + if (graph.getNodes().isEmpty()) { + return Collections.emptyList(); + } + if (graph.getBlocks().size() > 0) { - Collection tmpNodes = new ArrayList(graph.getNodes()); + Collection tmpNodes = new ArrayList<>(graph.getNodes()); for (InputNode n : tmpNodes) { String block = getBlockName(n); if (graph.getBlock(n) == null) { - graph.getBlock(block).addNode(n); + graph.getBlock(block).addNode(n.getId()); assert graph.getBlock(n) != null; } } return graph.getBlocks(); } else { - nodes = new ArrayList(); - inputNodeToNode = new HashMap(); + nodes = new ArrayList<>(); + inputNodeToNode = new HashMap<>(graph.getNodes().size()); this.graph = graph; buildUpGraph(); @@ -207,7 +208,16 @@ public class ServerCompilerScheduler implements Scheduler { buildCommonDominators(); scheduleLatest(); + InputBlock noBlock = null; for (InputNode n : graph.getNodes()) { + if (graph.getBlock(n) == null) { + if (noBlock == null) { + noBlock = graph.addBlock("(no block)"); + blocks.add(noBlock); + } + + graph.setBlock(n, noBlock); + } assert graph.getBlock(n) != null; } @@ -215,15 +225,17 @@ public class ServerCompilerScheduler implements Scheduler { } } - public void scheduleLatest() { - - + private void scheduleLatest() { Node root = findRoot(); + if(root == null) { + assert false : "No root found!"; + return; + } // Mark all nodes reachable in backward traversal from root - Set reachable = new HashSet(); + Set reachable = new HashSet<>(); reachable.add(root); - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(root); while (!stack.isEmpty()) { Node cur = stack.pop(); @@ -235,7 +247,7 @@ public class ServerCompilerScheduler implements Scheduler { } } - Set unscheduled = new HashSet(); + Set unscheduled = new HashSet<>(); for (Node n : this.nodes) { if (n.block == null && reachable.contains(n)) { unscheduled.add(n); @@ -245,7 +257,7 @@ public class ServerCompilerScheduler implements Scheduler { while (unscheduled.size() > 0) { boolean progress = false; - Set newUnscheduled = new HashSet(); + Set newUnscheduled = new HashSet<>(); for (Node n : unscheduled) { InputBlock block = null; @@ -285,7 +297,7 @@ public class ServerCompilerScheduler implements Scheduler { } } - Set curReachable = new HashSet(reachable); + Set curReachable = new HashSet<>(reachable); for (Node n : curReachable) { if (n.block != null) { for (Node s : n.succs) { @@ -300,7 +312,7 @@ public class ServerCompilerScheduler implements Scheduler { private void markWithBlock(Node n, InputBlock b, Set reachable) { assert !reachable.contains(n); - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.push(n); n.block = b; b.addNode(n.inputNode.getId()); @@ -356,7 +368,7 @@ public class ServerCompilerScheduler implements Scheduler { if (ba == bb) { return ba; } - Set visited = new HashSet(); + Set visited = new HashSet<>(); while (ba != null) { visited.add(ba); ba = dominatorMap.get(ba); @@ -374,12 +386,12 @@ public class ServerCompilerScheduler implements Scheduler { } public void buildDominators() { - dominatorMap = new HashMap(); + dominatorMap = new HashMap<>(graph.getBlocks().size()); if (blocks.size() == 0) { return; } - Vector intermediate = new Vector(); - Map map = new HashMap(); + Vector intermediate = new Vector<>(graph.getBlocks().size()); + Map map = new HashMap<>(graph.getBlocks().size()); int z = 0; for (InputBlock b : blocks) { BlockIntermediate bi = new BlockIntermediate(); @@ -390,16 +402,16 @@ public class ServerCompilerScheduler implements Scheduler { bi.parent = -1; bi.label = z; bi.ancestor = -1; - bi.pred = new ArrayList(); - bi.bucket = new ArrayList(); + bi.pred = new ArrayList<>(); + bi.bucket = new ArrayList<>(); intermediate.add(bi); map.put(b, bi); z++; } - Stack stack = new Stack(); + Stack stack = new Stack<>(); stack.add(0); - Vector array = new Vector(); + Vector array = new Vector<>(); intermediate.get(0).dominator = 0; int n = 0; @@ -538,15 +550,30 @@ public class ServerCompilerScheduler implements Scheduler { } private Node findRoot() { + Node minNode = null; + Node alternativeRoot = null; - for (Node n : nodes) { - InputNode inputNode = n.inputNode; - if (inputNode.getProperties().get("name").equals("Root")) { - return n; + for (Node node : nodes) { + InputNode inputNode = node.inputNode; + String s = inputNode.getProperties().get("name"); + if (s != null && s.equals("Root")) { + return node; + } + + if (alternativeRoot == null && node.preds.isEmpty()) { + alternativeRoot = node; + } + + if (minNode == null || node.inputNode.getId() < minNode.inputNode.getId()) { + minNode = node; } } - return null; + if (alternativeRoot != null) { + return alternativeRoot; + } else { + return minNode; + } } public void buildUpGraph() { @@ -562,7 +589,7 @@ public class ServerCompilerScheduler implements Scheduler { inputNodeToNode.put(n, node); } - Map> edgeMap = new HashMap>(); + Map> edgeMap = new HashMap<>(graph.getEdges().size()); for (InputEdge e : graph.getEdges()) { int to = e.getTo(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter index 3ad07276df8..dfaf7f3c1ac 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter @@ -1,5 +1,18 @@ colorize("name", ".*", yellow); colorize("name", "Catch.*", blue); - colorize("name", "Region|Loop|CountedLoop|Root", red); colorize("name", "CProj|IfFalse|IfTrue|JProj|CatchProj", magenta); +colorize("name", "Con.*", orange); +colorize("name", "Parm|Proj", lightGray); + +// Nodes with bci +colorize("bci", "..*", magenta); + +// Line style +var f = new ColorFilter("Line Style filter"); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "int:")), null, Color.BLUE, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "control")), null, Color.RED, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory")), null, Color.GREEN, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "tuple:")), null, Color.MAGENTA, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "bottom")), null, Color.LIGHT_GRAY, null)); +f.apply(graph); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/extendedColor.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/extendedColor.filter deleted file mode 100644 index 1ea0fb36abe..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/extendedColor.filter +++ /dev/null @@ -1,3 +0,0 @@ -colorize("name", "Con.*", orange); -colorize("name", "Parm|Proj", lightGray); -colorize("bci", "..*", magenta); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/linestyle.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/linestyle.filter deleted file mode 100644 index 9aa15e79298..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/linestyle.filter +++ /dev/null @@ -1,7 +0,0 @@ -var f = new ColorFilter("Line Style filter"); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "int:")), null, Color.BLUE, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "control")), null, Color.RED, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory")), null, Color.GREEN, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "tuple:")), null, Color.MAGENTA, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "bottom")), null, Color.LIGHT_GRAY, null)); -f.apply(graph); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter index 7230576a2ac..73c1f8ab615 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/onlyControlFlow.filter @@ -20,5 +20,5 @@ f.addRule( ), false ) ); -f.addRule( new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.RegexpPropertyMatcher("name", "Phi|Store.")), false)); +f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.RegexpPropertyMatcher("name", "Phi|Store.")))); f.apply(graph); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter index 5328246d288..e75079fd730 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter @@ -1,4 +1,5 @@ +// Register coloring colorize("reg", "EAX", green); colorize("reg", "EFLAGS", gray); colorize("reg", "EBP", orange); -colorize("reg", "ECX", cyan); +colorize("reg", "ECX", cyan); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter index 0333fccb337..9a051a89e60 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter @@ -1 +1,8 @@ -remove("dump_spec", "FramePtr|ReturnAdr|I_O"); \ No newline at end of file +remove("dump_spec", "FramePtr|ReturnAdr|I_O"); +removeInputs("name", "Root"); +var f = new RemoveSelfLoopsFilter("Remove Self-Loops"); +f.apply(graph); +removeInputs("name", "SafePoint|CallStaticJava|CallDynamicJava|CallJava|CallLeaf|CallRuntime|AbstractLock|CallLeafNoFP|Call|CallStaticJavaDirect", 5); +removeInputs("name", "Unlock|Lock", 7); +removeInputs("name", "Allocate", 7); +removeInputs("name", "AllocateArray", 9); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeMemory.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeMemory.filter deleted file mode 100644 index 842caed3b7f..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeMemory.filter +++ /dev/null @@ -1,7 +0,0 @@ - -//var f = new RemoveFilter("Remove Memory"); -//f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.StringPropertyMatcher("dump_spec", "Memory")), false)); -//f.addRule(new RemoveFilter.RemoveRule(new AndSelector(new MatcherSelector(new Properties.StringPropertyMatcher("name", "Proj")), new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory"))), false)); -//f.apply(graph); - -remove("dump_spec", "Memory"); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeRootInputs.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeRootInputs.filter deleted file mode 100644 index 8f6aacd4c4d..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeRootInputs.filter +++ /dev/null @@ -1 +0,0 @@ -removeInputs("name", "Root"); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSafepointInputs.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSafepointInputs.filter deleted file mode 100644 index b2abf0ee717..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSafepointInputs.filter +++ /dev/null @@ -1,4 +0,0 @@ -removeInputs("name", "SafePoint|CallStaticJava|CallDynamicJava|CallJava|CallLeaf|CallRuntime|AbstractLock|CallLeafNoFP|Call|CallStaticJavaDirect", 5); -removeInputs("name", "Unlock|Lock", 7); -removeInputs("name", "Allocate", 7); -removeInputs("name", "AllocateArray", 9); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSelfLoops.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSelfLoops.filter deleted file mode 100644 index debfd596de0..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSelfLoops.filter +++ /dev/null @@ -1,2 +0,0 @@ -var f = new RemoveSelfLoopsFilter("Remove Self-Loops"); -f.apply(graph); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/split.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/split.filter deleted file mode 100644 index 5f344ca6d76..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/split.filter +++ /dev/null @@ -1,2 +0,0 @@ -split("name", "BoxLock"); -split("name", "(Con.*)|(loadCon.*)"); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/combine.filter b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/structural.filter similarity index 80% rename from hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/combine.filter rename to hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/structural.filter index 8e5c5a0a7c7..3e59fbc1d2a 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/combine.filter +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/structural.filter @@ -1,4 +1,6 @@ var f = new CombineFilter("Combine Filter"); f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", ".*"), new Properties.RegexpPropertyMatcher("name", "Proj|IfFalse|IfTrue|JProj|MachProj|JumpProj|CatchProj"))); f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", "Cmp.*"), new Properties.RegexpPropertyMatcher("name", "Bool"))); -f.apply(graph); \ No newline at end of file +f.apply(graph); +split("name", "BoxLock"); +split("name", "(Con.*)|(loadCon.*)", "[dump_spec]"); \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml index 461692d832e..de53ba060ea 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml @@ -2,60 +2,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.xml index 0748a12fcaf..712ec85ba59 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/nbproject/project.xml @@ -12,7 +12,7 @@ 1 - 1.4 + 1.16.1 @@ -21,7 +21,7 @@ 1 - 1.5 + 1.21.1 @@ -29,7 +29,7 @@ - 6.11.0.1 + 7.30.1 @@ -37,7 +37,15 @@ - 7.9.0.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/Settings.java b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/Settings.java index 793edcd42e0..a1944210ae0 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/Settings.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/Settings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,9 @@ public class Settings { public final static String NODE_WIDTH = "nodeWidth"; public final static String NODE_WIDTH_DEFAULT = "100"; public final static String PORT = "port"; + public final static String PORT_BINARY = "portBinary"; public final static String PORT_DEFAULT = "4444"; + public final static String PORT_BINARY_DEFAULT = "4445"; public final static String DIRECTORY = "directory"; public final static String DIRECTORY_DEFAULT = System.getProperty("user.dir"); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java index 3642d7f629a..b49e2901d91 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsCategory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ import javax.swing.Icon; import javax.swing.ImageIcon; import org.netbeans.spi.options.OptionsCategory; import org.netbeans.spi.options.OptionsPanelController; +import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; -import org.openide.util.Utilities; /** * @@ -38,17 +38,20 @@ public final class ViewOptionsCategory extends OptionsCategory { @Override public Icon getIcon() { - return new ImageIcon(Utilities.loadImage("com/sun/hotspot/igv/settings/settings.gif")); + return new ImageIcon(ImageUtilities.loadImage("com/sun/hotspot/igv/settings/settings.png")); } + @Override public String getCategoryName() { return NbBundle.getMessage(ViewOptionsCategory.class, "OptionsCategory_Name_View"); } + @Override public String getTitle() { return NbBundle.getMessage(ViewOptionsCategory.class, "OptionsCategory_Title_View"); } + @Override public OptionsPanelController create() { return new ViewOptionsPanelController(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java index ba508630275..fcb7f26bcc3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewOptionsPanelController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,40 +40,49 @@ final class ViewOptionsPanelController extends OptionsPanelController { private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private boolean changed; + @Override public void update() { getPanel().load(); changed = false; } + @Override public void applyChanges() { getPanel().store(); changed = false; } + @Override public void cancel() { // need not do anything special, if no changes have been persisted yet } + @Override public boolean isValid() { return getPanel().valid(); } + @Override public boolean isChanged() { return changed; } + @Override public HelpCtx getHelpCtx() { return null; // new HelpCtx("...ID") if you have a help set } + @Override public JComponent getComponent(Lookup masterLookup) { return getPanel(); } + @Override public void addPropertyChangeListener(PropertyChangeListener l) { pcs.addPropertyChangeListener(l); } + @Override public void removePropertyChangeListener(PropertyChangeListener l) { pcs.removePropertyChangeListener(l); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewPanel.java b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewPanel.java index 697bda5cb66..e31a65edfd3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewPanel.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/ViewPanel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml index f7a7aba5018..7b649b15fff 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml @@ -2,8 +2,10 @@ - - - + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.gif b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.gif deleted file mode 100644 index 030be8228d7..00000000000 Binary files a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.gif and /dev/null differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.png b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.png new file mode 100644 index 00000000000..470793a4f8b Binary files /dev/null and b/hotspot/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/settings.png differ diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml index 3ae7755b1aa..c3c3a8567e7 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml @@ -19,7 +19,15 @@ - 2.9 + 2.27.1 + + + + org.openide.awt + + + + 7.39.1 @@ -27,7 +35,7 @@ - 7.2.1.1 + 7.20.1 @@ -35,7 +43,15 @@ - 7.10.1.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/BoundedZoomAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/BoundedZoomAction.java index e5843b4c461..e6e916260e0 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/BoundedZoomAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/BoundedZoomAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java index af79b9f3d4d..98d89ee1055 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ColorIcon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,21 +34,26 @@ import javax.swing.Icon; */ public class ColorIcon implements Icon { - private Color color; + private final Color color; public ColorIcon(Color c) { color = c; } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { + Color oldColor = g.getColor(); g.setColor(color); g.fillRect(x, y, 16, 16); + g.setColor(oldColor); } + @Override public int getIconWidth() { return 16; } + @Override public int getIconHeight() { return 16; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java index 596caac0e09..e8e7efdb0a3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ContextAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,7 @@ package com.sun.hotspot.igv.util; import java.awt.EventQueue; -import org.openide.util.ContextAwareAction; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.Utilities; +import org.openide.util.*; import org.openide.util.actions.CallableSystemAction; /** @@ -56,6 +52,7 @@ public abstract class ContextAction extends CallableSystemAction implements L resultChanged(null); } + @Override public void resultChanged(LookupEvent e) { if (result.allItems().size() != 0) { update(result.allInstances().iterator().next()); @@ -71,6 +68,7 @@ public abstract class ContextAction extends CallableSystemAction implements L // Ensure it's AWT event thread EventQueue.invokeLater(new Runnable() { + @Override public void run() { performAction(t); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickAction.java index 65e926d937a..49a10576a7f 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickHandler.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickHandler.java index 5a094adb6eb..3664949a2ef 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickHandler.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/DoubleClickHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java index 5072dfaf0b8..2f0808028ca 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSatelliteComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,10 @@ */ package com.sun.hotspot.igv.util; -import org.netbeans.api.visual.widget.Scene; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.JComponent; +import org.netbeans.api.visual.widget.Scene; /** * @author David Kaspar @@ -118,27 +117,34 @@ public class ExtendedSatelliteComponent extends JComponent implements MouseListe } } + @Override public void mouseClicked(MouseEvent e) { } + @Override public void mousePressed(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseReleased(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseEntered(MouseEvent e) { } + @Override public void mouseExited(MouseEvent e) { } + @Override public void mouseDragged(MouseEvent e) { moveVisibleRect(e.getPoint()); } + @Override public void mouseMoved(MouseEvent e) { } @@ -170,26 +176,33 @@ public class ExtendedSatelliteComponent extends JComponent implements MouseListe } + @Override public void sceneRepaint() { } + @Override public void sceneValidating() { } + @Override public void sceneValidated() { } + @Override public void componentResized(ComponentEvent e) { repaint(); } + @Override public void componentMoved(ComponentEvent e) { repaint(); } + @Override public void componentShown(ComponentEvent e) { } + @Override public void componentHidden(ComponentEvent e) { } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSelectAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSelectAction.java index e2863ca5954..ea8671c37f3 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSelectAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/ExtendedSelectAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java new file mode 100644 index 00000000000..4bf7781b2d8 --- /dev/null +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/LookupHistory.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.util; + +import java.util.HashMap; +import java.util.Map; +import org.openide.util.Lookup.Result; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; +import org.openide.util.Utilities; + +/** + * + * @author Thomas + */ +public class LookupHistory { + + private static Map cache = new HashMap<>(); + + private static class LookupHistoryImpl implements LookupListener { + + private Class klass; + private Result result; + private T last; + + public LookupHistoryImpl(Class klass) { + this.klass = klass; + result = Utilities.actionsGlobalContext().lookupResult(klass); + result.addLookupListener(this); + last = Utilities.actionsGlobalContext().lookup(klass); + } + + public T getLast() { + return last; + } + + @Override + public void resultChanged(LookupEvent ev) { + T current = Utilities.actionsGlobalContext().lookup(klass); + if (current != null) { + last = current; + } + } + } + + public static void init(Class klass) { + if (!cache.containsKey(klass)) { + cache.put(klass, new LookupHistoryImpl<>(klass)); + } + } + + @SuppressWarnings("unchecked") + public static T getLast(Class klass) { + init(klass); + assert cache.containsKey(klass); + return (T) cache.get(klass).getLast(); + } +} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/PropertiesSheet.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/PropertiesSheet.java index 2c3da099bed..22fd64a4bd1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/PropertiesSheet.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/PropertiesSheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java index 1a247320a49..19d76c66b06 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,33 +25,27 @@ package com.sun.hotspot.igv.util; import com.sun.hotspot.igv.data.ChangedListener; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.RenderingHints; +import java.awt.*; +import java.awt.geom.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.List; -import javax.swing.JComponent; +import javax.swing.*; /** * * @author Thomas Wuerthinger */ -public class RangeSlider extends JComponent implements ChangedListener, MouseListener, MouseMotionListener { +public class RangeSlider extends JComponent implements ChangedListener, MouseListener, MouseMotionListener, Scrollable { public static final int HEIGHT = 40; - public static final int BAR_HEIGHT = 22; - public static final int BAR_SELECTION_ENDING_HEIGHT = 16; - public static final int BAR_SELECTION_HEIGHT = 10; - public static final int BAR_THICKNESS = 2; - public static final int BAR_CIRCLE_SIZE = 9; + public static final float BAR_HEIGHT = 22; + public static final float BAR_SELECTION_ENDING_HEIGHT = 16; + public static final float BAR_SELECTION_HEIGHT = 10; + public static final float BAR_THICKNESS = 2; + public static final float BAR_CIRCLE_SIZE = 9; + public static final float BAR_CIRCLE_CONNECTOR_SIZE = 6; public static final int MOUSE_ENDING_OFFSET = 3; public static final Color BACKGROUND_COLOR = Color.white; public static final Color BAR_COLOR = Color.black; @@ -98,14 +92,61 @@ public class RangeSlider extends JComponent implements ChangedListenerJList component + * is the size required to accommodate all of the cells in its list. + * However, the value of preferredScrollableViewportSize + * is the size required for JList.getVisibleRowCount rows. + * A component without any properties that would affect the viewport + * size should just return getPreferredSize here. + * + * @return the preferredSize of a JViewport whose view + * is this Scrollable + * @see JViewport#getPreferredSize + */ + public Dimension getPreferredScrollableViewportSize() { + return getPreferredSize(); + } + + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + if (orientation == SwingConstants.VERTICAL) { + return 1; + } + + return (int)(BAR_CIRCLE_SIZE + BAR_CIRCLE_CONNECTOR_SIZE); + } + + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + return orientation == SwingConstants.VERTICAL ? visibleRect.height / 2 : visibleRect.width / 2; + } + + public boolean getScrollableTracksViewportWidth() { + return false; + } + + public boolean getScrollableTracksViewportHeight() { + return true; + } + @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = HEIGHT; + d.width = Math.max(d.width, (int)(2 * BAR_CIRCLE_CONNECTOR_SIZE + getPaintingModel().getPositions().size() * (BAR_CIRCLE_SIZE + BAR_CIRCLE_CONNECTOR_SIZE))); return d; } + @Override public void changed(RangeSliderModel source) { + revalidate(); + + float barStartY = getBarStartY(); + int circleCenterY = (int)(barStartY + BAR_HEIGHT / 2); + int startX = (int)getStartXPosition(model.getFirstPosition()); + int endX = (int)getEndXPosition(model.getSecondPosition()); + Rectangle r = new Rectangle(startX, circleCenterY, endX - startX, 1); + scrollRectToVisible(r); update(); } @@ -113,22 +154,22 @@ public class RangeSlider extends JComponent implements ChangedListener= 0 && index < getPaintingModel().getPositions().size(); return getXOffset() * (index + 1); } - private int getXOffset() { + private float getXOffset() { int size = getPaintingModel().getPositions().size(); - int width = getWidth(); + float width = (float)getWidth(); return (width / (size + 1)); } - private int getEndXPosition(int index) { + private float getEndXPosition(int index) { return getXPosition(index) + getXOffset() / 2; } - private int getStartXPosition(int index) { + private float getStartXPosition(int index) { return getXPosition(index) - getXOffset() / 2; } @@ -142,7 +183,7 @@ public class RangeSlider extends JComponent implements ChangedListener list = getPaintingModel().getPositions(); - int barStartY = getBarStartY(); + float barStartY = getBarStartY(); g.setColor(BAR_COLOR); - g.fillRect(getXPosition(0), barStartY + BAR_HEIGHT / 2 - BAR_THICKNESS / 2, getXPosition(list.size() - 1) - getXPosition(0), BAR_THICKNESS); + g.fill(new Rectangle2D.Float(getXPosition(0), barStartY + BAR_HEIGHT / 2 - BAR_THICKNESS / 2, getXPosition(list.size() - 1) - getXPosition(0), BAR_THICKNESS)); - int circleCenterY = barStartY + BAR_HEIGHT / 2; + float circleCenterY = barStartY + BAR_HEIGHT / 2; for (int i = 0; i < list.size(); i++) { - int curX = getXPosition(i); + float curX = getXPosition(i); g.setColor(getPaintingModel().getColors().get(i)); - g.fillOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE); + g.fill(new Ellipse2D.Float(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE)); g.setColor(Color.black); - g.drawOval(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE); + g.draw(new Ellipse2D.Float(curX - BAR_CIRCLE_SIZE / 2, circleCenterY - BAR_CIRCLE_SIZE / 2, BAR_CIRCLE_SIZE, BAR_CIRCLE_SIZE)); String curS = list.get(i); if (curS != null && curS.length() > 0) { - int startX = getStartXPosition(i); - int endX = getEndXPosition(i); + float startX = getStartXPosition(i); + float endX = getEndXPosition(i); FontMetrics metrics = g.getFontMetrics(); Rectangle bounds = metrics.getStringBounds(curS, g).getBounds(); if (bounds.width < endX - startX && bounds.height < barStartY) { @@ -194,10 +235,10 @@ public class RangeSlider extends JComponent implements ChangedListener= getBarStartY()) { - int destX = getEndXPosition(getPaintingModel().getSecondPosition()); - int off = Math.abs(destX - p.x); + float destX = getEndXPosition(getPaintingModel().getSecondPosition()); + float off = Math.abs(destX - p.x); return off <= MOUSE_ENDING_OFFSET; } return false; @@ -226,8 +267,8 @@ public class RangeSlider extends JComponent implements ChangedListener= getBarStartY()) { - int destX = getStartXPosition(getPaintingModel().getFirstPosition()); - int off = Math.abs(destX - p.x); + float destX = getStartXPosition(getPaintingModel().getFirstPosition()); + float off = Math.abs(destX - p.x); return off <= MOUSE_ENDING_OFFSET; } return false; @@ -240,10 +281,14 @@ public class RangeSlider extends JComponent implements ChangedListener= model.getPositions().size()) { newIndex = model.getPositions().size() - (model.getSecondPosition() - model.getFirstPosition()) - 1; @@ -270,13 +315,13 @@ public class RangeSlider extends JComponent implements ChangedListener= startX && x <= endX) { return i; } @@ -286,7 +331,7 @@ public class RangeSlider extends JComponent implements ChangedListener getStartXPosition(i)) { result = i; } @@ -294,6 +339,7 @@ public class RangeSlider extends JComponent implements ChangedListener 1) { // Double click @@ -321,6 +368,7 @@ public class RangeSlider extends JComponent implements ChangedListener public RangeSliderModel(List positions) { assert positions.size() > 0; - this.changedEvent = new ChangedEvent(this); - this.colorChangedEvent = new ChangedEvent(this); + this.changedEvent = new ChangedEvent<>(this); + this.colorChangedEvent = new ChangedEvent<>(this); setPositions(positions); } protected void setPositions(List positions) { this.positions = positions; - colors = new ArrayList(); + colors = new ArrayList<>(); for (int i = 0; i < positions.size(); i++) { colors.add(Color.black); } + firstPosition = Math.min(firstPosition, positions.size() - 1); + secondPosition = Math.min(secondPosition, positions.size() - 1); changedEvent.fire(); colorChangedEvent.fire(); } @@ -91,9 +93,7 @@ public class RangeSliderModel implements ChangedEventProvider public RangeSliderModel copy() { RangeSliderModel newModel = new RangeSliderModel(positions); - newModel.firstPosition = firstPosition; - newModel.secondPosition = secondPosition; - newModel.colors = colors; + newModel.setData(this); return newModel; } @@ -130,6 +130,7 @@ public class RangeSliderModel implements ChangedEventProvider return colorChangedEvent; } + @Override public ChangedEvent getChangedEvent() { return changedEvent; } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties index 152f44eca60..b0194c49776 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml index 96b103188e9..2167fe69767 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml @@ -54,6 +54,14 @@ 1.0 + + com.sun.hotspot.igv.selectioncoordinator + + + + 1.0 + + com.sun.hotspot.igv.settings @@ -83,7 +91,15 @@ - 2.9 + 2.27.1 + + + + org.netbeans.spi.quicksearch + + + + 1.0 @@ -91,7 +107,7 @@ - 6.6.0.1 + 6.21.1 @@ -99,7 +115,7 @@ - 6.11.0.1 + 7.30.1 @@ -107,7 +123,7 @@ - 7.5.1 + 7.18.1 @@ -115,7 +131,7 @@ - 6.7 + 7.20.1 @@ -123,7 +139,7 @@ - 7.2.1.1 + 7.20.1 @@ -131,7 +147,15 @@ - 7.9.0.1 + 8.14.1 + + + + org.openide.util.lookup + + + + 8.6.1 @@ -139,7 +163,7 @@ - 6.16 + 6.39.1 diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/META-INF/services/com.sun.hotspot.igv.data.services.InputGraphProvider b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/META-INF/services/com.sun.hotspot.igv.data.services.InputGraphProvider deleted file mode 100644 index e057d732d3d..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/META-INF/services/com.sun.hotspot.igv.data.services.InputGraphProvider +++ /dev/null @@ -1 +0,0 @@ -com.sun.hotspot.igv.view.EditorInputGraphProvider diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java index 667a09f85fe..05465850338 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/BoundedZoomAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/Bundle.properties b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/Bundle.properties index 4593549d591..95b5ed250ab 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/Bundle.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/Bundle.properties @@ -1,3 +1,3 @@ -HINT_EditorTopComponent=This is a Editor window -OpenIDE-Module-Name=View -CTL_EditorTopComponent=Editor Window +HINT_EditorTopComponent=Visualizes a graph. +OpenIDE-Module-Name=View +CTL_EditorTopComponent=Graph \ No newline at end of file diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ConnectionAnchor.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ConnectionAnchor.java deleted file mode 100644 index 6e6b7f1ffee..00000000000 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/ConnectionAnchor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.view; - -import com.sun.hotspot.igv.view.widgets.SlotWidget; -import java.awt.Point; -import java.awt.Rectangle; -import org.netbeans.api.visual.anchor.Anchor; -import org.netbeans.api.visual.anchor.Anchor.Entry; -import org.netbeans.api.visual.anchor.Anchor.Result; -import org.netbeans.api.visual.widget.Widget; - -/** - * - * @author Thomas Wuerthinger - */ -public class ConnectionAnchor extends Anchor { - - public enum HorizontalAlignment { - - Left, - Center, - Right - } - private HorizontalAlignment alignment; - - public ConnectionAnchor(Widget widget) { - this(HorizontalAlignment.Center, widget); - } - - public ConnectionAnchor(HorizontalAlignment alignment, Widget widget) { - super(widget); - this.alignment = alignment; - } - - public Result compute(Entry entry) { - return new Result(getRelatedSceneLocation(), Anchor.DIRECTION_ANY); - } - - @Override - public Point getRelatedSceneLocation() { - Point p = null; - Widget w = getRelatedWidget(); - if (w != null) { - if (w instanceof SlotWidget) { - p = ((SlotWidget) w).getAnchorPosition(); - } else { - Rectangle r = w.convertLocalToScene(w.getBounds()); - int y = r.y + r.height / 2; - int x = r.x; - if (alignment == HorizontalAlignment.Center) { - x = r.x + r.width / 2; - } else if (alignment == HorizontalAlignment.Right) { - x = r.x + r.width; - } - - p = new Point(x, y); - } - } - - return p; - } -} diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java index b391fe83000..f30003fdcdc 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,77 +23,42 @@ */ package com.sun.hotspot.igv.view; -import com.sun.hotspot.igv.view.widgets.BlockWidget; -import com.sun.hotspot.igv.view.widgets.LineWidget; -import com.sun.hotspot.igv.util.DoubleClickAction; +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.data.ControllableChangedListener; import com.sun.hotspot.igv.data.InputBlock; import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.graph.Connection; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.Figure; -import com.sun.hotspot.igv.graph.InputSlot; -import com.sun.hotspot.igv.graph.OutputSlot; -import com.sun.hotspot.igv.graph.Slot; -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalClusterLayoutManager; -import com.sun.hotspot.igv.hierarchicallayout.OldHierarchicalLayoutManager; -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; -import com.sun.hotspot.igv.view.widgets.FigureWidget; -import com.sun.hotspot.igv.view.widgets.InputSlotWidget; -import com.sun.hotspot.igv.view.widgets.OutputSlotWidget; -import com.sun.hotspot.igv.view.widgets.SlotWidget; -import com.sun.hotspot.igv.layout.LayoutGraph; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.services.Scheduler; -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.graph.Block; +import com.sun.hotspot.igv.graph.*; +import com.sun.hotspot.igv.hierarchicallayout.HierarchicalClusterLayoutManager; +import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; +import com.sun.hotspot.igv.layout.LayoutGraph; +import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; import com.sun.hotspot.igv.util.ColorIcon; -import com.sun.hotspot.igv.util.ExtendedSelectAction; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.HashMap; +import com.sun.hotspot.igv.util.DoubleClickAction; +import com.sun.hotspot.igv.util.PropertiesSheet; +import com.sun.hotspot.igv.view.actions.CustomizablePanAction; +import com.sun.hotspot.igv.view.widgets.*; +import java.awt.*; +import java.awt.event.*; import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +import java.util.*; +import javax.swing.*; import javax.swing.event.UndoableEditEvent; import javax.swing.undo.AbstractUndoableEdit; import javax.swing.undo.CannotRedoException; import javax.swing.undo.CannotUndoException; -import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.PopupMenuProvider; -import org.netbeans.api.visual.action.RectangularSelectDecorator; -import org.netbeans.api.visual.action.RectangularSelectProvider; -import org.netbeans.api.visual.action.SelectProvider; -import org.netbeans.api.visual.action.WidgetAction; +import org.netbeans.api.visual.action.*; import org.netbeans.api.visual.animator.SceneAnimator; import org.netbeans.api.visual.layout.LayoutFactory; -import org.netbeans.api.visual.widget.ConnectionWidget; +import org.netbeans.api.visual.model.*; import org.netbeans.api.visual.widget.LayerWidget; -import org.netbeans.api.visual.widget.Scene; import org.netbeans.api.visual.widget.Widget; -import org.netbeans.api.visual.widget.LabelWidget; import org.openide.awt.UndoRedo; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.Children; +import org.openide.nodes.Sheet; import org.openide.util.Lookup; import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; @@ -102,54 +67,58 @@ import org.openide.util.lookup.InstanceContent; * * @author Thomas Wuerthinger */ -public class DiagramScene extends Scene implements ChangedListener { +public class DiagramScene extends ObjectScene implements DiagramViewer { - private HashMap figureWidgets; - private HashMap slotWidgets; - private HashMap connectionWidgets; - private HashMap blockWidgets; - private Widget hoverWidget; + private CustomizablePanAction panAction; private WidgetAction hoverAction; - private List selectedWidgets; + private WidgetAction selectAction; private Lookup lookup; private InstanceContent content; private Action[] actions; + private Action[] actionsWithSelection; private LayerWidget connectionLayer; private JScrollPane scrollPane; private UndoRedo.Manager undoRedoManager; private LayerWidget mainLayer; - private LayerWidget slotLayer; private LayerWidget blockLayer; - private double realZoomFactor; - private BoundedZoomAction zoomAction; - private WidgetAction panAction; private Widget topLeft; private Widget bottomRight; - private LayerWidget startLayer; - private LabelWidget startLabel; private DiagramViewModel model; private DiagramViewModel modelCopy; - public static final int AFTER = 1; - public static final int BEFORE = 1; + private WidgetAction zoomAction; + private boolean rebuilding; + + /** + * The alpha level of partially visible figures. + */ public static final float ALPHA = 0.4f; - public static final int GRID_SIZE = 30; + + /** + * The offset of the graph to the border of the window showing it. + */ public static final int BORDER_SIZE = 20; + + public static final int UNDOREDO_LIMIT = 100; public static final int SCROLL_UNIT_INCREMENT = 80; public static final int SCROLL_BLOCK_INCREMENT = 400; public static final float ZOOM_MAX_FACTOR = 3.0f; public static final float ZOOM_MIN_FACTOR = 0.0f;//0.15f; public static final float ZOOM_INCREMENT = 1.5f; - public static final int SLOT_OFFSET = 6; + public static final int SLOT_OFFSET = 8; public static final int ANIMATION_LIMIT = 40; + private PopupMenuProvider popupMenuProvider = new PopupMenuProvider() { + @Override public JPopupMenu getPopupMenu(Widget widget, Point localLocation) { return DiagramScene.this.createPopupMenu(); } }; + private RectangularSelectDecorator rectangularSelectDecorator = new RectangularSelectDecorator() { + @Override public Widget createSelectionWidget() { Widget widget = new Widget(DiagramScene.this); widget.setBorder(BorderFactory.createLineBorder(Color.black, 2)); @@ -157,8 +126,98 @@ public class DiagramScene extends Scene implements ChangedListener T getWidget(Object o) { + Widget w = this.findWidget(o); + return (T) w; + } + + @SuppressWarnings("unchecked") + public T getWidget(Object o, Class klass) { + Widget w = this.findWidget(o); + return (T) w; + } + + private static boolean intersects(Set s1, Set s2) { + for (Object o : s1) { + if (s2.contains(o)) { + return true; + } + } + return false; + } + + @Override + public void zoomOut() { + double zoom = getZoomFactor(); + Point viewPosition = getScrollPane().getViewport().getViewPosition(); + double newZoom = zoom / DiagramScene.ZOOM_INCREMENT; + if (newZoom > DiagramScene.ZOOM_MIN_FACTOR) { + setZoomFactor(newZoom); + validate(); + getScrollPane().getViewport().setViewPosition(new Point((int) (viewPosition.x / DiagramScene.ZOOM_INCREMENT), (int) (viewPosition.y / DiagramScene.ZOOM_INCREMENT))); + } + } + + @Override + public void zoomIn() { + + double zoom = getZoomFactor(); + Point viewPosition = getScrollPane().getViewport().getViewPosition(); + double newZoom = zoom * DiagramScene.ZOOM_INCREMENT; + if (newZoom < DiagramScene.ZOOM_MAX_FACTOR) { + setZoomFactor(newZoom); + validate(); + getScrollPane().getViewport().setViewPosition(new Point((int) (viewPosition.x * DiagramScene.ZOOM_INCREMENT), (int) (viewPosition.y * DiagramScene.ZOOM_INCREMENT))); + } + } + + + @Override + public void centerFigures(List
list) { + + boolean b = getUndoRedoEnabled(); + setUndoRedoEnabled(false); + gotoFigures(list); + setUndoRedoEnabled(b); + } + + private Set getObjectsFromIdSet(Set set) { + Set selectedObjects = new HashSet<>(); + for (Figure f : getModel().getDiagramToView().getFigures()) { + if (intersects(f.getSource().getSourceNodesAsSet(), set)) { + selectedObjects.add(f); + } + + for (Slot s : f.getSlots()) { + if (intersects(s.getSource().getSourceNodesAsSet(), set)) { + selectedObjects.add(s); + } + } + } + return selectedObjects; + } + private ControllableChangedListener highlightedCoordinatorListener = new ControllableChangedListener() { + + @Override + public void filteredChanged(SelectionCoordinator source) { + DiagramScene.this.setHighlightedObjects(getObjectsFromIdSet(source.getHighlightedObjects())); + DiagramScene.this.validate(); + } + }; + private ControllableChangedListener selectedCoordinatorListener = new ControllableChangedListener() { + + @Override + public void filteredChanged(SelectionCoordinator source) { + DiagramScene.this.gotoSelection(source.getSelectedObjects()); + DiagramScene.this.validate(); + } + }; + private RectangularSelectProvider rectangularSelectProvider = new RectangularSelectProvider() { + @Override public void performSelection(Rectangle rectangle) { if (rectangle.width < 0) { rectangle.x += rectangle.width; @@ -170,168 +229,44 @@ public class DiagramScene extends Scene implements ChangedListener selectedObjects = new HashSet<>(); for (Figure f : getModel().getDiagramToView().getFigures()) { - FigureWidget w = figureWidgets.get(f); - Rectangle r = new Rectangle(w.getBounds()); - r.setLocation(w.getLocation()); - if (r.intersects(rectangle)) { - if (!selectedWidgets.contains(w)) { - addToSelection(w); - updated = true; + FigureWidget w = getWidget(f); + if (w != null) { + Rectangle r = new Rectangle(w.getBounds()); + r.setLocation(w.getLocation()); + + if (r.intersects(rectangle)) { + selectedObjects.add(f); + } + + for (Slot s : f.getSlots()) { + SlotWidget sw = getWidget(s); + Rectangle r2 = new Rectangle(sw.getBounds()); + r2.setLocation(sw.convertLocalToScene(new Point(0, 0))); + + if (r2.intersects(rectangle)) { + selectedObjects.add(s); + } } } else { - if (selectedWidgets.contains(w)) { - selectedWidgets.remove(w); - content.remove(w.getNode()); - w.setState(w.getState().deriveSelected(false)); - updated = true; - } + assert false : "w should not be null here!"; } } - if (updated) { - selectionUpdated(); - } - } - }; - private SelectProvider selectProvider = new SelectProvider() { - - public boolean isAimingAllowed(Widget widget, Point point, boolean b) { - return false; - } - - public boolean isSelectionAllowed(Widget widget, Point point, boolean b) { - return widget instanceof FigureWidget || widget == DiagramScene.this; - } - - public void select(Widget w, Point point, boolean change) { - - boolean updated = false; - - if (w == DiagramScene.this) { - if (DiagramScene.this.selectedWidgets.size() != 0) { - clearSelection(); - selectionUpdated(); - } - return; - } - - FigureWidget widget = (FigureWidget) w; - - - if (change) { - if (widget.getState().isSelected()) { - assert selectedWidgets.contains(widget); - widget.setState(widget.getState().deriveSelected(false)); - selectedWidgets.remove(widget); - content.remove(widget.getNode()); - updated = true; - } else { - assert !selectedWidgets.contains(widget); - addToSelection(widget); - updated = true; - assert widget.getState().isSelected(); - } - } else { - - if (widget.getState().isSelected()) { - assert selectedWidgets.contains(widget); - } else { - - assert !selectedWidgets.contains(widget); - clearSelection(); - addToSelection(widget); - updated = true; - assert widget.getState().isSelected(); - } - } - - if (updated) { - selectionUpdated(); - } - + setSelectedObjects(selectedObjects); } }; - private FigureWidget getFigureWidget(Figure f) { - return figureWidgets.get(f); - } - private FocusListener focusListener = new FocusListener() { - - public void focusGained(FocusEvent e) { - DiagramScene.this.getView().requestFocus(); - } - - public void focusLost(FocusEvent e) { - } - }; private MouseWheelListener mouseWheelListener = new MouseWheelListener() { + @Override public void mouseWheelMoved(MouseWheelEvent e) { - DiagramScene.this.zoomAction.mouseWheelMoved(DiagramScene.this, new WidgetAction.WidgetMouseWheelEvent(0, e)); - DiagramScene.this.validate(); - } - }; - private MouseListener mouseListener = new MouseListener() { - - public void mouseClicked(MouseEvent e) { - DiagramScene.this.panAction.mouseClicked(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - - public void mousePressed(MouseEvent e) { - DiagramScene.this.panAction.mousePressed(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - - public void mouseReleased(MouseEvent e) { - DiagramScene.this.panAction.mouseReleased(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - - public void mouseEntered(MouseEvent e) { - DiagramScene.this.panAction.mouseEntered(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - - public void mouseExited(MouseEvent e) { - DiagramScene.this.panAction.mouseExited(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - }; - private MouseMotionListener mouseMotionListener = new MouseMotionListener() { - - public void mouseDragged(MouseEvent e) { - DiagramScene.this.panAction.mouseDragged(DiagramScene.this, new WidgetAction.WidgetMouseEvent(0, e)); - } - - public void mouseMoved(MouseEvent e) { - } - }; - private ScrollChangeListener scrollChangeListener = new ScrollChangeListener(); - - private class ScrollChangeListener implements ChangeListener { - - private Map relativePositions = new HashMap(); - private Point oldPosition; - - public void register(Widget w, Point p) { - relativePositions.put(w, p); - } - - public void unregister(Widget w) { - relativePositions.remove(w); - } - - public void stateChanged(ChangeEvent e) { - Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition(); - if (oldPosition == null || !p.equals(oldPosition)) { - for (Widget w : relativePositions.keySet()) { - Point curPoint = relativePositions.get(w); - Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y); - w.setPreferredLocation(newPoint); - DiagramScene.this.validate(); - } - oldPosition = p; + if (e.isControlDown()) { + DiagramScene.this.relayoutWithoutLayout(null); } } - } + }; public Point getScrollPosition() { return getScrollPane().getViewport().getViewPosition(); @@ -341,42 +276,138 @@ public class DiagramScene extends Scene implements ChangedListener(); - content = new InstanceContent(); - lookup = new AbstractLookup(content); - this.setCheckClipping(true); - this.getInputBindings().setZoomActionModifiers(0); - + private JScrollPane createScrollPane() { JComponent comp = this.createView(); comp.setDoubleBuffered(true); comp.setBackground(Color.WHITE); comp.setOpaque(true); - this.setBackground(Color.WHITE); this.setOpaque(true); - scrollPane = new JScrollPane(comp); - scrollPane.setBackground(Color.WHITE); - scrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); - scrollPane.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); - scrollPane.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); - scrollPane.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); - scrollPane.getViewport().addChangeListener(scrollChangeListener); - hoverAction = this.createWidgetHoverAction(); + JScrollPane result = new JScrollPane(comp); + result.setBackground(Color.WHITE); + result.getVerticalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); + result.getVerticalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); + result.getHorizontalScrollBar().setUnitIncrement(SCROLL_UNIT_INCREMENT); + result.getHorizontalScrollBar().setBlockIncrement(SCROLL_BLOCK_INCREMENT); + return result; + } + private ObjectSceneListener selectionChangedListener = new ObjectSceneListener() { + + @Override + public void objectAdded(ObjectSceneEvent arg0, Object arg1) { + } + + @Override + public void objectRemoved(ObjectSceneEvent arg0, Object arg1) { + } + + @Override + public void objectStateChanged(ObjectSceneEvent e, Object o, ObjectState oldState, ObjectState newState) { + } + + @Override + public void selectionChanged(ObjectSceneEvent e, Set oldSet, Set newSet) { + DiagramScene scene = (DiagramScene) e.getObjectScene(); + if (scene.isRebuilding()) { + return; + } + + content.set(newSet, null); + + Set nodeSelection = new HashSet<>(); + for (Object o : newSet) { + if (o instanceof Properties.Provider) { + final Properties.Provider provider = (Properties.Provider) o; + AbstractNode node = new AbstractNode(Children.LEAF) { + + @Override + protected Sheet createSheet() { + Sheet s = super.createSheet(); + PropertiesSheet.initializeSheet(provider.getProperties(), s); + return s; + } + }; + node.setDisplayName(provider.getProperties().get("name")); + content.add(node); + } + + + if (o instanceof Figure) { + nodeSelection.addAll(((Figure) o).getSource().getSourceNodesAsSet()); + } else if (o instanceof Slot) { + nodeSelection.addAll(((Slot) o).getSource().getSourceNodesAsSet()); + } + } + getModel().setSelectedNodes(nodeSelection); + + boolean b = selectedCoordinatorListener.isEnabled(); + selectedCoordinatorListener.setEnabled(false); + SelectionCoordinator.getInstance().setSelectedObjects(nodeSelection); + selectedCoordinatorListener.setEnabled(b); + + } + + @Override + public void highlightingChanged(ObjectSceneEvent e, Set oldSet, Set newSet) { + Set nodeHighlighting = new HashSet<>(); + for (Object o : newSet) { + if (o instanceof Figure) { + nodeHighlighting.addAll(((Figure) o).getSource().getSourceNodesAsSet()); + } else if (o instanceof Slot) { + nodeHighlighting.addAll(((Slot) o).getSource().getSourceNodesAsSet()); + } + } + boolean b = highlightedCoordinatorListener.isEnabled(); + highlightedCoordinatorListener.setEnabled(false); + SelectionCoordinator.getInstance().setHighlightedObjects(nodeHighlighting); + highlightedCoordinatorListener.setEnabled(true); + } + + @Override + public void hoverChanged(ObjectSceneEvent e, Object oldObject, Object newObject) { + Set newHighlightedObjects = new HashSet<>(DiagramScene.this.getHighlightedObjects()); + if (oldObject != null) { + newHighlightedObjects.remove(oldObject); + } + if (newObject != null) { + newHighlightedObjects.add(newObject); + } + DiagramScene.this.setHighlightedObjects(newHighlightedObjects); + } + + @Override + public void focusChanged(ObjectSceneEvent arg0, Object arg1, Object arg2) { + } + }; + + public DiagramScene(Action[] actions, Action[] actionsWithSelection, DiagramViewModel model) { + + this.actions = actions; + this.actionsWithSelection = actionsWithSelection; + + content = new InstanceContent(); + lookup = new AbstractLookup(content); + + this.setCheckClipping(true); + + scrollPane = createScrollPane(); + + hoverAction = createObjectHoverAction(); + + // This panAction handles the event only when the left mouse button is + // pressed without any modifier keys, otherwise it will not consume it + // and the selection action (below) will handle the event + panAction = new CustomizablePanAction(~0, MouseEvent.BUTTON1_DOWN_MASK); + this.getActions().addAction(panAction); + + selectAction = createSelectAction(); + this.getActions().addAction(selectAction); blockLayer = new LayerWidget(this); this.addChild(blockLayer); - startLayer = new LayerWidget(this); - this.addChild(startLayer); - // TODO: String startLabelString = "Loading graph with " + originalDiagram.getFigures().size() + " figures and " + originalDiagram.getConnections().size() + " connections..."; - String startLabelString = ""; - LabelWidget w = new LabelWidget(this, startLabelString); - scrollChangeListener.register(w, new Point(10, 10)); - w.setAlignment(LabelWidget.Alignment.CENTER); - startLabel = w; - startLayer.addChild(w); + connectionLayer = new LayerWidget(this); + this.addChild(connectionLayer); mainLayer = new LayerWidget(this); this.addChild(mainLayer); @@ -385,83 +416,53 @@ public class DiagramScene extends Scene implements ChangedListener(); - boolean b = this.getUndoRedoEnabled(); this.setUndoRedoEnabled(false); this.setNewModel(model); this.setUndoRedoEnabled(b); - } - - private void selectionUpdated() { - getModel().setSelectedNodes(this.getSelectedNodes()); - addUndo(); + this.addObjectSceneListener(selectionChangedListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED, ObjectSceneEventType.OBJECT_HIGHLIGHTING_CHANGED, ObjectSceneEventType.OBJECT_HOVER_CHANGED); } public DiagramViewModel getModel() { return model; } - public void setRealZoomFactor(double d) { - this.realZoomFactor = d; - } - - public double getRealZoomFactor() { - if (realZoomFactor == 0.0) { - return getZoomFactor(); - } else { - return realZoomFactor; - } - } - public JScrollPane getScrollPane() { return scrollPane; } + @Override + public Component getComponent() { + return scrollPane; + } + public boolean isAllVisible() { - return getModel().getHiddenNodes().size() == 0; + return getModel().getHiddenNodes().isEmpty(); } public Action createGotoAction(final Figure f) { final DiagramScene diagramScene = this; - Action a = new AbstractAction() { - - public void actionPerformed(ActionEvent e) { - diagramScene.gotoFigure(f); - } - }; - - a.setEnabled(true); - a.putValue(Action.SMALL_ICON, new ColorIcon(f.getColor())); String name = f.getLines()[0]; name += " ("; @@ -469,112 +470,81 @@ public class DiagramScene extends Scene implements ChangedListener