src/share/vm/prims/unsafe.cpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 














  25 /*
  26  *      Implementation of class sun.misc.Unsafe
  27  */
  28 
  29 #include "incls/_precompiled.incl"
  30 #include "incls/_unsafe.cpp.incl"
  31 
  32 HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long);
  33 HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t);
  34 HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t);
  35 
  36 #define MAX_OBJECT_SIZE \
  37   ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \
  38     + ((julong)max_jint * sizeof(double)) )
  39 
  40 
  41 #define UNSAFE_ENTRY(result_type, header) \
  42   JVM_ENTRY(result_type, header)
  43 
  44 // Can't use UNSAFE_LEAF because it has the signature of a straight
  45 // call into the runtime (just like JVM_LEAF, funny that) but it's
  46 // called like a Java Native and thus the wrapper built for it passes
  47 // arguments like a JNI call.  It expects those arguments to be popped
  48 // from the stack on Intel like all good JNI args are, and adjusts the
  49 // stack according.  Since the JVM_LEAF call expects no extra
  50 // arguments the stack isn't popped in the C code, is pushed by the
  51 // wrapper and we get sick.


   1 /*
   2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/vmSymbols.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "prims/jni.h"
  29 #include "prims/jvm.h"
  30 #include "runtime/globals.hpp"
  31 #include "runtime/interfaceSupport.hpp"
  32 #include "runtime/reflection.hpp"
  33 #include "runtime/reflectionCompat.hpp"
  34 #include "runtime/synchronizer.hpp"
  35 #include "services/threadService.hpp"
  36 #include "utilities/copy.hpp"
  37 #include "utilities/dtrace.hpp"
  38 
  39 /*
  40  *      Implementation of class sun.misc.Unsafe
  41  */
  42 



  43 HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long);
  44 HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t);
  45 HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t);
  46 
  47 #define MAX_OBJECT_SIZE \
  48   ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \
  49     + ((julong)max_jint * sizeof(double)) )
  50 
  51 
  52 #define UNSAFE_ENTRY(result_type, header) \
  53   JVM_ENTRY(result_type, header)
  54 
  55 // Can't use UNSAFE_LEAF because it has the signature of a straight
  56 // call into the runtime (just like JVM_LEAF, funny that) but it's
  57 // called like a Java Native and thus the wrapper built for it passes
  58 // arguments like a JNI call.  It expects those arguments to be popped
  59 // from the stack on Intel like all good JNI args are, and adjusts the
  60 // stack according.  Since the JVM_LEAF call expects no extra
  61 // arguments the stack isn't popped in the C code, is pushed by the
  62 // wrapper and we get sick.