Title: [240242] trunk/Source/_javascript_Core
Revision
240242
Author
[email protected]
Date
2019-01-21 14:01:16 -0800 (Mon, 21 Jan 2019)

Log Message

[JSC] Lazily initialize JSModuleLoader
https://bugs.webkit.org/show_bug.cgi?id=193646

Reviewed by Keith Miller and Saam Barati.

Lazily initialize JSModuleLoader so that we do not need to initialize it until we need modules.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::moduleLoader const):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (240241 => 240242)


--- trunk/Source/_javascript_Core/ChangeLog	2019-01-21 20:50:59 UTC (rev 240241)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-01-21 22:01:16 UTC (rev 240242)
@@ -1,3 +1,18 @@
+2019-01-21  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Lazily initialize JSModuleLoader
+        https://bugs.webkit.org/show_bug.cgi?id=193646
+
+        Reviewed by Keith Miller and Saam Barati.
+
+        Lazily initialize JSModuleLoader so that we do not need to initialize it until we need modules.
+
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        (JSC::JSGlobalObject::visitChildren):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::moduleLoader const):
+
 2019-01-20  Yusuke Suzuki  <[email protected]>
 
         [JSC] sub op with 0 should be optimized

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (240241 => 240242)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2019-01-21 20:50:59 UTC (rev 240241)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2019-01-21 22:01:16 UTC (rev 240242)
@@ -788,9 +788,14 @@
     ReflectObject* reflectObject = ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get()));
     putDirectWithoutTransition(vm, vm.propertyNames->Reflect, reflectObject, static_cast<unsigned>(PropertyAttribute::DontEnum));
 
-    m_moduleLoader.set(vm, this, JSModuleLoader::create(globalExec(), vm, this, JSModuleLoader::createStructure(vm, this, jsNull())));
+    m_moduleLoader.initLater(
+        [] (const Initializer<JSModuleLoader>& init) {
+            auto catchScope = DECLARE_CATCH_SCOPE(init.vm);
+            init.set(JSModuleLoader::create(init.owner->globalExec(), init.vm, init.owner, JSModuleLoader::createStructure(init.vm, init.owner, jsNull())));
+            catchScope.releaseAssertNoException();
+        });
     if (Options::exposeInternalModuleLoader())
-        putDirectWithoutTransition(vm, vm.propertyNames->Loader, m_moduleLoader.get(), static_cast<unsigned>(PropertyAttribute::DontEnum));
+        putDirectWithoutTransition(vm, vm.propertyNames->Loader, moduleLoader(), static_cast<unsigned>(PropertyAttribute::DontEnum));
 
     JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
     JSFunction* builtinDescribe = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinDescribe);
@@ -1574,7 +1579,7 @@
     visitor.append(thisObject->m_functionProtoHasInstanceSymbolFunction);
     thisObject->m_throwTypeErrorGetterSetter.visit(visitor);
     visitor.append(thisObject->m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter);
-    visitor.append(thisObject->m_moduleLoader);
+    thisObject->m_moduleLoader.visit(visitor);
 
     visitor.append(thisObject->m_objectPrototype);
     visitor.append(thisObject->m_functionPrototype);

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (240241 => 240242)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2019-01-21 20:50:59 UTC (rev 240241)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2019-01-21 22:01:16 UTC (rev 240242)
@@ -300,7 +300,7 @@
     WriteBarrier<JSObject> m_regExpProtoUnicodeGetter;
     WriteBarrier<GetterSetter> m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter;
 
-    WriteBarrier<JSModuleLoader> m_moduleLoader;
+    LazyProperty<JSGlobalObject, JSModuleLoader> m_moduleLoader;
 
     WriteBarrier<ObjectPrototype> m_objectPrototype;
     WriteBarrier<FunctionPrototype> m_functionPrototype;
@@ -611,7 +611,7 @@
         return m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter.get();
     }
     
-    JSModuleLoader* moduleLoader() const { return m_moduleLoader.get(); }
+    JSModuleLoader* moduleLoader() const { return m_moduleLoader.get(this); }
 
     ObjectPrototype* objectPrototype() const { return m_objectPrototype.get(); }
     FunctionPrototype* functionPrototype() const { return m_functionPrototype.get(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to