mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Implement await dynamic import resolution
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
c4073deee7
commit
4cd0da1e07
9 changed files with 159 additions and 39 deletions
|
|
@ -322,7 +322,6 @@ Value Script::execute(ExecutionState& state, bool isExecuteOnEvalFunction, bool
|
|||
}
|
||||
|
||||
if (isModule()) {
|
||||
ASSERT(!moduleData()->m_didCallLoadedCallback);
|
||||
if (!moduleData()->m_didCallLoadedCallback) {
|
||||
context()->vmInstance()->platform()->didLoadModule(context(), nullptr, this);
|
||||
moduleData()->m_didCallLoadedCallback = true;
|
||||
|
|
@ -586,6 +585,22 @@ Value Script::executeLocal(ExecutionState& state, Value thisValue, InterpretedCo
|
|||
return resultValue;
|
||||
}
|
||||
|
||||
void* Script::ModuleData::ModulePromiseObject::operator new(size_t size)
|
||||
{
|
||||
static bool typeInited = false;
|
||||
static GC_descr descr;
|
||||
if (!typeInited) {
|
||||
GC_word desc[GC_BITMAP_SIZE(ModulePromiseObject)] = { 0 };
|
||||
PromiseObject::fillGCDescriptor(desc);
|
||||
GC_set_bit(desc, GC_WORD_OFFSET(ModulePromiseObject, m_referrer));
|
||||
GC_set_bit(desc, GC_WORD_OFFSET(ModulePromiseObject, m_loadedScript));
|
||||
GC_set_bit(desc, GC_WORD_OFFSET(ModulePromiseObject, m_value));
|
||||
descr = GC_make_descriptor(desc, GC_WORD_LEN(ModulePromiseObject));
|
||||
typeInited = true;
|
||||
}
|
||||
return GC_MALLOC_EXPLICITLY_TYPED(size, descr);
|
||||
}
|
||||
|
||||
Script::ModuleExecutionResult Script::moduleLinking(ExecutionState& state)
|
||||
{
|
||||
// On success, Instantiate transitions this module's [[Status]] from "unlinked" to "linked". On failure, an exception is thrown and this module's [[Status]] remains "unlinked".
|
||||
|
|
@ -1127,6 +1142,11 @@ void Script::asyncModuleFulfilled(ExecutionState& state, Script* module)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < module->moduleData()->m_asyncPendingPromises.size(); i++) {
|
||||
module->moduleData()->m_asyncPendingPromises[i]->fulfill(state, module->getModuleNamespace(state));
|
||||
}
|
||||
module->moduleData()->m_asyncPendingPromises.clear();
|
||||
}
|
||||
|
||||
Value Script::asyncModuleFulfilledFunction(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue