~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to deps/v8/src/platform-cygwin.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2006-2011 the V8 project authors. All rights reserved.
 
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
41
41
 
42
42
#include "v8.h"
43
43
 
 
44
#include "platform-posix.h"
44
45
#include "platform.h"
45
46
#include "v8threads.h"
46
47
#include "vm-state-inl.h"
61
62
static Mutex* limit_mutex = NULL;
62
63
 
63
64
 
64
 
void OS::Setup() {
65
 
  // Seed the random number generator.
66
 
  // Convert the current time to a 64-bit integer first, before converting it
67
 
  // to an unsigned. Going directly can cause an overflow and the seed to be
68
 
  // set to all ones. The seed will be identical for different instances that
69
 
  // call this setup code within the same millisecond.
70
 
  uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
71
 
  srandom(static_cast<unsigned int>(seed));
72
 
  limit_mutex = CreateMutex();
 
65
void OS::PostSetUp() {
 
66
  POSIXPostSetUp();
73
67
}
74
68
 
75
 
 
76
69
uint64_t OS::CpuFeaturesImpliedByPlatform() {
77
70
  return 0;  // Nothing special about Cygwin.
78
71
}
114
107
 
115
108
// We keep the lowest and highest addresses mapped as a quick way of
116
109
// determining that pointers are outside the heap (used mostly in assertions
117
 
// and verification).  The estimate is conservative, ie, not all addresses in
 
110
// and verification).  The estimate is conservative, i.e., not all addresses in
118
111
// 'allocated' space are actually allocated to our heap.  The range is
119
112
// [lowest, highest), inclusive on the low and and exclusive on the high end.
120
113
static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
290
283
      }
291
284
      LOG(isolate, SharedLibraryEvent(lib_name, start, end));
292
285
    } else {
293
 
      // Entry not describing executable data. Skip to end of line to setup
 
286
      // Entry not describing executable data. Skip to end of line to set up
294
287
      // reading the next entry.
295
288
      do {
296
289
        c = getc(fp);
355
348
}
356
349
 
357
350
 
 
351
bool VirtualMemory::Guard(void* address) {
 
352
  if (NULL == VirtualAlloc(address,
 
353
                           OS::CommitPageSize(),
 
354
                           MEM_COMMIT,
 
355
                           PAGE_READONLY | PAGE_GUARD)) {
 
356
    return false;
 
357
  }
 
358
  return true;
 
359
}
 
360
 
 
361
 
358
362
class Thread::PlatformData : public Malloced {
359
363
 public:
360
364
  PlatformData() : thread_(kNoThread) {}
365
369
 
366
370
 
367
371
Thread::Thread(const Options& options)
368
 
    : data_(new PlatformData),
369
 
      stack_size_(options.stack_size) {
370
 
  set_name(options.name);
371
 
}
372
 
 
373
 
 
374
 
Thread::Thread(const char* name)
375
 
    : data_(new PlatformData),
376
 
      stack_size_(0) {
377
 
  set_name(name);
 
372
    : data_(new PlatformData()),
 
373
      stack_size_(options.stack_size()) {
 
374
  set_name(options.name());
378
375
}
379
376
 
380
377
 
617
614
 
618
615
class SamplerThread : public Thread {
619
616
 public:
 
617
  static const int kSamplerThreadStackSize = 64 * KB;
 
618
 
620
619
  explicit SamplerThread(int interval)
621
 
      : Thread("SamplerThread"),
 
620
      : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
622
621
        interval_(interval) {}
623
622
 
 
623
  static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
 
624
  static void TearDown() { delete mutex_; }
 
625
 
624
626
  static void AddActiveSampler(Sampler* sampler) {
625
627
    ScopedLock lock(mutex_);
626
628
    SamplerRegistry::AddActiveSampler(sampler);
722
724
  static Mutex* mutex_;
723
725
  static SamplerThread* instance_;
724
726
 
 
727
 private:
725
728
  DISALLOW_COPY_AND_ASSIGN(SamplerThread);
726
729
};
727
730
 
728
731
 
729
 
Mutex* SamplerThread::mutex_ = OS::CreateMutex();
 
732
Mutex* SamplerThread::mutex_ = NULL;
730
733
SamplerThread* SamplerThread::instance_ = NULL;
731
734
 
732
735
 
 
736
void OS::SetUp() {
 
737
  // Seed the random number generator.
 
738
  // Convert the current time to a 64-bit integer first, before converting it
 
739
  // to an unsigned. Going directly can cause an overflow and the seed to be
 
740
  // set to all ones. The seed will be identical for different instances that
 
741
  // call this setup code within the same millisecond.
 
742
  uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
 
743
  srandom(static_cast<unsigned int>(seed));
 
744
  limit_mutex = CreateMutex();
 
745
  SamplerThread::SetUp();
 
746
}
 
747
 
 
748
 
 
749
void OS::TearDown() {
 
750
  SamplerThread::TearDown();
 
751
  delete limit_mutex;
 
752
}
 
753
 
 
754
 
733
755
Sampler::Sampler(Isolate* isolate, int interval)
734
756
    : isolate_(isolate),
735
757
      interval_(interval),