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
This commit is contained in:
ulan@chromium.org 2013-04-09 15:11:45 +00:00
parent 008e73d6a0
commit 7bdfa18ff9
5 changed files with 32 additions and 0 deletions

View File

@ -144,6 +144,11 @@ class DumbLineEditor: public LineEditor {
Handle<String> DumbLineEditor::Prompt(const char* prompt) { Handle<String> DumbLineEditor::Prompt(const char* prompt) {
printf("%s", 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_); return Shell::ReadFromStdin(isolate_);
} }

View File

@ -79,6 +79,8 @@ void CPU::DebugBreak() {
// instead // instead
// __asm { int 3 } // __asm { int 3 }
__debugbreak(); __debugbreak();
#elif defined(__native_client__)
asm("hlt");
#else #else
asm("int $3"); asm("int $3");
#endif #endif

View File

@ -424,6 +424,8 @@ void OS::DebugBreak() {
# endif # endif
#elif defined(__mips__) #elif defined(__mips__)
asm("break"); asm("break");
#elif defined(__native_client__)
asm("hlt");
#else #else
asm("int $3"); asm("int $3");
#endif #endif
@ -818,12 +820,16 @@ void Thread::set_name(const char* name) {
void Thread::Start() { void Thread::Start() {
pthread_attr_t* attr_ptr = NULL; pthread_attr_t* attr_ptr = NULL;
#if defined(__native_client__)
// use default stack size.
#else
pthread_attr_t attr; pthread_attr_t attr;
if (stack_size_ > 0) { if (stack_size_ > 0) {
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, static_cast<size_t>(stack_size_)); pthread_attr_setstacksize(&attr, static_cast<size_t>(stack_size_));
attr_ptr = &attr; attr_ptr = &attr;
} }
#endif
int result = pthread_create(&data_->thread_, attr_ptr, ThreadEntry, this); int result = pthread_create(&data_->thread_, attr_ptr, ThreadEntry, this);
CHECK_EQ(0, result); CHECK_EQ(0, result);
ASSERT(data_->thread_ != kNoThread); ASSERT(data_->thread_ != kNoThread);
@ -1070,6 +1076,11 @@ static int GetThreadID() {
static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { 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); USE(info);
if (signal != SIGPROF) return; if (signal != SIGPROF) return;
Isolate* isolate = Isolate::UncheckedCurrent(); Isolate* isolate = Isolate::UncheckedCurrent();
@ -1122,6 +1133,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
#endif // V8_HOST_ARCH_* #endif // V8_HOST_ARCH_*
sampler->SampleStack(sample); sampler->SampleStack(sample);
sampler->Tick(sample); sampler->Tick(sample);
#endif // __native_client__
} }

View File

@ -94,6 +94,12 @@ void OS::Guard(void* address, const size_t size) {
void* OS::GetRandomMmapAddr() { 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(); Isolate* isolate = Isolate::UncheckedCurrent();
// Note that the current isolate isn't set up in a call path via // 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 // CpuFeatures::Probe. We don't care about randomization in this case because

View File

@ -185,6 +185,13 @@ inline void MemsetPointer(T** dest, U* value, int counter) {
#elif defined(V8_HOST_ARCH_X64) #elif defined(V8_HOST_ARCH_X64)
#define STOS "stosq" #define STOS "stosq"
#endif #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) #if defined(__GNUC__) && defined(STOS)
asm volatile( asm volatile(