mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Remove busy waiting & fix memory bug
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
682f176d6d
commit
d698343196
10 changed files with 144 additions and 62 deletions
|
|
@ -415,11 +415,16 @@ static ValueRef* builtin262AgentStart(ExecutionStateRef* state, ValueRef* thisVa
|
|||
}
|
||||
}
|
||||
|
||||
while (instance->hasPendingJob()) {
|
||||
auto jobResult = instance->executePendingJob();
|
||||
if (jobResult.error) {
|
||||
while (context->vmInstance()->hasPendingJob() || context->vmInstance()->hasPendingJobFromAnotherThread()) {
|
||||
if (context->vmInstance()->waitEventFromAnotherThread(10)) {
|
||||
context->vmInstance()->executePendingJobFromAnotherThread();
|
||||
}
|
||||
if (context->vmInstance()->hasPendingJob()) {
|
||||
auto jobResult = context->vmInstance()->executePendingJob();
|
||||
if (jobResult.error) {
|
||||
fprintf(stderr, "Uncaught %s: in agent\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
if (jobResult.error) {
|
||||
fprintf(stderr, "Uncaught %s: in agent\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -571,6 +576,11 @@ public:
|
|||
// ignore. we always check pending job after eval script
|
||||
}
|
||||
|
||||
virtual void markJSJobFromAnotherThreadExists(ContextRef* relatedContext) override
|
||||
{
|
||||
// ignore. we always check pending job after eval script
|
||||
}
|
||||
|
||||
virtual LoadModuleResult onLoadModule(ContextRef* relatedContext, ScriptRef* whereRequestFrom, StringRef* moduleSrc, ModuleType type) override
|
||||
{
|
||||
std::string referrerPath = whereRequestFrom->src()->toStdUTF8String();
|
||||
|
|
@ -741,14 +751,19 @@ static bool evalScript(ContextRef* context, StringRef* source, StringRef* srcNam
|
|||
}
|
||||
|
||||
bool result = true;
|
||||
while (context->vmInstance()->hasPendingJob()) {
|
||||
auto jobResult = context->vmInstance()->executePendingJob();
|
||||
if (shouldPrintScriptResult || jobResult.error) {
|
||||
if (jobResult.error) {
|
||||
fprintf(stderr, "Uncaught %s:\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
result = false;
|
||||
} else {
|
||||
fprintf(stderr, "%s\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
while (context->vmInstance()->hasPendingJob() || context->vmInstance()->hasPendingJobFromAnotherThread()) {
|
||||
if (context->vmInstance()->waitEventFromAnotherThread(10)) {
|
||||
context->vmInstance()->executePendingJobFromAnotherThread();
|
||||
}
|
||||
if (context->vmInstance()->hasPendingJob()) {
|
||||
auto jobResult = context->vmInstance()->executePendingJob();
|
||||
if (shouldPrintScriptResult || jobResult.error) {
|
||||
if (jobResult.error) {
|
||||
fprintf(stderr, "Uncaught %s:\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
result = false;
|
||||
} else {
|
||||
fprintf(stderr, "%s\n", jobResult.resultOrErrorToString(context)->toStdUTF8String().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue