Changeset 264413 in webkit
- Timestamp:
- Jul 15, 2020, 12:20:21 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r264409 r264413 1 2020-07-15 Mark Lam <mark.lam@apple.com> 2 3 Add handling of out of memory handling while adding a worklet module. 4 https://bugs.webkit.org/show_bug.cgi?id=214354 5 <rdar://problem/65271931> 6 7 Reviewed by Yusuke Suzuki and Keith Miller. 8 9 We're skipping the new test on Debug builds because it will always run too slow. 10 The Release build is sufficient to test this OOME handling. 11 12 * TestExpectations: 13 * fast/css-custom-paint/out-of-memory-while-adding-worklet-module-expected.txt: Added. 14 * fast/css-custom-paint/out-of-memory-while-adding-worklet-module.html: Added. 15 * fast/css-custom-paint/script-tests: Added. 16 * fast/css-custom-paint/script-tests/out-of-memory-while-adding-worklet-module.js: Added. 17 (useAllMemory.try.get Object): 18 (useAllMemory.try.foo): 19 (useAllMemory): 20 (catch): 21 1 22 2020-07-15 Hector Lopez <hector_i_lopez@apple.com> 2 23 -
trunk/LayoutTests/TestExpectations
r264343 r264413 1108 1108 webkit.org/b/136078 fast/borders/border-painting-dotted.html [ ImageOnlyFailure ] 1109 1109 webkit.org/b/136078 fast/borders/border-painting-double.html [ ImageOnlyFailure ] 1110 1111 # Skip this because it is too slow on debug builds. 1112 [ Debug ] fast/css-custom-paint/out-of-memory-while-adding-worklet-module.html [ Skip ] 1110 1113 1111 1114 # official flexbox tests -
trunk/Source/JavaScriptCore/ChangeLog
r264400 r264413 1 2020-07-15 Mark Lam <mark.lam@apple.com> 2 3 Add handling of out of memory handling while adding a worklet module. 4 https://bugs.webkit.org/show_bug.cgi?id=214354 5 <rdar://problem/65271931> 6 7 Reviewed by Yusuke Suzuki and Keith Miller. 8 9 Add VM::tryCreate() that can fail if we encounter an out of memory issue. 10 As always, we're taking a best effort approach to handling out of memory errors. 11 Hence, we will not attempt to exhaustively handle every OOME scenario. This patch 12 only checks for failure to allocate a BigInt due to Gigacage exhaustion. While it 13 doesn't handle other allocation errors, it does enable us to add handling of other 14 cases in the future as needed. 15 16 * runtime/VM.cpp: 17 (JSC::VM::VM): 18 (JSC::VM::tryCreate): 19 * runtime/VM.h: 20 1 21 2020-07-15 Jim Mason <jmason@ibinx.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r264315 r264413 263 263 static bool vmCreationShouldCrash = false; 264 264 265 VM::VM(VMType vmType, HeapType heapType, WTF::RunLoop* runLoop )265 VM::VM(VMType vmType, HeapType heapType, WTF::RunLoop* runLoop, bool* success) 266 266 : m_id(nextID()) 267 267 , m_apiLock(adoptRef(new JSLock(this))) … … 465 465 { 466 466 auto* bigInt = JSBigInt::tryCreateFrom(*this, 1); 467 RELEASE_ASSERT(bigInt); 468 heapBigIntConstantOne.set(*this, bigInt); 467 if (bigInt) 468 heapBigIntConstantOne.set(*this, bigInt); 469 else { 470 if (success) 471 *success = false; 472 else 473 RELEASE_ASSERT(bigInt); 474 } 469 475 } 470 476 … … 673 679 { 674 680 return adoptRef(*new VM(Default, heapType, runLoop)); 681 } 682 683 RefPtr<VM> VM::tryCreate(HeapType heapType, WTF::RunLoop* runLoop) 684 { 685 bool success = true; 686 RefPtr<VM> vm = adoptRef(new VM(Default, heapType, runLoop, &success)); 687 if (!success) { 688 // Here, we're destructing a partially constructed VM and we know that 689 // no one else can be using it at the same time. So, acquiring the lock 690 // is superflous. However, we don't want to change how VMs are destructed. 691 // Just going through the motion of acquiring the lock here allows us to 692 // use the standard destruction process. 693 694 // VM expects us to be holding the VM lock when destructing it. Acquiring 695 // the lock also puts the VM in a state (e.g. acquiring heap access) that 696 // is needed for destruction. The lock will hold the last reference to 697 // the VM after we nullify the refPtr below. The VM will actually be 698 // destructed in JSLockHolder's destructor. 699 JSLockHolder lock(vm.get()); 700 vm = nullptr; 701 } 702 return vm; 675 703 } 676 704 -
trunk/Source/JavaScriptCore/runtime/VM.h
r264315 r264413 315 315 316 316 JS_EXPORT_PRIVATE static Ref<VM> create(HeapType = SmallHeap, WTF::RunLoop* = nullptr); 317 JS_EXPORT_PRIVATE static RefPtr<VM> tryCreate(HeapType = SmallHeap, WTF::RunLoop* = nullptr); 317 318 static Ref<VM> createContextGroup(HeapType = SmallHeap); 318 319 JS_EXPORT_PRIVATE ~VM(); … … 1102 1103 friend class LLIntOffsetsExtractor; 1103 1104 1104 VM(VMType, HeapType, WTF::RunLoop* = nullptr );1105 VM(VMType, HeapType, WTF::RunLoop* = nullptr, bool* success = nullptr); 1105 1106 static VM*& sharedInstanceInternal(); 1106 1107 void createNativeThunk(); -
trunk/Source/WebCore/ChangeLog
r264403 r264413 1 2020-07-15 Mark Lam <mark.lam@apple.com> 2 3 Add handling of out of memory handling while adding a worklet module. 4 https://bugs.webkit.org/show_bug.cgi?id=214354 5 <rdar://problem/65271931> 6 7 Reviewed by Yusuke Suzuki and Keith Miller. 8 9 Test: fast/css-custom-paint/out-of-memory-while-adding-worklet-module.html 10 11 * bindings/js/JSDOMExceptionHandling.cpp: 12 (WebCore::createDOMException): 13 * dom/ExceptionCode.h: 14 * worklets/PaintWorkletGlobalScope.cpp: 15 (WebCore::PaintWorkletGlobalScope::tryCreate): 16 (WebCore::PaintWorkletGlobalScope::PaintWorkletGlobalScope): 17 (WebCore::PaintWorkletGlobalScope::create): Deleted. 18 * worklets/PaintWorkletGlobalScope.h: 19 * worklets/Worklet.cpp: 20 (WebCore::Worklet::addModule): 21 * worklets/Worklet.h: 22 * worklets/Worklet.idl: 23 * worklets/WorkletGlobalScope.cpp: 24 (WebCore::WorkletGlobalScope::WorkletGlobalScope): 25 * worklets/WorkletGlobalScope.h: 26 * worklets/WorkletScriptController.cpp: 27 (WebCore::WorkletScriptController::WorkletScriptController): 28 * worklets/WorkletScriptController.h: 29 1 30 2020-07-15 Oriol Brufau <obrufau@igalia.com> 2 31 -
trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp
r263795 r264413 1 1 /* 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004-20 17Apple Inc. All rights reserved.3 * Copyright (C) 2004-2020 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2007 Samuel Weinig <sam@webkit.org> 5 5 * Copyright (C) 2013 Michael Pruett <michael@68k.org> … … 140 140 if (ec == StackOverflowError) 141 141 return createStackOverflowError(lexicalGlobalObject); 142 if (ec == OutOfMemoryError) 143 return createOutOfMemoryError(lexicalGlobalObject); 142 144 143 145 // FIXME: All callers to createDOMException need to pass in the correct global object. -
trunk/Source/WebCore/dom/ExceptionCode.h
r262933 r264413 1 1 /* 2 * Copyright (C) 2006-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 65 65 // Non-standard error. 66 66 StackOverflowError, 67 OutOfMemoryError, 67 68 68 69 // Used to indicate to the bindings that a JS exception was thrown below and it should be propagated. -
trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp
r260848 r264413 1 1 /* 2 * Copyright (C) 2018-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 42 42 WTF_MAKE_ISO_ALLOCATED_IMPL(PaintWorkletGlobalScope); 43 43 44 Ref <PaintWorkletGlobalScope> PaintWorkletGlobalScope::create(Document& document, ScriptSourceCode&& code)44 RefPtr<PaintWorkletGlobalScope> PaintWorkletGlobalScope::tryCreate(Document& document, ScriptSourceCode&& code) 45 45 { 46 return adoptRef(*new PaintWorkletGlobalScope(document, WTFMove(code))); 46 RefPtr<VM> vm = VM::tryCreate(); 47 if (!vm) 48 return nullptr; 49 return adoptRef(*new PaintWorkletGlobalScope(document, vm.releaseNonNull(), WTFMove(code))); 47 50 } 48 51 49 PaintWorkletGlobalScope::PaintWorkletGlobalScope(Document& document, ScriptSourceCode&& code)50 : WorkletGlobalScope(document, WTFMove( code))52 PaintWorkletGlobalScope::PaintWorkletGlobalScope(Document& document, Ref<VM>&& vm, ScriptSourceCode&& code) 53 : WorkletGlobalScope(document, WTFMove(vm), WTFMove(code)) 51 54 { 52 55 } -
trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.h
r254087 r264413 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 namespace JSC { 36 36 class JSObject; 37 class VM; 37 38 } // namespace JSC 38 39 … … 43 44 WTF_MAKE_ISO_ALLOCATED(PaintWorkletGlobalScope); 44 45 public: 45 static Ref <PaintWorkletGlobalScope> create(Document&, ScriptSourceCode&&);46 static RefPtr<PaintWorkletGlobalScope> tryCreate(Document&, ScriptSourceCode&&); 46 47 47 48 ExceptionOr<void> registerPaint(JSC::JSGlobalObject&, const String& name, JSC::Strong<JSC::JSObject> paintConstructor); … … 73 74 74 75 private: 75 PaintWorkletGlobalScope(Document&, ScriptSourceCode&&);76 PaintWorkletGlobalScope(Document&, Ref<JSC::VM>&&, ScriptSourceCode&&); 76 77 77 78 ~PaintWorkletGlobalScope() -
trunk/Source/WebCore/worklets/Worklet.cpp
r243887 r264413 47 47 } 48 48 49 voidWorklet::addModule(Document& document, const String& moduleURL)49 ExceptionOr<void> Worklet::addModule(Document& document, const String& moduleURL) 50 50 { 51 51 // FIXME: We should download the source from the URL 52 52 // https://bugs.webkit.org/show_bug.cgi?id=191136 53 auto context = PaintWorkletGlobalScope::create(document, ScriptSourceCode(moduleURL)); 53 auto maybeContext = PaintWorkletGlobalScope::tryCreate(document, ScriptSourceCode(moduleURL)); 54 if (UNLIKELY(!maybeContext)) 55 return Exception { OutOfMemoryError }; 56 auto context = maybeContext.releaseNonNull(); 54 57 context->evaluate(); 55 58 … … 57 60 for (auto& name : context->paintDefinitionMap().keys()) 58 61 document.setPaintWorkletGlobalScopeForName(name, makeRef(context.get())); 62 63 return { }; 59 64 } 60 65 -
trunk/Source/WebCore/worklets/Worklet.h
r260415 r264413 26 26 #pragma once 27 27 28 #include "ExceptionOr.h" 28 29 #include "ScriptWrappable.h" 29 30 #include <wtf/RefCounted.h> … … 39 40 static Ref<Worklet> create(); 40 41 41 voidaddModule(Document&, const String& moduleURL);42 ExceptionOr<void> addModule(Document&, const String& moduleURL); 42 43 43 44 private: -
trunk/Source/WebCore/worklets/Worklet.idl
r237766 r264413 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 Global=Worklet, 31 31 ] interface Worklet { 32 [CallWith=Document ] void addModule(USVString moduleURL/*, optional WorkletOptions options*/);32 [CallWith=Document, MayThrowException] void addModule(USVString moduleURL/*, optional WorkletOptions options*/); 33 33 }; -
trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp
r256012 r264413 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All Rights Reserved.2 * Copyright (C) 2018-2020 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 WTF_MAKE_ISO_ALLOCATED_IMPL(WorkletGlobalScope); 49 49 50 WorkletGlobalScope::WorkletGlobalScope(Document& document, ScriptSourceCode&& code)50 WorkletGlobalScope::WorkletGlobalScope(Document& document, Ref<JSC::VM>&& vm, ScriptSourceCode&& code) 51 51 : m_document(makeWeakPtr(document)) 52 , m_script(makeUnique<WorkletScriptController>( this))52 , m_script(makeUnique<WorkletScriptController>(WTFMove(vm), this)) 53 53 , m_topOrigin(SecurityOrigin::createUnique()) 54 54 , m_code(WTFMove(code)) -
trunk/Source/WebCore/worklets/WorkletGlobalScope.h
r256012 r264413 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 88 88 89 89 protected: 90 WorkletGlobalScope(Document&, ScriptSourceCode&&);90 WorkletGlobalScope(Document&, Ref<JSC::VM>&&, ScriptSourceCode&&); 91 91 WorkletGlobalScope(const WorkletGlobalScope&) = delete; 92 92 WorkletGlobalScope(WorkletGlobalScope&&) = delete; -
trunk/Source/WebCore/worklets/WorkletScriptController.cpp
r251691 r264413 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All Rights Reserved.2 * Copyright (C) 2018-2020 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 48 48 using namespace JSC; 49 49 50 WorkletScriptController::WorkletScriptController( WorkletGlobalScope* workletGlobalScope)51 : m_vm( VM::create())50 WorkletScriptController::WorkletScriptController(Ref<VM>&& vm, WorkletGlobalScope* workletGlobalScope) 51 : m_vm(WTFMove(vm)) 52 52 , m_workletGlobalScope(workletGlobalScope) 53 53 , m_workletGlobalScopeWrapper(*m_vm) -
trunk/Source/WebCore/worklets/WorkletScriptController.h
r237766 r264413 50 50 WTF_MAKE_NONCOPYABLE(WorkletScriptController); WTF_MAKE_FAST_ALLOCATED; 51 51 public: 52 WorkletScriptController( WorkletGlobalScope*);52 WorkletScriptController(Ref<VM>&&, WorkletGlobalScope*); 53 53 ~WorkletScriptController(); 54 54
Note:
See TracChangeset
for help on using the changeset viewer.