| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 double fast_sin(double input); | 101 double fast_sin(double input); |
| 102 double fast_cos(double input); | 102 double fast_cos(double input); |
| 103 double fast_tan(double input); | 103 double fast_tan(double input); |
| 104 double fast_log(double input); | 104 double fast_log(double input); |
| 105 double fast_exp(double input); | 105 double fast_exp(double input); |
| 106 double fast_sqrt(double input); | 106 double fast_sqrt(double input); |
| 107 // The custom exp implementation needs 16KB of lookup data; initialize it | 107 // The custom exp implementation needs 16KB of lookup data; initialize it |
| 108 // on demand. | 108 // on demand. |
| 109 void lazily_initialize_fast_exp(); | 109 void lazily_initialize_fast_exp(); |
| 110 | 110 |
| 111 // Forward declarations. | |
| 112 class Socket; | |
| 113 | |
| 114 // ---------------------------------------------------------------------------- | 111 // ---------------------------------------------------------------------------- |
| 115 // Fast TLS support | 112 // Fast TLS support |
| 116 | 113 |
| 117 #ifndef V8_NO_FAST_TLS | 114 #ifndef V8_NO_FAST_TLS |
| 118 | 115 |
| 119 #if defined(_MSC_VER) && V8_HOST_ARCH_IA32 | 116 #if defined(_MSC_VER) && V8_HOST_ARCH_IA32 |
| 120 | 117 |
| 121 #define V8_FAST_TLS_SUPPORTED 1 | 118 #define V8_FAST_TLS_SUPPORTED 1 |
| 122 | 119 |
| 123 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index)); | 120 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 171 |
| 175 class OS { | 172 class OS { |
| 176 public: | 173 public: |
| 177 // Initializes the platform OS support. Called once at VM startup. | 174 // Initializes the platform OS support. Called once at VM startup. |
| 178 static void SetUp(); | 175 static void SetUp(); |
| 179 | 176 |
| 180 // Initializes the platform OS support that depend on CPU features. This is | 177 // Initializes the platform OS support that depend on CPU features. This is |
| 181 // called after CPU initialization. | 178 // called after CPU initialization. |
| 182 static void PostSetUp(); | 179 static void PostSetUp(); |
| 183 | 180 |
| 184 // Clean up platform-OS-related things. Called once at VM shutdown. | |
| 185 static void TearDown(); | |
| 186 | |
| 187 // Returns the accumulated user time for thread. This routine | 181 // Returns the accumulated user time for thread. This routine |
| 188 // can be used for profiling. The implementation should | 182 // can be used for profiling. The implementation should |
| 189 // strive for high-precision timer resolution, preferable | 183 // strive for high-precision timer resolution, preferable |
| 190 // micro-second resolution. | 184 // micro-second resolution. |
| 191 static int GetUserTime(uint32_t* secs, uint32_t* usecs); | 185 static int GetUserTime(uint32_t* secs, uint32_t* usecs); |
| 192 | 186 |
| 193 // Returns current time as the number of milliseconds since | 187 // Returns current time as the number of milliseconds since |
| 194 // 00:00:00 UTC, January 1, 1970. | 188 // 00:00:00 UTC, January 1, 1970. |
| 195 static double TimeCurrentMillis(); | 189 static double TimeCurrentMillis(); |
| 196 | 190 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 244 |
| 251 // Assign memory as a guard page so that access will cause an exception. | 245 // Assign memory as a guard page so that access will cause an exception. |
| 252 static void Guard(void* address, const size_t size); | 246 static void Guard(void* address, const size_t size); |
| 253 | 247 |
| 254 // Generate a random address to be used for hinting mmap(). | 248 // Generate a random address to be used for hinting mmap(). |
| 255 static void* GetRandomMmapAddr(); | 249 static void* GetRandomMmapAddr(); |
| 256 | 250 |
| 257 // Get the Alignment guaranteed by Allocate(). | 251 // Get the Alignment guaranteed by Allocate(). |
| 258 static size_t AllocateAlignment(); | 252 static size_t AllocateAlignment(); |
| 259 | 253 |
| 260 // Returns an indication of whether a pointer is in a space that | |
| 261 // has been allocated by Allocate(). This method may conservatively | |
| 262 // always return false, but giving more accurate information may | |
| 263 // improve the robustness of the stack dump code in the presence of | |
| 264 // heap corruption. | |
| 265 static bool IsOutsideAllocatedSpace(void* pointer); | |
| 266 | |
| 267 // Sleep for a number of milliseconds. | 254 // Sleep for a number of milliseconds. |
| 268 static void Sleep(const int milliseconds); | 255 static void Sleep(const int milliseconds); |
| 269 | 256 |
| 270 // Abort the current process. | 257 // Abort the current process. |
| 271 static void Abort(); | 258 static void Abort(); |
| 272 | 259 |
| 273 // Debug break. | 260 // Debug break. |
| 274 static void DebugBreak(); | 261 static void DebugBreak(); |
| 275 | 262 |
| 276 // Dump C++ current stack trace (only functional on Linux). | 263 // Dump C++ current stack trace (only functional on Linux). |
| 277 static void DumpBacktrace(); | 264 static void DumpBacktrace(); |
| 278 | 265 |
| 279 // Walk the stack. | 266 // Walk the stack. |
| 280 static const int kStackWalkError = -1; | 267 static const int kStackWalkError = -1; |
| 281 static const int kStackWalkMaxNameLen = 256; | 268 static const int kStackWalkMaxNameLen = 256; |
| 282 static const int kStackWalkMaxTextLen = 256; | 269 static const int kStackWalkMaxTextLen = 256; |
| 283 struct StackFrame { | 270 struct StackFrame { |
| 284 void* address; | 271 void* address; |
| 285 char text[kStackWalkMaxTextLen]; | 272 char text[kStackWalkMaxTextLen]; |
| 286 }; | 273 }; |
| 287 | 274 |
| 288 static int StackWalk(Vector<StackFrame> frames); | 275 static int StackWalk(Vector<StackFrame> frames); |
| 289 | 276 |
| 290 // Factory method for creating platform dependent Socket. | |
| 291 // Please use delete to reclaim the storage for the returned Socket. | |
| 292 static Socket* CreateSocket(); | |
| 293 | |
| 294 class MemoryMappedFile { | 277 class MemoryMappedFile { |
| 295 public: | 278 public: |
| 296 static MemoryMappedFile* open(const char* name); | 279 static MemoryMappedFile* open(const char* name); |
| 297 static MemoryMappedFile* create(const char* name, int size, void* initial); | 280 static MemoryMappedFile* create(const char* name, int size, void* initial); |
| 298 virtual ~MemoryMappedFile() { } | 281 virtual ~MemoryMappedFile() { } |
| 299 virtual void* memory() = 0; | 282 virtual void* memory() = 0; |
| 300 virtual int size() = 0; | 283 virtual int size() = 0; |
| 301 }; | 284 }; |
| 302 | 285 |
| 303 // Safe formatting print. Ensures that str is always null-terminated. | 286 // Safe formatting print. Ensures that str is always null-terminated. |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 595 |
| 613 PlatformData* data_; | 596 PlatformData* data_; |
| 614 | 597 |
| 615 char name_[kMaxThreadNameLength]; | 598 char name_[kMaxThreadNameLength]; |
| 616 int stack_size_; | 599 int stack_size_; |
| 617 Semaphore* start_semaphore_; | 600 Semaphore* start_semaphore_; |
| 618 | 601 |
| 619 DISALLOW_COPY_AND_ASSIGN(Thread); | 602 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 620 }; | 603 }; |
| 621 | 604 |
| 622 | |
| 623 // ---------------------------------------------------------------------------- | |
| 624 // Socket | |
| 625 // | |
| 626 | |
| 627 class Socket { | |
| 628 public: | |
| 629 virtual ~Socket() {} | |
| 630 | |
| 631 // Server initialization. | |
| 632 virtual bool Bind(const int port) = 0; | |
| 633 virtual bool Listen(int backlog) const = 0; | |
| 634 virtual Socket* Accept() const = 0; | |
| 635 | |
| 636 // Client initialization. | |
| 637 virtual bool Connect(const char* host, const char* port) = 0; | |
| 638 | |
| 639 // Shutdown socket for both read and write. This causes blocking Send and | |
| 640 // Receive calls to exit. After Shutdown the Socket object cannot be used for | |
| 641 // any communication. | |
| 642 virtual bool Shutdown() = 0; | |
| 643 | |
| 644 // Data Transimission | |
| 645 // Return 0 on failure. | |
| 646 virtual int Send(const char* data, int len) const = 0; | |
| 647 virtual int Receive(char* data, int len) const = 0; | |
| 648 | |
| 649 // Set the value of the SO_REUSEADDR socket option. | |
| 650 virtual bool SetReuseAddress(bool reuse_address) = 0; | |
| 651 | |
| 652 virtual bool IsValid() const = 0; | |
| 653 | |
| 654 static bool SetUp(); | |
| 655 static int LastError(); | |
| 656 static uint16_t HToN(uint16_t value); | |
| 657 static uint16_t NToH(uint16_t value); | |
| 658 static uint32_t HToN(uint32_t value); | |
| 659 static uint32_t NToH(uint32_t value); | |
| 660 }; | |
| 661 | |
| 662 | |
| 663 } } // namespace v8::internal | 605 } } // namespace v8::internal |
| 664 | 606 |
| 665 #endif // V8_PLATFORM_H_ | 607 #endif // V8_PLATFORM_H_ |
| OLD | NEW |