| Index: test/cctest/profiler-extension.cc
|
| diff --git a/src/marking-thread.cc b/test/cctest/profiler-extension.cc
|
| similarity index 54%
|
| copy from src/marking-thread.cc
|
| copy to test/cctest/profiler-extension.cc
|
| index 574485abc7b1c7ae36c2cc04d1a2d2e663fa2921..12366934553c805752edb9077cca0a135da03e9c 100644
|
| --- a/src/marking-thread.cc
|
| +++ b/test/cctest/profiler-extension.cc
|
| @@ -25,64 +25,53 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -#include "marking-thread.h"
|
| -
|
| #include "v8.h"
|
|
|
| -#include "isolate.h"
|
| -#include "v8threads.h"
|
| +#include "profiler-extension.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
|
|
| -MarkingThread::MarkingThread(Isolate* isolate)
|
| - : Thread("MarkingThread"),
|
| - isolate_(isolate),
|
| - heap_(isolate->heap()),
|
| - start_marking_semaphore_(OS::CreateSemaphore(0)),
|
| - end_marking_semaphore_(OS::CreateSemaphore(0)),
|
| - stop_semaphore_(OS::CreateSemaphore(0)) {
|
| - NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
|
| - id_ = NoBarrier_AtomicIncrement(&id_counter_, 1);
|
| -}
|
| -
|
| -
|
| -Atomic32 MarkingThread::id_counter_ = -1;
|
| -
|
| -
|
| -void MarkingThread::Run() {
|
| - Isolate::SetIsolateThreadLocals(isolate_, NULL);
|
| - DisallowHeapAllocation no_allocation;
|
| - DisallowHandleAllocation no_handles;
|
| - DisallowHandleDereference no_deref;
|
| -
|
| - while (true) {
|
| - start_marking_semaphore_->Wait();
|
| -
|
| - if (Acquire_Load(&stop_thread_)) {
|
| - stop_semaphore_->Signal();
|
| - return;
|
| - }
|
| -
|
| - end_marking_semaphore_->Signal();
|
| +const char* ProfilerExtension::kName = "v8/profiler";
|
| +const char* ProfilerExtension::kSource =
|
| + "native function startProfiling();"
|
| + "native function stopProfiling();";
|
| +
|
| +v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
|
| + v8::Handle<v8::String> name) {
|
| + if (name->Equals(v8::String::New("startProfiling"))) {
|
| + return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
|
| + } else if (name->Equals(v8::String::New("stopProfiling"))) {
|
| + return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
|
| + } else {
|
| + FATAL("unknown function was requested");
|
| + return v8::Handle<v8::FunctionTemplate>();
|
| }
|
| }
|
|
|
|
|
| -void MarkingThread::Stop() {
|
| - Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
|
| - start_marking_semaphore_->Signal();
|
| - stop_semaphore_->Wait();
|
| +v8::Handle<v8::Value> ProfilerExtension::StartProfiling(
|
| + const v8::Arguments& args) {
|
| + v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
|
| + cpu_profiler->StartCpuProfiling(args.Length() > 0 ?
|
| + args[0].As<v8::String>() :
|
| + v8::String::New(""));
|
| + return v8::Undefined();
|
| }
|
|
|
|
|
| -void MarkingThread::StartMarking() {
|
| - start_marking_semaphore_->Signal();
|
| +v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
|
| + const v8::Arguments& args) {
|
| + v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
|
| + cpu_profiler->StopCpuProfiling(args.Length() > 0 ?
|
| + args[0].As<v8::String>() :
|
| + v8::String::New(""));
|
| + return v8::Undefined();
|
| }
|
|
|
|
|
| -void MarkingThread::WaitForMarkingThread() {
|
| - end_marking_semaphore_->Wait();
|
| -}
|
| +static ProfilerExtension kProfilerExtension;
|
| +v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
|
| +
|
|
|
| } } // namespace v8::internal
|
|
|