Changeset 188894 in webkit for trunk/Source/JavaScriptCore/runtime/Completion.cpp
- Timestamp:
- Aug 24, 2015, 4:48:55 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r188752 r188894 31 31 #include "JSCInlines.h" 32 32 #include "JSGlobalObject.h" 33 #include "JSInternalPromise.h" 34 #include "JSInternalPromiseDeferred.h" 33 35 #include "JSLock.h" 34 36 #include "JSModuleRecord.h" … … 112 114 } 113 115 114 void evaluateModule(ExecState* exec, const SourceCode& source, NakedPtr<Exception>& returnedException) 116 static JSInternalPromise* evaluateModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer) 117 { 118 return globalObject->moduleLoader()->loadModule(exec, moduleName, referrer); 119 } 120 121 static JSInternalPromise* evaluateModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName) 122 { 123 JSValue moduleNameValue; 124 if (moduleName.isSymbol()) 125 moduleNameValue = Symbol::create(exec->vm(), static_cast<SymbolImpl&>(*moduleName.impl())); 126 else 127 moduleNameValue = jsString(&exec->vm(), moduleName.impl()); 128 129 return evaluateModule(lock, exec, globalObject, moduleNameValue, jsUndefined()); 130 } 131 132 JSInternalPromise* evaluateModule(ExecState* exec, const SourceCode& source) 115 133 { 116 134 JSLockHolder lock(exec); 117 135 RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); 118 136 RELEASE_ASSERT(!exec->vm().isCollectorBusy()); 119 120 CodeProfiling profile(source);121 137 122 138 JSGlobalObject* globalObject = exec->vmEntryGlobalObject(); … … 126 142 Symbol* key = Symbol::create(exec->vm(), *privateName.uid()); 127 143 128 ModuleLoaderObject* moduleLoader = globalObject->moduleLoader();129 130 144 // Insert the given source code to the ModuleLoader registry as the fetched registry entry. 131 moduleLoader->provide(exec, key, ModuleLoaderObject::Status::Fetch, source.toString());145 globalObject->moduleLoader()->provide(exec, key, ModuleLoaderObject::Status::Fetch, source.toString()); 132 146 if (exec->hadException()) { 133 returnedException = exec->exception();147 JSValue exception = exec->exception()->value(); 134 148 exec->clearException(); 135 return; 149 JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject); 150 deferred->reject(exec, exception); 151 return deferred->promise(); 136 152 } 137 153 138 // FIXME: Now, we don't implement the linking phase yet. 139 // So here, we just call requestInstantiateAll to only perform the module loading. 140 // At last, it should be replaced with requestReady. 141 // https://bugs.webkit.org/show_bug.cgi?id=148172 142 moduleLoader->requestInstantiateAll(exec, key); 154 return evaluateModule(lock, exec, globalObject, key, jsUndefined()); 155 } 143 156 144 // FIXME: We should also handle the asynchronous Syntax Errors that will be delivered by the rejected promise. 145 // https://bugs.webkit.org/show_bug.cgi?id=148173 146 if (exec->hadException()) { 147 returnedException = exec->exception(); 148 exec->clearException(); 149 return; 150 } 157 JSInternalPromise* evaluateModule(ExecState* exec, const Identifier& moduleName) 158 { 159 JSLockHolder lock(exec); 160 RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); 161 RELEASE_ASSERT(!exec->vm().isCollectorBusy()); 162 163 return evaluateModule(lock, exec, exec->vmEntryGlobalObject(), moduleName); 164 } 165 166 JSInternalPromise* evaluateModule(ExecState* exec, const String& moduleName) 167 { 168 JSLockHolder lock(exec); 169 RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); 170 RELEASE_ASSERT(!exec->vm().isCollectorBusy()); 171 172 return evaluateModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName)); 151 173 } 152 174
Note:
See TracChangeset
for help on using the changeset viewer.