OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte
xt) | 324 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte
xt) |
325 { | 325 { |
326 if (ExecutionContext* executionContext = toExecutionContext(context)) { | 326 if (ExecutionContext* executionContext = toExecutionContext(context)) { |
327 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten
tSecurityPolicy()) | 327 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten
tSecurityPolicy()) |
328 return policy->allowEval(ScriptState::from(context), ContentSecurity
Policy::SendReport, ContentSecurityPolicy::WillThrowException); | 328 return policy->allowEval(ScriptState::from(context), ContentSecurity
Policy::SendReport, ContentSecurityPolicy::WillThrowException); |
329 } | 329 } |
330 return false; | 330 return false; |
331 } | 331 } |
332 | 332 |
| 333 static void idleGCTaskInMainThread(double deadlineSeconds) |
| 334 { |
| 335 ASSERT(isMainThread()); |
| 336 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); |
| 337 bool gcFinished = false; |
| 338 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 339 |
| 340 Platform* platform = Platform::current(); |
| 341 if (deadlineSeconds > platform->monotonicallyIncreasingTime()) |
| 342 gcFinished = isolate->IdleNotificationDeadline(deadlineSeconds); |
| 343 |
| 344 if (gcFinished) |
| 345 platform->currentThread()->scheduler()->postIdleTaskAfterWakeup(FROM_HER
E, WTF::bind<double>(idleGCTaskInMainThread)); |
| 346 else |
| 347 platform->currentThread()->scheduler()->postIdleTask(FROM_HERE, WTF::bin
d<double>(idleGCTaskInMainThread)); |
| 348 } |
| 349 |
333 static void timerTraceProfilerInMainThread(const char* name, int status) | 350 static void timerTraceProfilerInMainThread(const char* name, int status) |
334 { | 351 { |
335 if (!status) { | 352 if (!status) { |
336 TRACE_EVENT_BEGIN0("v8", name); | 353 TRACE_EVENT_BEGIN0("v8", name); |
337 } else { | 354 } else { |
338 TRACE_EVENT_END0("v8", name); | 355 TRACE_EVENT_END0("v8", name); |
339 } | 356 } |
340 } | 357 } |
341 | 358 |
342 static void initializeV8Common(v8::Isolate* isolate) | 359 static void initializeV8Common(v8::Isolate* isolate) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 initializeV8Common(isolate); | 408 initializeV8Common(isolate); |
392 | 409 |
393 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 410 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
394 v8::V8::AddMessageListener(messageHandlerInMainThread); | 411 v8::V8::AddMessageListener(messageHandlerInMainThread); |
395 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); | 412 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); |
396 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); | 413 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); |
397 | 414 |
398 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { | 415 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
399 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); | 416 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); |
400 V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner
(scheduler))); | 417 V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner
(scheduler))); |
| 418 // FIXME: Remove idleGCTaskInMainThread once V8 starts posting idle task
explicity. |
| 419 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThr
ead)); |
401 } | 420 } |
402 | 421 |
403 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 422 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
404 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); | 423 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); |
405 | 424 |
406 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) | 425 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) |
407 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); | 426 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); |
408 } | 427 } |
409 | 428 |
410 static void reportFatalErrorInWorker(const char* location, const char* message) | 429 static void reportFatalErrorInWorker(const char* location, const char* message) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 481 |
463 v8::V8::AddMessageListener(messageHandlerInWorker); | 482 v8::V8::AddMessageListener(messageHandlerInWorker); |
464 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 483 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
465 | 484 |
466 uint32_t here; | 485 uint32_t here; |
467 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 486 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
468 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 487 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
469 } | 488 } |
470 | 489 |
471 } // namespace blink | 490 } // namespace blink |
OLD | NEW |