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

Side by Side Diff: src/libplatform/default-platform.cc

Issue 1415383004: Fixing --verify-predictable mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « src/libplatform/default-platform.h ('k') | src/runtime/runtime-date.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/libplatform/default-platform.h" 5 #include "src/libplatform/default-platform.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
11 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
12 #include "src/base/platform/time.h" 12 #include "src/base/platform/time.h"
13 #include "src/base/sys-info.h" 13 #include "src/base/sys-info.h"
14 #include "src/flags.h"
Igor Sheludko 2015/11/10 10:41:06 Unfortunately this violates "-src" directive from
14 #include "src/libplatform/worker-thread.h" 15 #include "src/libplatform/worker-thread.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace platform { 18 namespace platform {
18 19
19 20
20 v8::Platform* CreateDefaultPlatform(int thread_pool_size) { 21 v8::Platform* CreateDefaultPlatform(int thread_pool_size) {
21 DefaultPlatform* platform = new DefaultPlatform(); 22 DefaultPlatform* platform = new DefaultPlatform();
22 platform->SetThreadPoolSize(thread_pool_size); 23 platform->SetThreadPoolSize(thread_pool_size);
23 platform->EnsureInitialized(); 24 platform->EnsureInitialized();
24 return platform; 25 return platform;
25 } 26 }
26 27
27 28
28 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) { 29 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) {
29 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate); 30 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate);
30 } 31 }
31 32
32 33
33 const int DefaultPlatform::kMaxThreadPoolSize = 4; 34 const int DefaultPlatform::kMaxThreadPoolSize = 4;
34 35
35 36
36 DefaultPlatform::DefaultPlatform() 37 DefaultPlatform::DefaultPlatform()
37 : initialized_(false), thread_pool_size_(0) {} 38 : initialized_(false), thread_pool_size_(0), synthetic_time_in_sec_(0.0) {}
38 39
39 40
40 DefaultPlatform::~DefaultPlatform() { 41 DefaultPlatform::~DefaultPlatform() {
41 base::LockGuard<base::Mutex> guard(&lock_); 42 base::LockGuard<base::Mutex> guard(&lock_);
42 queue_.Terminate(); 43 queue_.Terminate();
43 if (initialized_) { 44 if (initialized_) {
44 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) { 45 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) {
45 delete *i; 46 delete *i;
46 } 47 }
47 } 48 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void DefaultPlatform::CallIdleOnForegroundThread(Isolate* isolate, 159 void DefaultPlatform::CallIdleOnForegroundThread(Isolate* isolate,
159 IdleTask* task) { 160 IdleTask* task) {
160 UNREACHABLE(); 161 UNREACHABLE();
161 } 162 }
162 163
163 164
164 bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) { return false; } 165 bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) { return false; }
165 166
166 167
167 double DefaultPlatform::MonotonicallyIncreasingTime() { 168 double DefaultPlatform::MonotonicallyIncreasingTime() {
169 if (v8::internal::FLAG_verify_predictable) {
Igor Sheludko 2015/11/10 10:41:06 We could probably make FLAG_verify_predictable rea
jochen (gone - plz use gerrit) 2015/11/10 23:20:06 we can't rely on every embedder doing this. how ab
Igor Sheludko 2015/11/11 10:20:46 1) The VERIFY_PREDICTABLE (and then --verify-predi
170 synthetic_time_in_sec_ += 0.000001;
171 return synthetic_time_in_sec_;
172 }
173
168 return base::TimeTicks::HighResolutionNow().ToInternalValue() / 174 return base::TimeTicks::HighResolutionNow().ToInternalValue() /
169 static_cast<double>(base::Time::kMicrosecondsPerSecond); 175 static_cast<double>(base::Time::kMicrosecondsPerSecond);
170 } 176 }
171 } // namespace platform 177 } // namespace platform
172 } // namespace v8 178 } // namespace v8
OLDNEW
« no previous file with comments | « src/libplatform/default-platform.h ('k') | src/runtime/runtime-date.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698