Index: port/include/port_nonatomic.h =================================================================== --- port/include/port_nonatomic.h (revision 0) +++ port/include/port_nonatomic.h (revision 0) @@ -0,0 +1,46 @@ +/* + * 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 +* Provides explicit markers for a code region where potentially unsafe thread operations are performed, +* useful for thread analyzing tools. For example, they allows to ignore false alerts on hand-crafted +* synchronization mechanisms or "allowed" race conditions that are known/proven to not affect correctness of execution. +* Normally they do not affect behavior of code. +*/ + +#ifdef ITC +#include +#else +#define __itt_obj_mode_set(prop, state) +#endif + +/** +* Marks the beginning of code region where thread unsafe operations are performed. +* The unsafe area should be closed by UNSAFE_REGION_END. +*/ +#define UNSAFE_REGION_START __itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_set); + +/** +* Marks the end of code region where thread unsafe operation are performed. +*/ +#define UNSAFE_REGION_END __itt_obj_mode_set(__itt_obj_prop_ignore, __itt_obj_state_clr); + Index: vmcore/src/object/object_handles.cpp =================================================================== --- vmcore/src/object/object_handles.cpp (revision 526137) +++ 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); + UNSAFE_REGION_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 + UNSAFE_REGION_END ObjectHandlesNew* next = h->next; STD_FREE(h); h = next; } + UNSAFE_REGION_START #ifdef VM_STATS VM_Statistics::get_vm_stats().num_jni_handles_wasted_refs += (h->capacity - h->size); #endif //VM_STATS + UNSAFE_REGION_END } // Fill bjectHandles sructure as empty. Index: thread/src/thread_native_thin_monitor.c =================================================================== --- thread/src/thread_native_thin_monitor.c (revision 526137) +++ thread/src/thread_native_thin_monitor.c (working copy) @@ -28,6 +28,7 @@ #include "thread_private.h" #include #include +#include "port_nonatomic.h" /** @name Thin monitors support. Implement thin-fat scheme. */ @@ -75,7 +76,9 @@ #endif lockword&=0x7FF; lockword|=(monitor_id << 11) | 0x80000000; + UNSAFE_REGION_START *lockword_ptr=lockword; + UNSAFE_REGION_END apr_memory_rw_barrier(); } @@ -249,8 +252,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. - - lockword = *lockword_ptr; + UNSAFE_REGION_START + lockword = *lockword_ptr; + UNSAFE_REGION_END lock_id = THREAD_ID(lockword); //TRACE(("try lock %x %d", this_id, RECURSION(lockword)));