Index: port/include/port_nonatomic.h =================================================================== --- port/include/port_nonatomic.h (revision 0) +++ port/include/port_nonatomic.h (revision 0) @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* @author Intel, Leviev Ilia +* @version $Revision: $ +*/ + +/** +* @file +* Nonatomic operations. +* Nonatomic operation functions intended for marking a code region where thread unsafe operation are performed. +*/ + +#ifdef ITC +#include +#else +#define __itt_obj_mode_set(prop, state) +#endif +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +#define INLINE inline +#else +#ifdef WIN32 +#define INLINE __forceinline +#else +#define INLINE static +#endif +#endif + +/** +* The function open code region where nonatomic and thread unsafe operations are performed. +* The nonatomic area should be closed by port_nonatomic_operation_end() function. +*/ +INLINE void port_nonatomic_operation_start() { + +__itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_set); + +} + +/** +* The function close code region where unatomic and thread unsafe operation are performed. +*/ +INLINE void port_nonatomic_operation_end() { + +__itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_clr); + +} + +#ifdef __cplusplus +} +#endif Index: vmcore/src/object/object_handles.cpp =================================================================== --- vmcore/src/object/object_handles.cpp (revision 522820) +++ vmcore/src/object/object_handles.cpp (working copy) @@ -38,6 +38,7 @@ #include "open/types.h" #include "open/vm_util.h" #include "vtable.h" +#include "port_nonatomic.h" #ifndef NDEBUG // this is for managed object sanity checks @@ -459,6 +460,7 @@ { ObjectHandlesNew* h = (ObjectHandlesNew*)head; assert(h); + port_nonatomic_operation_start(); #ifdef VM_STATS VM_Statistics::get_vm_stats().num_free_local_called++; if(h->next != NULL) @@ -471,13 +473,16 @@ VM_Statistics::get_vm_stats().num_jni_handles_freed++; VM_Statistics::get_vm_stats().num_jni_handles_wasted_refs += (h->capacity - size); #endif //VM_STATS + port_nonatomic_operation_end(); ObjectHandlesNew* next = h->next; STD_FREE(h); h = next; } + port_nonatomic_operation_start(); #ifdef VM_STATS VM_Statistics::get_vm_stats().num_jni_handles_wasted_refs += (h->capacity - h->size); #endif //VM_STATS + port_nonatomic_operation_end(); } // Fill bjectHandles sructure as empty. Index: thread/src/thread_native_thin_monitor.c =================================================================== --- thread/src/thread_native_thin_monitor.c (revision 522820) +++ thread/src/thread_native_thin_monitor.c (working copy) @@ -28,7 +28,7 @@ #include "thread_private.h" #include #include - +#include "port_nonatomic.h" /** @name Thin monitors support. Implement thin-fat scheme. */ //@{ @@ -75,7 +75,9 @@ #endif lockword&=0x7FF; lockword|=(monitor_id << 11) | 0x80000000; + port_nonatomic_operation_start(); *lockword_ptr=lockword; + port_nonatomic_operation_end(); apr_memory_rw_barrier(); } @@ -249,8 +251,9 @@ // is only modified without compare-and-exchange by owner thread. If tools // like Intel Thread Checker find a bug about this line, it may actually be a // false-positive. - + port_nonatomic_operation_start(); lockword = *lockword_ptr; + port_nonatomic_operation_end(); lock_id = THREAD_ID(lockword); //TRACE(("try lock %x %d", this_id, RECURSION(lockword)));