Chromium Code Reviews| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 level = WarningMessageLevel; | 135 level = WarningMessageLevel; |
| 136 break; | 136 break; |
| 137 case v8::Isolate::kMessageError: | 137 case v8::Isolate::kMessageError: |
| 138 level = InfoMessageLevel; | 138 level = InfoMessageLevel; |
| 139 break; | 139 break; |
| 140 default: | 140 default: |
| 141 NOTREACHED(); | 141 NOTREACHED(); |
| 142 } | 142 } |
| 143 return level; | 143 return level; |
| 144 } | 144 } |
| 145 | |
| 146 const size_t kWasmWireBytesLimit = 1 << 12; | |
| 147 | |
| 145 } // namespace | 148 } // namespace |
| 146 | 149 |
| 147 void V8Initializer::messageHandlerInMainThread(v8::Local<v8::Message> message, | 150 void V8Initializer::messageHandlerInMainThread(v8::Local<v8::Message> message, |
| 148 v8::Local<v8::Value> data) { | 151 v8::Local<v8::Value> data) { |
| 149 ASSERT(isMainThread()); | 152 ASSERT(isMainThread()); |
| 150 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 153 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 151 | 154 |
| 152 if (isolate->GetEnteredContext().IsEmpty()) | 155 if (isolate->GetEnteredContext().IsEmpty()) |
| 153 return; | 156 return; |
| 154 | 157 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 if (ExecutionContext* executionContext = toExecutionContext(context)) { | 315 if (ExecutionContext* executionContext = toExecutionContext(context)) { |
| 313 if (ContentSecurityPolicy* policy = | 316 if (ContentSecurityPolicy* policy = |
| 314 toDocument(executionContext)->contentSecurityPolicy()) | 317 toDocument(executionContext)->contentSecurityPolicy()) |
| 315 return policy->allowEval(ScriptState::from(context), | 318 return policy->allowEval(ScriptState::from(context), |
| 316 ContentSecurityPolicy::SendReport, | 319 ContentSecurityPolicy::SendReport, |
| 317 ContentSecurityPolicy::WillThrowException); | 320 ContentSecurityPolicy::WillThrowException); |
| 318 } | 321 } |
| 319 return false; | 322 return false; |
| 320 } | 323 } |
| 321 | 324 |
| 325 static bool allowWasmCompileCallbackInMainThread(v8::Local<v8::Value> source, | |
| 326 bool asPromise) { | |
| 327 if (asPromise) | |
|
bradnelson
2017/02/18 22:16:22
Maybe comment that we allow any size for promise i
Mircea Trofin
2017/02/19 00:18:33
Done.
| |
| 328 return true; | |
| 329 if (source->IsArrayBuffer() && | |
| 330 v8::Local<v8::ArrayBuffer>::Cast(source)->ByteLength() > | |
| 331 kWasmWireBytesLimit) { | |
| 332 return false; | |
| 333 } | |
| 334 if (source->IsArrayBufferView() && | |
| 335 v8::Local<v8::ArrayBufferView>::Cast(source)->ByteLength() > | |
| 336 kWasmWireBytesLimit) { | |
| 337 return false; | |
| 338 } | |
| 339 return true; | |
| 340 } | |
| 341 | |
| 342 static bool allowWasmInstantiateCallbackInMainThread( | |
| 343 v8::Local<v8::WasmCompiledModule> source, | |
| 344 v8::Local<v8::Value> ffi, | |
| 345 bool asPromise) { | |
| 346 if (asPromise) | |
| 347 return true; | |
| 348 if (static_cast<size_t>(source->GetWasmWireBytes()->Length()) > | |
| 349 kWasmWireBytesLimit) { | |
| 350 return false; | |
| 351 } | |
| 352 return true; | |
| 353 } | |
| 354 | |
| 322 static void initializeV8Common(v8::Isolate* isolate) { | 355 static void initializeV8Common(v8::Isolate* isolate) { |
| 323 isolate->AddGCPrologueCallback(V8GCController::gcPrologue); | 356 isolate->AddGCPrologueCallback(V8GCController::gcPrologue); |
| 324 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue); | 357 isolate->AddGCEpilogueCallback(V8GCController::gcEpilogue); |
| 325 std::unique_ptr<ScriptWrappableVisitor> visitor( | 358 std::unique_ptr<ScriptWrappableVisitor> visitor( |
| 326 new ScriptWrappableVisitor(isolate)); | 359 new ScriptWrappableVisitor(isolate)); |
| 327 V8PerIsolateData::from(isolate)->setScriptWrappableVisitor( | 360 V8PerIsolateData::from(isolate)->setScriptWrappableVisitor( |
| 328 std::move(visitor)); | 361 std::move(visitor)); |
| 329 isolate->SetEmbedderHeapTracer( | 362 isolate->SetEmbedderHeapTracer( |
| 330 V8PerIsolateData::from(isolate)->scriptWrappableVisitor()); | 363 V8PerIsolateData::from(isolate)->scriptWrappableVisitor()); |
| 331 | 364 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 isolate->SetFatalErrorHandler(reportFatalErrorInMainThread); | 440 isolate->SetFatalErrorHandler(reportFatalErrorInMainThread); |
| 408 isolate->AddMessageListenerWithErrorLevel( | 441 isolate->AddMessageListenerWithErrorLevel( |
| 409 messageHandlerInMainThread, | 442 messageHandlerInMainThread, |
| 410 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | | 443 v8::Isolate::kMessageError | v8::Isolate::kMessageWarning | |
| 411 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | | 444 v8::Isolate::kMessageInfo | v8::Isolate::kMessageDebug | |
| 412 v8::Isolate::kMessageLog); | 445 v8::Isolate::kMessageLog); |
| 413 isolate->SetFailedAccessCheckCallbackFunction( | 446 isolate->SetFailedAccessCheckCallbackFunction( |
| 414 failedAccessCheckCallbackInMainThread); | 447 failedAccessCheckCallbackInMainThread); |
| 415 isolate->SetAllowCodeGenerationFromStringsCallback( | 448 isolate->SetAllowCodeGenerationFromStringsCallback( |
| 416 codeGenerationCheckCallbackInMainThread); | 449 codeGenerationCheckCallbackInMainThread); |
| 417 | 450 isolate->SetAllowWasmCompileCallback(allowWasmCompileCallbackInMainThread); |
| 451 isolate->SetAllowWasmInstantiateCallback( | |
| 452 allowWasmInstantiateCallbackInMainThread); | |
| 418 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { | 453 if (RuntimeEnabledFeatures::v8IdleTasksEnabled()) { |
| 419 V8PerIsolateData::enableIdleTasks( | 454 V8PerIsolateData::enableIdleTasks( |
| 420 isolate, WTF::makeUnique<V8IdleTaskRunner>(scheduler)); | 455 isolate, WTF::makeUnique<V8IdleTaskRunner>(scheduler)); |
| 421 } | 456 } |
| 422 | 457 |
| 423 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); | 458 isolate->SetPromiseRejectCallback(promiseRejectHandlerInMainThread); |
| 424 | 459 |
| 425 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) { | 460 if (v8::HeapProfiler* profiler = isolate->GetHeapProfiler()) { |
| 426 profiler->SetWrapperClassInfoProvider( | 461 profiler->SetWrapperClassInfoProvider( |
| 427 WrapperTypeInfo::NodeClassId, &RetainedDOMInfo::createRetainedDOMInfo); | 462 WrapperTypeInfo::NodeClassId, &RetainedDOMInfo::createRetainedDOMInfo); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 v8::Isolate::kMessageLog); | 549 v8::Isolate::kMessageLog); |
| 515 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); | 550 isolate->SetFatalErrorHandler(reportFatalErrorInWorker); |
| 516 | 551 |
| 517 uint32_t here; | 552 uint32_t here; |
| 518 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - | 553 isolate->SetStackLimit(reinterpret_cast<uintptr_t>(&here) - |
| 519 kWorkerMaxStackSize); | 554 kWorkerMaxStackSize); |
| 520 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); | 555 isolate->SetPromiseRejectCallback(promiseRejectHandlerInWorker); |
| 521 } | 556 } |
| 522 | 557 |
| 523 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |