12 TEST(SamplingCircularQueue) {
13 typedef SamplingCircularQueue::Cell Record;
14 const int kRecordsPerChunk = 4;
15 SamplingCircularQueue scq(
sizeof(Record),
16 kRecordsPerChunk *
sizeof(Record),
20 CHECK_NE(SamplingCircularQueue::kClear, 1);
21 CHECK_NE(SamplingCircularQueue::kEnd, 1);
24 for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) {
25 Record* rec =
reinterpret_cast<Record*
>(scq.Enqueue());
33 for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) {
34 Record* rec =
reinterpret_cast<Record*
>(scq.Enqueue());
40 Record* rec =
reinterpret_cast<Record*
>(scq.Enqueue());
48 for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) {
49 Record* rec =
reinterpret_cast<Record*
>(scq.StartDequeue());
51 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
52 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
54 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
60 scq.FlushResidualRecords();
65 for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) {
66 Record* rec =
reinterpret_cast<Record*
>(scq.StartDequeue());
68 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
69 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
71 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
83 typedef SamplingCircularQueue::Cell Record;
85 ProducerThread(SamplingCircularQueue* scq,
86 int records_per_chunk,
91 records_per_chunk_(records_per_chunk),
93 finished_(finished) { }
96 for (Record i = value_; i < value_ + records_per_chunk_; ++i) {
97 Record* rec =
reinterpret_cast<Record*
>(scq_->Enqueue());
106 SamplingCircularQueue* scq_;
107 const int records_per_chunk_;
114 TEST(SamplingCircularQueueMultithreading) {
120 typedef ProducerThread::Record Record;
121 const int kRecordsPerChunk = 4;
122 SamplingCircularQueue scq(
sizeof(Record),
123 kRecordsPerChunk *
sizeof(Record),
128 scq.FlushResidualRecords();
131 CHECK_NE(SamplingCircularQueue::kClear, 1);
132 CHECK_NE(SamplingCircularQueue::kEnd, 1);
133 ProducerThread producer1(&scq, kRecordsPerChunk, 1, semaphore);
134 ProducerThread producer2(&scq, kRecordsPerChunk, 10, semaphore);
135 ProducerThread producer3(&scq, kRecordsPerChunk, 20, semaphore);
140 for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) {
141 Record* rec =
reinterpret_cast<Record*
>(scq.StartDequeue());
143 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
144 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
146 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
152 for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) {
153 Record* rec =
reinterpret_cast<Record*
>(scq.StartDequeue());
155 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
156 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
158 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
164 for (Record i = 20; i < 20 + kRecordsPerChunk; ++i) {
165 Record* rec =
reinterpret_cast<Record*
>(scq.StartDequeue());
167 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
168 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
170 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
#define CHECK_EQ(expected, value)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
#define CHECK_NE(unexpected, value)
static Semaphore * CreateSemaphore(int count)
v8::internal::Semaphore * semaphore
TEST(SamplingCircularQueue)