src/share/vm/prims/unsafe.cpp

changeset 8368
32b682649973
parent 7547
f46871c6c063
child 8415
d109bda16490
     1.1 --- a/src/share/vm/prims/unsafe.cpp	Mon Jan 11 13:41:45 2016 -0800
     1.2 +++ b/src/share/vm/prims/unsafe.cpp	Fri Jan 15 22:33:15 2016 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -156,13 +156,22 @@
    1.11  
    1.12  ///// Data in the Java heap.
    1.13  
    1.14 +#define truncate_jboolean(x) ((x) & 1)
    1.15 +#define truncate_jbyte(x) (x)
    1.16 +#define truncate_jshort(x) (x)
    1.17 +#define truncate_jchar(x) (x)
    1.18 +#define truncate_jint(x) (x)
    1.19 +#define truncate_jlong(x) (x)
    1.20 +#define truncate_jfloat(x) (x)
    1.21 +#define truncate_jdouble(x) (x)
    1.22 +
    1.23  #define GET_FIELD(obj, offset, type_name, v) \
    1.24    oop p = JNIHandles::resolve(obj); \
    1.25    type_name v = *(type_name*)index_oop_from_field_offset_long(p, offset)
    1.26  
    1.27  #define SET_FIELD(obj, offset, type_name, x) \
    1.28    oop p = JNIHandles::resolve(obj); \
    1.29 -  *(type_name*)index_oop_from_field_offset_long(p, offset) = x
    1.30 +  *(type_name*)index_oop_from_field_offset_long(p, offset) = truncate_##type_name(x)
    1.31  
    1.32  #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \
    1.33    oop p = JNIHandles::resolve(obj); \
    1.34 @@ -173,7 +182,7 @@
    1.35  
    1.36  #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \
    1.37    oop p = JNIHandles::resolve(obj); \
    1.38 -  OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x);
    1.39 +  OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), truncate_##type_name(x));
    1.40  
    1.41  // Macros for oops that check UseCompressedOops
    1.42  

mercurial