v8/src/platform-nullos.cc
yurys@chromium.org c7ce87f865 Add sanity test for CPU profiler
The new test checks full CPU profiling cycle: using public
V8 API it starts profiling, executes a script, stops profiling
and analyzes collected profile to check that its top-down
tree has expected strutcture. The script that is being profiled
is guaranteed to run > 200ms to make sure enough samples
are collected.

To avoid possible flakiness due to non-deterministic time required
to start new thread on varios OSs when Sampler and ProfilerEventsProcessor
threads are being started the main thread is blocked until the threads
are running.

Also I removed the heuristic in profile-generator.cc where we try
to figure out if the value on top of the sampled stack is return address
of some frameless stub invocation. The code periodically gives false positive
with the new test ending up in an extra node in the collected cpu profile.
After discussion with jkummerow@ we concluded that the logic is too fragile
and that we can address frameless stub invocations in a more reliable way
later should they have a noticeable effect on cpu profiling.

BUG=None

Review URL: https://codereview.chromium.org/13627002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14205 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2013-04-10 09:47:44 +00:00

530 lines
9.3 KiB
C++

// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// 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.
// Platform specific code for NULLOS goes here
// Minimal include to get access to abort, fprintf and friends for bootstrapping
// messages.
#include <stdio.h>
#include <stdlib.h>
#include "v8.h"
#include "platform.h"
#include "vm-state-inl.h"
namespace v8 {
namespace internal {
// Give V8 the opportunity to override the default ceil behaviour.
double ceiling(double x) {
UNIMPLEMENTED();
return 0;
}
// Give V8 the opportunity to override the default fmod behavior.
double modulo(double x, double y) {
UNIMPLEMENTED();
return 0;
}
double fast_sin(double x) {
UNIMPLEMENTED();
return 0;
}
double fast_cos(double x) {
UNIMPLEMENTED();
return 0;
}
double fast_tan(double x) {
UNIMPLEMENTED();
return 0;
}
double fast_log(double x) {
UNIMPLEMENTED();
return 0;
}
// Initialize OS class early in the V8 startup.
void OS::SetUp() {
// Seed the random number generator.
UNIMPLEMENTED();
}
void OS::PostSetUp() {
UNIMPLEMENTED();
}
void OS::TearDown() {
UNIMPLEMENTED();
}
// Returns the accumulated user time for thread.
int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
UNIMPLEMENTED();
*secs = 0;
*usecs = 0;
return 0;
}
// Returns current time as the number of milliseconds since
// 00:00:00 UTC, January 1, 1970.
double OS::TimeCurrentMillis() {
UNIMPLEMENTED();
return 0;
}
// Returns ticks in microsecond resolution.
int64_t OS::Ticks() {
UNIMPLEMENTED();
return 0;
}
// Returns a string identifying the current timezone taking into
// account daylight saving.
const char* OS::LocalTimezone(double time) {
UNIMPLEMENTED();
return "<none>";
}
// Returns the daylight savings offset in milliseconds for the given time.
double OS::DaylightSavingsOffset(double time) {
UNIMPLEMENTED();
return 0;
}
int OS::GetLastError() {
UNIMPLEMENTED();
return 0;
}
// Returns the local time offset in milliseconds east of UTC without
// taking daylight savings time into account.
double OS::LocalTimeOffset() {
UNIMPLEMENTED();
return 0;
}
// Print (debug) message to console.
void OS::Print(const char* format, ...) {
UNIMPLEMENTED();
}
// Print (debug) message to console.
void OS::VPrint(const char* format, va_list args) {
// Minimalistic implementation for bootstrapping.
vfprintf(stdout, format, args);
}
void OS::FPrint(FILE* out, const char* format, ...) {
va_list args;
va_start(args, format);
VFPrint(out, format, args);
va_end(args);
}
void OS::VFPrint(FILE* out, const char* format, va_list args) {
vfprintf(out, format, args);
}
// Print error message to console.
void OS::PrintError(const char* format, ...) {
// Minimalistic implementation for bootstrapping.
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
// Print error message to console.
void OS::VPrintError(const char* format, va_list args) {
// Minimalistic implementation for bootstrapping.
vfprintf(stderr, format, args);
}
int OS::SNPrintF(char* str, size_t size, const char* format, ...) {
UNIMPLEMENTED();
return 0;
}
int OS::VSNPrintF(char* str, size_t size, const char* format, va_list args) {
UNIMPLEMENTED();
return 0;
}
uint64_t OS::CpuFeaturesImpliedByPlatform() {
return 0;
}
double OS::nan_value() {
UNIMPLEMENTED();
return 0;
}
CpuImplementer OS::GetCpuImplementer() {
UNIMPLEMENTED();
}
bool OS::ArmCpuHasFeature(CpuFeature feature) {
UNIMPLEMENTED();
}
bool OS::ArmUsingHardFloat() {
UNIMPLEMENTED();
}
bool OS::IsOutsideAllocatedSpace(void* address) {
UNIMPLEMENTED();
return false;
}
size_t OS::AllocateAlignment() {
UNIMPLEMENTED();
return 0;
}
void* OS::Allocate(const size_t requested,
size_t* allocated,
bool executable) {
UNIMPLEMENTED();
return NULL;
}
void OS::Free(void* buf, const size_t length) {
// TODO(1240712): potential system call return value which is ignored here.
UNIMPLEMENTED();
}
void OS::Guard(void* address, const size_t size) {
UNIMPLEMENTED();
}
void OS::Sleep(int milliseconds) {
UNIMPLEMENTED();
}
int OS::NumberOfCores() {
UNIMPLEMENTED();
return 0;
}
void OS::Abort() {
// Minimalistic implementation for bootstrapping.
abort();
}
void OS::DebugBreak() {
UNIMPLEMENTED();
}
void OS::DumpBacktrace() {
// Currently unsupported.
}
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
UNIMPLEMENTED();
return NULL;
}
OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
void* initial) {
UNIMPLEMENTED();
return NULL;
}
void OS::LogSharedLibraryAddresses() {
UNIMPLEMENTED();
}
void OS::SignalCodeMovingGC() {
UNIMPLEMENTED();
}
int OS::StackWalk(Vector<OS::StackFrame> frames) {
UNIMPLEMENTED();
return 0;
}
VirtualMemory::VirtualMemory(size_t size, void* address_hint) {
UNIMPLEMENTED();
}
VirtualMemory::~VirtualMemory() {
UNIMPLEMENTED();
}
bool VirtualMemory::IsReserved() {
UNIMPLEMENTED();
return false;
}
bool VirtualMemory::Commit(void* address, size_t size, bool executable) {
UNIMPLEMENTED();
return false;
}
bool VirtualMemory::Uncommit(void* address, size_t size) {
UNIMPLEMENTED();
return false;
}
bool VirtualMemory::Guard(void* address) {
UNIMPLEMENTED();
return false;
}
bool VirtualMemory::HasLazyCommits() {
// TODO(alph): implement for the platform.
return false;
}
class Thread::PlatformData : public Malloced {
public:
PlatformData() {
UNIMPLEMENTED();
}
void* pd_data_;
};
Thread::Thread(const Options& options)
: data_(new PlatformData()),
stack_size_(options.stack_size),
start_semaphore_(NULL) {
set_name(options.name);
UNIMPLEMENTED();
}
Thread::Thread(const char* name)
: data_(new PlatformData()),
stack_size_(0) {
set_name(name);
UNIMPLEMENTED();
}
Thread::~Thread() {
delete data_;
UNIMPLEMENTED();
}
void Thread::set_name(const char* name) {
strncpy(name_, name, sizeof(name_));
name_[sizeof(name_) - 1] = '\0';
}
void Thread::Start() {
UNIMPLEMENTED();
}
void Thread::Join() {
UNIMPLEMENTED();
}
Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
UNIMPLEMENTED();
return static_cast<LocalStorageKey>(0);
}
void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
UNIMPLEMENTED();
}
void* Thread::GetThreadLocal(LocalStorageKey key) {
UNIMPLEMENTED();
return NULL;
}
void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
UNIMPLEMENTED();
}
void Thread::YieldCPU() {
UNIMPLEMENTED();
}
class NullMutex : public Mutex {
public:
NullMutex() : data_(NULL) {
UNIMPLEMENTED();
}
virtual ~NullMutex() {
UNIMPLEMENTED();
}
virtual int Lock() {
UNIMPLEMENTED();
return 0;
}
virtual int Unlock() {
UNIMPLEMENTED();
return 0;
}
private:
void* data_;
};
Mutex* OS::CreateMutex() {
UNIMPLEMENTED();
return new NullMutex();
}
class NullSemaphore : public Semaphore {
public:
explicit NullSemaphore(int count) : data_(NULL) {
UNIMPLEMENTED();
}
virtual ~NullSemaphore() {
UNIMPLEMENTED();
}
virtual void Wait() {
UNIMPLEMENTED();
}
virtual void Signal() {
UNIMPLEMENTED();
}
private:
void* data_;
};
Semaphore* OS::CreateSemaphore(int count) {
UNIMPLEMENTED();
return new NullSemaphore(count);
}
class ProfileSampler::PlatformData : public Malloced {
public:
PlatformData() {
UNIMPLEMENTED();
}
};
ProfileSampler::ProfileSampler(int interval) {
UNIMPLEMENTED();
// Shared setup follows.
data_ = new PlatformData();
interval_ = interval;
active_ = false;
}
ProfileSampler::~ProfileSampler() {
UNIMPLEMENTED();
// Shared tear down follows.
delete data_;
}
void ProfileSampler::Start() {
UNIMPLEMENTED();
}
void ProfileSampler::Stop() {
UNIMPLEMENTED();
}
} } // namespace v8::internal