< prev index next >

test/hotspot/gtest/utilities/test_lockFreeStack.cpp

Print this page
rev 53406 : 8217423: Windows gtest build fails after JDK-8212826 (Make PtrQueue free list lock-free)
Reviewed-by: XXX

*** 44,60 **** public: LockFreeStackTestElement(size_t id = 0) : _entry(), _entry1(), _id(id) {} size_t id() const { return _id; } void set_id(size_t value) { _id = value; } ! typedef LockFreeStack<Element, &entry_ptr> Stack; ! typedef LockFreeStack<Element, &entry1_ptr> Stack1; }; typedef LockFreeStackTestElement Element; ! typedef Element::Stack Stack; ! typedef Element::Stack1 Stack1; static void initialize_ids(Element* elements, size_t size) { for (size_t i = 0; i < size; ++i) { elements[i].set_id(i); } --- 44,60 ---- public: LockFreeStackTestElement(size_t id = 0) : _entry(), _entry1(), _id(id) {} size_t id() const { return _id; } void set_id(size_t value) { _id = value; } ! typedef LockFreeStack<Element, &entry_ptr> TestStack; ! typedef LockFreeStack<Element, &entry1_ptr> TestStack1; }; typedef LockFreeStackTestElement Element; ! typedef Element::TestStack TestStack; ! typedef Element::TestStack1 TestStack1; static void initialize_ids(Element* elements, size_t size) { for (size_t i = 0; i < size; ++i) { elements[i].set_id(i); }
*** 64,74 **** public: LockFreeStackTestBasics(); static const size_t nelements = 10; Element elements[nelements]; ! Stack stack; private: void initialize(); }; --- 64,74 ---- public: LockFreeStackTestBasics(); static const size_t nelements = 10; Element elements[nelements]; ! TestStack stack; private: void initialize(); };
*** 109,119 **** ASSERT_EQ(0u, stack.length()); ASSERT_TRUE(stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, prepend_one) { ! Stack other_stack; ASSERT_TRUE(other_stack.empty()); ASSERT_TRUE(other_stack.pop() == NULL); ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.top() == NULL); ASSERT_TRUE(other_stack.pop() == NULL); --- 109,119 ---- ASSERT_EQ(0u, stack.length()); ASSERT_TRUE(stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, prepend_one) { ! TestStack other_stack; ASSERT_TRUE(other_stack.empty()); ASSERT_TRUE(other_stack.pop() == NULL); ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.top() == NULL); ASSERT_TRUE(other_stack.pop() == NULL);
*** 136,146 **** ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, prepend_two) { ! Stack other_stack; ASSERT_TRUE(other_stack.empty()); ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.top() == NULL); ASSERT_TRUE(other_stack.pop() == NULL); --- 136,146 ---- ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, prepend_two) { ! TestStack other_stack; ASSERT_TRUE(other_stack.empty()); ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.top() == NULL); ASSERT_TRUE(other_stack.pop() == NULL);
*** 159,169 **** ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, two_stacks) { ! Stack1 stack1; ASSERT_TRUE(stack1.pop() == NULL); for (size_t id = 0; id < nelements; ++id) { stack1.push(elements[id]); } --- 159,169 ---- ASSERT_EQ(0u, other_stack.length()); ASSERT_TRUE(other_stack.pop() == NULL); } TEST_F(LockFreeStackTestBasics, two_stacks) { ! TestStack1 stack1; ASSERT_TRUE(stack1.pop() == NULL); for (size_t id = 0; id < nelements; ++id) { stack1.push(elements[id]); }
*** 199,220 **** ASSERT_TRUE(stack1.pop() == NULL); } class LockFreeStackTestThread : public JavaTestThread { uint _id; ! Stack* _from; ! Stack* _to; volatile size_t* _processed; size_t _process_limit; size_t _local_processed; volatile bool _ready; public: LockFreeStackTestThread(Semaphore* post, uint id, ! Stack* from, ! Stack* to, volatile size_t* processed, size_t process_limit) : JavaTestThread(post), _id(id), _from(from), --- 199,220 ---- ASSERT_TRUE(stack1.pop() == NULL); } class LockFreeStackTestThread : public JavaTestThread { uint _id; ! TestStack* _from; ! TestStack* _to; volatile size_t* _processed; size_t _process_limit; size_t _local_processed; volatile bool _ready; public: LockFreeStackTestThread(Semaphore* post, uint id, ! TestStack* from, ! TestStack* to, volatile size_t* processed, size_t process_limit) : JavaTestThread(post), _id(id), _from(from),
*** 243,256 **** bool ready() const { return OrderAccess::load_acquire(&_ready); } }; TEST_VM(LockFreeStackTest, stress) { Semaphore post; ! Stack initial_stack; ! Stack start_stack; ! Stack middle_stack; ! Stack final_stack; volatile size_t stage1_processed = 0; volatile size_t stage2_processed = 0; const size_t nelements = 10000; Element* elements = NEW_C_HEAP_ARRAY(Element, nelements, mtOther); --- 243,256 ---- bool ready() const { return OrderAccess::load_acquire(&_ready); } }; TEST_VM(LockFreeStackTest, stress) { Semaphore post; ! TestStack initial_stack; ! TestStack start_stack; ! TestStack middle_stack; ! TestStack final_stack; volatile size_t stage1_processed = 0; volatile size_t stage2_processed = 0; const size_t nelements = 10000; Element* elements = NEW_C_HEAP_ARRAY(Element, nelements, mtOther);
*** 269,280 **** const uint stage2_threads = 2; const uint nthreads = stage1_threads + stage2_threads; LockFreeStackTestThread* threads[nthreads] = {}; for (uint i = 0; i < ARRAY_SIZE(threads); ++i) { ! Stack* from = &start_stack; ! Stack* to = &middle_stack; volatile size_t* processed = &stage1_processed; if (i >= stage1_threads) { from = &middle_stack; to = &final_stack; processed = &stage2_processed; --- 269,280 ---- const uint stage2_threads = 2; const uint nthreads = stage1_threads + stage2_threads; LockFreeStackTestThread* threads[nthreads] = {}; for (uint i = 0; i < ARRAY_SIZE(threads); ++i) { ! TestStack* from = &start_stack; ! TestStack* to = &middle_stack; volatile size_t* processed = &stage1_processed; if (i >= stage1_threads) { from = &middle_stack; to = &final_stack; processed = &stage2_processed;
< prev index next >