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 | |
350 static void timerTraceProfilerInMainThread(const char* name, int status) | 333 static void timerTraceProfilerInMainThread(const char* name, int status) |
351 { | 334 { |
352 if (!status) { | 335 if (!status) { |
353 TRACE_EVENT_BEGIN0("v8", name); | 336 TRACE_EVENT_BEGIN0("v8", name); |
354 } else { | 337 } else { |
355 TRACE_EVENT_END0("v8", name); | 338 TRACE_EVENT_END0("v8", name); |
356 } | 339 } |
357 } | 340 } |
358 | 341 |
359 static void initializeV8Common(v8::Isolate* isolate) | 342 static void initializeV8Common(v8::Isolate* isolate) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 initializeV8Common(isolate); | 391 initializeV8Common(isolate); |
409 | 392 |
410 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 393 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
411 v8::V8::AddMessageListener(messageHandlerInMainThread); | 394 v8::V8::AddMessageListener(messageHandlerInMainThread); |
412 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); | 395 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); |
413 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); | 396 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); |
414 | 397 |
415 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { | 398 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
416 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); | 399 WebScheduler* scheduler = Platform::current()->currentThread()->schedule
r(); |
417 V8PerIsolateData::enableIdleTasks(isolate, adoptPtr(new V8IdleTaskRunner
(scheduler))); | 400 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)); | |
420 } | 401 } |
421 | 402 |
422 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 403 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
423 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); | 404 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); |
424 | 405 |
425 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) | 406 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) |
426 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); | 407 profiler->SetWrapperClassInfoProvider(WrapperTypeInfo::NodeClassId, &Ret
ainedDOMInfo::retainedDOMInfo); |
427 } | 408 } |
428 | 409 |
429 static void reportFatalErrorInWorker(const char* location, const char* message) | 410 static void reportFatalErrorInWorker(const char* location, const char* message) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 462 |
482 v8::V8::AddMessageListener(messageHandlerInWorker); | 463 v8::V8::AddMessageListener(messageHandlerInWorker); |
483 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 464 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
484 | 465 |
485 uint32_t here; | 466 uint32_t here; |
486 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); | 467 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here - kWorkerMaxStackSi
ze / sizeof(uint32_t*))); |
487 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 468 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
488 } | 469 } |
489 | 470 |
490 } // namespace blink | 471 } // namespace blink |
OLD | NEW |