Home | History | Annotate | Download | only in cctest

Lines Matching refs:v8

1 // Copyright 2010 the V8 project authors. All rights reserved.
5 #include "v8.h"
8 #include "../include/v8-profiler.h"
24 namespace v8 {
34 } } // namespace v8::internal
39 v8::HandleScope hs;
40 v8::Local<v8::String> token1(v8::String::New("1x"));
41 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
42 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
43 v8::Local<v8::String> token2(v8::String::New("2x"));
44 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
45 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
46 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
48 v8::HandleScope hs;
49 v8::Local<v8::String> token3(v8::String::New("3x"));
50 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3)));
51 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
52 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
57 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
58 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
693 class ProfilerExtension : public v8::Extension {
695 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
696 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
697 v8::Handle<v8::String> name);
698 static v8::Handle<v8::Value> StartProfiling(const v8::Arguments& args);
699 static v8::Handle<v8::Value> StopProfiling(const v8::Arguments& args);
709 v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
710 v8::Handle<v8::String> name) {
711 if (name->Equals(v8::String::New("startProfiling"))) {
712 return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
713 } else if (name->Equals(v8::String::New("stopProfiling"))) {
714 return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
717 return v8::Handle<v8::FunctionTemplate>();
722 v8::Handle<v8::Value> ProfilerExtension::StartProfiling(
723 const v8::Arguments& args) {
725 v8::CpuProfiler::StartProfiling(args[0].As<v8::String>());
727 v8::CpuProfiler::StartProfiling(v8::String::New(""));
728 return v8::Undefined();
732 v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
733 const v8::Arguments& args) {
735 v8::CpuProfiler::StopProfiling(args[0].As<v8::String>());
737 v8::CpuProfiler::StopProfiling(v8::String::New(""));
738 return v8::Undefined();
743 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
744 static v8::Persistent<v8::Context> env;
762 v8::HandleScope scope;
763 const char* extensions[] = { "v8/profiler" };
764 v8::ExtensionConfiguration config(1, extensions);
765 env = v8::Context::New(&config);
767 v8::HandleScope scope;