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

Side by Side Diff: src/platform.h

Issue 9873023: Fix performance regressions due to lazy initialization. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make init traits non-template structs. Created 8 years, 8 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/lazy-instance.h ('k') | src/platform-cygwin.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 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // 112 //
113 // This class has static methods for the different platform specific 113 // This class has static methods for the different platform specific
114 // functions. Add methods here to cope with differences between the 114 // functions. Add methods here to cope with differences between the
115 // supported platforms. 115 // supported platforms.
116 116
117 class OS { 117 class OS {
118 public: 118 public:
119 // Initializes the platform OS support. Called once at VM startup. 119 // Initializes the platform OS support. Called once at VM startup.
120 static void SetUp(); 120 static void SetUp();
121 121
122 // Initializes the platform OS support that depend on CPU features. This is
123 // called after CPU initialization.
124 static void PostSetUp();
125
122 // Returns the accumulated user time for thread. This routine 126 // Returns the accumulated user time for thread. This routine
123 // can be used for profiling. The implementation should 127 // can be used for profiling. The implementation should
124 // strive for high-precision timer resolution, preferable 128 // strive for high-precision timer resolution, preferable
125 // micro-second resolution. 129 // micro-second resolution.
126 static int GetUserTime(uint32_t* secs, uint32_t* usecs); 130 static int GetUserTime(uint32_t* secs, uint32_t* usecs);
127 131
128 // Get a tick counter normalized to one tick per microsecond. 132 // Get a tick counter normalized to one tick per microsecond.
129 // Used for calculating time intervals. 133 // Used for calculating time intervals.
130 static int64_t Ticks(); 134 static int64_t Ticks();
131 135
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 542
539 // POD Mutex initialized lazily (i.e. the first time Pointer() is called). 543 // POD Mutex initialized lazily (i.e. the first time Pointer() is called).
540 // Usage: 544 // Usage:
541 // static LazyMutex my_mutex = LAZY_MUTEX_INITIALIZER; 545 // static LazyMutex my_mutex = LAZY_MUTEX_INITIALIZER;
542 // 546 //
543 // void my_function() { 547 // void my_function() {
544 // ScopedLock my_lock(my_mutex.Pointer()); 548 // ScopedLock my_lock(my_mutex.Pointer());
545 // // Do something. 549 // // Do something.
546 // } 550 // }
547 // 551 //
548 typedef LazyDynamicInstance<Mutex, CreateMutexTrait>::type LazyMutex; 552 typedef LazyDynamicInstance<
553 Mutex, CreateMutexTrait, ThreadSafeInitOnceTrait>::type LazyMutex;
549 554
550 #define LAZY_MUTEX_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER 555 #define LAZY_MUTEX_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
551 556
552 // ---------------------------------------------------------------------------- 557 // ----------------------------------------------------------------------------
553 // ScopedLock 558 // ScopedLock
554 // 559 //
555 // Stack-allocated ScopedLocks provide block-scoped locking and 560 // Stack-allocated ScopedLocks provide block-scoped locking and
556 // unlocking of a mutex. 561 // unlocking of a mutex.
557 class ScopedLock { 562 class ScopedLock {
558 public: 563 public:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 // // The following semaphore starts at 0. 614 // // The following semaphore starts at 0.
610 // static LazySemaphore<0>::type my_semaphore = LAZY_SEMAPHORE_INITIALIZER; 615 // static LazySemaphore<0>::type my_semaphore = LAZY_SEMAPHORE_INITIALIZER;
611 // 616 //
612 // void my_function() { 617 // void my_function() {
613 // // Do something with my_semaphore.Pointer(). 618 // // Do something with my_semaphore.Pointer().
614 // } 619 // }
615 // 620 //
616 template <int InitialValue> 621 template <int InitialValue>
617 struct LazySemaphore { 622 struct LazySemaphore {
618 typedef typename LazyDynamicInstance< 623 typedef typename LazyDynamicInstance<
619 Semaphore, CreateSemaphoreTrait<InitialValue> >::type type; 624 Semaphore, CreateSemaphoreTrait<InitialValue>,
625 ThreadSafeInitOnceTrait>::type type;
620 }; 626 };
621 627
622 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER 628 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
623 629
624 630
625 // ---------------------------------------------------------------------------- 631 // ----------------------------------------------------------------------------
626 // Socket 632 // Socket
627 // 633 //
628 634
629 class Socket { 635 class Socket {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 Atomic32 active_; 753 Atomic32 active_;
748 PlatformData* data_; // Platform specific data. 754 PlatformData* data_; // Platform specific data.
749 int samples_taken_; // Counts stack samples taken. 755 int samples_taken_; // Counts stack samples taken.
750 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 756 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
751 }; 757 };
752 758
753 759
754 } } // namespace v8::internal 760 } } // namespace v8::internal
755 761
756 #endif // V8_PLATFORM_H_ 762 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/lazy-instance.h ('k') | src/platform-cygwin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698