Skip to content

chore: update Escargot #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
name: tizen_std_${{ matrix.profile }}
path: /home/runner/GBS-ROOT/${{ matrix.profile }}/local/repos/${{ matrix.profile }}/armv7l/RPMS/
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def setupCLIOptions(parser):
lwnode_optgroup.add_option(
'--escargot-lib-type',
choices=['shared_lib', 'static_lib'],
default='static_lib',
default='shared_lib',
help='shared_lib | static_lib (%default)',
)

Expand Down
2 changes: 1 addition & 1 deletion deps/escargot
Submodule escargot updated 317 files
1 change: 1 addition & 0 deletions deps/node/test/skip_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ test/parallel/test-worker-nexttick-terminate.js
test/parallel/test-worker-process-cwd.js
test/parallel/test-worker-process-env.js
test/parallel/test-worker-sharedarraybuffer-from-worker-thread.js
test/parallel/test-worker-stack-overflow.js # CI 테스트중 간헐적으로 timeout
test/parallel/test-worker-stdio.js # CI 테스트중 간헐적으로 crash. 타이밍 이슈로 추정됨
test/parallel/test-worker-syntax-error-file.js
test/parallel/test-worker-syntax-error.js
Expand Down
5 changes: 2 additions & 3 deletions escargot.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@
'output_dir': '<(SHARED_INTERMEDIATE_DIR)/escargot',
'escargot_libs': [
'<(output_dir)/libescargot<(lib_ext)',
'<(output_dir)/third_party/GCutil/libgc-lib.a',
'<(output_dir)/third_party/runtime_icu_binder/libruntime-icu-binder-static.a',
'<(output_dir)/liblibbf.a',
],
'escargot_configs': [
'-DESCARGOT_SMALL_CONFIG=1',
'-DESCARGOT_USE_CUSTOM_LOGGING=ON',
'-DESCARGOT_USE_EXTENDED_API=ON',
'-DESCARGOT_ARCH=<(target_arch)',
'-DESCARGOT_HOST=<(build_host)',
'-DESCARGOT_MODE=<(escargot_build_mode)',
Expand Down Expand Up @@ -86,6 +84,7 @@
'<(escargot_dir)/src/api',
'<(escargot_dir)/third_party/GCutil',
'<(escargot_dir)/third_party/GCutil/bdwgc/include',
'<(escargot_dir)/third_party/GCutil/bdwgc/include/gc',
],
'conditions': [
['escargot_threading==1', {
Expand Down
6 changes: 3 additions & 3 deletions include/lwnode/lwnode-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#pragma once

#define LWNODE_VERSION_MAJOR 1
#define LWNODE_VERSION_MINOR 0
#define LWNODE_VERSION_PATCH 2
#define LWNODE_VERSION_TAG "v1.0.2"
#define LWNODE_VERSION_MINOR 1
#define LWNODE_VERSION_PATCH 0
#define LWNODE_VERSION_TAG "v1.1.0"
1 change: 1 addition & 0 deletions modules/packages/device-api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include_directories(
${PROJECT_ROOT_PATH}/deps/escargot/src/api
${PROJECT_ROOT_PATH}/deps/escargot/third_party/GCutil
${PROJECT_ROOT_PATH}/deps/escargot/third_party/GCutil/bdwgc/include
${PROJECT_ROOT_PATH}/deps/escargot/third_party/GCutil/bdwgc/include/gc
${PROJECT_ROOT_PATH}/deps/node/deps/uv/include
${PROJECT_ROOT_PATH}/src
include
Expand Down
8 changes: 4 additions & 4 deletions src/api-data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2314,14 +2314,14 @@ void String::ExternalStringResourceBase::operator delete(void* ptr) {

Local<Value> Symbol::Description() const {
auto lwIsolate = IsolateWrap::GetCurrent();
auto esDescription = CVAL(this)->value()->asSymbol()->description();
return Utils::NewLocal<String>(lwIsolate->toV8(), esDescription.get());
auto esDescription = CVAL(this)->value()->asSymbol()->descriptionString();
return Utils::NewLocal<String>(lwIsolate->toV8(), esDescription);
}

Local<Value> Private::Name() const {
auto lwIsolate = IsolateWrap::GetCurrent();
auto esDescription = CVAL(this)->value()->asSymbol()->description();
return Utils::NewLocal<String>(lwIsolate->toV8(), esDescription.get());
auto esDescription = CVAL(this)->value()->asSymbol()->descriptionString();
return Utils::NewLocal<String>(lwIsolate->toV8(), esDescription);
}

template <typename T, typename F>
Expand Down
125 changes: 92 additions & 33 deletions src/api-environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "api.h"
#include "api/engine.h"
#include "api/utils/cast.h"
#include "api/utils/debug.h"
#include "base.h"
#include "init/v8.h"

Expand Down Expand Up @@ -691,19 +692,73 @@ double v8::Date::ValueOf() const {
return scope.self()->asDateObject()->primitiveValue();
}

static RegExpObjectRef::RegExpObjectOption ToEsRegExpObjectOption(
v8::RegExp::Flags flags) {
int option = RegExpObjectRef::RegExpObjectOption::None;

if (flags & v8::RegExp::Flags::kGlobal) {
option |= RegExpObjectRef::RegExpObjectOption::Global;
}
if (flags & v8::RegExp::Flags::kIgnoreCase) {
option |= RegExpObjectRef::RegExpObjectOption::IgnoreCase;
}
if (flags & v8::RegExp::Flags::kMultiline) {
option |= RegExpObjectRef::RegExpObjectOption::MultiLine;
}
if (flags & v8::RegExp::Flags::kSticky) {
option |= RegExpObjectRef::RegExpObjectOption::Sticky;
}
if (flags & v8::RegExp::Flags::kUnicode) {
option |= RegExpObjectRef::RegExpObjectOption::Unicode;
}
if (flags & v8::RegExp::Flags::kDotAll) {
option |= RegExpObjectRef::RegExpObjectOption::DotAll;
}

return static_cast<RegExpObjectRef::RegExpObjectOption>(option);
}

static v8::RegExp::Flags ToV8RegExpFlags(
RegExpObjectRef::RegExpObjectOption option) {
int flags = v8::RegExp::Flags::kNone;

if (option & RegExpObjectRef::RegExpObjectOption::Global) {
flags |= v8::RegExp::Flags::kGlobal;
}
if (option & RegExpObjectRef::RegExpObjectOption::IgnoreCase) {
flags |= v8::RegExp::Flags::kIgnoreCase;
}
if (option & RegExpObjectRef::RegExpObjectOption::MultiLine) {
flags |= v8::RegExp::Flags::kMultiline;
}
if (option & RegExpObjectRef::RegExpObjectOption::Sticky) {
flags |= v8::RegExp::Flags::kSticky;
}
if (option & RegExpObjectRef::RegExpObjectOption::Unicode) {
flags |= v8::RegExp::Flags::kUnicode;
}
if (option & RegExpObjectRef::RegExpObjectOption::DotAll) {
flags |= v8::RegExp::Flags::kDotAll;
}

return static_cast<v8::RegExp::Flags>(flags);
}

MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context,
Local<String> pattern,
Flags flags) {
API_ENTER_WITH_CONTEXT(context, MaybeLocal<RegExp>());
auto lwContext = lwIsolate->GetCurrentContext();
auto lwPattern = CVAL(*pattern)->value();
int flagsValue = (int)flags;
RegExpObjectRef::RegExpObjectOption flagsValue =
ToEsRegExpObjectOption(flags);

auto r = Evaluator::execute(
lwContext->get(),
[](ExecutionStateRef* esState, ValueRef* source, int flags) -> ValueRef* {
return RegExpObjectRef::create(
esState, source, (RegExpObjectRef::RegExpObjectOption)flags);
[](ExecutionStateRef* esState,
ValueRef* source,
RegExpObjectRef::RegExpObjectOption flags) -> ValueRef* {
return RegExpObjectRef::create(esState, source, flags);
},
lwPattern,
flagsValue);
Expand Down Expand Up @@ -747,7 +802,7 @@ v8::RegExp::Flags v8::RegExp::GetFlags() const {
[](ExecutionStateRef* esState,
RegExpObjectRef* self,
int* flags) -> ValueRef* {
*flags = self->option();
*flags = ToV8RegExpFlags(self->option());
return ValueRef::createNull();
},
self->asRegExpObject(),
Expand Down Expand Up @@ -936,34 +991,38 @@ Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) {
Local<Array> Map::AsArray() const {
API_ENTER_NO_TERMINATION_CHECK(EsScope, nullptr);

EvalResult r = Evaluator::execute(
scope.context(),
[](ExecutionStateRef* esState, MapObjectRef* esSelf) -> ValueRef* {
auto done = StringRef::createFromASCII("done");
auto value = StringRef::createFromASCII("value");
auto zero = ValueRef::create(0);
auto one = ValueRef::create(1);
auto vector = ValueVectorRef::create();

auto itr = esSelf->entries(esState);
for (auto entry = itr->next(esState);
entry->asObject()->get(esState, done)->isFalse();
entry = itr->next(esState)) {
auto keyValueArray =
entry->asObject()->get(esState, value)->asObject();
auto key = keyValueArray->getIndexedProperty(esState, zero);
auto value = keyValueArray->getIndexedProperty(esState, one);

vector->pushBack(key);
vector->pushBack(value);
}

return ArrayObjectRef::create(esState, vector);
},
scope.self()->asMapObject());
LWNODE_CHECK(r.isSuccessful());

return Utils::NewLocal<Array>(scope.v8Isolate(), r.result);
LWNODE_UNIMPLEMENT;
return Utils::NewLocal<Array>(
scope.v8Isolate(), ArrayObjectRefHelper::create(scope.context(), 1));

// EvalResult r = Evaluator::execute(
// scope.context(),
// [](ExecutionStateRef* esState, MapObjectRef* esSelf) -> ValueRef* {
// auto done = StringRef::createFromASCII("done");
// auto value = StringRef::createFromASCII("value");
// auto zero = ValueRef::create(0);
// auto one = ValueRef::create(1);
// auto vector = ValueVectorRef::create();

// auto itr = esSelf->entries(esState);
// for (auto entry = itr->next(esState);
// entry->asObject()->get(esState, done)->isFalse();
// entry = itr->next(esState)) {
// auto keyValueArray =
// entry->asObject()->get(esState, value)->asObject();
// auto key = keyValueArray->getIndexedProperty(esState, zero);
// auto value = keyValueArray->getIndexedProperty(esState, one);

// vector->pushBack(key);
// vector->pushBack(value);
// }

// return ArrayObjectRef::create(esState, vector);
// },
// scope.self()->asMapObject());
// LWNODE_CHECK(r.isSuccessful());

// return Utils::NewLocal<Array>(scope.v8Isolate(), r.result);
}

Local<v8::Set> v8::Set::New(Isolate* isolate) {
Expand Down
5 changes: 4 additions & 1 deletion src/api/es-helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ EvalResult ObjectRefHelper::setPrototype(ContextRef* context,
[](ExecutionStateRef* state,
ObjectRef* object,
ValueRef* prototype) -> ValueRef* {
return ValueRef::create(object->setPrototype(state, prototype));
// call ObjectRef::setObjectPrototype instead of ObjectRef::setPrototype
// here because ImmutablePrototypeObject blocks __proto__ property
// setting
return ValueRef::create(object->setObjectPrototype(state, prototype));
},
object,
prototype);
Expand Down
25 changes: 18 additions & 7 deletions src/api/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,12 @@ IsolateWrap::IsolateWrap() {

// NOTE: check lock_gc_release(); is needed (and where)
// lock_gc_release();
Memory::gcRegisterFinalizer(this, [](void* self) {
reinterpret_cast<IsolateWrap*>(self)->~IsolateWrap();
});
Memory::gcRegisterFinalizer(
this,
[](void* self, void* data) {
reinterpret_cast<IsolateWrap*>(self)->~IsolateWrap();
},
nullptr);

MemoryUtil::gcSetWarningListener([](WarnEventType type) {
switch (type) {
Expand Down Expand Up @@ -394,6 +397,14 @@ void IsolateWrap::Initialize(const v8::Isolate::CreateParams& params) {
LWNODE_CALL_TRACE_GC_END();
});

size_t config = vmInstance_->config();
config =
config &
(~static_cast<size_t>(
Escargot::VMInstanceRef::ConfigFlag::PruneCompiledByteCodesWhileGC));
vmInstance_->setConfig(config);
vmInstance_->setMaxCompiledByteCodeSize(1024 * 1024 * 2);

vmInstance_->registerErrorCreationCallback(
[](ExecutionStateRef* state, ErrorObjectRef* error) {
ExceptionHelper::addStackPropertyCallback(state, error);
Expand Down Expand Up @@ -576,7 +587,7 @@ SymbolRef* IsolateWrap::createApiSymbol(StringRef* name) {
auto newSymbol = SymbolRef::create(name);
bool found = false;
for (size_t i = 0; i < apiSymbols_.size(); i++) {
if (apiSymbols_[i]->description()->equals(name)) {
if (apiSymbols_[i]->descriptionString()->equals(name)) {
apiSymbols_[i] = newSymbol;
found = true;
break;
Expand All @@ -596,7 +607,7 @@ SymbolRef* IsolateWrap::getApiSymbol(StringRef* name) {
LWNODE_CALL_TRACE_ID(ISOWRAP);

for (auto apiSymbols : apiSymbols_) {
if (apiSymbols->description()->equals(name)) {
if (apiSymbols->descriptionString()->equals(name)) {
return apiSymbols;
}
}
Expand All @@ -609,7 +620,7 @@ SymbolRef* IsolateWrap::createApiPrivateSymbol(StringRef* name) {
auto newSymbol = SymbolRef::create(name);
bool found = false;
for (size_t i = 0; i < apiPrivateSymbols_.size(); i++) {
if (apiPrivateSymbols_[i]->description()->equals(name)) {
if (apiPrivateSymbols_[i]->descriptionString()->equals(name)) {
apiPrivateSymbols_[i] = newSymbol;
found = true;
break;
Expand All @@ -630,7 +641,7 @@ SymbolRef* IsolateWrap::getApiPrivateSymbol(StringRef* name) {
LWNODE_CALL_TRACE_ID(ISOWRAP);

for (auto apiPrivateSymbol : apiPrivateSymbols_) {
if (apiPrivateSymbol->description()->equals(name)) {
if (apiPrivateSymbol->descriptionString()->equals(name)) {
return apiPrivateSymbol;
}
}
Expand Down
21 changes: 12 additions & 9 deletions src/api/utils/gc-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void MemoryUtil::gcSetWarningListener(OnGCWarnEventListener callback) {
if (g_gcWarnEventListener == nullptr) {
g_gcWarnEventListener = callback;

GC_set_warn_proc([](char* format, GC_word arg) {
GC_set_warn_proc([](const char* format, GC_uintptr_t arg) {
/*
GC Warning: ...May lead to memory leak and poor performance
GC Warning: ...Failed to expand heap
Expand Down Expand Up @@ -316,21 +316,24 @@ void MemoryUtil::prettyBytes(char* buf,
}

void MemoryUtil::gcRegisterFinalizer(Escargot::ValueRef* ptr,
GCAllocatedMemoryFinalizer callback) {
Escargot::Memory::gcRegisterFinalizer(ptr->asObject(), callback);
GCAllocatedMemoryFinalizer callback,
void* data) {
Escargot::Memory::gcRegisterFinalizer(ptr->asObject(), callback, data);
}

void MemoryUtil::gcRegisterFinalizer(EscargotShim::ValueWrap* ptr,
GCAllocatedMemoryFinalizer callback) {
Escargot::Memory::gcRegisterFinalizer(ptr, callback);
GCAllocatedMemoryFinalizer callback,
void* data) {
Escargot::Memory::gcRegisterFinalizer(ptr, callback, data);
}

void MemoryUtil::gcUnregisterFinalizer(Escargot::ValueRef* ptr,
GCAllocatedMemoryFinalizer callback) {
Escargot::Memory::gcUnregisterFinalizer(ptr->asObject(), callback);
GCAllocatedMemoryFinalizer callback,
void* data) {
Escargot::Memory::gcUnregisterFinalizer(ptr->asObject(), callback, data);
}

void MemoryUtil::gcRegisterFinalizer(
void* gcPtr, GCAllocatedMemoryFinalizerWithData callback, void* data) {
REGISTER_FINALIZER(gcPtr, callback, data);
void* gcPtr, GCAllocatedMemoryFinalizer callback, void* data) {
Escargot::Memory::gcRegisterFinalizer(gcPtr, callback, data);
}
Loading
Loading