| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 bool Commit(void* address, size_t size, bool is_executable); | 347 bool Commit(void* address, size_t size, bool is_executable); |
| 348 | 348 |
| 349 // Uncommit real memory. Returns whether the operation succeeded. | 349 // Uncommit real memory. Returns whether the operation succeeded. |
| 350 bool Uncommit(void* address, size_t size); | 350 bool Uncommit(void* address, size_t size); |
| 351 | 351 |
| 352 private: | 352 private: |
| 353 void* address_; // Start address of the virtual memory. | 353 void* address_; // Start address of the virtual memory. |
| 354 size_t size_; // Size of the virtual memory. | 354 size_t size_; // Size of the virtual memory. |
| 355 }; | 355 }; |
| 356 | 356 |
| 357 | |
| 358 // ---------------------------------------------------------------------------- | |
| 359 // ThreadHandle | |
| 360 // | |
| 361 // A ThreadHandle represents a thread identifier for a thread. The ThreadHandle | |
| 362 // does not own the underlying os handle. Thread handles can be used for | |
| 363 // refering to threads and testing equality. | |
| 364 | |
| 365 class ThreadHandle { | |
| 366 public: | |
| 367 enum Kind { SELF, INVALID }; | |
| 368 explicit ThreadHandle(Kind kind); | |
| 369 | |
| 370 // Destructor. | |
| 371 ~ThreadHandle(); | |
| 372 | |
| 373 // Test for thread running. | |
| 374 bool IsSelf() const; | |
| 375 | |
| 376 // Test for valid thread handle. | |
| 377 bool IsValid() const; | |
| 378 | |
| 379 // Get platform-specific data. | |
| 380 class PlatformData; | |
| 381 PlatformData* thread_handle_data() { return data_; } | |
| 382 | |
| 383 // Initialize the handle to kind | |
| 384 void Initialize(Kind kind); | |
| 385 | |
| 386 private: | |
| 387 PlatformData* data_; // Captures platform dependent data. | |
| 388 }; | |
| 389 | |
| 390 | |
| 391 // ---------------------------------------------------------------------------- | 357 // ---------------------------------------------------------------------------- |
| 392 // Thread | 358 // Thread |
| 393 // | 359 // |
| 394 // Thread objects are used for creating and running threads. When the start() | 360 // Thread objects are used for creating and running threads. When the start() |
| 395 // method is called the new thread starts running the run() method in the new | 361 // method is called the new thread starts running the run() method in the new |
| 396 // thread. The Thread object should not be deallocated before the thread has | 362 // thread. The Thread object should not be deallocated before the thread has |
| 397 // terminated. | 363 // terminated. |
| 398 | 364 |
| 399 class Thread: public ThreadHandle { | 365 class Thread { |
| 400 public: | 366 public: |
| 401 // Opaque data type for thread-local storage keys. | 367 // Opaque data type for thread-local storage keys. |
| 402 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified | 368 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified |
| 403 // to ensure that enumeration type has correct value range (see Issue 830 for | 369 // to ensure that enumeration type has correct value range (see Issue 830 for |
| 404 // more details). | 370 // more details). |
| 405 enum LocalStorageKey { | 371 enum LocalStorageKey { |
| 406 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt, | 372 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt, |
| 407 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt | 373 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt |
| 408 }; | 374 }; |
| 409 | 375 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 #endif | 427 #endif |
| 462 | 428 |
| 463 // A hint to the scheduler to let another thread run. | 429 // A hint to the scheduler to let another thread run. |
| 464 static void YieldCPU(); | 430 static void YieldCPU(); |
| 465 | 431 |
| 466 Isolate* isolate() const { return isolate_; } | 432 Isolate* isolate() const { return isolate_; } |
| 467 | 433 |
| 468 // The thread name length is limited to 16 based on Linux's implementation of | 434 // The thread name length is limited to 16 based on Linux's implementation of |
| 469 // prctl(). | 435 // prctl(). |
| 470 static const int kMaxThreadNameLength = 16; | 436 static const int kMaxThreadNameLength = 16; |
| 437 |
| 438 class PlatformData; |
| 439 PlatformData* data() { return data_; } |
| 440 |
| 471 private: | 441 private: |
| 472 void set_name(const char *name); | 442 void set_name(const char *name); |
| 473 | 443 |
| 474 class PlatformData; | |
| 475 PlatformData* data_; | 444 PlatformData* data_; |
| 445 |
| 476 Isolate* isolate_; | 446 Isolate* isolate_; |
| 477 char name_[kMaxThreadNameLength]; | 447 char name_[kMaxThreadNameLength]; |
| 478 int stack_size_; | 448 int stack_size_; |
| 479 | 449 |
| 480 DISALLOW_COPY_AND_ASSIGN(Thread); | 450 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 481 }; | 451 }; |
| 482 | 452 |
| 483 | 453 |
| 484 // ---------------------------------------------------------------------------- | 454 // ---------------------------------------------------------------------------- |
| 485 // Mutex | 455 // Mutex |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 int samples_taken_; // Counts stack samples taken. | 654 int samples_taken_; // Counts stack samples taken. |
| 685 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 655 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 686 }; | 656 }; |
| 687 | 657 |
| 688 | 658 |
| 689 #endif // ENABLE_LOGGING_AND_PROFILING | 659 #endif // ENABLE_LOGGING_AND_PROFILING |
| 690 | 660 |
| 691 } } // namespace v8::internal | 661 } } // namespace v8::internal |
| 692 | 662 |
| 693 #endif // V8_PLATFORM_H_ | 663 #endif // V8_PLATFORM_H_ |
| OLD | NEW |