Commit 7bdfa18f authored by ulan@chromium.org's avatar ulan@chromium.org

Minor Native Client specific changes to files in src.

These changes are required for Native Client validation and to
accomodate the limitations of the NaCl runtime.

BUG=2614

Review URL: https://chromiumcodereview.appspot.com/13704002
Patch from Brad Chen <bradchen@google.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14187 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 008e73d6
......@@ -144,6 +144,11 @@ class DumbLineEditor: public LineEditor {
Handle<String> DumbLineEditor::Prompt(const char* prompt) {
printf("%s", prompt);
#if defined(__native_client__)
// Native Client libc is used to being embedded in Chrome and
// has trouble recognizing when to flush.
fflush(stdout);
#endif
return Shell::ReadFromStdin(isolate_);
}
......
......@@ -79,6 +79,8 @@ void CPU::DebugBreak() {
// instead
// __asm { int 3 }
__debugbreak();
#elif defined(__native_client__)
asm("hlt");
#else
asm("int $3");
#endif
......
......@@ -424,6 +424,8 @@ void OS::DebugBreak() {
# endif
#elif defined(__mips__)
asm("break");
#elif defined(__native_client__)
asm("hlt");
#else
asm("int $3");
#endif
......@@ -818,12 +820,16 @@ void Thread::set_name(const char* name) {
void Thread::Start() {
pthread_attr_t* attr_ptr = NULL;
#if defined(__native_client__)
// use default stack size.
#else
pthread_attr_t attr;
if (stack_size_ > 0) {
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, static_cast<size_t>(stack_size_));
attr_ptr = &attr;
}
#endif
int result = pthread_create(&data_->thread_, attr_ptr, ThreadEntry, this);
CHECK_EQ(0, result);
ASSERT(data_->thread_ != kNoThread);
......@@ -1070,6 +1076,11 @@ static int GetThreadID() {
static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
#if defined(__native_client__)
// As Native Client does not support signal handling, profiling
// is disabled.
return;
#else
USE(info);
if (signal != SIGPROF) return;
Isolate* isolate = Isolate::UncheckedCurrent();
......@@ -1122,6 +1133,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
#endif // V8_HOST_ARCH_*
sampler->SampleStack(sample);
sampler->Tick(sample);
#endif // __native_client__
}
......
......@@ -94,6 +94,12 @@ void OS::Guard(void* address, const size_t size) {
void* OS::GetRandomMmapAddr() {
#if defined(__native_client__)
// TODO(bradchen): restore randomization once Native Client gets
// smarter about using mmap address hints.
// See http://code.google.com/p/nativeclient/issues/3341
return NULL;
#endif
Isolate* isolate = Isolate::UncheckedCurrent();
// Note that the current isolate isn't set up in a call path via
// CpuFeatures::Probe. We don't care about randomization in this case because
......
......@@ -185,6 +185,13 @@ inline void MemsetPointer(T** dest, U* value, int counter) {
#elif defined(V8_HOST_ARCH_X64)
#define STOS "stosq"
#endif
#if defined(__native_client__)
// This STOS sequence does not validate for x86_64 Native Client.
// Here we #undef STOS to force use of the slower C version.
// TODO(bradchen): Profile V8 and implement a faster REP STOS
// here if the profile indicates it matters.
#undef STOS
#endif
#if defined(__GNUC__) && defined(STOS)
asm volatile(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment