Implement Atomics.wait, notify

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2021-08-12 17:47:14 +09:00 committed by Boram Bae
commit 19298e2216
12 changed files with 272 additions and 99 deletions

View file

@ -540,6 +540,18 @@ static ValueRef* builtin262AgentSleep(ExecutionStateRef* state, ValueRef* thisVa
class ShellPlatform : public PlatformRef {
public:
bool m_canBlock;
ShellPlatform()
: m_canBlock(true)
{
}
void setCanBlock(bool b)
{
m_canBlock = b;
}
virtual void markJSJobEnqueued(ContextRef* relatedContext) override
{
// ignore. we always check pending job after eval script
@ -601,6 +613,11 @@ public:
notifyHostImportModuleDynamicallyResult(relatedContext, referrer, src, promise, loadedModuleResult);
}
virtual bool canBlockExecution(ContextRef* relatedContext) override
{
return m_canBlock;
}
virtual void* allocateThreadLocalCustomData() override
{
return new std::vector<std::tuple<std::string /* abs path */, ContextRef*, PersistentRefHolder<ScriptRef>>>();
@ -913,7 +930,8 @@ int main(int argc, char* argv[])
mallopt(M_MMAP_MAX, 1024 * 1024);
#endif
Globals::initialize(new ShellPlatform());
ShellPlatform* platform = new ShellPlatform();
Globals::initialize(platform);
Memory::setGCFrequency(24);
@ -940,6 +958,10 @@ int main(int argc, char* argv[])
seenModule = true;
continue;
}
if (strcmp(argv[i], "--canblock-is-false") == 0) {
platform->setCanBlock(false);
continue;
}
if (strstr(argv[i], "--filename-as=") == argv[i]) {
fileName = argv[i] + sizeof("--filename-as=") - 1;
continue;