Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: test/cctest/profiler-extension.cc

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/profiler-extension.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/profiler-extension.cc
diff --git a/src/extensions/free-buffer-extension.cc b/test/cctest/profiler-extension.cc
similarity index 52%
copy from src/extensions/free-buffer-extension.cc
copy to test/cctest/profiler-extension.cc
index 5cf2b68146c9d325096b6f94172bca55d498c2fa..7b0b099fa751c49bfa1b0fba396d6ae43508f294 100644
--- a/src/extensions/free-buffer-extension.cc
+++ b/test/cctest/profiler-extension.cc
@@ -24,37 +24,49 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Tests of profiles generator and utilities.
-#include "free-buffer-extension.h"
-#include "platform.h"
-#include "v8.h"
+#include "profiler-extension.h"
-namespace v8 {
-namespace internal {
+#include "cctest.h"
+const v8::CpuProfile* ProfilerExtension::last_profile = NULL;
+const char* ProfilerExtension::kSource =
+ "native function startProfiling();"
+ "native function stopProfiling();";
-v8::Handle<v8::FunctionTemplate> FreeBufferExtension::GetNativeFunctionTemplate(
- v8::Isolate* isolate,
- v8::Handle<v8::String> str) {
- return v8::FunctionTemplate::New(FreeBufferExtension::FreeBuffer);
+v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
+ v8::Isolate* isolate, v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) {
+ return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
+ } else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) {
+ return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
+ } else {
+ CHECK(false);
+ return v8::Handle<v8::FunctionTemplate>();
+ }
}
-void FreeBufferExtension::FreeBuffer(
+void ProfilerExtension::StartProfiling(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- v8::Handle<v8::ArrayBuffer> arrayBuffer = args[0].As<v8::ArrayBuffer>();
- v8::ArrayBuffer::Contents contents = arrayBuffer->Externalize();
- V8::ArrayBufferAllocator()->Free(contents.Data(), contents.ByteLength());
+ last_profile = NULL;
+ v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
+ cpu_profiler->StartCpuProfiling((args.Length() > 0)
+ ? args[0].As<v8::String>()
+ : v8::String::Empty(args.GetIsolate()));
}
-void FreeBufferExtension::Register() {
- static char buffer[100];
- Vector<char> temp_vector(buffer, sizeof(buffer));
- OS::SNPrintF(temp_vector, "native function freeBuffer();");
-
- static FreeBufferExtension buffer_free_extension(buffer);
- static v8::DeclareExtension declaration(&buffer_free_extension);
+void ProfilerExtension::StopProfiling(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
+ last_profile = cpu_profiler->StopCpuProfiling((args.Length() > 0)
+ ? args[0].As<v8::String>()
+ : v8::String::Empty(args.GetIsolate()));
}
-} } // namespace v8::internal
+
+static ProfilerExtension kProfilerExtension;
+v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
« no previous file with comments | « test/cctest/profiler-extension.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698