Source Code Cross Referenced for VMHelper.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » drlvm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.apache.harmony.drlvm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Mikhail Y. Fursov
019:         */package org.apache.harmony.drlvm;
020:
021:        import org.vmmagic.unboxed.*;
022:        import org.vmmagic.pragma.*;
023:
024:        /**
025:         Core class for DRLVM's vmmagic based helpers.
026:         Resolved and initilized during VM startup
027:        
028:         Note: All classes with vmmagic based helpers registred in VM are also resolved and initialized at VM startup
029:         Note: If you need to initialize another DRLVM's specific utility class related to vmmagic infrastructure
030:         refer to it from static section of this class: and it will also be automatically initialized
031:         */
032:        public class VMHelper {
033:
034:            //public constants
035:
036:            public static final int POINTER_TYPE_SIZE = getPointerTypeSize();
037:
038:            public static final boolean COMPRESSED_REFS_MODE = isCompressedRefsMode();
039:
040:            public static final boolean COMPRESSED_VTABLE_MODE = isCompressedVTableMode();
041:
042:            public static final long COMPRESSED_VTABLE_BASE_OFFSET = getCompressedModeVTableBaseOffset();
043:
044:            public static final long COMPRESSED_REFS_OBJ_BASE_OFFSET = getCompressedModeObjectBaseOffset();
045:
046:            public static final int OBJ_VTABLE_OFFSET = getObjectVtableOffset();
047:
048:            public static final int VTABLE_GCPRIVATE_OFFSET = 0;
049:
050:            public static final int VTABLE_CLASS_OFFSET = getVtableClassOffset();
051:
052:            public static final int OBJ_INFO_OFFSET = 4;
053:
054:            public static final int CLASS_JLC_HANDLE_OFFSET = getClassJLCHanldeOffset();
055:
056:            // preload @Inline vmmagic class
057:            static final Class pragmaInline = org.vmmagic.pragma.Inline.class;
058:            static final Class threadHelper = org.apache.harmony.drlvm.thread.ThreadHelper.class;
059:            static final Class vmFastPathes = org.apache.harmony.drlvm.VMHelperFastPath.class;
060:
061:            //Slow path versions of helpers
062:
063:            //TODO: allocation handle is int only on 32bit OS or (64bit OS && compressed mode)
064:            public static Address newResolvedUsingAllocHandleAndSize(
065:                    int objSize, int allocationHandle) {
066:                fail();
067:                return null;
068:            }
069:
070:            //TODO: allocation handle is int only on 32bit OS or (64bit OS && compressed mode)
071:            public static Address newVectorUsingAllocHandle(int arrayLen,
072:                    int allocationHandle) {
073:                fail();
074:                return null;
075:            }
076:
077:            public static void monitorEnter(Object obj) {
078:                fail();
079:            }
080:
081:            public static void monitorExit(Object obj) {
082:                fail();
083:            }
084:
085:            public static void memset0(Address addr, int size) {
086:                fail();
087:            }
088:
089:            public static void prefetch(Address addr, int distance, int stride) {
090:                fail();
091:            }
092:
093:            public static void writeBarrier(Address objBase, Address objSlot,
094:                    Address source) {
095:                fail();
096:            }
097:
098:            public static Address getInterfaceVTable(Object obj,
099:                    Address intfTypePtr) {
100:                fail();
101:                return null;
102:            }
103:
104:            public static void checkCast(Object obj, Address castTypePtr) {
105:                fail();
106:            }
107:
108:            public static boolean instanceOf(Object obj, Address castTypePtr) {
109:                fail();
110:                return false;
111:            }
112:
113:            //utility magics supported by JIT
114:
115:            public static boolean isVMMagicPackageSupported() {
116:                return false;
117:            }
118:
119:            public static Address getTlsBaseAddress() {
120:                fail();
121:                return null;
122:            }
123:
124:            public static boolean isArray(Address classHandle) {
125:                VMHelper.fail();
126:                return false;
127:            }
128:
129:            public static boolean isInterface(Address classHandle) {
130:                VMHelper.fail();
131:                return false;
132:            }
133:
134:            public static boolean isFinal(Address classHandle) {
135:                VMHelper.fail();
136:                return false;
137:            }
138:
139:            public static Address getArrayClass(Address elemClassHandle) {
140:                VMHelper.fail();
141:                return null;
142:            }
143:
144:            public static int getAllocationHandle(Address classHandle) {
145:                VMHelper.fail();
146:                return 0;
147:            }
148:
149:            public static int getTypeSize(Address classHandle) {
150:                VMHelper.fail();
151:                return 0;
152:            }
153:
154:            public static int getArrayElemSize(Address arrayClassHandle) {
155:                VMHelper.fail();
156:                return 0;
157:            }
158:
159:            public static int getFastTypeCheckDepth(Address classHandle) {
160:                VMHelper.fail();
161:                return 0;
162:            }
163:
164:            protected static void fail() {
165:                throw new RuntimeException("Not supported!");
166:            }
167:
168:            //helpers implemented with magics
169:
170:            @Inline
171:            public static Address getVTable(Object obj) {
172:                Address objAddr = ObjectReference.fromObject(obj).toAddress();
173:                if (COMPRESSED_VTABLE_MODE) {
174:                    int compressedAddr = objAddr.loadInt(Offset
175:                            .fromIntZeroExtend(OBJ_VTABLE_OFFSET));
176:                    return Address.fromLong(compressedAddr
177:                            + COMPRESSED_VTABLE_BASE_OFFSET);
178:                }
179:                return objAddr.loadAddress(Offset
180:                        .fromIntZeroExtend(OBJ_VTABLE_OFFSET));
181:            }
182:
183:            @Inline
184:            public static Address getNativeClass(Object obj) {
185:                Address nativeClass = getVTable(obj).loadAddress(
186:                        Offset.fromIntZeroExtend(VTABLE_CLASS_OFFSET));
187:                return nativeClass;
188:            }
189:
190:            @Inline
191:            public static Address getManagedClass(Object obj) {
192:                //accessing to ManagedObject** m_class_handle field + 1 dereference in Class.h
193:                Address moAddr = getNativeClass(obj).loadAddress(
194:                        Offset.fromIntZeroExtend(CLASS_JLC_HANDLE_OFFSET))
195:                        .loadAddress();
196:                return moAddr;
197:            }
198:
199:            // private area
200:
201:            private VMHelper() {
202:            }
203:
204:            /** @return vtable offset in managed object structure */
205:            private static native int getObjectVtableOffset();
206:
207:            /** @return pointer-type size. 4 or 8 */
208:            private static native int getPointerTypeSize();
209:
210:            /** @return true if VM is run in compressed reference mode */
211:            private static native boolean isCompressedRefsMode();
212:
213:            /** @return true if VM is run in compressed vtables mode */
214:            private static native boolean isCompressedVTableMode();
215:
216:            /** @return vtable base offset if is in compressed-refs mode or -1*/
217:            private static native long getCompressedModeVTableBaseOffset();
218:
219:            /** @return object base offset if is in compressed-refs mode or -1*/
220:            private static native long getCompressedModeObjectBaseOffset();
221:
222:            /** @return native Class* struct offset in vtable*/
223:            private static native int getVtableClassOffset();
224:
225:            /** @return managed object field offset in vtable*/
226:            private static native int getClassJLCHanldeOffset();
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.