| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 class TestGCScope { | 224 class TestGCScope { |
| 225 public: | 225 public: |
| 226 explicit TestGCScope(ThreadState::StackState state) | 226 explicit TestGCScope(ThreadState::StackState state) |
| 227 : m_state(ThreadState::current()) | 227 : m_state(ThreadState::current()) |
| 228 , m_safePointScope(state) | 228 , m_safePointScope(state) |
| 229 , m_parkedAllThreads(false) | 229 , m_parkedAllThreads(false) |
| 230 { | 230 { |
| 231 m_state->checkThread(); | 231 m_state->checkThread(); |
| 232 if (LIKELY(ThreadState::stopThreads())) { | 232 if (LIKELY(ThreadState::stopThreads())) { |
| 233 Heap::preGC(); | 233 Heap::preGC(ThreadState::GCWithSweep); |
| 234 m_parkedAllThreads = true; | 234 m_parkedAllThreads = true; |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool allThreadsParked() { return m_parkedAllThreads; } | 238 bool allThreadsParked() { return m_parkedAllThreads; } |
| 239 | 239 |
| 240 ~TestGCScope() | 240 ~TestGCScope() |
| 241 { | 241 { |
| 242 // Only cleanup if we parked all threads in which case the GC happened | 242 // Only cleanup if we parked all threads in which case the GC happened |
| 243 // and we need to resume the other threads. | 243 // and we need to resume the other threads. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 for (int i = 0; i < numberOfAllocations; i++) { | 510 for (int i = 0; i < numberOfAllocations; i++) { |
| 511 wrapper = IntWrapper::create(0x0bbac0de); | 511 wrapper = IntWrapper::create(0x0bbac0de); |
| 512 if (!(i % 10)) { | 512 if (!(i % 10)) { |
| 513 globalPersistent = adoptPtr(new GlobalIntWrapperPersiste
nt(IntWrapper::create(0x0ed0cabb))); | 513 globalPersistent = adoptPtr(new GlobalIntWrapperPersiste
nt(IntWrapper::create(0x0ed0cabb))); |
| 514 } | 514 } |
| 515 SafePointScope scope(ThreadState::NoHeapPointersOnStack); | 515 SafePointScope scope(ThreadState::NoHeapPointersOnStack); |
| 516 Platform::current()->yieldCurrentThread(); | 516 Platform::current()->yieldCurrentThread(); |
| 517 } | 517 } |
| 518 | 518 |
| 519 if (gcCount < gcPerThread) { | 519 if (gcCount < gcPerThread) { |
| 520 // Taking snapshot shouldn't have any bad side effect. |
| 521 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr
eadState::TakeSnapshot, Heap::ForcedGC); |
| 520 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr
eadState::GCWithSweep, Heap::ForcedGC); | 522 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, Thr
eadState::GCWithSweep, Heap::ForcedGC); |
| 521 gcCount++; | 523 gcCount++; |
| 522 atomicIncrement(&m_gcCount); | 524 atomicIncrement(&m_gcCount); |
| 523 } | 525 } |
| 524 | 526 |
| 527 // Taking snapshot shouldn't have any bad side effect. |
| 528 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS
tate::TakeSnapshot, Heap::ForcedGC); |
| 525 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS
tate::GCWithSweep, Heap::ForcedGC); | 529 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack, ThreadS
tate::GCWithSweep, Heap::ForcedGC); |
| 526 EXPECT_EQ(wrapper->value(), 0x0bbac0de); | 530 EXPECT_EQ(wrapper->value(), 0x0bbac0de); |
| 527 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb); | 531 EXPECT_EQ((*globalPersistent)->value(), 0x0ed0cabb); |
| 528 } | 532 } |
| 529 SafePointScope scope(ThreadState::NoHeapPointersOnStack); | 533 SafePointScope scope(ThreadState::NoHeapPointersOnStack); |
| 530 Platform::current()->yieldCurrentThread(); | 534 Platform::current()->yieldCurrentThread(); |
| 531 } | 535 } |
| 532 ThreadState::detach(); | 536 ThreadState::detach(); |
| 533 atomicDecrement(&m_threadsToFinish); | 537 atomicDecrement(&m_threadsToFinish); |
| 534 } | 538 } |
| (...skipping 5575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6110 { | 6114 { |
| 6111 Persistent<ClassWithMember> object = ClassWithMember::create(); | 6115 Persistent<ClassWithMember> object = ClassWithMember::create(); |
| 6112 EXPECT_EQ(0, object->traceCount()); | 6116 EXPECT_EQ(0, object->traceCount()); |
| 6113 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); | 6117 TestMixinAllocatingObject* mixin = TestMixinAllocatingObject::create(object.
get()); |
| 6114 EXPECT_TRUE(mixin); | 6118 EXPECT_TRUE(mixin); |
| 6115 EXPECT_GT(object->traceCount(), 0); | 6119 EXPECT_GT(object->traceCount(), 0); |
| 6116 EXPECT_GT(mixin->traceCount(), 0); | 6120 EXPECT_GT(mixin->traceCount(), 0); |
| 6117 } | 6121 } |
| 6118 | 6122 |
| 6119 } // namespace blink | 6123 } // namespace blink |
| OLD | NEW |