You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(127) |
Feb
(34) |
Mar
(16) |
Apr
(26) |
May
(55) |
Jun
(107) |
Jul
(36) |
Aug
(72) |
Sep
(90) |
Oct
(41) |
Nov
(27) |
Dec
(13) |
2008 |
Jan
(37) |
Feb
(39) |
Mar
(98) |
Apr
(115) |
May
(134) |
Jun
(120) |
Jul
(86) |
Aug
(149) |
Sep
(68) |
Oct
(66) |
Nov
(104) |
Dec
(49) |
2009 |
Jan
(131) |
Feb
(132) |
Mar
(125) |
Apr
(172) |
May
(161) |
Jun
(43) |
Jul
(47) |
Aug
(38) |
Sep
(18) |
Oct
(6) |
Nov
(1) |
Dec
(15) |
2010 |
Jan
(21) |
Feb
(8) |
Mar
(10) |
Apr
(4) |
May
(9) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(4) |
2011 |
Jan
(23) |
Feb
(10) |
Mar
(13) |
Apr
(3) |
May
|
Jun
(19) |
Jul
(11) |
Aug
(22) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(12) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
(7) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(1) |
Aug
(30) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(8) |
2013 |
Jan
(3) |
Feb
(40) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(12) |
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <ls...@us...> - 2009-12-28 21:36:12
|
Revision: 5701 http://jnode.svn.sourceforge.net/jnode/?rev=5701&view=rev Author: lsantha Date: 2009-12-28 21:36:03 +0000 (Mon, 28 Dec 2009) Log Message: ----------- Published classlib to new location. Modified Paths: -------------- trunk/all/lib/ftp.properties Modified: trunk/all/lib/ftp.properties =================================================================== --- trunk/all/lib/ftp.properties 2009-12-12 16:55:34 UTC (rev 5700) +++ trunk/all/lib/ftp.properties 2009-12-28 21:36:03 UTC (rev 5701) @@ -1,3 +1,3 @@ -classlib.url=http://codemammoth.com/jnodeftp/classlib/20090722120045 -classlib.md5=db80e29d8154341d4cf4dc8b1476a131 -classlib-src.md5=72ead15492b953ed1b8022b816971730 \ No newline at end of file +classlib.url=http://jnode.ro//classlib/20091228090913 +classlib.md5=ac4c3f52a31d0a1f58e4515c0be7480b +classlib-src.md5=0ba30a72207217ba95cb6c5f0031ad86 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-12 16:55:41
|
Revision: 5700 http://jnode.svn.sourceforge.net/jnode/?rev=5700&view=rev Author: fduminy Date: 2009-12-12 16:55:34 +0000 (Sat, 12 Dec 2009) Log Message: ----------- reverted changes in r5696 Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java Modified: trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:44:38 UTC (rev 5699) +++ trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:55:34 UTC (rev 5700) @@ -95,23 +95,6 @@ return mc; } } - - /** - * Indicate if the given class name corresponds to a magic class. - * - * @param name Name of a class. - * @return true if the class is magic. - */ - static boolean isMagic(String name) { - boolean magic = false; - for (MagicClass mc : values()) { - if (mc.name.equals(name)) { - magic = true; - break; - } - } - return magic; - } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-12 16:44:51
|
Revision: 5699 http://jnode.svn.sourceforge.net/jnode/?rev=5699&view=rev Author: fduminy Date: 2009-12-12 16:44:38 +0000 (Sat, 12 Dec 2009) Log Message: ----------- reverted changes in r5696 Added Paths: ----------- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java Removed Paths: ------------- trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java Deleted: trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java 2009-12-12 16:33:36 UTC (rev 5698) +++ trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java 2009-12-12 16:44:38 UTC (rev 5699) @@ -1,321 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.vm.classmgr; - -import java.util.Map; - -import org.jnode.util.BootableHashMap; -import org.jnode.annotation.SharedStatics; - -/** - * @author Ewout Prangsma (ep...@us...) - */ -public class BaseMagicHelper { - - /** - * Enum of all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicClass { - ADDRESS("org.vmmagic.unboxed.Address"), - EXTENT("org.vmmagic.unboxed.Extent"), - OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), - OFFSET("org.vmmagic.unboxed.Offset"), - WORD("org.vmmagic.unboxed.Word"), - ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), - EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), - OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), - OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), - WORDARRAY("org.vmmagic.unboxed.WordArray"), - VMMAGIC("org.jnode.vm.VmMagic"); - - /** - * Name of the class - */ - private final String name; - - /** - * Lookup table - */ - private static final Map<String, MagicClass> nameToClass; - - /** - * Initialize this instance. - * - * @param name - */ - private MagicClass(String name) { - this.name = name; - } - - /** - * Initialize the lookup table - */ - static { - nameToClass = new BootableHashMap<String, MagicClass>(); - for (MagicClass mc : values()) { - nameToClass.put(mc.name, mc); - } - } - - /** - * Gets the MagicClass instance for the given type. - * - * @param type - * @return a MagicClass instance - * @throws InternalError When type is no magic type. - */ - public static MagicClass get(VmType<?> type) { - MagicClass mc = nameToClass.get(type.getName()); - if (mc == null) { - throw new InternalError("Unknown magic type " + type.getName()); - } else { - return mc; - } - } - - /** - * Indicate if the given class name corresponds to a magic class. - * - * @param name Name of a class. - * @return true if the class is magic. - */ - static boolean isMagic(String name) { - boolean magic = false; - for (MagicClass mc : values()) { - if (mc.name.equals(name)) { - magic = true; - break; - } - } - return magic; - } - } - - /** - * Enum of all methods in all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicMethod { - ADD("add", false), - AND("and", false), - OR("or", false), - NOT("not", false), - SUB("sub", false), - XOR("xor", false), - ZERO("zero", false), - MAX("max", false), - ONE("one", false), - TOINT("toInt", false), - TOLONG("toLong", false), - TOWORD("toWord", false), - TOADDRESS("toAddress", true), - TOEXTENT("toExtent", false), - TOOFFSET("toOffset", false), - TOOBJECTREFERENCE("toObjectReference", true), - EQUALS("equals", false), - ISZERO("isZero", false), - ISMAX("isMax", false), - ISNULL("isNull", false), - EQ("EQ", false), - NE("NE", false), - GT("GT", false), - GE("GE", false), - LT("LT", false), - LE("LE", false), - SGT("sGT", false), - SGE("sGE", false), - SLT("sLT", false), - SLE("sLE", false), - FROMINT("fromInt", false), - FROMINTSIGNEXTEND("fromIntSignExtend", false), - FROMINTZEROEXTEND("fromIntZeroExtend", false), - FROMLONG("fromLong", false), - LSH("lsh", false), - RSHL("rshl", false), - RSHA("rsha", false), - LOADBYTE("loadByte", true, "()B"), - LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), - LOADCHAR("loadChar", true, "()C"), - LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), - LOADSHORT("loadShort", true, "()S"), - LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), - LOADINT("loadInt", true, "()I"), - LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - LOADFLOAT("loadFloat", true, "()F"), - LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), - LOADLONG("loadLong", true, "()J"), - LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), - LOADDOUBLE("loadDouble", true, "()D"), - LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), - LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), - LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - LOADOBJECTREFERENCE_OFS("loadObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - SIZE("size", false), - STOREBYTE("store", true, "(B)V"), - STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), - STORECHAR("store", true, "(C)V"), - STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), - STORESHORT("store", true, "(S)V"), - STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), - STOREINT("store", true, "(I)V"), - STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), - STOREFLOAT("store", true, "(F)V"), - STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), - STORELONG("store", true, "(J)V"), - STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), - STOREDOUBLE("store", true, "(D)V"), - STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), - STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), - STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), - STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), - STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), - STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), - STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), - PREPAREINT("prepareInt", true, "()I"), - PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), - PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - ATTEMPTINT("attempt", true, "(II)Z"), - ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), - ATTEMPTADDRESS_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTOBJECTREFERENCE("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), - ATTEMPTOBJECTREFERENCE_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + - "Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), - ATTEMPTWORD_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), - FROMOBJECT("fromObject", true), - FROMADDRESS("fromAddress", true), - GETOBJECTTYPE("getObjectType", true), - GETTIB("getTIB", true), - GETOBJECTFLAGS("getObjectFlags", true), - SETOBJECTFLAGS("setObjectFlags", true), - TOOBJECT("toObject", true), - GETARRAYDATA("getArrayData", true), - GETOBJECTCOLOR("getObjectColor", true), - ISFINALIZED("isFinalized", true), - ATOMICADD("atomicAdd", true), - ATOMICAND("atomicAnd", true), - ATOMICOR("atomicOr", true), - ATOMICSUB("atomicSub", true), - GETCURRENTFRAME("getCurrentFrame", true), - GETTIMESTAMP("getTimeStamp", true), - INTBITSTOFLOAT("intBitsToFloat", false), - FLOATTORAWINTBITS("floatToRawIntBits", false), - LONGBITSTODOUBLE("longBitsToDouble", false), - DOUBLETORAWLONGBITS("doubleToRawLongBits", false), - BREAKPOINT("breakPoint", true), - DIFF("diff", false), - NULLREFERENCE("nullReference", false), - CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), - GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), - GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), - ISRUNNINGJNODE("isRunningJNode", false, "()Z"), - - // Array classes - ARR_CREATE("create", true), - ARR_GET("get", true), - ARR_SET("set", true), - ARR_LENGTH("length", false); - - private final String name; - private final String signature; - private final boolean permissionRequired; - private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); - - private MagicMethod(String name, boolean permissionRequired) { - this.name = name; - this.signature = null; - this.permissionRequired = permissionRequired; - } - - private MagicMethod(String name, boolean permissionRequired, String signature) { - this.name = name; - this.permissionRequired = permissionRequired; - this.signature = signature; - } - - public static MagicMethod get(VmMethod method) { - MagicMethod mm = methods.get(method); - if (mm != null) { - return mm; - } - final String mname = method.getName(); - final String msignature = method.getSignature(); - - for (MagicMethod m : values()) { - if (m.name.equals(mname)) { - if ((m.signature == null) || m.signature.equals(msignature)) { - methods.put(method, m); - return m; - } - - } - } - throw new InternalError("Unknown method " + mname + '#' + msignature + " in " - + method.getDeclaringClass().getName()); - } - - /** - * Is MagicPermission required for this method. - * - * @return - */ - final boolean isPermissionRequired() { - return this.permissionRequired; - } - } - - /** - * Is the given method allowed to call magic code. - * - * @param caller - */ - public static void testMagicPermission(MagicMethod callee, VmMethod caller) - throws SecurityException { - if (callee.isPermissionRequired()) { - if (!caller.getDeclaringClass().isMagicPermissionGranted()) { - System.out.println("MagicPermission is not granted for type: " - + caller.getDeclaringClass().getName()); - // throw new SecurityException("MagicPermission is not granted - // for method: " + caller.getFullName()); - } - } - } -} Copied: trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java (from rev 5697, trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java) =================================================================== --- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:44:38 UTC (rev 5699) @@ -0,0 +1,323 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.vm.compiler; + +import java.util.Map; + +import org.jnode.util.BootableHashMap; +import org.jnode.vm.classmgr.VmMethod; +import org.jnode.vm.classmgr.VmType; +import org.jnode.annotation.SharedStatics; + +/** + * @author Ewout Prangsma (ep...@us...) + */ +public class BaseMagicHelper { + + /** + * Enum of all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicClass { + ADDRESS("org.vmmagic.unboxed.Address"), + EXTENT("org.vmmagic.unboxed.Extent"), + OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), + OFFSET("org.vmmagic.unboxed.Offset"), + WORD("org.vmmagic.unboxed.Word"), + ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), + EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), + OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), + OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), + WORDARRAY("org.vmmagic.unboxed.WordArray"), + VMMAGIC("org.jnode.vm.VmMagic"); + + /** + * Name of the class + */ + private final String name; + + /** + * Lookup table + */ + private static final Map<String, MagicClass> nameToClass; + + /** + * Initialize this instance. + * + * @param name + */ + private MagicClass(String name) { + this.name = name; + } + + /** + * Initialize the lookup table + */ + static { + nameToClass = new BootableHashMap<String, MagicClass>(); + for (MagicClass mc : values()) { + nameToClass.put(mc.name, mc); + } + } + + /** + * Gets the MagicClass instance for the given type. + * + * @param type + * @return a MagicClass instance + * @throws InternalError When type is no magic type. + */ + public static MagicClass get(VmType<?> type) { + MagicClass mc = nameToClass.get(type.getName()); + if (mc == null) { + throw new InternalError("Unknown magic type " + type.getName()); + } else { + return mc; + } + } + + /** + * Indicate if the given class name corresponds to a magic class. + * + * @param name Name of a class. + * @return true if the class is magic. + */ + static boolean isMagic(String name) { + boolean magic = false; + for (MagicClass mc : values()) { + if (mc.name.equals(name)) { + magic = true; + break; + } + } + return magic; + } + } + + /** + * Enum of all methods in all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicMethod { + ADD("add", false), + AND("and", false), + OR("or", false), + NOT("not", false), + SUB("sub", false), + XOR("xor", false), + ZERO("zero", false), + MAX("max", false), + ONE("one", false), + TOINT("toInt", false), + TOLONG("toLong", false), + TOWORD("toWord", false), + TOADDRESS("toAddress", true), + TOEXTENT("toExtent", false), + TOOFFSET("toOffset", false), + TOOBJECTREFERENCE("toObjectReference", true), + EQUALS("equals", false), + ISZERO("isZero", false), + ISMAX("isMax", false), + ISNULL("isNull", false), + EQ("EQ", false), + NE("NE", false), + GT("GT", false), + GE("GE", false), + LT("LT", false), + LE("LE", false), + SGT("sGT", false), + SGE("sGE", false), + SLT("sLT", false), + SLE("sLE", false), + FROMINT("fromInt", false), + FROMINTSIGNEXTEND("fromIntSignExtend", false), + FROMINTZEROEXTEND("fromIntZeroExtend", false), + FROMLONG("fromLong", false), + LSH("lsh", false), + RSHL("rshl", false), + RSHA("rsha", false), + LOADBYTE("loadByte", true, "()B"), + LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), + LOADCHAR("loadChar", true, "()C"), + LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), + LOADSHORT("loadShort", true, "()S"), + LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), + LOADINT("loadInt", true, "()I"), + LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + LOADFLOAT("loadFloat", true, "()F"), + LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), + LOADLONG("loadLong", true, "()J"), + LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), + LOADDOUBLE("loadDouble", true, "()D"), + LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), + LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), + LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + LOADOBJECTREFERENCE_OFS("loadObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + SIZE("size", false), + STOREBYTE("store", true, "(B)V"), + STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), + STORECHAR("store", true, "(C)V"), + STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), + STORESHORT("store", true, "(S)V"), + STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), + STOREINT("store", true, "(I)V"), + STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), + STOREFLOAT("store", true, "(F)V"), + STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), + STORELONG("store", true, "(J)V"), + STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), + STOREDOUBLE("store", true, "(D)V"), + STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), + STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), + STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), + STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), + STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), + STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), + STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), + PREPAREINT("prepareInt", true, "()I"), + PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), + PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + ATTEMPTINT("attempt", true, "(II)Z"), + ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), + ATTEMPTADDRESS_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTOBJECTREFERENCE("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), + ATTEMPTOBJECTREFERENCE_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + + "Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), + ATTEMPTWORD_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), + FROMOBJECT("fromObject", true), + FROMADDRESS("fromAddress", true), + GETOBJECTTYPE("getObjectType", true), + GETTIB("getTIB", true), + GETOBJECTFLAGS("getObjectFlags", true), + SETOBJECTFLAGS("setObjectFlags", true), + TOOBJECT("toObject", true), + GETARRAYDATA("getArrayData", true), + GETOBJECTCOLOR("getObjectColor", true), + ISFINALIZED("isFinalized", true), + ATOMICADD("atomicAdd", true), + ATOMICAND("atomicAnd", true), + ATOMICOR("atomicOr", true), + ATOMICSUB("atomicSub", true), + GETCURRENTFRAME("getCurrentFrame", true), + GETTIMESTAMP("getTimeStamp", true), + INTBITSTOFLOAT("intBitsToFloat", false), + FLOATTORAWINTBITS("floatToRawIntBits", false), + LONGBITSTODOUBLE("longBitsToDouble", false), + DOUBLETORAWLONGBITS("doubleToRawLongBits", false), + BREAKPOINT("breakPoint", true), + DIFF("diff", false), + NULLREFERENCE("nullReference", false), + CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), + GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), + GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), + ISRUNNINGJNODE("isRunningJNode", false, "()Z"), + + // Array classes + ARR_CREATE("create", true), + ARR_GET("get", true), + ARR_SET("set", true), + ARR_LENGTH("length", false); + + private final String name; + private final String signature; + private final boolean permissionRequired; + private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); + + private MagicMethod(String name, boolean permissionRequired) { + this.name = name; + this.signature = null; + this.permissionRequired = permissionRequired; + } + + private MagicMethod(String name, boolean permissionRequired, String signature) { + this.name = name; + this.permissionRequired = permissionRequired; + this.signature = signature; + } + + public static MagicMethod get(VmMethod method) { + MagicMethod mm = methods.get(method); + if (mm != null) { + return mm; + } + final String mname = method.getName(); + final String msignature = method.getSignature(); + + for (MagicMethod m : values()) { + if (m.name.equals(mname)) { + if ((m.signature == null) || m.signature.equals(msignature)) { + methods.put(method, m); + return m; + } + + } + } + throw new InternalError("Unknown method " + mname + '#' + msignature + " in " + + method.getDeclaringClass().getName()); + } + + /** + * Is MagicPermission required for this method. + * + * @return + */ + final boolean isPermissionRequired() { + return this.permissionRequired; + } + } + + /** + * Is the given method allowed to call magic code. + * + * @param caller + */ + public static void testMagicPermission(MagicMethod callee, VmMethod caller) + throws SecurityException { + if (callee.isPermissionRequired()) { + if (!caller.getDeclaringClass().isMagicPermissionGranted()) { + System.out.println("MagicPermission is not granted for type: " + + caller.getDeclaringClass().getName()); + // throw new SecurityException("MagicPermission is not granted + // for method: " + caller.getFullName()); + } + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-12 16:33:42
|
Revision: 5698 http://jnode.svn.sourceforge.net/jnode/?rev=5698&view=rev Author: fduminy Date: 2009-12-12 16:33:36 +0000 (Sat, 12 Dec 2009) Log Message: ----------- reverted changes in r5696 Removed Paths: ------------- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java Deleted: trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:15:04 UTC (rev 5697) +++ trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:33:36 UTC (rev 5698) @@ -1,306 +0,0 @@ -/* - * $Id: BaseMagicHelper.java 5226 2009-04-06 14:55:27Z lsantha $ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.vm.compiler; - -import java.util.Map; - -import org.jnode.util.BootableHashMap; -import org.jnode.vm.classmgr.VmMethod; -import org.jnode.vm.classmgr.VmType; -import org.jnode.annotation.SharedStatics; - -/** - * @author Ewout Prangsma (ep...@us...) - */ -public class BaseMagicHelper { - - /** - * Enum of all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicClass { - ADDRESS("org.vmmagic.unboxed.Address"), - EXTENT("org.vmmagic.unboxed.Extent"), - OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), - OFFSET("org.vmmagic.unboxed.Offset"), - WORD("org.vmmagic.unboxed.Word"), - ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), - EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), - OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), - OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), - WORDARRAY("org.vmmagic.unboxed.WordArray"), - VMMAGIC("org.jnode.vm.VmMagic"); - - /** - * Name of the class - */ - private final String name; - - /** - * Lookup table - */ - private static final Map<String, MagicClass> nameToClass; - - /** - * Initialize this instance. - * - * @param name - */ - private MagicClass(String name) { - this.name = name; - } - - /** - * Initialize the lookup table - */ - static { - nameToClass = new BootableHashMap<String, MagicClass>(); - for (MagicClass mc : values()) { - nameToClass.put(mc.name, mc); - } - } - - /** - * Gets the MagicClass instance for the given type. - * - * @param type - * @return a MagicClass instance - * @throws InternalError When type is no magic type. - */ - public static MagicClass get(VmType<?> type) { - MagicClass mc = nameToClass.get(type.getName()); - if (mc == null) { - throw new InternalError("Unknown magic type " + type.getName()); - } else { - return mc; - } - } - } - - /** - * Enum of all methods in all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicMethod { - ADD("add", false), - AND("and", false), - OR("or", false), - NOT("not", false), - SUB("sub", false), - XOR("xor", false), - ZERO("zero", false), - MAX("max", false), - ONE("one", false), - TOINT("toInt", false), - TOLONG("toLong", false), - TOWORD("toWord", false), - TOADDRESS("toAddress", true), - TOEXTENT("toExtent", false), - TOOFFSET("toOffset", false), - TOOBJECTREFERENCE("toObjectReference", true), - EQUALS("equals", false), - ISZERO("isZero", false), - ISMAX("isMax", false), - ISNULL("isNull", false), - EQ("EQ", false), - NE("NE", false), - GT("GT", false), - GE("GE", false), - LT("LT", false), - LE("LE", false), - SGT("sGT", false), - SGE("sGE", false), - SLT("sLT", false), - SLE("sLE", false), - FROMINT("fromInt", false), - FROMINTSIGNEXTEND("fromIntSignExtend", false), - FROMINTZEROEXTEND("fromIntZeroExtend", false), - FROMLONG("fromLong", false), - LSH("lsh", false), - RSHL("rshl", false), - RSHA("rsha", false), - LOADBYTE("loadByte", true, "()B"), - LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), - LOADCHAR("loadChar", true, "()C"), - LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), - LOADSHORT("loadShort", true, "()S"), - LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), - LOADINT("loadInt", true, "()I"), - LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - LOADFLOAT("loadFloat", true, "()F"), - LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), - LOADLONG("loadLong", true, "()J"), - LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), - LOADDOUBLE("loadDouble", true, "()D"), - LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), - LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), - LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - LOADOBJECTREFERENCE_OFS("loadObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - SIZE("size", false), - STOREBYTE("store", true, "(B)V"), - STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), - STORECHAR("store", true, "(C)V"), - STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), - STORESHORT("store", true, "(S)V"), - STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), - STOREINT("store", true, "(I)V"), - STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), - STOREFLOAT("store", true, "(F)V"), - STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), - STORELONG("store", true, "(J)V"), - STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), - STOREDOUBLE("store", true, "(D)V"), - STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), - STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), - STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), - STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), - STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), - STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), - STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), - PREPAREINT("prepareInt", true, "()I"), - PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), - PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - ATTEMPTINT("attempt", true, "(II)Z"), - ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), - ATTEMPTADDRESS_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTOBJECTREFERENCE("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), - ATTEMPTOBJECTREFERENCE_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + - "Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), - ATTEMPTWORD_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), - FROMOBJECT("fromObject", true), - FROMADDRESS("fromAddress", true), - GETOBJECTTYPE("getObjectType", true), - GETTIB("getTIB", true), - GETOBJECTFLAGS("getObjectFlags", true), - SETOBJECTFLAGS("setObjectFlags", true), - TOOBJECT("toObject", true), - GETARRAYDATA("getArrayData", true), - GETOBJECTCOLOR("getObjectColor", true), - ISFINALIZED("isFinalized", true), - ATOMICADD("atomicAdd", true), - ATOMICAND("atomicAnd", true), - ATOMICOR("atomicOr", true), - ATOMICSUB("atomicSub", true), - GETCURRENTFRAME("getCurrentFrame", true), - GETTIMESTAMP("getTimeStamp", true), - INTBITSTOFLOAT("intBitsToFloat", false), - FLOATTORAWINTBITS("floatToRawIntBits", false), - LONGBITSTODOUBLE("longBitsToDouble", false), - DOUBLETORAWLONGBITS("doubleToRawLongBits", false), - BREAKPOINT("breakPoint", true), - DIFF("diff", false), - NULLREFERENCE("nullReference", false), - CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), - GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), - GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), - ISRUNNINGJNODE("isRunningJNode", false, "()Z"), - - // Array classes - ARR_CREATE("create", true), - ARR_GET("get", true), - ARR_SET("set", true), - ARR_LENGTH("length", false); - - private final String name; - private final String signature; - private final boolean permissionRequired; - private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); - - private MagicMethod(String name, boolean permissionRequired) { - this.name = name; - this.signature = null; - this.permissionRequired = permissionRequired; - } - - private MagicMethod(String name, boolean permissionRequired, String signature) { - this.name = name; - this.permissionRequired = permissionRequired; - this.signature = signature; - } - - public static MagicMethod get(VmMethod method) { - MagicMethod mm = methods.get(method); - if (mm != null) { - return mm; - } - final String mname = method.getName(); - final String msignature = method.getSignature(); - - for (MagicMethod m : values()) { - if (m.name.equals(mname)) { - if ((m.signature == null) || m.signature.equals(msignature)) { - methods.put(method, m); - return m; - } - - } - } - throw new InternalError("Unknown method " + mname + '#' + msignature + " in " - + method.getDeclaringClass().getName()); - } - - /** - * Is MagicPermission required for this method. - * - * @return - */ - final boolean isPermissionRequired() { - return this.permissionRequired; - } - } - - /** - * Is the given method allowed to call magic code. - * - * @param caller - */ - public static void testMagicPermission(MagicMethod callee, VmMethod caller) - throws SecurityException { - if (callee.isPermissionRequired()) { - if (!caller.getDeclaringClass().isMagicPermissionGranted()) { - System.out.println("MagicPermission is not granted for type: " - + caller.getDeclaringClass().getName()); - // throw new SecurityException("MagicPermission is not granted - // for method: " + caller.getFullName()); - } - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-12 16:15:13
|
Revision: 5697 http://jnode.svn.sourceforge.net/jnode/?rev=5697&view=rev Author: fduminy Date: 2009-12-12 16:15:04 +0000 (Sat, 12 Dec 2009) Log Message: ----------- reverted changes in r5696 Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/VmMagic.java trunk/core/src/core/org/jnode/vm/classmgr/VmType.java trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java Modified: trunk/core/src/core/org/jnode/vm/VmMagic.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -36,8 +36,8 @@ * Methods in this class can also be called from inside JNode. * * @author Ewout Prangsma (ep...@us...) - * @see {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass} to get the list of "magic" classes (including this class). - * @see {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod} to get the list of "magic" methods. + * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass} to get the list of "magic" classes (including this class). + * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod} to get the list of "magic" methods. */ @MagicPermission public final class VmMagic { Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmType.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -302,8 +302,18 @@ throw new IllegalArgumentException("name contains '/'"); } - if (BaseMagicHelper.MagicClass.isMagic(name)) { - modifiers |= Modifier.ACC_MAGIC; + final String pkg = VMClassHelper.getPackagePortion(name); + if (pkg.equals("org.vmmagic.unboxed") || pkg.equals("org.jnode.vm")) { + final String cname = VMClassHelper.getClassNamePortion(name); + if (cname.equals("Address") || cname.equals("AddressArray") + || cname.equals("Extent") || cname.equals("ExtentArray") + || cname.equals("ObjectReference") + || cname.equals("ObjectReferenceArray") + || cname.equals("Offset") || cname.equals("OffsetArray") + || cname.equals("Word") || cname.equals("WordArray") + | cname.equals("VmMagic")) { + modifiers |= Modifier.ACC_MAGIC; + } } this.name = InternString.internString(name); Added: trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -0,0 +1,306 @@ +/* + * $Id: BaseMagicHelper.java 5226 2009-04-06 14:55:27Z lsantha $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.vm.compiler; + +import java.util.Map; + +import org.jnode.util.BootableHashMap; +import org.jnode.vm.classmgr.VmMethod; +import org.jnode.vm.classmgr.VmType; +import org.jnode.annotation.SharedStatics; + +/** + * @author Ewout Prangsma (ep...@us...) + */ +public class BaseMagicHelper { + + /** + * Enum of all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicClass { + ADDRESS("org.vmmagic.unboxed.Address"), + EXTENT("org.vmmagic.unboxed.Extent"), + OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), + OFFSET("org.vmmagic.unboxed.Offset"), + WORD("org.vmmagic.unboxed.Word"), + ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), + EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), + OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), + OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), + WORDARRAY("org.vmmagic.unboxed.WordArray"), + VMMAGIC("org.jnode.vm.VmMagic"); + + /** + * Name of the class + */ + private final String name; + + /** + * Lookup table + */ + private static final Map<String, MagicClass> nameToClass; + + /** + * Initialize this instance. + * + * @param name + */ + private MagicClass(String name) { + this.name = name; + } + + /** + * Initialize the lookup table + */ + static { + nameToClass = new BootableHashMap<String, MagicClass>(); + for (MagicClass mc : values()) { + nameToClass.put(mc.name, mc); + } + } + + /** + * Gets the MagicClass instance for the given type. + * + * @param type + * @return a MagicClass instance + * @throws InternalError When type is no magic type. + */ + public static MagicClass get(VmType<?> type) { + MagicClass mc = nameToClass.get(type.getName()); + if (mc == null) { + throw new InternalError("Unknown magic type " + type.getName()); + } else { + return mc; + } + } + } + + /** + * Enum of all methods in all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicMethod { + ADD("add", false), + AND("and", false), + OR("or", false), + NOT("not", false), + SUB("sub", false), + XOR("xor", false), + ZERO("zero", false), + MAX("max", false), + ONE("one", false), + TOINT("toInt", false), + TOLONG("toLong", false), + TOWORD("toWord", false), + TOADDRESS("toAddress", true), + TOEXTENT("toExtent", false), + TOOFFSET("toOffset", false), + TOOBJECTREFERENCE("toObjectReference", true), + EQUALS("equals", false), + ISZERO("isZero", false), + ISMAX("isMax", false), + ISNULL("isNull", false), + EQ("EQ", false), + NE("NE", false), + GT("GT", false), + GE("GE", false), + LT("LT", false), + LE("LE", false), + SGT("sGT", false), + SGE("sGE", false), + SLT("sLT", false), + SLE("sLE", false), + FROMINT("fromInt", false), + FROMINTSIGNEXTEND("fromIntSignExtend", false), + FROMINTZEROEXTEND("fromIntZeroExtend", false), + FROMLONG("fromLong", false), + LSH("lsh", false), + RSHL("rshl", false), + RSHA("rsha", false), + LOADBYTE("loadByte", true, "()B"), + LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), + LOADCHAR("loadChar", true, "()C"), + LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), + LOADSHORT("loadShort", true, "()S"), + LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), + LOADINT("loadInt", true, "()I"), + LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + LOADFLOAT("loadFloat", true, "()F"), + LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), + LOADLONG("loadLong", true, "()J"), + LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), + LOADDOUBLE("loadDouble", true, "()D"), + LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), + LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), + LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + LOADOBJECTREFERENCE_OFS("loadObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + SIZE("size", false), + STOREBYTE("store", true, "(B)V"), + STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), + STORECHAR("store", true, "(C)V"), + STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), + STORESHORT("store", true, "(S)V"), + STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), + STOREINT("store", true, "(I)V"), + STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), + STOREFLOAT("store", true, "(F)V"), + STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), + STORELONG("store", true, "(J)V"), + STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), + STOREDOUBLE("store", true, "(D)V"), + STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), + STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), + STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), + STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), + STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), + STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), + STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), + PREPAREINT("prepareInt", true, "()I"), + PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), + PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + ATTEMPTINT("attempt", true, "(II)Z"), + ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), + ATTEMPTADDRESS_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTOBJECTREFERENCE("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), + ATTEMPTOBJECTREFERENCE_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + + "Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), + ATTEMPTWORD_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), + FROMOBJECT("fromObject", true), + FROMADDRESS("fromAddress", true), + GETOBJECTTYPE("getObjectType", true), + GETTIB("getTIB", true), + GETOBJECTFLAGS("getObjectFlags", true), + SETOBJECTFLAGS("setObjectFlags", true), + TOOBJECT("toObject", true), + GETARRAYDATA("getArrayData", true), + GETOBJECTCOLOR("getObjectColor", true), + ISFINALIZED("isFinalized", true), + ATOMICADD("atomicAdd", true), + ATOMICAND("atomicAnd", true), + ATOMICOR("atomicOr", true), + ATOMICSUB("atomicSub", true), + GETCURRENTFRAME("getCurrentFrame", true), + GETTIMESTAMP("getTimeStamp", true), + INTBITSTOFLOAT("intBitsToFloat", false), + FLOATTORAWINTBITS("floatToRawIntBits", false), + LONGBITSTODOUBLE("longBitsToDouble", false), + DOUBLETORAWLONGBITS("doubleToRawLongBits", false), + BREAKPOINT("breakPoint", true), + DIFF("diff", false), + NULLREFERENCE("nullReference", false), + CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), + GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), + GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), + ISRUNNINGJNODE("isRunningJNode", false, "()Z"), + + // Array classes + ARR_CREATE("create", true), + ARR_GET("get", true), + ARR_SET("set", true), + ARR_LENGTH("length", false); + + private final String name; + private final String signature; + private final boolean permissionRequired; + private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); + + private MagicMethod(String name, boolean permissionRequired) { + this.name = name; + this.signature = null; + this.permissionRequired = permissionRequired; + } + + private MagicMethod(String name, boolean permissionRequired, String signature) { + this.name = name; + this.permissionRequired = permissionRequired; + this.signature = signature; + } + + public static MagicMethod get(VmMethod method) { + MagicMethod mm = methods.get(method); + if (mm != null) { + return mm; + } + final String mname = method.getName(); + final String msignature = method.getSignature(); + + for (MagicMethod m : values()) { + if (m.name.equals(mname)) { + if ((m.signature == null) || m.signature.equals(msignature)) { + methods.put(method, m); + return m; + } + + } + } + throw new InternalError("Unknown method " + mname + '#' + msignature + " in " + + method.getDeclaringClass().getName()); + } + + /** + * Is MagicPermission required for this method. + * + * @return + */ + final boolean isPermissionRequired() { + return this.permissionRequired; + } + } + + /** + * Is the given method allowed to call magic code. + * + * @param caller + */ + public static void testMagicPermission(MagicMethod callee, VmMethod caller) + throws SecurityException { + if (callee.isPermissionRequired()) { + if (!caller.getDeclaringClass().isMagicPermissionGranted()) { + System.out.println("MagicPermission is not granted for type: " + + caller.getDeclaringClass().getName()); + // throw new SecurityException("MagicPermission is not granted + // for method: " + caller.getFullName()); + } + } + } +} Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -23,7 +23,7 @@ import org.jnode.assembler.x86.X86Constants; import org.jnode.assembler.x86.X86Operation; import org.jnode.vm.JvmType; -import org.jnode.vm.classmgr.BaseMagicHelper; +import org.jnode.vm.compiler.BaseMagicHelper; /** * @author Ewout Prangsma (ep...@us...) Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -20,12 +20,12 @@ package org.jnode.vm.x86.compiler.l1a; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.ATTEMPTINT; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.ATTEMPTINT; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; import org.jnode.assembler.x86.X86Assembler; import org.jnode.assembler.x86.X86Constants; Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -20,12 +20,12 @@ package org.jnode.vm.x86.compiler.l1b; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.ATTEMPTINT; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; -import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.ATTEMPTINT; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; +import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; import org.jnode.assembler.x86.X86Assembler; import org.jnode.assembler.x86.X86Constants; Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -24,9 +24,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -18,9 +18,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -19,9 +19,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-11 17:49:06 UTC (rev 5696) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-12 16:15:04 UTC (rev 5697) @@ -22,9 +22,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-11 17:49:14
|
Revision: 5696 http://jnode.svn.sourceforge.net/jnode/?rev=5696&view=rev Author: fduminy Date: 2009-12-11 17:49:06 +0000 (Fri, 11 Dec 2009) Log Message: ----------- - before, VmType and BaseMagicHelper had both definition of magic classes. now, it's centralized in BaseMagicHelper - moved BaseMagicHelper from org.jnode.vm.x86.compiler to org.jnode.vm.classmgr to avoid that classmgr depends on x86 compiler Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/VmMagic.java trunk/core/src/core/org/jnode/vm/classmgr/VmType.java trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java Added Paths: ----------- trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java Removed Paths: ------------- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java Modified: trunk/core/src/core/org/jnode/vm/VmMagic.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -36,8 +36,8 @@ * Methods in this class can also be called from inside JNode. * * @author Ewout Prangsma (ep...@us...) - * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass} to get the list of "magic" classes (including this class). - * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod} to get the list of "magic" methods. + * @see {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass} to get the list of "magic" classes (including this class). + * @see {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod} to get the list of "magic" methods. */ @MagicPermission public final class VmMagic { Copied: trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java (from rev 5693, trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java) =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java (rev 0) +++ trunk/core/src/core/org/jnode/vm/classmgr/BaseMagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -0,0 +1,321 @@ +/* + * $Id$ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.vm.classmgr; + +import java.util.Map; + +import org.jnode.util.BootableHashMap; +import org.jnode.annotation.SharedStatics; + +/** + * @author Ewout Prangsma (ep...@us...) + */ +public class BaseMagicHelper { + + /** + * Enum of all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicClass { + ADDRESS("org.vmmagic.unboxed.Address"), + EXTENT("org.vmmagic.unboxed.Extent"), + OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), + OFFSET("org.vmmagic.unboxed.Offset"), + WORD("org.vmmagic.unboxed.Word"), + ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), + EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), + OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), + OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), + WORDARRAY("org.vmmagic.unboxed.WordArray"), + VMMAGIC("org.jnode.vm.VmMagic"); + + /** + * Name of the class + */ + private final String name; + + /** + * Lookup table + */ + private static final Map<String, MagicClass> nameToClass; + + /** + * Initialize this instance. + * + * @param name + */ + private MagicClass(String name) { + this.name = name; + } + + /** + * Initialize the lookup table + */ + static { + nameToClass = new BootableHashMap<String, MagicClass>(); + for (MagicClass mc : values()) { + nameToClass.put(mc.name, mc); + } + } + + /** + * Gets the MagicClass instance for the given type. + * + * @param type + * @return a MagicClass instance + * @throws InternalError When type is no magic type. + */ + public static MagicClass get(VmType<?> type) { + MagicClass mc = nameToClass.get(type.getName()); + if (mc == null) { + throw new InternalError("Unknown magic type " + type.getName()); + } else { + return mc; + } + } + + /** + * Indicate if the given class name corresponds to a magic class. + * + * @param name Name of a class. + * @return true if the class is magic. + */ + static boolean isMagic(String name) { + boolean magic = false; + for (MagicClass mc : values()) { + if (mc.name.equals(name)) { + magic = true; + break; + } + } + return magic; + } + } + + /** + * Enum of all methods in all magic classes. + * + * @author Ewout Prangsma (ep...@us...) + */ + @SharedStatics + public enum MagicMethod { + ADD("add", false), + AND("and", false), + OR("or", false), + NOT("not", false), + SUB("sub", false), + XOR("xor", false), + ZERO("zero", false), + MAX("max", false), + ONE("one", false), + TOINT("toInt", false), + TOLONG("toLong", false), + TOWORD("toWord", false), + TOADDRESS("toAddress", true), + TOEXTENT("toExtent", false), + TOOFFSET("toOffset", false), + TOOBJECTREFERENCE("toObjectReference", true), + EQUALS("equals", false), + ISZERO("isZero", false), + ISMAX("isMax", false), + ISNULL("isNull", false), + EQ("EQ", false), + NE("NE", false), + GT("GT", false), + GE("GE", false), + LT("LT", false), + LE("LE", false), + SGT("sGT", false), + SGE("sGE", false), + SLT("sLT", false), + SLE("sLE", false), + FROMINT("fromInt", false), + FROMINTSIGNEXTEND("fromIntSignExtend", false), + FROMINTZEROEXTEND("fromIntZeroExtend", false), + FROMLONG("fromLong", false), + LSH("lsh", false), + RSHL("rshl", false), + RSHA("rsha", false), + LOADBYTE("loadByte", true, "()B"), + LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), + LOADCHAR("loadChar", true, "()C"), + LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), + LOADSHORT("loadShort", true, "()S"), + LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), + LOADINT("loadInt", true, "()I"), + LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + LOADFLOAT("loadFloat", true, "()F"), + LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), + LOADLONG("loadLong", true, "()J"), + LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), + LOADDOUBLE("loadDouble", true, "()D"), + LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), + LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), + LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + LOADOBJECTREFERENCE_OFS("loadObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + SIZE("size", false), + STOREBYTE("store", true, "(B)V"), + STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), + STORECHAR("store", true, "(C)V"), + STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), + STORESHORT("store", true, "(S)V"), + STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), + STOREINT("store", true, "(I)V"), + STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), + STOREFLOAT("store", true, "(F)V"), + STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), + STORELONG("store", true, "(J)V"), + STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), + STOREDOUBLE("store", true, "(D)V"), + STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), + STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), + STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), + STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), + STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), + STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), + STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), + PREPAREINT("prepareInt", true, "()I"), + PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), + PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), + PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), + PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), + PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), + PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), + PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, + "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), + ATTEMPTINT("attempt", true, "(II)Z"), + ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), + ATTEMPTADDRESS_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTOBJECTREFERENCE("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), + ATTEMPTOBJECTREFERENCE_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + + "Lorg/vmmagic/unboxed/Offset;)Z"), + ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), + ATTEMPTWORD_OFS("attempt", true, + "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), + FROMOBJECT("fromObject", true), + FROMADDRESS("fromAddress", true), + GETOBJECTTYPE("getObjectType", true), + GETTIB("getTIB", true), + GETOBJECTFLAGS("getObjectFlags", true), + SETOBJECTFLAGS("setObjectFlags", true), + TOOBJECT("toObject", true), + GETARRAYDATA("getArrayData", true), + GETOBJECTCOLOR("getObjectColor", true), + ISFINALIZED("isFinalized", true), + ATOMICADD("atomicAdd", true), + ATOMICAND("atomicAnd", true), + ATOMICOR("atomicOr", true), + ATOMICSUB("atomicSub", true), + GETCURRENTFRAME("getCurrentFrame", true), + GETTIMESTAMP("getTimeStamp", true), + INTBITSTOFLOAT("intBitsToFloat", false), + FLOATTORAWINTBITS("floatToRawIntBits", false), + LONGBITSTODOUBLE("longBitsToDouble", false), + DOUBLETORAWLONGBITS("doubleToRawLongBits", false), + BREAKPOINT("breakPoint", true), + DIFF("diff", false), + NULLREFERENCE("nullReference", false), + CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), + GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), + GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), + ISRUNNINGJNODE("isRunningJNode", false, "()Z"), + + // Array classes + ARR_CREATE("create", true), + ARR_GET("get", true), + ARR_SET("set", true), + ARR_LENGTH("length", false); + + private final String name; + private final String signature; + private final boolean permissionRequired; + private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); + + private MagicMethod(String name, boolean permissionRequired) { + this.name = name; + this.signature = null; + this.permissionRequired = permissionRequired; + } + + private MagicMethod(String name, boolean permissionRequired, String signature) { + this.name = name; + this.permissionRequired = permissionRequired; + this.signature = signature; + } + + public static MagicMethod get(VmMethod method) { + MagicMethod mm = methods.get(method); + if (mm != null) { + return mm; + } + final String mname = method.getName(); + final String msignature = method.getSignature(); + + for (MagicMethod m : values()) { + if (m.name.equals(mname)) { + if ((m.signature == null) || m.signature.equals(msignature)) { + methods.put(method, m); + return m; + } + + } + } + throw new InternalError("Unknown method " + mname + '#' + msignature + " in " + + method.getDeclaringClass().getName()); + } + + /** + * Is MagicPermission required for this method. + * + * @return + */ + final boolean isPermissionRequired() { + return this.permissionRequired; + } + } + + /** + * Is the given method allowed to call magic code. + * + * @param caller + */ + public static void testMagicPermission(MagicMethod callee, VmMethod caller) + throws SecurityException { + if (callee.isPermissionRequired()) { + if (!caller.getDeclaringClass().isMagicPermissionGranted()) { + System.out.println("MagicPermission is not granted for type: " + + caller.getDeclaringClass().getName()); + // throw new SecurityException("MagicPermission is not granted + // for method: " + caller.getFullName()); + } + } + } +} Modified: trunk/core/src/core/org/jnode/vm/classmgr/VmType.java =================================================================== --- trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/classmgr/VmType.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -302,18 +302,8 @@ throw new IllegalArgumentException("name contains '/'"); } - final String pkg = VMClassHelper.getPackagePortion(name); - if (pkg.equals("org.vmmagic.unboxed") || pkg.equals("org.jnode.vm")) { - final String cname = VMClassHelper.getClassNamePortion(name); - if (cname.equals("Address") || cname.equals("AddressArray") - || cname.equals("Extent") || cname.equals("ExtentArray") - || cname.equals("ObjectReference") - || cname.equals("ObjectReferenceArray") - || cname.equals("Offset") || cname.equals("OffsetArray") - || cname.equals("Word") || cname.equals("WordArray") - | cname.equals("VmMagic")) { - modifiers |= Modifier.ACC_MAGIC; - } + if (BaseMagicHelper.MagicClass.isMagic(name)) { + modifiers |= Modifier.ACC_MAGIC; } this.name = InternString.internString(name); Deleted: trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/compiler/BaseMagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -1,306 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.vm.compiler; - -import java.util.Map; - -import org.jnode.util.BootableHashMap; -import org.jnode.vm.classmgr.VmMethod; -import org.jnode.vm.classmgr.VmType; -import org.jnode.annotation.SharedStatics; - -/** - * @author Ewout Prangsma (ep...@us...) - */ -public class BaseMagicHelper { - - /** - * Enum of all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicClass { - ADDRESS("org.vmmagic.unboxed.Address"), - EXTENT("org.vmmagic.unboxed.Extent"), - OBJECTREFERENCE("org.vmmagic.unboxed.ObjectReference"), - OFFSET("org.vmmagic.unboxed.Offset"), - WORD("org.vmmagic.unboxed.Word"), - ADDRESSARRAY("org.vmmagic.unboxed.AddressArray"), - EXTENTARRAY("org.vmmagic.unboxed.ExtentArray"), - OBJECTREFERENCEARRAY("org.vmmagic.unboxed.ObjectReferenceArray"), - OFFSETARRAY("org.vmmagic.unboxed.OffsetArray"), - WORDARRAY("org.vmmagic.unboxed.WordArray"), - VMMAGIC("org.jnode.vm.VmMagic"); - - /** - * Name of the class - */ - private final String name; - - /** - * Lookup table - */ - private static final Map<String, MagicClass> nameToClass; - - /** - * Initialize this instance. - * - * @param name - */ - private MagicClass(String name) { - this.name = name; - } - - /** - * Initialize the lookup table - */ - static { - nameToClass = new BootableHashMap<String, MagicClass>(); - for (MagicClass mc : values()) { - nameToClass.put(mc.name, mc); - } - } - - /** - * Gets the MagicClass instance for the given type. - * - * @param type - * @return a MagicClass instance - * @throws InternalError When type is no magic type. - */ - public static MagicClass get(VmType<?> type) { - MagicClass mc = nameToClass.get(type.getName()); - if (mc == null) { - throw new InternalError("Unknown magic type " + type.getName()); - } else { - return mc; - } - } - } - - /** - * Enum of all methods in all magic classes. - * - * @author Ewout Prangsma (ep...@us...) - */ - @SharedStatics - public enum MagicMethod { - ADD("add", false), - AND("and", false), - OR("or", false), - NOT("not", false), - SUB("sub", false), - XOR("xor", false), - ZERO("zero", false), - MAX("max", false), - ONE("one", false), - TOINT("toInt", false), - TOLONG("toLong", false), - TOWORD("toWord", false), - TOADDRESS("toAddress", true), - TOEXTENT("toExtent", false), - TOOFFSET("toOffset", false), - TOOBJECTREFERENCE("toObjectReference", true), - EQUALS("equals", false), - ISZERO("isZero", false), - ISMAX("isMax", false), - ISNULL("isNull", false), - EQ("EQ", false), - NE("NE", false), - GT("GT", false), - GE("GE", false), - LT("LT", false), - LE("LE", false), - SGT("sGT", false), - SGE("sGE", false), - SLT("sLT", false), - SLE("sLE", false), - FROMINT("fromInt", false), - FROMINTSIGNEXTEND("fromIntSignExtend", false), - FROMINTZEROEXTEND("fromIntZeroExtend", false), - FROMLONG("fromLong", false), - LSH("lsh", false), - RSHL("rshl", false), - RSHA("rsha", false), - LOADBYTE("loadByte", true, "()B"), - LOADBYTE_OFS("loadByte", true, "(Lorg/vmmagic/unboxed/Offset;)B"), - LOADCHAR("loadChar", true, "()C"), - LOADCHAR_OFS("loadChar", true, "(Lorg/vmmagic/unboxed/Offset;)C"), - LOADSHORT("loadShort", true, "()S"), - LOADSHORT_OFS("loadShort", true, "(Lorg/vmmagic/unboxed/Offset;)S"), - LOADINT("loadInt", true, "()I"), - LOADINT_OFS("loadInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - LOADFLOAT("loadFloat", true, "()F"), - LOADFLOAT_OFS("loadFloat", true, "(Lorg/vmmagic/unboxed/Offset;)F"), - LOADLONG("loadLong", true, "()J"), - LOADLONG_OFS("loadLong", true, "(Lorg/vmmagic/unboxed/Offset;)J"), - LOADDOUBLE("loadDouble", true, "()D"), - LOADDOUBLE_OFS("loadDouble", true, "(Lorg/vmmagic/unboxed/Offset;)D"), - LOADADDRESS("loadAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - LOADADDRESS_OFS("loadAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - LOADWORD("loadWord", true, "()Lorg/vmmagic/unboxed/Word;"), - LOADWORD_OFS("loadWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - LOADOBJECTREFERENCE("loadObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - LOADOBJECTREFERENCE_OFS("loadObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - SIZE("size", false), - STOREBYTE("store", true, "(B)V"), - STOREBYTE_OFS("store", true, "(BLorg/vmmagic/unboxed/Offset;)V"), - STORECHAR("store", true, "(C)V"), - STORECHAR_OFS("store", true, "(CLorg/vmmagic/unboxed/Offset;)V"), - STORESHORT("store", true, "(S)V"), - STORESHORT_OFS("store", true, "(SLorg/vmmagic/unboxed/Offset;)V"), - STOREINT("store", true, "(I)V"), - STOREINT_OFS("store", true, "(ILorg/vmmagic/unboxed/Offset;)V"), - STOREFLOAT("store", true, "(F)V"), - STOREFLOAT_OFS("store", true, "(FLorg/vmmagic/unboxed/Offset;)V"), - STORELONG("store", true, "(J)V"), - STORELONG_OFS("store", true, "(JLorg/vmmagic/unboxed/Offset;)V"), - STOREDOUBLE("store", true, "(D)V"), - STOREDOUBLE_OFS("store", true, "(DLorg/vmmagic/unboxed/Offset;)V"), - STOREADDRESS("store", true, "(Lorg/vmmagic/unboxed/Address;)V"), - STOREADDRESS_OFS("store", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)V"), - STOREWORD("store", true, "(Lorg/vmmagic/unboxed/Word;)V"), - STOREWORD_OFS("store", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)V"), - STOREOBJECTREFERENCE("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;)V"), - STOREOBJECTREFERENCE_OFS("store", true, "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/Offset;)V"), - PREPAREINT("prepareInt", true, "()I"), - PREPAREINT_OFS("prepareInt", true, "(Lorg/vmmagic/unboxed/Offset;)I"), - PREPAREADDRESS("prepareAddress", true, "()Lorg/vmmagic/unboxed/Address;"), - PREPAREADDRESS_OFS("prepareAddress", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Address;"), - PREPAREWORD("prepareWord", true, "()Lorg/vmmagic/unboxed/Word;"), - PREPAREWORD_OFS("prepareWord", true, "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/Word;"), - PREPAREOBJECTREFERENCE("prepareObjectReference", true, "()Lorg/vmmagic/unboxed/ObjectReference;"), - PREPAREOBJECTREFERENCE_OFS("prepareObjectReference", true, - "(Lorg/vmmagic/unboxed/Offset;)Lorg/vmmagic/unboxed/ObjectReference;"), - ATTEMPTINT("attempt", true, "(II)Z"), - ATTEMPTINT_OFS("attempt", true, "(IILorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTADDRESS("attempt", true, "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)Z"), - ATTEMPTADDRESS_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTOBJECTREFERENCE("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;)Z"), - ATTEMPTOBJECTREFERENCE_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/ObjectReference;Lorg/vmmagic/unboxed/ObjectReference;" + - "Lorg/vmmagic/unboxed/Offset;)Z"), - ATTEMPTWORD("attempt", true, "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;)Z"), - ATTEMPTWORD_OFS("attempt", true, - "(Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Word;Lorg/vmmagic/unboxed/Offset;)Z"), - FROMOBJECT("fromObject", true), - FROMADDRESS("fromAddress", true), - GETOBJECTTYPE("getObjectType", true), - GETTIB("getTIB", true), - GETOBJECTFLAGS("getObjectFlags", true), - SETOBJECTFLAGS("setObjectFlags", true), - TOOBJECT("toObject", true), - GETARRAYDATA("getArrayData", true), - GETOBJECTCOLOR("getObjectColor", true), - ISFINALIZED("isFinalized", true), - ATOMICADD("atomicAdd", true), - ATOMICAND("atomicAnd", true), - ATOMICOR("atomicOr", true), - ATOMICSUB("atomicSub", true), - GETCURRENTFRAME("getCurrentFrame", true), - GETTIMESTAMP("getTimeStamp", true), - INTBITSTOFLOAT("intBitsToFloat", false), - FLOATTORAWINTBITS("floatToRawIntBits", false), - LONGBITSTODOUBLE("longBitsToDouble", false), - DOUBLETORAWLONGBITS("doubleToRawLongBits", false), - BREAKPOINT("breakPoint", true), - DIFF("diff", false), - NULLREFERENCE("nullReference", false), - CURRENTPROCESSOR("currentProcessor", true, "()Lorg/jnode/vm/scheduler/VmProcessor;"), - GETSHAREDSTATICSFIELDADDRESS("getSharedStaticFieldAddress", true), - GETISOLATEDSTATICSFIELDADDRESS("getIsolatedStaticFieldAddress", true), - ISRUNNINGJNODE("isRunningJNode", false, "()Z"), - - // Array classes - ARR_CREATE("create", true), - ARR_GET("get", true), - ARR_SET("set", true), - ARR_LENGTH("length", false); - - private final String name; - private final String signature; - private final boolean permissionRequired; - private static BootableHashMap<VmMethod, MagicMethod> methods = new BootableHashMap<VmMethod, MagicMethod>(); - - private MagicMethod(String name, boolean permissionRequired) { - this.name = name; - this.signature = null; - this.permissionRequired = permissionRequired; - } - - private MagicMethod(String name, boolean permissionRequired, String signature) { - this.name = name; - this.permissionRequired = permissionRequired; - this.signature = signature; - } - - public static MagicMethod get(VmMethod method) { - MagicMethod mm = methods.get(method); - if (mm != null) { - return mm; - } - final String mname = method.getName(); - final String msignature = method.getSignature(); - - for (MagicMethod m : values()) { - if (m.name.equals(mname)) { - if ((m.signature == null) || m.signature.equals(msignature)) { - methods.put(method, m); - return m; - } - - } - } - throw new InternalError("Unknown method " + mname + '#' + msignature + " in " - + method.getDeclaringClass().getName()); - } - - /** - * Is MagicPermission required for this method. - * - * @return - */ - final boolean isPermissionRequired() { - return this.permissionRequired; - } - } - - /** - * Is the given method allowed to call magic code. - * - * @param caller - */ - public static void testMagicPermission(MagicMethod callee, VmMethod caller) - throws SecurityException { - if (callee.isPermissionRequired()) { - if (!caller.getDeclaringClass().isMagicPermissionGranted()) { - System.out.println("MagicPermission is not granted for type: " - + caller.getDeclaringClass().getName()); - // throw new SecurityException("MagicPermission is not granted - // for method: " + caller.getFullName()); - } - } - } -} Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/BaseX86MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -23,7 +23,7 @@ import org.jnode.assembler.x86.X86Constants; import org.jnode.assembler.x86.X86Operation; import org.jnode.vm.JvmType; -import org.jnode.vm.compiler.BaseMagicHelper; +import org.jnode.vm.classmgr.BaseMagicHelper; /** * @author Ewout Prangsma (ep...@us...) Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -20,12 +20,12 @@ package org.jnode.vm.x86.compiler.l1a; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.ATTEMPTINT; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.ATTEMPTINT; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; import org.jnode.assembler.x86.X86Assembler; import org.jnode.assembler.x86.X86Constants; Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/MagicHelper.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -20,12 +20,12 @@ package org.jnode.vm.x86.compiler.l1b; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.ATTEMPTINT; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; -import static org.jnode.vm.compiler.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.ATTEMPTINT; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.FROMINTZEROEXTEND; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.INTBITSTOFLOAT; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LOADCHAR_OFS; +import static org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod.LONGBITSTODOUBLE; import org.jnode.assembler.x86.X86Assembler; import org.jnode.assembler.x86.X86Constants; Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -24,9 +24,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -18,9 +18,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -19,9 +19,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-11 00:14:12 UTC (rev 5695) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-11 17:49:06 UTC (rev 5696) @@ -22,9 +22,9 @@ * methods that are interpreted by the VM itself, instead of being executed * as normal java methods. The actual method bodies are not used. <br/> * For further details, see the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicClass list of "magic" classes} * and the - * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * {@link org.jnode.vm.classmgr.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-11 00:18:58
|
Revision: 5695 http://jnode.svn.sourceforge.net/jnode/?rev=5695&view=rev Author: fduminy Date: 2009-12-11 00:14:12 +0000 (Fri, 11 Dec 2009) Log Message: ----------- optimization : specify initial capacity of the underlying map (mapCache) when entryArray != null Modified Paths: -------------- trunk/core/src/core/org/jnode/util/BootableHashMap.java Modified: trunk/core/src/core/org/jnode/util/BootableHashMap.java =================================================================== --- trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-12-10 23:42:46 UTC (rev 5694) +++ trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-12-11 00:14:12 UTC (rev 5695) @@ -218,14 +218,18 @@ throw new RuntimeException("Cannot change a locked BootableHashMap"); } if (mapCache == null) { - mapCache = new HashMap<K, V>(); if (entryArray != null) { final int max = entryArray.length; + + mapCache = new HashMap<K, V>(max); for (int i = 0; i < max; i++) { final Entry<K, V> e = entryArray[i]; mapCache.put(e.getKey(), e.getValue()); } + entryArray = null; + } else { + mapCache = new HashMap<K, V>(); } } return mapCache; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-10 23:42:52
|
Revision: 5694 http://jnode.svn.sourceforge.net/jnode/?rev=5694&view=rev Author: fduminy Date: 2009-12-10 23:42:46 +0000 (Thu, 10 Dec 2009) Log Message: ----------- fixed javadoc Modified Paths: -------------- trunk/core/src/core/org/jnode/util/BootableHashMap.java Modified: trunk/core/src/core/org/jnode/util/BootableHashMap.java =================================================================== --- trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-12-09 23:16:45 UTC (rev 5693) +++ trunk/core/src/core/org/jnode/util/BootableHashMap.java 2009-12-10 23:42:46 UTC (rev 5694) @@ -38,16 +38,16 @@ private transient boolean locked; /** - * Constructs an empty HashMap with the default initial capacity (16) - * and the default load factor (0.75). + * Constructs an empty HashMap. + * @see java.util.HashMap#HashMap() */ public BootableHashMap() { this.hashCode = super.hashCode(); } /** - * Constructs an empty HashMap with the default initial capacity (16) - * and the default load factor (0.75). + * Constructs an empty HashMap. + * @see java.util.HashMap#HashMap(int) * * @param initialCapacity */ @@ -141,7 +141,7 @@ /** * @param key - * @return True if the key is contained, false otherwiser + * @return True if the key is contained, false otherwise */ public boolean containsKey(Object key) { return getMapCache().containsKey(key); @@ -232,7 +232,7 @@ } /** - * @see org.jnode.vm.VmSystemObject#verifyBeforeEmit() + * {@inheritDoc} */ @SuppressWarnings("unchecked") public void verifyBeforeEmit() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-09 23:16:54
|
Revision: 5693 http://jnode.svn.sourceforge.net/jnode/?rev=5693&view=rev Author: fduminy Date: 2009-12-09 23:16:45 +0000 (Wed, 09 Dec 2009) Log Message: ----------- - specified generic parameter for nativeStreamHolder member variable - fixed doc typo Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java 2009-12-09 22:42:13 UTC (rev 5692) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/AbstractX86Compiler.java 2009-12-09 23:16:45 UTC (rev 5693) @@ -60,7 +60,7 @@ private TypeSizeInfo typeSizeInfo; - private final ThreadLocal nativeStreamHolder = new ThreadLocal(); + private final ThreadLocal<X86BinaryAssembler> nativeStreamHolder = new ThreadLocal<X86BinaryAssembler>(); /** * Initialize this compiler @@ -76,8 +76,7 @@ } public NativeStream createNativeStream(ObjectResolver resolver) { - X86BinaryAssembler os; - os = (X86BinaryAssembler) nativeStreamHolder.get(); + X86BinaryAssembler os = nativeStreamHolder.get(); if (os == null) { os = new X86BinaryAssembler((X86CpuID) VmProcessor.current() .getCPUID(), mode, 0); @@ -91,7 +90,7 @@ protected final CompiledMethod doCompileAbstract(VmMethod method, NativeStream nos, int level, boolean isBootstrap) { if (isBootstrap) { - // System.out.println("Abstraxct method " + method); + // System.out.println("Abstract method " + method); final CompiledMethod cm = new CompiledMethod(level); final X86Assembler os = (X86Assembler) nos; // Create the helper This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-09 22:42:22
|
Revision: 5692 http://jnode.svn.sourceforge.net/jnode/?rev=5692&view=rev Author: fduminy Date: 2009-12-09 22:42:13 +0000 (Wed, 09 Dec 2009) Log Message: ----------- - fixed typo error - added link to the Open Runtime Platform (ORP) project Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-12-09 20:10:00 UTC (rev 5691) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java 2009-12-09 22:42:13 UTC (rev 5692) @@ -73,7 +73,7 @@ /** * Actual converter from bytecodes to X86 native code. Uses a virtual stack to - * delay item emission, as described in the ORP project + * delay item emission, as described in the <a href="http://orp.sourceforge.net/">Open Runtime Platform (ORP)</a> project. * * @author Ewout Prangsma (ep...@us...) * @author Patrik Reali @@ -1647,7 +1647,7 @@ * @see org.jnode.vm.bytecode.BytecodeVisitor#visit_dup2_x2() */ public final void visit_dup2_x2() { - // TODO: port to ORP style + // TODO: port to ORP style (http://orp.sourceforge.net/) // Push all on the stack, since this opcode is just too complicated vstack.push(eContext); @@ -2800,7 +2800,7 @@ if (declClass.isMagicType()) { magicHelper.emitMagic(eContext, method, false, this, currentMethod); } else { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); dropParameters(mts, true); @@ -2826,7 +2826,7 @@ /* Get objectref -> EAX */ os.writeMOV(asize, helper.AAX, helper.SP, argSlotCount * slotSize); - /* Get VMT of objectef -> EAX */ + /* Get VMT of objectref -> EAX */ os.writeMOV(asize, helper.AAX, helper.AAX, tibOffset); /* Get entry in VMT -> EAX */ os.writeMOV(asize, helper.AAX, helper.AAX, @@ -3169,7 +3169,7 @@ counters.getCounter("ldiv").inc(); if (os.isCode32()) { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); final LongItem v2 = vstack.popLong(); final LongItem v1 = vstack.popLong(); @@ -3228,7 +3228,7 @@ if (os.isCode32()) { final Label curInstrLabel = getCurInstrLabel(); - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); final LongItem v2 = vstack.popLong(); final LongItem v1 = vstack.popLong(); @@ -3359,7 +3359,7 @@ */ public final void visit_lrem() { if (os.isCode32()) { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); Item v2 = vstack.pop(JvmType.LONG); Item v1 = vstack.pop(JvmType.LONG); Modified: trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java =================================================================== --- trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java 2009-12-09 20:10:00 UTC (rev 5691) +++ trunk/core/src/core/org/jnode/vm/x86/compiler/l1b/X86BytecodeVisitor.java 2009-12-09 22:42:13 UTC (rev 5692) @@ -74,7 +74,7 @@ /** * Actual converter from bytecodes to X86 native code. Uses a virtual stack to - * delay item emission, as described in the ORP project + * delay item emission, as described in the <a href="http://orp.sourceforge.net/">Open Runtime Platform (ORP)</a> project. * * @author Ewout Prangsma (ep...@us...) * @author Patrik Reali @@ -3504,7 +3504,7 @@ if (declClass.isMagicType()) { magicHelper.emitMagic(eContext, method, false, this, currentMethod); } else { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); dropParameters(mts, true); @@ -3979,7 +3979,7 @@ } if (os.isCode32()) { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); final LongItem v2 = vstack.popLong(); final LongItem v1 = vstack.popLong(); @@ -4051,7 +4051,7 @@ if (os.isCode32()) { final Label curInstrLabel = getCurInstrLabel(); - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); final LongItem v2 = vstack.popLong(); final LongItem v1 = vstack.popLong(); @@ -4216,7 +4216,7 @@ } if (os.isCode32()) { - // TODO: port to orp-style + // TODO: port to ORP style (http://orp.sourceforge.net/) vstack.push(eContext); Item v2 = vstack.pop(JvmType.LONG); Item v1 = vstack.pop(JvmType.LONG); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-09 20:10:21
|
Revision: 5691 http://jnode.svn.sourceforge.net/jnode/?rev=5691&view=rev Author: fduminy Date: 2009-12-09 20:10:00 +0000 (Wed, 09 Dec 2009) Log Message: ----------- fixed error in javadoc Modified Paths: -------------- trunk/core/src/core/org/jnode/assembler/NativeStream.java Modified: trunk/core/src/core/org/jnode/assembler/NativeStream.java =================================================================== --- trunk/core/src/core/org/jnode/assembler/NativeStream.java 2009-12-06 19:15:41 UTC (rev 5690) +++ trunk/core/src/core/org/jnode/assembler/NativeStream.java 2009-12-09 20:10:00 UTC (rev 5691) @@ -232,7 +232,7 @@ } /** - * Gets the object i'm refering to. + * Gets the object i'm referring to. * * @return Object */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2009-12-06 19:15:57
|
Revision: 5690 http://jnode.svn.sourceforge.net/jnode/?rev=5690&view=rev Author: fduminy Date: 2009-12-06 19:15:41 +0000 (Sun, 06 Dec 2009) Log Message: ----------- added javadoc + links to MagicClass and MagicMethod classes, where "magic" methods are referenced Modified Paths: -------------- trunk/core/src/core/org/jnode/vm/VmMagic.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java Modified: trunk/core/src/core/org/jnode/vm/VmMagic.java =================================================================== --- trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-03 21:18:57 UTC (rev 5689) +++ trunk/core/src/core/org/jnode/vm/VmMagic.java 2009-12-06 19:15:41 UTC (rev 5690) @@ -33,9 +33,11 @@ * instead of being executed as normal java methods. The actual method * bodies are not used. * <p/> - * Methods is this class can also be called from inside JNode. + * Methods in this class can also be called from inside JNode. * * @author Ewout Prangsma (ep...@us...) + * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass} to get the list of "magic" classes (including this class). + * @see {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod} to get the list of "magic" methods. */ @MagicPermission public final class VmMagic { Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-03 21:18:57 UTC (rev 5689) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Address.java 2009-12-06 19:15:41 UTC (rev 5690) @@ -18,7 +18,15 @@ import org.jnode.annotation.Uninterruptible; /** - * Stub implementation of an Address type. Needs commenting. + * Stub implementation of an Address type. + * <p/> + * <u>JNode specific notes</u> : This class contains some "magic" + * methods that are interpreted by the VM itself, instead of being executed + * as normal java methods. The actual method bodies are not used. <br/> + * For further details, see the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * and the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-03 21:18:57 UTC (rev 5689) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Extent.java 2009-12-06 19:15:41 UTC (rev 5690) @@ -14,8 +14,14 @@ package org.vmmagic.unboxed; /** - * Commenting required - * + * <u>JNode specific notes</u> : This class contains some "magic" + * methods that are interpreted by the VM itself, instead of being executed + * as normal java methods. The actual method bodies are not used. <br/> + * For further details, see the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * and the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * * @author Daniel Frampton */ public final class Extent implements UnboxedObject { Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-03 21:18:57 UTC (rev 5689) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Offset.java 2009-12-06 19:15:41 UTC (rev 5690) @@ -14,8 +14,15 @@ package org.vmmagic.unboxed; /** - * To be commented - * + * <p/> + * <u>JNode specific notes</u> : This class contains some "magic" + * methods that are interpreted by the VM itself, instead of being executed + * as normal java methods. The actual method bodies are not used. <br/> + * For further details, see the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * and the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. + * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton */ Modified: trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java =================================================================== --- trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-03 21:18:57 UTC (rev 5689) +++ trunk/core/src/vmmagic/org/vmmagic/unboxed/Word.java 2009-12-06 19:15:41 UTC (rev 5690) @@ -17,7 +17,14 @@ import org.jnode.annotation.Uninterruptible; /** - * To be commented. + * <p/> + * <u>JNode specific notes</u> : This class contains some "magic" + * methods that are interpreted by the VM itself, instead of being executed + * as normal java methods. The actual method bodies are not used. <br/> + * For further details, see the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicClass list of "magic" classes} + * and the + * {@link org.jnode.vm.compiler.BaseMagicHelper.MagicMethod list of "magic" methods}. * * @author Ewout Prangsma (ep...@us...) * @author Daniel Frampton This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-12-03 21:19:08
|
Revision: 5689 http://jnode.svn.sourceforge.net/jnode/?rev=5689&view=rev Author: lsantha Date: 2009-12-03 21:18:57 +0000 (Thu, 03 Dec 2009) Log Message: ----------- Fixed NPE. Improved help. Applied patch by Mario Zsilak. Modified Paths: -------------- trunk/cli/descriptors/org.jnode.command.file.xml trunk/cli/src/commands/org/jnode/command/file/DuCommand.java Modified: trunk/cli/descriptors/org.jnode.command.file.xml =================================================================== --- trunk/cli/descriptors/org.jnode.command.file.xml 2009-11-23 17:09:02 UTC (rev 5688) +++ trunk/cli/descriptors/org.jnode.command.file.xml 2009-12-03 21:18:57 UTC (rev 5689) @@ -173,10 +173,10 @@ <option argLabel="exclude" shortName="" longName="exclude"/> <!-- exclude has no shortname --> <option argLabel="exclude-from" shortName="X" longName="exclude-from"/> <option argLabel="block-size-custom" shortName="B" longName="block-size"/> <!-- not in man page, but works on unix like systems --> - <option argLabel="filesystem-block-size" shortName="" longName="fs-block-size"/> <!-- not in man page, but works on unix like systems --> + <option argLabel="filesystem-block-size" shortName="" longName="fs-block-size"/> <!-- testing --> </optionSet> </sequence> - </syntax> + </syntax> <syntax alias="find"> <sequence description="find files or directories"> <repeat minCount="0"> Modified: trunk/cli/src/commands/org/jnode/command/file/DuCommand.java =================================================================== --- trunk/cli/src/commands/org/jnode/command/file/DuCommand.java 2009-11-23 17:09:02 UTC (rev 5688) +++ trunk/cli/src/commands/org/jnode/command/file/DuCommand.java 2009-12-03 21:18:57 UTC (rev 5689) @@ -56,7 +56,7 @@ private static final String HELP_TOTAL = "Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk usage of a given set of files or directories."; private static final String HELP_DEREF_ARGS = - "Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as `/usr/tmp', which are often symbolic links."; + "Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as `/usr/tmp', which are often symbolic links. (not implemented"; private static final String HELP_HUMAN_READABLE_1024 = "Append a size letter such as `M' for megabytes to each size. Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes. Use the `-H' or `--si' option if you prefer powers of 1000."; private static final String HELP_HUMAN_READABLE_1000 = @@ -64,22 +64,22 @@ private static final String HELP_BLOCK_SIZE_1024 = "Print sizes in 1024-byte blocks, overriding the default block size"; private static final String HELP_COUNT_LINKS = - "Count the size of all files, even if they have appeared already (as a hard link)."; + "Count the size of all files, even if they have appeared already (as a hard link). (not implemented"; private static final String HELP_DEREF = - "Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link)."; + "Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link). (not implemented"; private static final String HELP_MAX_DEPTH = - "Show the total for each directory (and file if -all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so `du --max-depth=0' is equivalent to `du -s'."; + "Show the total for each directory (and file if -all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so `du --max-depth=0' is equivalent to `du -s'. (not tested)"; private static final String HELP_BLOCK_SIZE_1024x1024 = "Print sizes in megabyte (that is, 1,048,576-byte) blocks."; private static final String HELP_SUM = "Display only a total for each argument."; private static final String HELP_SEPERATE_DIRS = "Report the size of each directory separately, not including the sizes of subdirectories."; private static final String HELP_ONE_FS = - "Skip directories that are on different filesystems from the one that the argument being processed is on."; + "Skip directories that are on different filesystems from the one that the argument being processed is on. (not implemented)"; private static final String HELP_EXCLUDE = - "When recursing, skip subdirectories or files matching PAT. For example, `du --exclude='*.o'' excludes files whose names end in `.o'."; + "When recursing, skip subdirectories or files matching PAT. For example, `du --exclude='*.o'' excludes files whose names end in `.o'. (not tested)"; private static final String HELP_EXCLUDE_FROM = - "Like `--exclude', except take the patterns to exclude from FILE, one per line. If FILE is `-', take the patterns from standard input."; + "Like `--exclude', except take the patterns to exclude from FILE, one per line. If FILE is `-', take the patterns from standard input. (not implemented)"; private static final String HELP_BLOCK_SIZE_CUSTOM = "Print sizes in the user defined block size, overriding the default block size"; private static final String HELP_FS_BLOCK_SIZE = @@ -225,7 +225,7 @@ private void printFileSize(final File filename, final long size) { if (argAll.isSet()) { - out.println(size + "\t" + filename); + out.println(sizeToString(size) + "\t" + filename); } } @@ -325,7 +325,7 @@ retValue = ((FSBlockDeviceAPI) device).getSectorSize(); } else { - logger.warn("No FSBlockDeviceAPI device for device" + device); + logger.warn("No FSBlockDeviceAPI device for device: " + device); logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE); logger.info("override with --fs-block-size"); } @@ -386,12 +386,9 @@ public Directory getParent() { - long dirSize = size + calc(directory.length()); // only the size for - // this directory + - // files (in other - // words: excludes - // the size of - // subDirs) + long dirSize = size + calc(directory.length()); + // only the size for this directory + files + // (in other words: excludes the size of subDirs) long subDirSize = 0; while (!subDirs.isEmpty()) { @@ -408,6 +405,11 @@ public long getSize() { return size; } + + @Override + public int hashCode() { + return directory.hashCode(); + } public boolean equals(Object other) { boolean retValue = false; @@ -450,18 +452,28 @@ } @Override + /** + * Set the "root" Directory to the Starting Dir + */ protected void handleStartingDir(File file) throws IOException { log("starting dir: " + file); root = new Directory(null, file); } @Override + /** + * Calculate the "root" directory and reset the "current" directory .. we are done for now + */ protected void lastAction(boolean wasCancelled) { root.getParent(); + currentDir = null; totalSize = root.getSize(); } @Override + /** + * add the currently handled directory/file to the correct position in the hierarchy + */ public void handleDir(File file) { log("handleDir: " + file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-11-23 17:09:15
|
Revision: 5688 http://jnode.svn.sourceforge.net/jnode/?rev=5688&view=rev Author: lsantha Date: 2009-11-23 17:09:02 +0000 (Mon, 23 Nov 2009) Log Message: ----------- Extensions to du command. Applied patch by Mario Zsilak. Modified Paths: -------------- trunk/cli/descriptors/org.jnode.command.file.xml trunk/cli/src/commands/org/jnode/command/file/DuCommand.java Modified: trunk/cli/descriptors/org.jnode.command.file.xml =================================================================== --- trunk/cli/descriptors/org.jnode.command.file.xml 2009-10-23 08:21:09 UTC (rev 5687) +++ trunk/cli/descriptors/org.jnode.command.file.xml 2009-11-23 17:09:02 UTC (rev 5688) @@ -151,14 +151,29 @@ <argument argLabel="path" description="list a file or directory"/> </syntax> <syntax alias="du"> - <sequence description="print file sizes"> + <sequence description="Disk Usage - report the amount of disk space used by the specified directory and for each subdirectory."> <repeat minCount="0"> <argument argLabel="directory" description="directory to start printing sizes recursively"/> </repeat> <optionSet> - <option argLabel="sum" shortName="s" longName="summarize"/> - <option argLabel="all" shortName="a" longName="all"/> - <option argLabel="human-readable" shortName="h" longName="human-readable"/> + <option argLabel="all" shortName="a" longName="all"/> + <option argLabel="block-size-1" shortName="b" longName="bytes"/> + <option argLabel="total" shortName="c" longName="total"/> + <option argLabel="derefArgs" shortName="D" longName="dereference-args"/> + <option argLabel="human-readable-1024" shortName="h" longName="human-readable"/> + <option argLabel="human-readable-1000" shortName="H" longName="si"/> + <option argLabel="block-size-1024" shortName="k" longName="kilobytes"/> + <option argLabel="count-links" shortName="l" longName="count-links"/> + <option argLabel="dereference" shortName="L" longName="dereference"/> + <option argLabel="max-depth" shortName="" longName="max-depth"/> <!-- max-depth has no shortname --> + <option argLabel="block-size-1024x1024" shortName="m" longName="megabytes"/> + <option argLabel="summarize" shortName="s" longName="summarize"/> + <option argLabel="separate-dirs" shortName="S" longName="separate-dirs"/> + <option argLabel="one-file-system" shortName="x" longName="one-file-system"/> <!-- can't test this currently --> + <option argLabel="exclude" shortName="" longName="exclude"/> <!-- exclude has no shortname --> + <option argLabel="exclude-from" shortName="X" longName="exclude-from"/> + <option argLabel="block-size-custom" shortName="B" longName="block-size"/> <!-- not in man page, but works on unix like systems --> + <option argLabel="filesystem-block-size" shortName="" longName="fs-block-size"/> <!-- not in man page, but works on unix like systems --> </optionSet> </sequence> </syntax> Modified: trunk/cli/src/commands/org/jnode/command/file/DuCommand.java =================================================================== --- trunk/cli/src/commands/org/jnode/command/file/DuCommand.java 2009-10-23 08:21:09 UTC (rev 5687) +++ trunk/cli/src/commands/org/jnode/command/file/DuCommand.java 2009-11-23 17:09:02 UTC (rev 5688) @@ -1,5 +1,5 @@ /* - * $Id: CdCommand.java 4975 2009-02-02 08:30:52Z lsantha $ + * $Id: DuCommand.java 4975 2009-02-02 08:30:52Z lsantha $ * * Copyright (C) 2003-2009 JNode.org * @@ -22,175 +22,475 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.util.Map; -import java.util.NavigableMap; -import java.util.TreeMap; -import java.util.Map.Entry; +import java.util.Stack; +import javax.naming.NameNotFoundException; + +import org.apache.log4j.Logger; import org.jnode.command.util.AbstractDirectoryWalker; +import org.jnode.driver.Device; +import org.jnode.driver.block.FSBlockDeviceAPI; +import org.jnode.fs.service.FileSystemService; +import org.jnode.naming.InitialNaming; import org.jnode.shell.AbstractCommand; import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.FileArgument; import org.jnode.shell.syntax.FlagArgument; +import org.jnode.shell.syntax.IntegerArgument; +import org.jnode.shell.syntax.StringArgument; import org.jnode.util.NumberUtils; +import org.jnode.vm.VmExit; -/* +/** * @author Alexander Kerner + * @author Mario Zsilak */ public class DuCommand extends AbstractCommand { - - private static final String err_perm = "Permission denied for '%s'%n"; - - private abstract class Walker extends AbstractDirectoryWalker { - protected final TreeMap<File, Long> map = new TreeMap<File, Long>(); - protected final boolean humanReadable; + private static final String HELP_SUPER = + "With no arguments, `du' reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes, but this can be overridden"; + private static final String HELP_DIR = "directory to start printing sizes recursively"; + private static final String HELP_ALL = "Show counts for all files, not just directories."; + private static final String HELP_BLOCK_SIZE_1 = + "Print sizes in bytes, overriding the default block size"; + private static final String HELP_TOTAL = + "Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk usage of a given set of files or directories."; + private static final String HELP_DEREF_ARGS = + "Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as `/usr/tmp', which are often symbolic links."; + private static final String HELP_HUMAN_READABLE_1024 = + "Append a size letter such as `M' for megabytes to each size. Powers of 1024 are used, not 1000; `M' stands for 1,048,576 bytes. Use the `-H' or `--si' option if you prefer powers of 1000."; + private static final String HELP_HUMAN_READABLE_1000 = + "Append a size letter such as `M' for megabytes to each size. (SI is the International System of Units, which defines these letters as prefixes.) Powers of 1000 are used, not 1024; `M' stands for 1,000,000 bytes. Use the `-h' or `--human-readable' option if you prefer powers of 1024."; + private static final String HELP_BLOCK_SIZE_1024 = + "Print sizes in 1024-byte blocks, overriding the default block size"; + private static final String HELP_COUNT_LINKS = + "Count the size of all files, even if they have appeared already (as a hard link)."; + private static final String HELP_DEREF = + "Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link)."; + private static final String HELP_MAX_DEPTH = + "Show the total for each directory (and file if -all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so `du --max-depth=0' is equivalent to `du -s'."; + private static final String HELP_BLOCK_SIZE_1024x1024 = + "Print sizes in megabyte (that is, 1,048,576-byte) blocks."; + private static final String HELP_SUM = "Display only a total for each argument."; + private static final String HELP_SEPERATE_DIRS = + "Report the size of each directory separately, not including the sizes of subdirectories."; + private static final String HELP_ONE_FS = + "Skip directories that are on different filesystems from the one that the argument being processed is on."; + private static final String HELP_EXCLUDE = + "When recursing, skip subdirectories or files matching PAT. For example, `du --exclude='*.o'' excludes files whose names end in `.o'."; + private static final String HELP_EXCLUDE_FROM = + "Like `--exclude', except take the patterns to exclude from FILE, one per line. If FILE is `-', take the patterns from standard input."; + private static final String HELP_BLOCK_SIZE_CUSTOM = + "Print sizes in the user defined block size, overriding the default block size"; + private static final String HELP_FS_BLOCK_SIZE = + "Overrides the filesystem block size -- use it for testing"; - Walker(boolean humanReadable) { - this.humanReadable = humanReadable; + private final FileArgument argDir = + new FileArgument("directory", + Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, HELP_DIR); + private final FlagArgument argAll = new FlagArgument("all", Argument.OPTIONAL, HELP_ALL); + private final FlagArgument argBlockSize_1 = + new FlagArgument("block-size-1", Argument.OPTIONAL, HELP_BLOCK_SIZE_1); + private final FlagArgument argTotal = new FlagArgument("total", Argument.OPTIONAL, HELP_TOTAL); + private final FlagArgument argDerefArgs = + new FlagArgument("derefArgs", Argument.OPTIONAL, HELP_DEREF_ARGS); + private final FlagArgument argHumanReadable_1024 = + new FlagArgument("human-readable-1024", Argument.OPTIONAL, HELP_HUMAN_READABLE_1024); + private final FlagArgument argHumanReadable_1000 = + new FlagArgument("human-readable-1000", Argument.OPTIONAL, HELP_HUMAN_READABLE_1000); + private final FlagArgument argBlockSize_1024 = + new FlagArgument("block-size-1024", Argument.OPTIONAL, HELP_BLOCK_SIZE_1024); + private final FlagArgument argCountLinks = + new FlagArgument("count-links", Argument.OPTIONAL, HELP_COUNT_LINKS); + private final FlagArgument argDereference = + new FlagArgument("dereference", Argument.OPTIONAL, HELP_DEREF); + private final IntegerArgument argMaxDepth = + new IntegerArgument("max-depth", Argument.OPTIONAL, HELP_MAX_DEPTH); + private final FlagArgument argBlockSize_1024x1024 = + new FlagArgument("block-size-1024x1024", Argument.OPTIONAL, HELP_BLOCK_SIZE_1024x1024); + private final FlagArgument argSum = new FlagArgument("summarize", Argument.OPTIONAL, HELP_SUM); + private final FlagArgument argSeperateDirs = + new FlagArgument("separate-dirs", Argument.OPTIONAL, HELP_SEPERATE_DIRS); + private static final FlagArgument argOneFS = + new FlagArgument("one-file-system", Argument.OPTIONAL, HELP_ONE_FS); + private final StringArgument argExclude = + new StringArgument("exclude", Argument.OPTIONAL, HELP_EXCLUDE); + private static final StringArgument argExcludeFrom = + new StringArgument("exclude-from", Argument.OPTIONAL, HELP_EXCLUDE_FROM); + private final IntegerArgument argBlockSize_Custom = + new IntegerArgument("block-size-custom", Argument.OPTIONAL, HELP_BLOCK_SIZE_CUSTOM); + private final IntegerArgument argFilesystemBlockSize = + new IntegerArgument("filesystem-block-size", Argument.OPTIONAL, HELP_FS_BLOCK_SIZE); + + private static final String ERR_PERMISSION = "Permission denied for '%s'%n"; + + private static final int DEFAULT_FILESYSTEM_BLOCK_SIZE = 1024; + private static final int DEFAULT_DISPLAY_BLOCK_SIZE = 1024; + + private Logger logger = Logger.getLogger(getClass()); + + private int fsBlockSize; + private int displayBlockSize; + private PrintWriter out; + private PrintWriter err; + + public static void main(String[] args) throws IOException { + new DuCommand().execute(); + } + + public DuCommand() { + super(HELP_SUPER); + registerArguments(argDir, argAll, argBlockSize_1, argTotal, argDerefArgs, + argHumanReadable_1024, argHumanReadable_1000, argBlockSize_1024, argCountLinks, + argDereference, argMaxDepth, argBlockSize_1024x1024, argSum, argSeperateDirs, + argOneFS, argExclude, argExcludeFrom, argBlockSize_Custom, argFilesystemBlockSize); + } + + public void execute() throws IOException { + + Walker walker = null; + File[] startPoints = null; + + out = getOutput().getPrintWriter(); + err = getError().getPrintWriter(); + + if (argAll.isSet() && argSum.isSet()) { + err.println("Summarize and show all not possible at the some time!"); + throw new VmExit(1); } - @Override - public void handleDir(File file) { - handleAll(file); + if (argDerefArgs.isSet()) { + logger.warn(argDerefArgs.getLabel() + " is currently not supported"); } - @Override - public void handleFile(File file) { - handleAll(file); + if (argOneFS.isSet()) { + logger.warn(argOneFS.getLabel() + " is currently not supported"); } - - @Override - protected void handleRestrictedFile(File file) throws IOException { - err.format(err_perm, file); + + if (argExcludeFrom.isSet()) { + logger.warn(argExcludeFrom.getLabel() + " is currently not supported"); } - private void handleAll(File file) { - map.put(file, file.length()); + if (argDereference.isSet()) { + logger.warn(argDereference.getLabel() + " is currently not supported"); } - protected TreeMap<File, Long> summariseIt(TreeMap<File, Long> map) { - TreeMap<File, Long> result = new TreeMap<File, Long>(); - NavigableMap<File, Long> navMap = map.descendingMap(); - Long tmpSize = 0L; - while (navMap.size() != 0) { - Entry<File, Long> e = navMap.pollFirstEntry(); - File key = e.getKey(); - Long value = e.getValue(); - tmpSize += key.length(); + if (argCountLinks.isSet()) { + logger.warn(argCountLinks.getLabel() + " is currently not supported"); + } - if (key.isFile()) { - result.put(key, value); - } else if (key.isDirectory()) { - result.put(key, tmpSize); - } else { - // ignore unknown file type - } + startPoints = argDir.getValues(); + + if (startPoints.length == 0) { + startPoints = new File[] {new File(System.getProperty("user.dir"))}; + } + + if (argFilesystemBlockSize.isSet()) + fsBlockSize = argFilesystemBlockSize.getValue(); + else { + fsBlockSize = getFsBlockSize(startPoints[0]); + } + + if (argBlockSize_Custom.isSet()) { + displayBlockSize = argBlockSize_Custom.getValue(); + } else if (argBlockSize_1024x1024.isSet()) { + displayBlockSize = 1024 * 1024; + } else if (argBlockSize_1024.isSet()) { + displayBlockSize = 1024; + } else if (argBlockSize_1.isSet()) { + displayBlockSize = 1; + } else { + displayBlockSize = DEFAULT_DISPLAY_BLOCK_SIZE; + } + + if (argSum.isSet() || argTotal.isSet()) { + + long total = 0; + + for (File start : startPoints) { + walker = new Walker(argMaxDepth, argExclude); + walker.walk(start); + + printSize(start.getAbsolutePath(), walker.getSize()); + total += walker.getSize(); } - return result; + + if (argTotal.isSet()) { + printSize("Total", total); + } + } else { + new Walker(argMaxDepth, argExclude).walk(startPoints); } } - private class AllWalker extends Walker { + private void printFileSize(final File filename, final long size) { + if (argAll.isSet()) { + out.println(size + "\t" + filename); + } + } - AllWalker(boolean humanReadable) { - super(humanReadable); + private void printDirSize(final File filename, final long dirSizeOnly, final long subDirSize) { + if (!argSum.isSet()) { + if (argSeperateDirs.isSet()) { + out.println(sizeToString(dirSizeOnly) + "\t" + filename); + } else { + out.println(sizeToString(dirSizeOnly + subDirSize) + "\t" + filename); + } } + } - @Override - protected void lastAction(boolean wasCancelled) { - Map<File, Long> summarisedMap = summariseIt(map); - for (Entry<File, Long> e : summarisedMap.entrySet()) { - if (humanReadable) - out.println(NumberUtils.toBinaryByte(e.getValue()) + "\t" + e.getKey()); - else - out.println(e.getValue() + "\t" + e.getKey()); + private void printSize(final String filename, final long size) { + out.println(sizeToString(size) + "\t" + filename); + } + + private void log(String message) { + // logger.debug(message); + } + + /** + * should be in NumberUtils I guess + * + * @param lenght in bytes of the file / directory + * @return the number of blocks it uses up depending on the int + * displayBlockSize + */ + private long calc(long bytes) { + + double factor = fsBlockSize / displayBlockSize; + long ret = -1; + + if (fsBlockSize > displayBlockSize) { + if (bytes % displayBlockSize == 0) { + ret = bytes / displayBlockSize; + } else { + ret = (long) ((bytes / (fsBlockSize) + 1) * factor); } + } else { + if (bytes % displayBlockSize == 0) { + ret = bytes / displayBlockSize; + } else { + ret = (long) ((bytes / (displayBlockSize) + 1)); + } } + + return ret; } - private class OnlyDirsWalker extends Walker { + private String sizeToString(long size) { - OnlyDirsWalker(boolean humanReadable) { - super(humanReadable); + String retValue = null; + + if (argHumanReadable_1024.isSet()) { + retValue = NumberUtils.toBinaryByte(size); + } else if (argHumanReadable_1000.isSet()) { + retValue = NumberUtils.toDecimalByte(size); + } else { + retValue = String.valueOf(size); } - @Override - protected void lastAction(boolean wasCancelled) { - Map<File, Long> summarisedMap = summariseIt(map); - for (Entry<File, Long> e : summarisedMap.entrySet()) { - if (e.getKey().isDirectory()) { - if (humanReadable) - out.println(NumberUtils.toBinaryByte(e.getValue()) + "\t" + e.getKey()); - else - out.println(e.getValue() + "\t" + e.getKey()); + return retValue; + } + + /** + * taken from the DfCommand + */ + private int getFsBlockSize(File file) throws IOException { + + int retValue = DEFAULT_FILESYSTEM_BLOCK_SIZE; // default block size + FileSystemService fss = null; + Device device = null; + String path = null; + String mp = null; + + try { + fss = InitialNaming.lookup(FileSystemService.NAME); + path = file.getCanonicalPath(); + mp = null; + + for (String mountPoint : fss.getMountPoints().keySet()) { + if (path.startsWith(mountPoint)) { + if (mp != null) { + if (!mp.startsWith(mountPoint)) { + continue; + } + } + mp = mountPoint; } } + + if (mp != null) { + device = fss.getMountPoints().get(mp).getDevice(); + + if (device instanceof FSBlockDeviceAPI) { + retValue = ((FSBlockDeviceAPI) device).getSectorSize(); + + } else { + logger.warn("No FSBlockDeviceAPI device for device" + device); + logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE); + logger.info("override with --fs-block-size"); + } + } else { + + logger.warn("No mount point found for " + path); + + for (String mountPoint : fss.getMountPoints().keySet()) { + logger.warn("mountpoints on system: " + mountPoint); + } + + logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE); + logger.info("override with --fs-block-size"); + } + + } catch (NameNotFoundException e) { + logger.warn("FileSystemService lookup failed ...", e); + logger.info("Using default block-size: " + DEFAULT_FILESYSTEM_BLOCK_SIZE); + logger.info("override with --fs-block-size"); } + + return retValue; } - private class TotalWalker extends Walker { + private class Directory { + private Directory parent = null; + private File directory = null; + private Stack<Directory> subDirs = null; + private long size = 0; - TotalWalker(boolean humanReadable) { - super(humanReadable); + public Directory(Directory parent, File directory) { + this.parent = parent; + this.directory = directory; + subDirs = new Stack<Directory>(); } - @Override - protected void lastAction(boolean wasCancelled) { - TreeMap<File, Long> summarisedMap = summariseIt(map); - Entry<File, Long> e = summarisedMap.firstEntry(); - if (humanReadable) - out.println(NumberUtils.toBinaryByte(e.getValue()) + "\t" + e.getKey()); - else - out.println(e.getValue() + "\t" + e.getKey()); + public Directory addDirectory(File file) { + Directory retValue = null; + if (file.getParentFile().equals(directory)) { + retValue = new Directory(this, file); + subDirs.push(retValue); + } else { + logger.warn("addDirectory: tried to add " + file + " to " + directory); + } + + return retValue; } - } - private PrintWriter out; - private PrintWriter err; + public void addFile(File file) { + if (!file.getParentFile().equals(directory)) { + logger.warn("addFile: tried to add " + file + " to " + directory); + } - private static final String HELP_TOTAL = "display only a total for each argument"; - private static final String HELP_ALL = "write counts for all files, not just directories"; - private static final String HELP_SUPER = "print file sizes"; - private static final String HELP_DIR = "directory to start printing sizes"; - private static final String HELP_HUMAN_READABLE = "print sizes in human readable format (e.g., 1K 234M 2G)"; + printFileSize(file, calc(file.length())); + size += calc(file.length()); + } - private final FlagArgument totalArg; - private final FlagArgument allArg; - private final FileArgument dirArg; - private final FlagArgument humanReadableArg; + public Directory getParent() { - public DuCommand() { - super(HELP_SUPER); - totalArg = new FlagArgument("sum", Argument.OPTIONAL, HELP_TOTAL); - allArg = new FlagArgument("all", Argument.OPTIONAL, HELP_ALL); - dirArg = new FileArgument("directory", Argument.OPTIONAL | Argument.MULTIPLE, HELP_DIR); - humanReadableArg = new FlagArgument("human-readable", Argument.OPTIONAL, HELP_HUMAN_READABLE); - registerArguments(totalArg, allArg, humanReadableArg, dirArg); - } + long dirSize = size + calc(directory.length()); // only the size for + // this directory + + // files (in other + // words: excludes + // the size of + // subDirs) + long subDirSize = 0; - public static void main(String[] args) throws IOException { - new DuCommand().execute(); + while (!subDirs.isEmpty()) { + subDirSize += subDirs.pop().getSize(); + } + + printDirSize(directory, dirSize, subDirSize); + + size = dirSize + subDirSize; + + return parent; + } + + public long getSize() { + return size; + } + + public boolean equals(Object other) { + boolean retValue = false; + + if (other instanceof Directory) { + retValue = (other != null && ((Directory) other).directory.equals(this.directory)); + } else if (other instanceof File) { + retValue = (other != null && ((File) other).equals(this.directory)); + } + + return retValue; + } + + @Override + public String toString() { + return directory.toString(); + } } - public void execute() throws IOException { - out = getOutput().getPrintWriter(); - err = getError().getPrintWriter(); - Walker walker = null; - if (totalArg.isSet()) { - walker = new TotalWalker(humanReadableArg.isSet()); - } else if (allArg.isSet()) { - walker = new AllWalker(humanReadableArg.isSet()); - } else { - walker = new OnlyDirsWalker(humanReadableArg.isSet()); + private class Walker extends AbstractDirectoryWalker { + + long totalSize; + protected Directory root = null; + protected Directory currentDir = null; + + private Walker(IntegerArgument argMaxDepth, StringArgument argExclude) { + super(); + + if (argMaxDepth.isSet()) { + super.setMaxDepth(argMaxDepth.getValue().longValue()); + } + + if (argExclude.isSet()) { + super.addFilter(new RegexPatternFilter(argExclude.getValue(), true)); + } } - - if (dirArg.isSet()) { - walker.walk(dirArg.getValues()); - } else { - walker.walk(new File(System.getProperty("user.dir"))); + + public long getSize() { + return totalSize; } + + @Override + protected void handleStartingDir(File file) throws IOException { + log("starting dir: " + file); + root = new Directory(null, file); + } + + @Override + protected void lastAction(boolean wasCancelled) { + root.getParent(); + totalSize = root.getSize(); + } + + @Override + public void handleDir(File file) { + log("handleDir: " + file); + + if (currentDir == null || currentDir.equals(file)) { + currentDir = root; + return; + } + + while (!currentDir.equals(file.getParentFile())) { + log("in while"); + currentDir = currentDir.getParent(); + } + + currentDir = currentDir.addDirectory(file); + } + + @Override + public void handleFile(File file) { + log("handleFile: " + file); + + while (!currentDir.equals(file.getParentFile())) { + currentDir = currentDir.getParent(); + } + currentDir.addFile(file); + } + + @Override + protected void handleRestrictedFile(File file) throws IOException { + err.format(ERR_PERMISSION, file); + } } } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2009-10-23 08:21:16
|
Revision: 5687 http://jnode.svn.sourceforge.net/jnode/?rev=5687&view=rev Author: galatnm Date: 2009-10-23 08:21:09 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Fix some findbugs problems. Modified Paths: -------------- trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xCore.java trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java trunk/net/src/net/org/jnode/net/ipv4/dhcp/DHCPMessage.java trunk/net/src/net/org/jnode/net/ipv4/udp/UDPProtocol.java trunk/net/src/net/org/jnode/net/service/DefaultNetworkLayerManager.java Modified: trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xCore.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xCore.java 2009-10-23 07:53:39 UTC (rev 5686) +++ trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xCore.java 2009-10-23 08:21:09 UTC (rev 5687) @@ -561,14 +561,12 @@ final SocketBuffer skbuf = null; // rxRing.getPacket(pktLen); try { - // FIXME ... this always throws an NPE since skbuf is null - if (skbuf.getSize() > 0) { + + if (skbuf != null && skbuf.getSize() > 0) { driver.onReceive(skbuf); } } catch (NetworkException e) { - e.printStackTrace(); // To change body of catch statement - // use Options | File - // Templates. + e.printStackTrace(); } finally { // FIXME } Modified: trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java =================================================================== --- trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java 2009-10-23 07:53:39 UTC (rev 5686) +++ trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java 2009-10-23 08:21:09 UTC (rev 5687) @@ -177,7 +177,7 @@ for (y = 0, x = 0, sum = 0; x < eeSize; x++) { int value = doEepromCmd((eeReadCmd | (x << 16)), 27); eeprom[x] = value; - sum += new Integer(value).shortValue(); + sum += (short)value; if (x < 3) { hwAddrArr[y++] = (byte) value; hwAddrArr[y++] = (byte) (value >> 8); @@ -407,7 +407,7 @@ regs.setReg16(SCBeeprom, EE_ENB); eepromDelay(2); regs.setReg16(SCBeeprom, (EE_ENB & ~EE_CS)); - return NumberUtils.toUnsigned(new Integer(retVal).shortValue()); + return NumberUtils.toUnsigned((short)retVal); } // --- OTHER METHODS Modified: trunk/net/src/net/org/jnode/net/ipv4/dhcp/DHCPMessage.java =================================================================== --- trunk/net/src/net/org/jnode/net/ipv4/dhcp/DHCPMessage.java 2009-10-23 07:53:39 UTC (rev 5686) +++ trunk/net/src/net/org/jnode/net/ipv4/dhcp/DHCPMessage.java 2009-10-23 08:21:09 UTC (rev 5687) @@ -217,7 +217,7 @@ if (code == MESSAGE_TYPE_OPTION) { messageType = value[0]; } else { - options.put(new Integer(code), value); + options.put(Integer.valueOf(code), value); } } @@ -254,7 +254,7 @@ if (code == MESSAGE_TYPE_OPTION) return new byte[] {(byte) messageType}; else - return (byte[]) options.get(new Integer(code)); + return (byte[]) options.get(Integer.valueOf(code)); } /** Modified: trunk/net/src/net/org/jnode/net/ipv4/udp/UDPProtocol.java =================================================================== --- trunk/net/src/net/org/jnode/net/ipv4/udp/UDPProtocol.java 2009-10-23 07:53:39 UTC (rev 5686) +++ trunk/net/src/net/org/jnode/net/ipv4/udp/UDPProtocol.java 2009-10-23 08:21:09 UTC (rev 5687) @@ -84,7 +84,7 @@ /** * for random listener ports */ - private final Integer zero = new Integer(0); + private final Integer zero = Integer.valueOf(0); private final Random random = new Random(); private final int startRandom = 1024; @@ -199,7 +199,7 @@ * @param skbuf */ private synchronized void deliver(UDPHeader hdr, SocketBuffer skbuf) throws SocketException { - final Integer lport = new Integer(hdr.getDstPort()); + final Integer lport = Integer.valueOf(hdr.getDstPort()); final IPv4Header ipHdr = (IPv4Header) skbuf.getNetworkLayerHeader(); final UDPDatagramSocketImpl socket = (UDPDatagramSocketImpl) sockets.get(lport); if (socket != null) { @@ -232,10 +232,10 @@ Integer ran; while (lport.compareTo(zero) == 0) { - ran = new Integer(random.nextInt(stopRandom) + startRandom); + ran = Integer.valueOf(random.nextInt(stopRandom) + startRandom); if (!sockets.containsKey(ran)) { - // hmmm..... should we have one stop condition more?? + // Should we have one stop condition more?? lport = ran; socket.setLocalPort(lport.intValue()); } @@ -251,7 +251,7 @@ * @param socket */ protected synchronized void unbind(UDPDatagramSocketImpl socket) { - final Integer lport = new Integer(socket.getLocalPort()); + final Integer lport = Integer.valueOf(socket.getLocalPort()); if (sockets.get(lport) == socket) { sockets.remove(lport); } Modified: trunk/net/src/net/org/jnode/net/service/DefaultNetworkLayerManager.java =================================================================== --- trunk/net/src/net/org/jnode/net/service/DefaultNetworkLayerManager.java 2009-10-23 07:53:39 UTC (rev 5686) +++ trunk/net/src/net/org/jnode/net/service/DefaultNetworkLayerManager.java 2009-10-23 08:21:09 UTC (rev 5687) @@ -109,7 +109,7 @@ * @throws NoSuchProtocolException */ public NetworkLayer getNetworkLayer(int protocolID) throws NoSuchProtocolException { - final NetworkLayer pt = (NetworkLayer) layers.get(new Integer(protocolID)); + final NetworkLayer pt = (NetworkLayer) layers.get(Integer.valueOf(protocolID)); if (pt == null) { throw new NoSuchProtocolException("protocolID " + protocolID); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2009-10-23 07:53:49
|
Revision: 5686 http://jnode.svn.sourceforge.net/jnode/?rev=5686&view=rev Author: galatnm Date: 2009-10-23 07:53:39 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Fix some findbugs problems. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java Modified: trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2009-10-23 07:44:44 UTC (rev 5685) +++ trunk/fs/src/fs/org/jnode/fs/ext2/Ext2FileSystem.java 2009-10-23 07:53:39 UTC (rev 5686) @@ -329,7 +329,7 @@ int blockSize = superblock.getBlockSize(); Block result; - Integer key = new Integer((int) (nr)); + Integer key = Integer.valueOf((int) nr); synchronized (blockCache) { // check if the block has already been retrieved if (blockCache.containsKey(key)) { @@ -387,7 +387,7 @@ Block block; - Integer key = new Integer((int) nr); + Integer key = Integer.valueOf((int) nr); int blockSize = superblock.getBlockSize(); // check if the block is in the cache synchronized (blockCache) { @@ -475,7 +475,7 @@ throw new FileSystemException("INode number (" + iNodeNr + ") out of range (0-" + superblock.getINodesCount() + ")"); - Integer key = new Integer(iNodeNr); + Integer key = Integer.valueOf(iNodeNr); log.debug("iNodeCache size: " + inodeCache.size()); @@ -598,7 +598,7 @@ // put the inode into the cache synchronized (inodeCache) { - Integer key = new Integer(iNodeNr); + Integer key = Integer.valueOf(iNodeNr); if (inodeCache.containsKey(key)) throw new FileSystemException("Newly allocated inode is already in the inode cache!?"); else @@ -896,7 +896,7 @@ // add the inode to the inode cache synchronized (inodeCache) { - inodeCache.put(new Integer(Ext2Constants.EXT2_ROOT_INO), iNode); + inodeCache.put(Integer.valueOf(Ext2Constants.EXT2_ROOT_INO), iNode); } modifyUsedDirsCount(0, 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2009-10-23 07:44:52
|
Revision: 5685 http://jnode.svn.sourceforge.net/jnode/?rev=5685&view=rev Author: galatnm Date: 2009-10-23 07:44:44 +0000 (Fri, 23 Oct 2009) Log Message: ----------- Fix possible null pointer. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2009-10-20 21:23:04 UTC (rev 5684) +++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2009-10-23 07:44:44 UTC (rev 5685) @@ -279,10 +279,10 @@ final String name = child.getName(); // never include the parent directory and the current directory in - // the result - // if they exist by any chance - if (name.equals(".") || name.equals("..")) + // the result if they exist by any chance. + if (".".equals(name) || "..".equals(name)){ continue; + } entryPath.append(name); entryCache.setEntry(entryPath.toString(), child); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2009-10-20 21:23:10
|
Revision: 5684 http://jnode.svn.sourceforge.net/jnode/?rev=5684&view=rev Author: lsantha Date: 2009-10-20 21:23:04 +0000 (Tue, 20 Oct 2009) Log Message: ----------- Applied patch by Mark Kokish. Modified Paths: -------------- trunk/cli/descriptors/org.jnode.command.file.xml trunk/cli/src/commands/org/jnode/command/file/DirCommand.java Modified: trunk/cli/descriptors/org.jnode.command.file.xml =================================================================== --- trunk/cli/descriptors/org.jnode.command.file.xml 2009-10-15 14:50:26 UTC (rev 5683) +++ trunk/cli/descriptors/org.jnode.command.file.xml 2009-10-20 21:23:04 UTC (rev 5684) @@ -262,7 +262,8 @@ <option argLabel="url" shortName="u" longName="url" description="print a hex dump of a URL"/> </syntax> <syntax alias="ls"> - <empty description="list the current directory"/> + <empty description="with -l, print sizes in human readable format (e.g., 1K 234M 2G)"/> + <option argLabel="humanReadable" shortName="h" longName="human-readable"/> <repeat> <argument argLabel="path" description="list files or directories"/> </repeat> Modified: trunk/cli/src/commands/org/jnode/command/file/DirCommand.java =================================================================== --- trunk/cli/src/commands/org/jnode/command/file/DirCommand.java 2009-10-15 14:50:26 UTC (rev 5683) +++ trunk/cli/src/commands/org/jnode/command/file/DirCommand.java 2009-10-20 21:23:04 UTC (rev 5684) @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Comparator; @@ -31,6 +32,7 @@ import org.jnode.shell.AbstractCommand; import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.FlagArgument; /** * @author epr @@ -44,15 +46,18 @@ private static final SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm"); private static final String help_path = "the file or directory to list"; + private static final String help_humanReadable = "with -l, print sizes in human readable format (e.g., 1K 234M 2G)"; private static final String help_super = "List files or directories"; private static final String fmt_no_path = "No such path: %s%n"; - + private final FileArgument argPath; - + private final FlagArgument humanReadableArg; + public DirCommand() { super(help_super); + humanReadableArg = new FlagArgument("humanReadable", Argument.OPTIONAL, help_humanReadable); argPath = new FileArgument("path", Argument.OPTIONAL | Argument.MULTIPLE | Argument.EXISTING, help_path); - registerArguments(argPath); + registerArguments(argPath, humanReadableArg); } public static void main(String[] args) throws Exception { @@ -102,10 +107,9 @@ sb.setLength(0); lastModified.setTime(f.lastModified()); if (f.isFile()) { - String ln = String.valueOf(f.length()).concat("B"); + String ln = formatSize(f.length()); int cnt = LEFT_MARGIN - ln.length(); - for (int j = 0; j < cnt; j++, sb.append(' ')) - ; + for (int j = 0; j < cnt; j++) sb.append(' '); sb.append(ln); sb.append(" "); sb.append(df.format(lastModified)); @@ -125,4 +129,16 @@ out.println(); } } + + private static final String[] units = {"B", "K", "M", "G", "T", "P", "E", "Z", "Y"}; + + protected String formatSize(double bytes) { + if (humanReadableArg.isSet()) { + int index; + for (index = 0; bytes >= 1024; index++) bytes = bytes / 1024; + DecimalFormat df = new DecimalFormat("###0.0"); + return df.format(bytes) + units[index]; + } else + return bytes + "B"; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-10-15 14:50:34
|
Revision: 5683 http://jnode.svn.sourceforge.net/jnode/?rev=5683&view=rev Author: crawley Date: 2009-10-15 14:50:26 +0000 (Thu, 15 Oct 2009) Log Message: ----------- Fixes to get the JNode bootimage build working with Jikes compiler. The most important one changes the way that JNode native methods are handled. Previously, the compiler would simply use the bytecodes from the replacement method as the actual method, but this crashed because Jikes used the wrong constant pool. Now, we generate bytecodes for the actual method on the fly. Modified Paths: -------------- branches/jikesRVM/core/descriptors/org.classpath.core.xml branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java branches/jikesRVM/core/src/core/org/jnode/vm/JvmType.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java Added Paths: ----------- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/NativeStubGenerator.java Modified: branches/jikesRVM/core/descriptors/org.classpath.core.xml =================================================================== --- branches/jikesRVM/core/descriptors/org.classpath.core.xml 2009-10-06 14:18:58 UTC (rev 5682) +++ branches/jikesRVM/core/descriptors/org.classpath.core.xml 2009-10-15 14:50:26 UTC (rev 5683) @@ -43,12 +43,13 @@ <export name="sun.security.acl.GroupImpl"/> <export name="sun.security.action.*"/> <export name="sun.security.jca.*"/> - <export name="sun.security.pkcs.ParsingException"/> + <export name="sun.security.pkcs.*"/> <export name="sun.security.provider.SecureRandom"/> <export name="sun.security.provider.PolicyFile"/> <export name="sun.security.provider.PolicyParser"/> + <export name="sun.security.timestamp.TimestampToken"/> <export name="sun.security.util.*"/> - <export name="sun.security.x509.X509CertImpl"/> + <export name="sun.security.x509.*"/> <export name="sun.misc.Service"/> <export name="sun.misc.ServiceConfigurationError"/> Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-10-06 14:18:58 UTC (rev 5682) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-10-15 14:50:26 UTC (rev 5683) @@ -127,7 +127,7 @@ int n = method.getBytecode().getExceptionHandlers().size(); if (n!=0) eMap = new VM_ExceptionHandlerMap(method.getBytecode().getExceptionHandlers(), dc, n); VmLineNumberMap jnodeLineMap = method.getBytecode().getLineNrs(); - int [] lineMap = new int[jnodeLineMap.getLength()]; + int [] lineMap = new int[jnodeLineMap == null ? 0 : jnodeLineMap.getLength()]; for (int i = 0; i < lineMap.length; i++) { int startPC = jnodeLineMap.getStartPCAt(i); int lineNumber = jnodeLineMap.getLineNrAt(i); Modified: branches/jikesRVM/core/src/core/org/jnode/vm/JvmType.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/JvmType.java 2009-10-06 14:18:58 UTC (rev 5682) +++ branches/jikesRVM/core/src/core/org/jnode/vm/JvmType.java 2009-10-15 14:50:26 UTC (rev 5683) @@ -259,7 +259,68 @@ return types; } + + /** + * Gets the argument signatures for a method signature. + * + * @param signature + * @return the argument type signatures as an array of strings + */ + public static String[] getArgumentSignatures(String signature) { + final int len = signature.length(); + final String[] types = new String[getArgumentCount(signature)]; + int cnt = 0; + int start; + for (int i = 1; i < len; i++) { + final String t; + switch (signature.charAt(i)) { + case 'Z': + case 'B': + case 'C': + case 'S': + case 'I': + case 'F': + case 'J': + case 'D': + t = Character.toString(signature.charAt(i)); + break; + case 'L': + start = i; + while (signature.charAt(i) != ';') { + i++; + } + t = signature.substring(start, i + 1); + break; + case '[': + start = i; + while (signature.charAt(i) == '[') { + i++; + } + if (signature.charAt(i) == 'L') { + while (signature.charAt(i) != ';') { + i++; + } + } + t = signature.substring(start, i + 1); + break; + case ')': + // the end + i = len; + t = null; + break; + default: + throw new IllegalArgumentException("Unknown type" + + signature.substring(i)); + } + if (t != null) { + types[cnt++] = t; + } + } + return types; + } + + /** * Gets the return type of a method signature. * * @param signature @@ -276,6 +337,17 @@ } /** + * Gets the return type signature of a method signature. + * + * @param signature + * @return the return type signature + */ + public static String getReturnSignature(String signature) { + final int endIdx = signature.indexOf(')'); + return signature.substring(endIdx + 1); + } + + /** * Test if the given internal type value a floating point type. * * @param type the type value Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-10-06 14:18:58 UTC (rev 5682) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-10-15 14:50:26 UTC (rev 5683) @@ -54,6 +54,16 @@ * @author Ewout Prangsma (ep...@us...) */ public final class ClassDecoder { + + // This constant controls how we deal with native method replacement. The first + // step is to find a suitable replacement method in the "Native<ClassName>" class. + // If that works, we then need to arrange that the replacement is used. The old + // way to do this was to simply attach the bytecodes for the replacement method + // to the native method and mark it as non-native. That doesn't work with Jikes + // (because of issues with using the right constant pool.) So the alternative is + // to generate bytecodes to turn the native method into a stub method that calls + // the replacement method. This is controlled by the following constant. + private static boolean GENERATE_STUB_METHODS = true; // ------------------------------------------ // VM ClassLoader Code @@ -497,7 +507,7 @@ nativeType = cl.loadClass(nativeClassName, false); } catch (ClassNotFoundException ex) { if (verbose) { - BootLog.error("Native class replacement (" + nativeClassName + BootLog.error("Native replacement class (" + nativeClassName + ") not found"); } return null; @@ -508,20 +518,26 @@ signature = "(" + Signature.toSignature(method.getDeclaringClass()) + signature.substring(1); } - final VmMethod nativeMethod = nativeType.getNativeMethodReplacement(method.getName(), signature); + final VmMethod replacementMethod = + nativeType.getNativeMethodReplacement(method.getName(), signature); - if (nativeMethod == null) { + if (replacementMethod == null) { if (verbose) { - BootLog.error("Native method replacement (" + method - + ") not found"); + BootLog.error("Native method replacement (" + nativeClassName + + "." + method + " with signature '" + signature + "') not found"); } return null; } - if (!nativeMethod.isStatic()) { + if (!replacementMethod.isStatic()) { throw new ClassFormatError( - "Native method replacement must be static"); + "Native method replacement must be static (" + nativeClassName + + "." + method + " with signature '" + signature + "')"); } - return nativeMethod.getBytecode(); + if (GENERATE_STUB_METHODS) { + return NativeStubGenerator.generate(method, replacementMethod); + } else { + return replacementMethod.getBytecode(); + } } /** Added: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/NativeStubGenerator.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/NativeStubGenerator.java (rev 0) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/NativeStubGenerator.java 2009-10-15 14:50:26 UTC (rev 5683) @@ -0,0 +1,194 @@ +/* + * $Id: ClassDecoder.java 5682 2009-10-06 14:18:58Z crawley $ + * + * Copyright (C) 2003-2009 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jnode.vm.classmgr; + +import org.jnode.vm.JvmType; +import org.jnode.vm.bytecode.BytecodeWriter; + +/** + * This class is used to generate the bytecodes for native code replacement stubs. + * Only 32bit vms are supported for now, since we are using JvmType.getCategory(). + * + * @author cr...@jn... + */ +public class NativeStubGenerator { + + /** + * Create the bytecodes for a stub replacement for the native method. This + * will add entries to the method's constant pool as required. + * + * @param nativeMethod the native method to be replaced + * @param replacementMethod the (non-native) Java method that will do the work + * @return the bytecodes for the stub method to replace the native method. + */ + public static VmByteCode generate(VmMethod nativeMethod, VmMethod replacementMethod) { + VmCP cp = nativeMethod.getDeclaringClass().getCP(); + int classIndex = findOrAddConstClass( + cp, replacementMethod.getDeclaringClass().getName()); + int methodIndex = findOrAddConstMethod( + cp, classIndex, replacementMethod.getName(), replacementMethod.signature); + BytecodeWriter bw = new BytecodeWriter(1024); + // (We cannot use method.getNoArguments, method.getArgumentType because they + // depend on org.jnode.vm.classmgr.Signature, which in turn assumes that + // the primitive type classes have been initialized. Instead, we use the + // JvmType class to unpick the method signature.) + String signature = nativeMethod.getSignature(); + int slotOffset = nativeMethod.isStatic() ? 0 : JvmType.getCategory(JvmType.REFERENCE); + int slot = slotOffset; + int[] argTypes = JvmType.getArgumentTypes(signature); + // Generate a stack load instruction for each argument + if (!nativeMethod.isStatic()) { + genArgLoad(bw, JvmType.REFERENCE, 0); + } + for (int i = 0; i < argTypes.length; i++) { + genArgLoad(bw, argTypes[i], slot); + slot += JvmType.getCategory(argTypes[i]); + } + // Generate the invoke instruction to call the replacement method + bw.invokestatic(methodIndex); + // Generate the return instruction depending on the return type + int returnType = JvmType.getReturnType(signature); + int returnTypeSize = JvmType.getCategory(returnType); + switch (returnType) { + case JvmType.BOOLEAN: + case JvmType.BYTE: + case JvmType.CHAR: + case JvmType.SHORT: + case JvmType.INT: + bw.ireturn(); + break; + case JvmType.LONG: + bw.lreturn(); + break; + case JvmType.FLOAT: + bw.freturn(); + break; + case JvmType.DOUBLE: + bw.dreturn(); + break; + case JvmType.REFERENCE: + bw.areturn(); + break; + default: + bw.return_(); + } + int endPos = bw.getLength(); + // Prepare a locals table with an entry for each argument. + int localOffset; + VmLocalVariable[] locals; + if (nativeMethod.isStatic()) { + localOffset = 0; + locals = new VmLocalVariable[argTypes.length]; + } else { + localOffset = 1; + locals = new VmLocalVariable[argTypes.length + localOffset]; + locals[0] = new VmLocalVariable( + (char) 0, (char) endPos, (char) 0, (char) 0, (char) 0); + } + slot = slotOffset; + String[] argSignatures = JvmType.getArgumentSignatures(signature); + for (int i = 0; i < argTypes.length; i++) { + int nameIndex = findOrAddUTF8(cp, "arg" + i); + int descriptorIndex = findOrAddUTF8(cp, argSignatures[i]); + locals[i + localOffset] = new VmLocalVariable( + (char) 0, (char) endPos, (char) nameIndex, (char) descriptorIndex, (char) slot); + slot += JvmType.getCategory(argTypes[i]); + } + // Put it all together + return new VmByteCode(nativeMethod, bw.toByteBuffer(), locals.length, + Math.max(slot, returnTypeSize), + new VmInterpretedExceptionHandler[0], + new VmLineNumberMap(new char[]{0, 1}), + new VmLocalVariableTable(locals)); + } + + private static void genArgLoad(BytecodeWriter bw, int type, int slot) { + switch (type) { + case JvmType.BOOLEAN: + case JvmType.BYTE: + case JvmType.CHAR: + case JvmType.SHORT: + case JvmType.INT: + bw.iload(slot); + break; + case JvmType.LONG: + bw.lload(slot); + break; + case JvmType.FLOAT: + bw.fload(slot); + break; + case JvmType.DOUBLE: + bw.dload(slot); + break; + case JvmType.REFERENCE: + bw.aload(slot); + break; + default: + throw new AssertionError("Unexpected arg type (" + type + ")"); + } + } + + private static int findOrAddConstMethod(VmCP cp, int classIndex, String name, + String signature) { + VmConstClass classRef = cp.getConstClass(classIndex); + for (int i = 0; i < cp.getLength(); i++) { + Object obj = cp.getAny(i); + if (obj instanceof VmConstMethodRef) { + VmConstMethodRef ref = (VmConstMethodRef) obj; + if (ref.getClassName().equals(classRef.getClassName()) && + ref.getName().equals(name) && ref.getSignature().equals(signature)) { + return i; + } + } + } + VmConstMethodRef ref = new VmConstMethodRef(classRef, name, signature); + int index = cp.getUnusedIndex(); + cp.setConstMethodRef(index, ref); + return index; + } + + private static int findOrAddConstClass(VmCP cp, String name) { + for (int i = 0; i < cp.getLength(); i++) { + Object obj = cp.getAny(i); + if (obj instanceof VmConstClass) { + VmConstClass ref = (VmConstClass) obj; + if (ref.getClassName().equals(name)) { + return i; + } + } + } + VmConstClass ref = new VmConstClass(name); + int index = cp.getUnusedIndex(); + cp.setConstClass(index, ref); + return index; + } + + private static int findOrAddUTF8(VmCP cp, String name) { + for (int i = 0; i < cp.getLength(); i++) { + if (name.equals(cp.getAny(i))) { + return i; + } + } + int index = cp.getUnusedIndex(); + cp.setUTF8(index, name); + return index; + } +} Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-10-06 14:18:58 UTC (rev 5682) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-10-15 14:50:26 UTC (rev 5683) @@ -305,7 +305,7 @@ * @param index The index where to read * @param data The Object to write */ - private void set(int index, Object data) { + public void set(int index, Object data) { if (data == null) { throw new NullPointerException( "Cannot set a null data"); @@ -316,6 +316,15 @@ final void reset(int index) { cp[index] = null; } + + public int getUnusedIndex() { + if (used == cp.length) { + Object[] newCP = new Object[cp.length + 1]; + System.arraycopy(cp, 0, newCP, 0, cp.length); + cp = newCP; + } + return used++; + } public VmType getParentType() { return parentType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-10-06 14:19:05
|
Revision: 5682 http://jnode.svn.sourceforge.net/jnode/?rev=5682&view=rev Author: crawley Date: 2009-10-06 14:18:58 +0000 (Tue, 06 Oct 2009) Log Message: ----------- Reverting last checkin. That approach doesn't work. Modified Paths: -------------- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -16,8 +16,8 @@ * @author Igor Pechtchanski */ public class VM_BytecodeStream implements VM_BytecodeConstants, VM_SizeConstants { - private VM_NormalMethod method; - private VM_Class declaringClass; + private final VM_NormalMethod method; + private final VM_Class declaringClass; private final int bcLength; private final byte[] bcodes; private int bcIndex; @@ -25,7 +25,6 @@ private boolean wide; /** - * Create a bytecode stream from a method descriptor and an array of bytecodes. * @param m the method containing the bytecodes * @param bc the array of bytecodes */ @@ -36,15 +35,6 @@ bcLength = bc.length; bcIndex = 0; } - - /** - * Create a bytecode stream from an existing one. The method and bytecode - * array will be shared. - * @param stream the existing bytecode stream - */ - public VM_BytecodeStream(VM_BytecodeStream stream) { - this(stream.method, stream.bcodes); - } /** * Returns the method that this bytecode stream is from @@ -71,14 +61,6 @@ public final int length() { return bcLength; } - - /** - * Returns the bytecodes or {@code null}. - * @return the bytecode array - */ - public final byte[] bytecodes() { - return bcodes; - } /** * Returns the current bytecode index Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -2,7 +2,6 @@ import java.nio.ByteBuffer; -import org.jnode.vm.classmgr.VmByteCode; import org.jnode.vm.classmgr.VmExceptions; import org.jnode.vm.classmgr.VmInstanceMethod; import org.jnode.vm.classmgr.VmLineNumberMap; @@ -42,7 +41,7 @@ } public final boolean hasNoInlinePragma() { - return ((VmMethod) jnodeMember).hasNoInlinePragma(); + return ((VmMethod)jnodeMember).hasNoInlinePragma(); } @@ -51,24 +50,22 @@ } public void invalidateCompiledMethod(VM_CompiledMethod cm) { - if (VM.VerifyAssertions) { - VM._assert(declaringClass.isInstantiated()); - } + if (VM.VerifyAssertions) VM._assert(declaringClass.isInstantiated()); if (currentCompiledMethod == cm) { - replaceCompiledMethod(null); + replaceCompiledMethod(null); } } public boolean isObjectInitializer() { - return ((VmMethod) jnodeMember).isConstructor(); + return ((VmMethod)jnodeMember).isConstructor(); } public boolean isNative() { - return ((VmMethod) jnodeMember).isNative(); + return ((VmMethod)jnodeMember).isNative(); } public boolean isAbstract() { - return ((VmMethod) jnodeMember).isAbstract(); + return ((VmMethod)jnodeMember).isAbstract(); } public boolean mayWrite(VM_Field f) { @@ -76,15 +73,15 @@ } public boolean isInterruptible() { - return !((VmMethod) jnodeMember).isUninterruptible(); + return !((VmMethod)jnodeMember).isUninterruptible(); } public boolean hasInlinePragma() { - return ((VmMethod) jnodeMember).hasInlinePragma(); + return ((VmMethod)jnodeMember).hasInlinePragma(); } public boolean isClassInitializer() { - return ((VmMethod) jnodeMember).isInitializer(); + return ((VmMethod)jnodeMember).isInitializer(); } public boolean isCompiled() { @@ -105,26 +102,20 @@ * Check that it provides the functionality you want before calling it. */ public static VM_Method buildFromJnodeMethod(VmMethod method) { - if (method == null) { - return null; - } - VM_Class dc = method.isReplacement() ? - VM_Class.buildFromJnodeClass(method.getRealDeclaringClass()) : - VM_Class.buildFromJnodeClass(method.getDeclaringClass()); + if(method == null) return null; + VM_Class dc = VM_Class.buildFromJnodeClass(method.getDeclaringClass()); String name = method.getName(); String desc = method.getSignature(); VM_Atom mn = VM_Atom.findOrCreateAsciiAtom(name); VM_Atom d = VM_Atom.findOrCreateAsciiAtom(desc); VM_MemberReference mr = VM_MemberReference.findOrCreate(dc.getTypeRef(), mn, d); - if (((VM_MethodReference) mr).isResolved()) { - return (VM_Method) mr.resolveMember(); - } - if (method.isAbstract()) { - return new VM_AbstractMethod(dc, mr, method.getModifiers(), null, method); - } - if (method.isNative()) { - return new VM_NativeMethod(dc, mr, method.getModifiers(), null, method); - } + if (((VM_MethodReference)mr).isResolved()) + return (VM_Method)mr.resolveMember(); + VM_Method jikesMethod; + if(method.isAbstract()) + return jikesMethod = new VM_AbstractMethod(dc, mr, method.getModifiers(), null, method); + if(method.isNative()) + return jikesMethod = new VM_NativeMethod(dc, mr, method.getModifiers(), null, method); //If we reach here the method is definitely "normal", i.e. not native and not abstract int bclength = method.getBytecodeSize(); @@ -134,34 +125,27 @@ VmExceptions jnodeExceptions = method.getExceptions(); VM_ExceptionHandlerMap eMap = null; int n = method.getBytecode().getExceptionHandlers().size(); - if (n != 0) { - eMap = new VM_ExceptionHandlerMap(method.getBytecode().getExceptionHandlers(), dc, n); + if (n!=0) eMap = new VM_ExceptionHandlerMap(method.getBytecode().getExceptionHandlers(), dc, n); + VmLineNumberMap jnodeLineMap = method.getBytecode().getLineNrs(); + int [] lineMap = new int[jnodeLineMap.getLength()]; + for (int i = 0; i < lineMap.length; i++) { + int startPC = jnodeLineMap.getStartPCAt(i); + int lineNumber = jnodeLineMap.getLineNrAt(i); + lineMap[i] = (lineNumber << BITS_IN_SHORT) | startPC; } - VmLineNumberMap jnodeLineMap = method.getBytecode().getLineNrs(); - int [] lineMap; - if (jnodeLineMap == null) { - // FIXME ... figure out why this happens - lineMap = null; - } else { - lineMap = new int[jnodeLineMap.getLength()]; - for (int i = 0; i < lineMap.length; i++) { - int startPC = jnodeLineMap.getStartPCAt(i); - int lineNumber = jnodeLineMap.getLineNrAt(i); - lineMap[i] = (lineNumber << BITS_IN_SHORT) | startPC; - } - } - VM_NormalMethod jikesMethod = new VM_NormalMethod(dc, mr, method.getModifiers(), + return jikesMethod = new VM_NormalMethod(dc, mr, method.getModifiers(), null, method.getBytecode().getNoLocals(), method.getNoArguments(), bcodes, eMap, lineMap, method); - return jikesMethod; + + } public int getSelector() { - return ((VmMethod) jnodeMember).getSelector(); + return ((VmMethod)jnodeMember).getSelector(); } public Offset getTibOffset() { - return Offset.fromIntZeroExtend(((VmInstanceMethod) jnodeMember).getTibOffset()); + return Offset.fromIntZeroExtend(((VmInstanceMethod)jnodeMember).getTibOffset()); } Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -132,7 +132,7 @@ /** * bytecodes for this method (null --> none) */ - private final VM_BytecodeStream bytecodes; + private final byte[] bytecodes; // Extra fields for on-stack replacement // TODO: rework the system so we don't waste space for this on the VM_Method @@ -152,12 +152,12 @@ private VM_ExceptionHandlerMap exceptionHandlerMap; public VM_NormalMethod(VM_Class dc, VM_MemberReference mr, int mo, - VM_TypeReference[] et, int lw, int ow, byte[] bcodes, + VM_TypeReference[] et, int lw, int ow, byte[] bc, VM_ExceptionHandlerMap eMap, int[] lm, VmMethod ref) { super(dc, mr, mo, et, ref); localWords = lw; operandWords = ow; - bytecodes = new VM_BytecodeStream(this, bcodes); + bytecodes = bc; exceptionHandlerMap = eMap; lineNumberMap = lm; computeSummary(); @@ -188,7 +188,7 @@ * @return object representing the bytecodes */ public final VM_BytecodeStream getBytecodes() { - return new VM_BytecodeStream(bytecodes); + return new VM_BytecodeStream(this, bytecodes); } @@ -257,10 +257,10 @@ if (VM.VerifyAssertions) VM._assert(this.synthesizedBytecodes == null); - byte[] newBytecodes = new byte[prologue.length + bytecodes.length()]; + byte[] newBytecodes = new byte[prologue.length + bytecodes.length]; System.arraycopy(prologue, 0, newBytecodes, 0, prologue.length); - System.arraycopy(bytecodes.bytecodes(), 0, newBytecodes, prologue.length, - bytecodes.length()); + System.arraycopy(bytecodes, 0, newBytecodes, prologue.length, + bytecodes.length); this.osrPrologue = prologue; this.synthesizedBytecodes = newBytecodes; Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -1034,9 +1034,7 @@ rejectNatives); if (bc != null) { mts.setModifier(false, Modifier.ACC_NATIVE); - mts.setModifier(true, Modifier.ACC_REPLACED); mts.setBytecode(bc); - mts.setRealDeclaringClass(bc.getMethod().getDeclaringClass()); } else { if (rejectNatives) { throw new ClassFormatError("Native method " + mts); Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -62,12 +62,6 @@ public static final int ACC_MAGIC = 0x10000000; // C /** - * Is this a replaced method; i.e. one declared as native and - * then replaced with a Java method by the boot image builder. - */ - public static final int ACC_REPLACED = 0x40000000; - - /** * Is this a special method (init, clinit) */ public static final int ACC_SPECIAL = 0x80000000; @@ -120,10 +114,6 @@ return ((modifier & ACC_NATIVE) != 0); } - public static boolean isReplaced(int modifier) { - return ((modifier & ACC_REPLACED) != 0); - } - public static boolean isInterface(int modifier) { return ((modifier & ACC_INTERFACE) != 0); } Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -44,14 +44,10 @@ */ private int modifiers; /** - * Notional declaring class of this member + * Declaring class of this member */ protected final VmType<?> declaringClass; /** - * Actual declaring class of this member - */ - protected VmType<?> realDeclaringClass; - /** * Hashcode of name+signature */ private final int cachedHashCode; @@ -64,8 +60,7 @@ * @param modifiers * @param declaringClass */ - protected VmMember(String name, String signature, int modifiers, - VmType declaringClass) { + protected VmMember(String name, String signature, int modifiers, VmType declaringClass) { if (name.equals("<clinit>")) { modifiers |= Modifier.ACC_INITIALIZER; } else if (name.equals("<init>")) { @@ -78,7 +73,6 @@ this.signature = signature; this.modifiers = modifiers; this.declaringClass = declaringClass; - this.realDeclaringClass = declaringClass; this.cachedHashCode = calcHashCode(name, signature); } @@ -139,7 +133,7 @@ } /** - * Gets the Class i'm notionally declared in. + * Gets the Class i'm declared in. * * @return VmClass */ @@ -150,26 +144,6 @@ } /** - * Gets the Class i'm actually declared in. This differs from the - * notional declaring class if this is a native method that has been - * replaced by a Java method. - * - * @return VmClass - */ - @KernelSpace - @org.jnode.annotation.Uninterruptible - public final VmType<?> getRealDeclaringClass() { - return realDeclaringClass; - } - - /** - * Sets the Class i'm actually declared in. - */ - public void setRealDeclaringClass(VmType<?> realDeclaringClass) { - this.realDeclaringClass = realDeclaringClass; - } - - /** * Is this member public? * * @return boolean Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-09-18 07:23:15 UTC (rev 5681) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-10-06 14:18:58 UTC (rev 5682) @@ -113,7 +113,7 @@ * @param declaringClass */ protected VmMethod(String name, String signature, int modifiers, - VmType<?> declaringClass) { + VmType<?> declaringClass) { super( name, signature, @@ -310,11 +310,7 @@ public final boolean isNative() { return Modifier.isNative(getModifiers()); } - - public boolean isReplacement() { - return Modifier.isReplaced(getModifiers()); - } - + public final boolean isSpecial() { return Modifier.isSpecial(getModifiers()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-09-18 07:23:28
|
Revision: 5681 http://jnode.svn.sourceforge.net/jnode/?rev=5681&view=rev Author: crawley Date: 2009-09-18 07:23:15 +0000 (Fri, 18 Sep 2009) Log Message: ----------- When a native method is replaced with a Java one (from a Native... class), the method's bytecode stream must still use the constant pool for the Native... class. Modified Paths: -------------- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_BytecodeStream.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -16,8 +16,8 @@ * @author Igor Pechtchanski */ public class VM_BytecodeStream implements VM_BytecodeConstants, VM_SizeConstants { - private final VM_NormalMethod method; - private final VM_Class declaringClass; + private VM_NormalMethod method; + private VM_Class declaringClass; private final int bcLength; private final byte[] bcodes; private int bcIndex; @@ -25,6 +25,7 @@ private boolean wide; /** + * Create a bytecode stream from a method descriptor and an array of bytecodes. * @param m the method containing the bytecodes * @param bc the array of bytecodes */ @@ -35,6 +36,15 @@ bcLength = bc.length; bcIndex = 0; } + + /** + * Create a bytecode stream from an existing one. The method and bytecode + * array will be shared. + * @param stream the existing bytecode stream + */ + public VM_BytecodeStream(VM_BytecodeStream stream) { + this(stream.method, stream.bcodes); + } /** * Returns the method that this bytecode stream is from @@ -61,6 +71,14 @@ public final int length() { return bcLength; } + + /** + * Returns the bytecodes or {@code null}. + * @return the bytecode array + */ + public final byte[] bytecodes() { + return bcodes; + } /** * Returns the current bytecode index Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Method.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -2,6 +2,7 @@ import java.nio.ByteBuffer; +import org.jnode.vm.classmgr.VmByteCode; import org.jnode.vm.classmgr.VmExceptions; import org.jnode.vm.classmgr.VmInstanceMethod; import org.jnode.vm.classmgr.VmLineNumberMap; @@ -41,7 +42,7 @@ } public final boolean hasNoInlinePragma() { - return ((VmMethod)jnodeMember).hasNoInlinePragma(); + return ((VmMethod) jnodeMember).hasNoInlinePragma(); } @@ -50,22 +51,24 @@ } public void invalidateCompiledMethod(VM_CompiledMethod cm) { - if (VM.VerifyAssertions) VM._assert(declaringClass.isInstantiated()); + if (VM.VerifyAssertions) { + VM._assert(declaringClass.isInstantiated()); + } if (currentCompiledMethod == cm) { - replaceCompiledMethod(null); + replaceCompiledMethod(null); } } public boolean isObjectInitializer() { - return ((VmMethod)jnodeMember).isConstructor(); + return ((VmMethod) jnodeMember).isConstructor(); } public boolean isNative() { - return ((VmMethod)jnodeMember).isNative(); + return ((VmMethod) jnodeMember).isNative(); } public boolean isAbstract() { - return ((VmMethod)jnodeMember).isAbstract(); + return ((VmMethod) jnodeMember).isAbstract(); } public boolean mayWrite(VM_Field f) { @@ -73,15 +76,15 @@ } public boolean isInterruptible() { - return !((VmMethod)jnodeMember).isUninterruptible(); + return !((VmMethod) jnodeMember).isUninterruptible(); } public boolean hasInlinePragma() { - return ((VmMethod)jnodeMember).hasInlinePragma(); + return ((VmMethod) jnodeMember).hasInlinePragma(); } public boolean isClassInitializer() { - return ((VmMethod)jnodeMember).isInitializer(); + return ((VmMethod) jnodeMember).isInitializer(); } public boolean isCompiled() { @@ -102,20 +105,26 @@ * Check that it provides the functionality you want before calling it. */ public static VM_Method buildFromJnodeMethod(VmMethod method) { - if(method == null) return null; - VM_Class dc = VM_Class.buildFromJnodeClass(method.getDeclaringClass()); + if (method == null) { + return null; + } + VM_Class dc = method.isReplacement() ? + VM_Class.buildFromJnodeClass(method.getRealDeclaringClass()) : + VM_Class.buildFromJnodeClass(method.getDeclaringClass()); String name = method.getName(); String desc = method.getSignature(); VM_Atom mn = VM_Atom.findOrCreateAsciiAtom(name); VM_Atom d = VM_Atom.findOrCreateAsciiAtom(desc); VM_MemberReference mr = VM_MemberReference.findOrCreate(dc.getTypeRef(), mn, d); - if (((VM_MethodReference)mr).isResolved()) - return (VM_Method)mr.resolveMember(); - VM_Method jikesMethod; - if(method.isAbstract()) - return jikesMethod = new VM_AbstractMethod(dc, mr, method.getModifiers(), null, method); - if(method.isNative()) - return jikesMethod = new VM_NativeMethod(dc, mr, method.getModifiers(), null, method); + if (((VM_MethodReference) mr).isResolved()) { + return (VM_Method) mr.resolveMember(); + } + if (method.isAbstract()) { + return new VM_AbstractMethod(dc, mr, method.getModifiers(), null, method); + } + if (method.isNative()) { + return new VM_NativeMethod(dc, mr, method.getModifiers(), null, method); + } //If we reach here the method is definitely "normal", i.e. not native and not abstract int bclength = method.getBytecodeSize(); @@ -125,27 +134,34 @@ VmExceptions jnodeExceptions = method.getExceptions(); VM_ExceptionHandlerMap eMap = null; int n = method.getBytecode().getExceptionHandlers().size(); - if (n!=0) eMap = new VM_ExceptionHandlerMap(method.getBytecode().getExceptionHandlers(), dc, n); - VmLineNumberMap jnodeLineMap = method.getBytecode().getLineNrs(); - int [] lineMap = new int[jnodeLineMap.getLength()]; - for (int i = 0; i < lineMap.length; i++) { - int startPC = jnodeLineMap.getStartPCAt(i); - int lineNumber = jnodeLineMap.getLineNrAt(i); - lineMap[i] = (lineNumber << BITS_IN_SHORT) | startPC; + if (n != 0) { + eMap = new VM_ExceptionHandlerMap(method.getBytecode().getExceptionHandlers(), dc, n); } - return jikesMethod = new VM_NormalMethod(dc, mr, method.getModifiers(), + VmLineNumberMap jnodeLineMap = method.getBytecode().getLineNrs(); + int [] lineMap; + if (jnodeLineMap == null) { + // FIXME ... figure out why this happens + lineMap = null; + } else { + lineMap = new int[jnodeLineMap.getLength()]; + for (int i = 0; i < lineMap.length; i++) { + int startPC = jnodeLineMap.getStartPCAt(i); + int lineNumber = jnodeLineMap.getLineNrAt(i); + lineMap[i] = (lineNumber << BITS_IN_SHORT) | startPC; + } + } + VM_NormalMethod jikesMethod = new VM_NormalMethod(dc, mr, method.getModifiers(), null, method.getBytecode().getNoLocals(), method.getNoArguments(), bcodes, eMap, lineMap, method); - - + return jikesMethod; } public int getSelector() { - return ((VmMethod)jnodeMember).getSelector(); + return ((VmMethod) jnodeMember).getSelector(); } public Offset getTibOffset() { - return Offset.fromIntZeroExtend(((VmInstanceMethod)jnodeMember).getTibOffset()); + return Offset.fromIntZeroExtend(((VmInstanceMethod) jnodeMember).getTibOffset()); } Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java =================================================================== --- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_NormalMethod.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -132,7 +132,7 @@ /** * bytecodes for this method (null --> none) */ - private final byte[] bytecodes; + private final VM_BytecodeStream bytecodes; // Extra fields for on-stack replacement // TODO: rework the system so we don't waste space for this on the VM_Method @@ -152,12 +152,12 @@ private VM_ExceptionHandlerMap exceptionHandlerMap; public VM_NormalMethod(VM_Class dc, VM_MemberReference mr, int mo, - VM_TypeReference[] et, int lw, int ow, byte[] bc, + VM_TypeReference[] et, int lw, int ow, byte[] bcodes, VM_ExceptionHandlerMap eMap, int[] lm, VmMethod ref) { super(dc, mr, mo, et, ref); localWords = lw; operandWords = ow; - bytecodes = bc; + bytecodes = new VM_BytecodeStream(this, bcodes); exceptionHandlerMap = eMap; lineNumberMap = lm; computeSummary(); @@ -188,7 +188,7 @@ * @return object representing the bytecodes */ public final VM_BytecodeStream getBytecodes() { - return new VM_BytecodeStream(this, bytecodes); + return new VM_BytecodeStream(bytecodes); } @@ -257,10 +257,10 @@ if (VM.VerifyAssertions) VM._assert(this.synthesizedBytecodes == null); - byte[] newBytecodes = new byte[prologue.length + bytecodes.length]; + byte[] newBytecodes = new byte[prologue.length + bytecodes.length()]; System.arraycopy(prologue, 0, newBytecodes, 0, prologue.length); - System.arraycopy(bytecodes, 0, newBytecodes, prologue.length, - bytecodes.length); + System.arraycopy(bytecodes.bytecodes(), 0, newBytecodes, prologue.length, + bytecodes.length()); this.osrPrologue = prologue; this.synthesizedBytecodes = newBytecodes; Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -1034,7 +1034,9 @@ rejectNatives); if (bc != null) { mts.setModifier(false, Modifier.ACC_NATIVE); + mts.setModifier(true, Modifier.ACC_REPLACED); mts.setBytecode(bc); + mts.setRealDeclaringClass(bc.getMethod().getDeclaringClass()); } else { if (rejectNatives) { throw new ClassFormatError("Native method " + mts); Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/Modifier.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -62,6 +62,12 @@ public static final int ACC_MAGIC = 0x10000000; // C /** + * Is this a replaced method; i.e. one declared as native and + * then replaced with a Java method by the boot image builder. + */ + public static final int ACC_REPLACED = 0x40000000; + + /** * Is this a special method (init, clinit) */ public static final int ACC_SPECIAL = 0x80000000; @@ -114,6 +120,10 @@ return ((modifier & ACC_NATIVE) != 0); } + public static boolean isReplaced(int modifier) { + return ((modifier & ACC_REPLACED) != 0); + } + public static boolean isInterface(int modifier) { return ((modifier & ACC_INTERFACE) != 0); } Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMember.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -44,10 +44,14 @@ */ private int modifiers; /** - * Declaring class of this member + * Notional declaring class of this member */ protected final VmType<?> declaringClass; /** + * Actual declaring class of this member + */ + protected VmType<?> realDeclaringClass; + /** * Hashcode of name+signature */ private final int cachedHashCode; @@ -60,7 +64,8 @@ * @param modifiers * @param declaringClass */ - protected VmMember(String name, String signature, int modifiers, VmType declaringClass) { + protected VmMember(String name, String signature, int modifiers, + VmType declaringClass) { if (name.equals("<clinit>")) { modifiers |= Modifier.ACC_INITIALIZER; } else if (name.equals("<init>")) { @@ -73,6 +78,7 @@ this.signature = signature; this.modifiers = modifiers; this.declaringClass = declaringClass; + this.realDeclaringClass = declaringClass; this.cachedHashCode = calcHashCode(name, signature); } @@ -133,7 +139,7 @@ } /** - * Gets the Class i'm declared in. + * Gets the Class i'm notionally declared in. * * @return VmClass */ @@ -144,6 +150,26 @@ } /** + * Gets the Class i'm actually declared in. This differs from the + * notional declaring class if this is a native method that has been + * replaced by a Java method. + * + * @return VmClass + */ + @KernelSpace + @org.jnode.annotation.Uninterruptible + public final VmType<?> getRealDeclaringClass() { + return realDeclaringClass; + } + + /** + * Sets the Class i'm actually declared in. + */ + public void setRealDeclaringClass(VmType<?> realDeclaringClass) { + this.realDeclaringClass = realDeclaringClass; + } + + /** * Is this member public? * * @return boolean Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-09-18 07:00:06 UTC (rev 5680) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmMethod.java 2009-09-18 07:23:15 UTC (rev 5681) @@ -113,7 +113,7 @@ * @param declaringClass */ protected VmMethod(String name, String signature, int modifiers, - VmType<?> declaringClass) { + VmType<?> declaringClass) { super( name, signature, @@ -310,7 +310,11 @@ public final boolean isNative() { return Modifier.isNative(getModifiers()); } - + + public boolean isReplacement() { + return Modifier.isReplaced(getModifiers()); + } + public final boolean isSpecial() { return Modifier.isSpecial(getModifiers()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-09-18 07:00:13
|
Revision: 5680 http://jnode.svn.sourceforge.net/jnode/?rev=5680&view=rev Author: crawley Date: 2009-09-18 07:00:06 +0000 (Fri, 18 Sep 2009) Log Message: ----------- Added a missing sun.security class to the list exported by the "rt" plugin. Modified Paths: -------------- branches/jikesRVM/core/descriptors/org.classpath.core.xml Modified: branches/jikesRVM/core/descriptors/org.classpath.core.xml =================================================================== --- branches/jikesRVM/core/descriptors/org.classpath.core.xml 2009-09-12 03:49:18 UTC (rev 5679) +++ branches/jikesRVM/core/descriptors/org.classpath.core.xml 2009-09-18 07:00:06 UTC (rev 5680) @@ -16,7 +16,7 @@ <export name="com.sun.java.util.jar.pack.*"/> <export name="com.sun.naming.internal.*"/> <export name="com.sun.security.auth.UserPrincipal"/> - <export name="com.sun.security.auth.PrincipalComparator"/> + <export name="com.sun.security.auth.PrincipalComparator"/> <export name="sun.awt.EventListenerAggregate" /> <export name="sun.misc.*"/> @@ -47,7 +47,8 @@ <export name="sun.security.provider.SecureRandom"/> <export name="sun.security.provider.PolicyFile"/> <export name="sun.security.provider.PolicyParser"/> - <export name="sun.security.util.*"/> + <export name="sun.security.util.*"/> + <export name="sun.security.x509.X509CertImpl"/> <export name="sun.misc.Service"/> <export name="sun.misc.ServiceConfigurationError"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-09-12 03:49:26
|
Revision: 5679 http://jnode.svn.sourceforge.net/jnode/?rev=5679&view=rev Author: crawley Date: 2009-09-12 03:49:18 +0000 (Sat, 12 Sep 2009) Log Message: ----------- Added diagnostics for problems using a classes constant pool. Modified Paths: -------------- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -456,7 +456,7 @@ createFields(cls, fieldData, sharedStatics, isolatedStatics, slotSize, cls.getPragmaFlags()); } - + cp.setParentType(cls); return cls; } Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmAnnotation.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -255,8 +255,10 @@ itable[0] = new VmImplementedInterface(annType); implType.setInterfaceTable(itable); - return (VmNormalClass<? extends ImplBase>) loader - .defineClass(implType); + VmNormalClass<? extends ImplBase> res = (VmNormalClass<? extends ImplBase>) + loader.defineClass(implType); + cp.setParentType(res); + return res; } /** Modified: branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java =================================================================== --- branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-09-10 14:36:30 UTC (rev 5678) +++ branches/jikesRVM/core/src/core/org/jnode/vm/classmgr/VmCP.java 2009-09-12 03:49:18 UTC (rev 5679) @@ -55,6 +55,8 @@ private Object[] cp; private int used; + + private VmType parentType; /** * Construct a new VmCP with a given number of entries @@ -84,8 +86,15 @@ public int getInt(int index) { if (index == 0) return 0; - else - return ((VmConstInt) get(index)).intValue(); + else { + try { + return ((VmConstInt) get(index)).intValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstInt"); + } + } } /** @@ -105,7 +114,13 @@ * @return long */ public long getLong(int index) { - return ((VmConstLong) get(index)).longValue(); + try { + return ((VmConstLong) get(index)).longValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstLong"); + } } /** @@ -125,7 +140,13 @@ * @return float */ public float getFloat(int index) { - return ((VmConstFloat) get(index)).floatValue(); + try { + return ((VmConstFloat) get(index)).floatValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstFloat"); + } } /** @@ -145,7 +166,13 @@ * @return double */ public double getDouble(int index) { - return ((VmConstDouble) get(index)).doubleValue(); + try { + return ((VmConstDouble) get(index)).doubleValue(); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstDouble"); + } } /** @@ -159,23 +186,41 @@ } protected String getUTF8(int index) { - return (String) get(index); + try { + return (String) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a String"); + } } protected void setUTF8(int index, String value) { - set(index, InternString.internString(value)); + set(index, InternString.internString(value)); } public VmConstString getString(int index) { - return (VmConstString) get(index); + try { + return (VmConstString) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstString"); + } } protected void setString(int index, VmConstString value) { - set(index, value); + set(index, value); } public VmConstClass getConstClass(int index) { - return (VmConstClass) get(index); + try { + return (VmConstClass) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstClass"); + } } protected void setConstClass(int index, VmConstClass value) { @@ -183,7 +228,13 @@ } public VmConstFieldRef getConstFieldRef(int index) { - return (VmConstFieldRef) get(index); + try { + return (VmConstFieldRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstFieldRef"); + } } protected void setConstFieldRef(int index, VmConstFieldRef value) { @@ -191,7 +242,13 @@ } public VmConstMethodRef getConstMethodRef(int index) { - return (VmConstMethodRef) get(index); + try { + return (VmConstMethodRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstMethodRef"); + } } protected void setConstMethodRef(int index, VmConstMethodRef value) { @@ -199,7 +256,13 @@ } public VmConstIMethodRef getConstIMethodRef(int index) { - return (VmConstIMethodRef) get(index); + try { + return (VmConstIMethodRef) get(index); + } catch (ClassCastException ex) { + throw new AssertionError("CP entry at slot " + index + " for class " + + parentType.getName() + " (" + parentType.getSourceFile() + + ") is not a VmConstIMethodRef"); + } } protected void setConstIMethodRef(int index, VmConstIMethodRef value) { @@ -253,4 +316,12 @@ final void reset(int index) { cp[index] = null; } + + public VmType getParentType() { + return parentType; + } + + public void setParentType(VmType parentType) { + this.parentType = parentType; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-09-10 14:36:41
|
Revision: 5678 http://jnode.svn.sourceforge.net/jnode/?rev=5678&view=rev Author: crawley Date: 2009-09-10 14:36:30 +0000 (Thu, 10 Sep 2009) Log Message: ----------- The Eclipse project references and build paths were a bit confused which was causing intermittent build failures in Eclipse. Modified Paths: -------------- branches/jikesRVM/all/.classpath branches/jikesRVM/all/.project branches/jikesRVM/builder/.project branches/jikesRVM/cli/.project branches/jikesRVM/distr/.project branches/jikesRVM/fs/.project branches/jikesRVM/gui/.project branches/jikesRVM/net/.project branches/jikesRVM/shell/.project branches/jikesRVM/textui/.project Modified: branches/jikesRVM/all/.classpath =================================================================== --- branches/jikesRVM/all/.classpath 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/all/.classpath 2009-09-10 14:36:30 UTC (rev 5678) @@ -1,10 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="/builder"/> - <classpathentry kind="src" path="/core"/> - <classpathentry kind="src" path="/fs"/> - <classpathentry kind="src" path="/gui"/> - <classpathentry kind="src" path="/net"/> - <classpathentry kind="src" path="/shell"/> <classpathentry kind="output" path="build"/> </classpath> Modified: branches/jikesRVM/all/.project =================================================================== --- branches/jikesRVM/all/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/all/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -3,13 +3,6 @@ <name>all</name> <comment></comment> <projects> - <project>JNode-Builder</project> - <project>JNode-Core</project> - <project>JNode-Distr</project> - <project>JNode-FS</project> - <project>JNode-GUI</project> - <project>JNode-Net</project> - <project>JNode-Shell</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/builder/.project =================================================================== --- branches/jikesRVM/builder/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/builder/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -3,9 +3,8 @@ <name>builder</name> <comment></comment> <projects> - <project>all</project> - <project>JNode-Core</project> - <project>JNode-FS</project> + <project>core</project> + <project>fs</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/cli/.project =================================================================== --- branches/jikesRVM/cli/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/cli/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,6 +4,8 @@ <comment></comment> <projects> <project>core</project> + <project>fs</project> + <project>net</project> <project>shell</project> </projects> <buildSpec> Modified: branches/jikesRVM/distr/.project =================================================================== --- branches/jikesRVM/distr/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/distr/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,9 +4,10 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> - <project>JNode-GUI</project> - <project>JNode-Shell</project> + <project>core</project> + <project>gui</project> + <project>shell</project> + <project>textui</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/fs/.project =================================================================== --- branches/jikesRVM/fs/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/fs/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,8 +4,8 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> - <project>JNode-Shell</project> + <project>core</project> + <project>shell</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/gui/.project =================================================================== --- branches/jikesRVM/gui/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/gui/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,8 +4,8 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> - <project>JNode-Shell</project> + <project>core</project> + <project>shell</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/net/.project =================================================================== --- branches/jikesRVM/net/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/net/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,8 +4,8 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> - <project>JNode-Shell</project> + <project>core</project> + <project>shell</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/shell/.project =================================================================== --- branches/jikesRVM/shell/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/shell/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,7 +4,7 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> + <project>core</project> </projects> <buildSpec> <buildCommand> Modified: branches/jikesRVM/textui/.project =================================================================== --- branches/jikesRVM/textui/.project 2009-09-10 13:32:36 UTC (rev 5677) +++ branches/jikesRVM/textui/.project 2009-09-10 14:36:30 UTC (rev 5678) @@ -4,8 +4,8 @@ <comment></comment> <projects> <project>all</project> - <project>JNode-Core</project> - <project>JNode-Shell</project> + <project>core</project> + <project>shell</project> </projects> <buildSpec> <buildCommand> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cr...@us...> - 2009-09-10 13:32:49
|
Revision: 5677 http://jnode.svn.sourceforge.net/jnode/?rev=5677&view=rev Author: crawley Date: 2009-09-10 13:32:36 +0000 (Thu, 10 Sep 2009) Log Message: ----------- Delete a couple of stragglers Removed Paths: ------------- branches/jikesRVM/shell/src/shell/org/jnode/shell/command/DefaultCompilerCommand.java branches/jikesRVM/shell/src/shell/org/jnode/shell/help/InetAddressArgument.java Deleted: branches/jikesRVM/shell/src/shell/org/jnode/shell/command/DefaultCompilerCommand.java =================================================================== --- branches/jikesRVM/shell/src/shell/org/jnode/shell/command/DefaultCompilerCommand.java 2009-09-10 12:23:51 UTC (rev 5676) +++ branches/jikesRVM/shell/src/shell/org/jnode/shell/command/DefaultCompilerCommand.java 2009-09-10 13:32:36 UTC (rev 5677) @@ -1,49 +0,0 @@ -/* - * $Id: CompileCommand.java 2224 2006-01-01 12:49:03Z epr $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.command; - -import org.jnode.shell.help.Help; -import org.jnode.shell.help.IntegerArgument; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.ParsedArguments; -import org.jnode.vm.LoadCompileService; - -/** - * @author Mohammad Ansari (ans...@us...) - */ - -public class DefaultCompilerCommand { - - static final IntegerArgument ARG_LEVEL = new IntegerArgument("number", "the compiler number (usually JikesOpt is 2"); - - public static Help.Info HELP_INFO = new Help.Info("defcomp", "Set default compiler", new Parameter[] { new Parameter(ARG_LEVEL, Parameter.MANDATORY)}); - - public static void main(String[] args) throws Exception { - final ParsedArguments cmdLine = HELP_INFO.parse(args); - - final int level = ARG_LEVEL.getInteger(cmdLine); - - LoadCompileService.setDefaultCompiler(level); - System.out.println("Default compiler id now: " + level); - } - -} Deleted: branches/jikesRVM/shell/src/shell/org/jnode/shell/help/InetAddressArgument.java =================================================================== --- branches/jikesRVM/shell/src/shell/org/jnode/shell/help/InetAddressArgument.java 2009-09-10 12:23:51 UTC (rev 5676) +++ branches/jikesRVM/shell/src/shell/org/jnode/shell/help/InetAddressArgument.java 2009-09-10 13:32:36 UTC (rev 5677) @@ -1,55 +0,0 @@ -/* - * $Id: $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.help; - -import java.net.*; - -/** - * @author Martin Husted Hartvig (ha...@jn...) - */ -public class InetAddressArgument extends Argument -{ - - /** - * @param name - * @param description - */ - public InetAddressArgument(String name, String description) - { - super(name, description); - } - - /** - * @param name - * @param description - * @param multi - */ - public InetAddressArgument(String name, String description, boolean multi) - { - super(name, description, multi); - } - - public InetAddress getAddress(ParsedArguments args) throws UnknownHostException - { - return InetAddress.getByName(this.getValue(args)); - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |