Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: src/platform.h

Issue 6066010: Merge 6095:6198 from bleeding_edge to experimental/gc. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified 389 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified
390 // to ensure that enumeration type has correct value range (see Issue 830 for 390 // to ensure that enumeration type has correct value range (see Issue 830 for
391 // more details). 391 // more details).
392 enum LocalStorageKey { 392 enum LocalStorageKey {
393 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt, 393 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt,
394 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt 394 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt
395 }; 395 };
396 396
397 // Create new thread. 397 // Create new thread.
398 Thread(); 398 Thread();
399 explicit Thread(const char* name);
399 virtual ~Thread(); 400 virtual ~Thread();
400 401
401 // Start new thread by calling the Run() method in the new thread. 402 // Start new thread by calling the Run() method in the new thread.
402 void Start(); 403 void Start();
403 404
404 // Wait until thread terminates. 405 // Wait until thread terminates.
405 void Join(); 406 void Join();
406 407
408 inline const char* name() const {
409 return name_;
410 }
411
407 // Abstract method for run handler. 412 // Abstract method for run handler.
408 virtual void Run() = 0; 413 virtual void Run() = 0;
409 414
410 // Thread-local storage. 415 // Thread-local storage.
411 static LocalStorageKey CreateThreadLocalKey(); 416 static LocalStorageKey CreateThreadLocalKey();
412 static void DeleteThreadLocalKey(LocalStorageKey key); 417 static void DeleteThreadLocalKey(LocalStorageKey key);
413 static void* GetThreadLocal(LocalStorageKey key); 418 static void* GetThreadLocal(LocalStorageKey key);
414 static int GetThreadLocalInt(LocalStorageKey key) { 419 static int GetThreadLocalInt(LocalStorageKey key) {
415 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key))); 420 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key)));
416 } 421 }
417 static void SetThreadLocal(LocalStorageKey key, void* value); 422 static void SetThreadLocal(LocalStorageKey key, void* value);
418 static void SetThreadLocalInt(LocalStorageKey key, int value) { 423 static void SetThreadLocalInt(LocalStorageKey key, int value) {
419 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value))); 424 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
420 } 425 }
421 static bool HasThreadLocal(LocalStorageKey key) { 426 static bool HasThreadLocal(LocalStorageKey key) {
422 return GetThreadLocal(key) != NULL; 427 return GetThreadLocal(key) != NULL;
423 } 428 }
424 429
425 // A hint to the scheduler to let another thread run. 430 // A hint to the scheduler to let another thread run.
426 static void YieldCPU(); 431 static void YieldCPU();
427 432
433 // The thread name length is limited to 16 based on Linux's implementation of
434 // prctl().
435 static const int kMaxThreadNameLength = 16;
428 private: 436 private:
437 void set_name(const char *name);
438
429 class PlatformData; 439 class PlatformData;
430 PlatformData* data_; 440 PlatformData* data_;
441
442 char name_[kMaxThreadNameLength];
443
431 DISALLOW_COPY_AND_ASSIGN(Thread); 444 DISALLOW_COPY_AND_ASSIGN(Thread);
432 }; 445 };
433 446
434 447
435 // ---------------------------------------------------------------------------- 448 // ----------------------------------------------------------------------------
436 // Mutex 449 // Mutex
437 // 450 //
438 // Mutexes are used for serializing access to non-reentrant sections of code. 451 // Mutexes are used for serializing access to non-reentrant sections of code.
439 // The implementations of mutex should allow for nested/recursive locking. 452 // The implementations of mutex should allow for nested/recursive locking.
440 453
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 PlatformData* data_; // Platform specific data. 633 PlatformData* data_; // Platform specific data.
621 int samples_taken_; // Counts stack samples taken. 634 int samples_taken_; // Counts stack samples taken.
622 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 635 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
623 }; 636 };
624 637
625 #endif // ENABLE_LOGGING_AND_PROFILING 638 #endif // ENABLE_LOGGING_AND_PROFILING
626 639
627 } } // namespace v8::internal 640 } } // namespace v8::internal
628 641
629 #endif // V8_PLATFORM_H_ 642 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698