comparison src/share/vm/code/nmethod.hpp @ 20227:63e0c47ca943

8050972: Concurrency problem in PcDesc cache Summary: The entries of the PcDesc cache in nmethods are not declared as volatile, but they are accessed and modified by several threads concurrently. Reviewed-by: kvn, dholmes, dcubed
author mdoerr
date Thu, 17 Jul 2014 10:21:31 +0200
parents 606acabe7b5c
children 9717199cb8de
comparison
equal deleted inserted replaced
20226:6ad19ab94176 20227:63e0c47ca943
67 // cache pc descs found in earlier inquiries 67 // cache pc descs found in earlier inquiries
68 class PcDescCache VALUE_OBJ_CLASS_SPEC { 68 class PcDescCache VALUE_OBJ_CLASS_SPEC {
69 friend class VMStructs; 69 friend class VMStructs;
70 private: 70 private:
71 enum { cache_size = 4 }; 71 enum { cache_size = 4 };
72 PcDesc* _pc_descs[cache_size]; // last cache_size pc_descs found 72 // The array elements MUST be volatile! Several threads may modify
73 // and read from the cache concurrently. find_pc_desc_internal has
74 // returned wrong results. C++ compiler (namely xlC12) may duplicate
75 // C++ field accesses if the elements are not volatile.
76 typedef PcDesc* PcDescPtr;
77 volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found
73 public: 78 public:
74 PcDescCache() { debug_only(_pc_descs[0] = NULL); } 79 PcDescCache() { debug_only(_pc_descs[0] = NULL); }
75 void reset_to(PcDesc* initial_pc_desc); 80 void reset_to(PcDesc* initial_pc_desc);
76 PcDesc* find_pc_desc(int pc_offset, bool approximate); 81 PcDesc* find_pc_desc(int pc_offset, bool approximate);
77 void add_pc_desc(PcDesc* pc_desc); 82 void add_pc_desc(PcDesc* pc_desc);