Refactoring Job

* all types of job now handled in the task queue

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2021-02-10 16:52:59 +09:00 committed by Boram Bae
commit 90522697eb
13 changed files with 73 additions and 84 deletions

View file

@ -274,8 +274,8 @@ static ValueRef* builtinUneval(ExecutionStateRef* state, ValueRef* thisValue, si
static ValueRef* builtinDrainJobQueue(ExecutionStateRef* state, ValueRef* thisValue, size_t argc, ValueRef** argv, bool isConstructCall)
{
ContextRef* context = state->context();
while (context->vmInstance()->hasPendingPromiseJob()) {
auto jobResult = context->vmInstance()->executePendingPromiseJob();
while (context->vmInstance()->hasPendingJob()) {
auto jobResult = context->vmInstance()->executePendingJob();
if (jobResult.error) {
return ValueRef::create(false);
}
@ -458,7 +458,7 @@ PersistentRefHolder<ContextRef> createEscargotContext(VMInstanceRef* instance)
class ShellPlatform : public PlatformRef {
public:
virtual void didPromiseJobEnqueued(ContextRef* relatedContext, PromiseObjectRef* obj) override
virtual void markJSJobEnqueued(ContextRef* relatedContext) override
{
// ignore. we always check pending job after eval script
}
@ -632,8 +632,8 @@ static bool evalScript(ContextRef* context, StringRef* source, StringRef* srcNam
puts(evalResult.resultOrErrorToString(context)->toStdUTF8String().data());
}
while (context->vmInstance()->hasPendingPromiseJob()) {
auto jobResult = context->vmInstance()->executePendingPromiseJob();
while (context->vmInstance()->hasPendingJob()) {
auto jobResult = context->vmInstance()->executePendingJob();
if (shouldPrintScriptResult) {
if (jobResult.error) {
fprintf(stderr, "Uncaught %s:\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());