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)
#define CHECK_NE(unexpected, value)
static Semaphore * CreateSemaphore(int count)
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
v8::internal::Semaphore * semaphore
TEST(SamplingCircularQueue)