| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte
xt) | 321 static bool codeGenerationCheckCallbackInMainThread(v8::Local<v8::Context> conte
xt) |
| 322 { | 322 { |
| 323 if (ExecutionContext* executionContext = toExecutionContext(context)) { | 323 if (ExecutionContext* executionContext = toExecutionContext(context)) { |
| 324 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten
tSecurityPolicy()) | 324 if (ContentSecurityPolicy* policy = toDocument(executionContext)->conten
tSecurityPolicy()) |
| 325 return policy->allowEval(ScriptState::from(context), ContentSecurity
Policy::SendReport, ContentSecurityPolicy::WillThrowException); | 325 return policy->allowEval(ScriptState::from(context), ContentSecurity
Policy::SendReport, ContentSecurityPolicy::WillThrowException); |
| 326 } | 326 } |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 static void idleGCTaskInMainThread(double deadlineSeconds) | |
| 331 { | |
| 332 ASSERT(isMainThread()); | |
| 333 ASSERT(RuntimeEnabledFeatures::v8IdleTasksEnabled()); | |
| 334 bool gcFinished = false; | |
| 335 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 336 | |
| 337 Platform* platform = Platform::current(); | |
| 338 if (deadlineSeconds > platform->monotonicallyIncreasingTime()) | |
| 339 gcFinished = isolate->IdleNotificationDeadline(deadlineSeconds); | |
| 340 | |
| 341 if (gcFinished) | |
| 342 platform->currentThread()->scheduler()->postIdleTaskAfterWakeup(FROM_HER
E, WTF::bind<double>(idleGCTaskInMainThread)); | |
| 343 else | |
| 344 platform->currentThread()->scheduler()->postIdleTask(FROM_HERE, WTF::bin
d<double>(idleGCTaskInMainThread)); | |
| 345 } | |
| 346 | |
| 347 static void timerTraceProfilerInMainThread(const char* name, int status) | 330 static void timerTraceProfilerInMainThread(const char* name, int status) |
| 348 { | 331 { |
| 349 if (!status) { | 332 if (!status) { |
| 350 TRACE_EVENT_BEGIN0("v8", name); | 333 TRACE_EVENT_BEGIN0("v8", name); |
| 351 } else { | 334 } else { |
| 352 TRACE_EVENT_END0("v8", name); | 335 TRACE_EVENT_END0("v8", name); |
| 353 } | 336 } |
| 354 } | 337 } |
| 355 | 338 |
| 356 static void initializeV8Common(v8::Isolate* isolate) | 339 static void initializeV8Common(v8::Isolate* isolate) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 initializeV8Common(isolate); | 388 initializeV8Common(isolate); |
| 406 | 389 |
| 407 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 390 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
| 408 v8::V8::AddMessageListener(messageHandlerInMainThread); | 391 v8::V8::AddMessageListener(messageHandlerInMainThread); |
| 409 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); | 392 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); |
| 410 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); | 393 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); |
| 411 | 394 |
| 412 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { | 395 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
| 413 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); | 396 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); |
| 414 V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner
(scheduler))); | 397 V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner
(scheduler))); |
| 415 // FIXME: Remove idleGCTaskInMainThread once V8 starts posting idle task
explicity. | |
| 416 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(idleGCTaskInMainThr
ead)); | |
| 417 } | 398 } |
| 418 | 399 |
| 419 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 400 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
| 420 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); | 401 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); |
| 421 | 402 |
| 422 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) | 403 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) |
| 423 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); | 404 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); |
| 424 } | 405 } |
| 425 | 406 |
| 426 static void reportFatalErrorInWorker(const char* location, const char* message) | 407 static void reportFatalErrorInWorker(const char* location, const char* message) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 459 |
| 479 v8::V8::AddMessageListener(messageHandlerInWorker); | 460 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 480 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 461 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 481 | 462 |
| 482 uint32_t here; | 463 uint32_t here; |
| 483 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 464 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
| 484 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 465 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 485 } | 466 } |
| 486 | 467 |
| 487 } // namespace blink | 468 } // namespace blink |
| OLD | NEW |