Skip to content

Commit

Permalink
Use quickjs-ng 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Oct 15, 2024
1 parent 3890f3f commit 841fca1
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61,494 deletions.
18 changes: 7 additions & 11 deletions c/jsdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ static void print_jsval(JSValue val) {
errorf("JS_IsNumber\n");
} else if(JS_IsBigInt(NULL, val)) {
errorf("JS_IsBigInt\n");
} else if(JS_IsBigFloat(val)) {
errorf("JS_IsBigFloat\n");
} else if(JS_IsBigDecimal(val)) {
errorf("JS_IsBigDecimal\n");
} else if(JS_IsBool(val)) {
errorf("JS_IsBool\n");
} else if(JS_IsNull(val)) {
Expand Down Expand Up @@ -104,8 +100,10 @@ static int js_load_module(JSContext *ctx, const uint8_t *bytes, const uint32_t s
return 0;
}

//print_jsval(obj);
JSValue val = JS_EvalFunction(ctx, obj);
if (JS_IsException(val)) {
errorf("Error: jsdec thrown an exception when loading a module\n");
jsdec_handle_exception(ctx);
return 0;
}
Expand Down Expand Up @@ -194,17 +192,14 @@ jsdec_t *jsdec_new() {

// initialize all intrisic
JS_AddIntrinsicBaseObjects(ctx);
JS_AddIntrinsicDate(ctx);
JS_AddIntrinsicEval(ctx);
JS_AddIntrinsicRegExpCompiler(ctx);
JS_AddIntrinsicRegExp(ctx);
JS_AddIntrinsicJSON(ctx);
JS_AddIntrinsicMapSet(ctx);
JS_AddIntrinsicTypedArrays(ctx);
JS_AddIntrinsicPromise(ctx);
JS_AddIntrinsicBigInt(ctx);
JS_AddIntrinsicBigFloat(ctx);
JS_AddIntrinsicBigDecimal(ctx);
JS_AddIntrinsicOperators(ctx);
JS_AddIntrinsicEval(ctx);
JS_EnableBignumExt(ctx, 1);


// Setup global objects.
JSValue global = JS_GetGlobalObject(ctx);
Expand All @@ -223,6 +218,7 @@ jsdec_t *jsdec_new() {
JS_FreeValue(ctx, global);

if (!js_load_all_modules(ctx)) {
errorf("Error: failed to load modules\n");
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions js/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ if get_option('build_type') == 'standalone'
build_always_stale: true,
output : 'bytecode.h',
input : jsdec_testsuite,
command : [qjsc, '-m', '-N', 'main_bytecode', '-c', '-o', '@OUTPUT@', '@INPUT@'],
command : [qjsc, '-m', '-N', 'main_bytecode', '-o', '@OUTPUT@', '@INPUT@'],
)
else
bytecode_h = custom_target(
'bytecode.h',
build_always_stale: true,
output : 'bytecode.h',
input : jsdec_plugin,
command : [qjsc, '-m', '-N', 'main_bytecode', '-c', '-o', '@OUTPUT@', '@INPUT@'],
command : [qjsc, '-m', '-N', 'main_bytecode', '-o', '@OUTPUT@', '@INPUT@'],
)
endif

Expand Down
5 changes: 3 additions & 2 deletions subprojects/libquickjs.wrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[wrap-git]
url = https://github.com/frida/quickjs.git
revision = c81f05c9859cea5f83a80057416a0c7affe9b876
url = https://github.com/quickjs-ng/quickjs.git
revision = v0.6.1
directory = libquickjs
patch_directory = libquickjs
depth = 1
109 changes: 49 additions & 60 deletions subprojects/packagefiles/libquickjs/meson.build
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
project('quickjs', 'c',
version: '2021-03-27-frida',
project('quickjs-ng', 'c',
version: 'v0.6.1',
)

cc = meson.get_compiler('c')

have_msvc = cc.get_id() == 'msvc'

threads_dep = dependency('threads')
dl_dep = cc.find_library('dl', required: false)
m_dep = cc.find_library('m', required: false)
Expand All @@ -15,77 +13,68 @@ headers = [
]

sources = [
'quickjs.c',
'libregexp.c',
'libunicode.c',
'cutils.c',
'libbf.c',
'libregexp.c',
'libunicode.c',
'quickjs.c',
]

cdata = configuration_data()
cdata.set_quoted('CONFIG_VERSION', meson.project_version())

if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif

if cc.has_header('unistd.h')
cdata.set('HAVE_UNISTD_H', 1)
endif

if cc.has_function('malloc_usable_size')
cdata.set('HAVE_MALLOC_USABLE_SIZE', 1)
endif
compiler_flags = [
'-fvisibility=hidden',
'-Wno-implicit-fallthrough',
'-Wno-sign-compare',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-unused-but-set-variable',
'-Wno-array-bounds',
'-Wno-format-truncation',
'-Wno-format-zero-length',
'-funsigned-char',
]

if get_option('libc')
headers += 'quickjs-libc.h'
sources += 'quickjs-libc.c'
if cc.get_id() == 'msvc'
compiler_flags += '-Wno-unsafe-buffer-usage'
compiler_flags += '-Wno-sign-conversion'
compiler_flags += '-Wno-nonportable-system-include-path'
compiler_flags += '-Wno-implicit-int-conversion'
compiler_flags += '-Wno-shorten-64-to-32'
compiler_flags += '-Wno-reserved-macro-identifier'
compiler_flags += '-Wno-reserved-identifier'
compiler_flags += '-Wdeprecated-declarations'
compiler_flags += '/experimental:c11atomics'
compiler_flags += '/wd4018' # -Wno-sign-conversion
compiler_flags += '/wd4061' # -Wno-implicit-fallthrough
compiler_flags += '/wd4100' # -Wno-unused-parameter
compiler_flags += '/wd4200' # -Wno-zero-length-array
compiler_flags += '/wd4242' # -Wno-shorten-64-to-32
compiler_flags += '/wd4244' # -Wno-shorten-64-to-32
compiler_flags += '/wd4245' # -Wno-sign-compare
compiler_flags += '/wd4267' # -Wno-shorten-64-to-32
compiler_flags += '/wd4388' # -Wno-sign-compare
compiler_flags += '/wd4389' # -Wno-sign-compare
compiler_flags += '/wd4710' # Function not inlined
compiler_flags += '/wd4711' # Function was inlined
compiler_flags += '/wd4820' # Padding added after construct
compiler_flags += '/wd4996' # -Wdeprecated-declarations
compiler_flags += '/wd5045' # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
endif

cdata.set('CONFIG_BIGNUM', get_option('bignum'))

atomics = false
opt = get_option('atomics')
if not opt.disabled()
if opt.auto()
atomics = not have_msvc
elif not have_msvc
atomics = true
else
error('Atomics support was requested but is not available')
endif
endif
cdata.set('CONFIG_ATOMICS', atomics)
# required on linux, but ignored by windows
add_project_arguments('-D_GNU_SOURCE=1', language: 'c')

stack_check = false
opt = get_option('stack_check')
if not opt.disabled()
if opt.auto()
stack_check = not have_msvc
elif not have_msvc
stack_check = true
else
error('Stack limitation was requested but is not available')
foreach flag: compiler_flags
if cc.has_argument(flag)
add_project_arguments(flag, language: 'c')
endif
endif
cdata.set('CONFIG_STACK_CHECK', stack_check)

configure_file(
output: 'config.h',
configuration: cdata,
)

add_project_arguments(
have_msvc ? '/FI' : '-include', meson.current_build_dir() / 'config.h',
'-D_GNU_SOURCE=1',
language: 'c',
)
endforeach

quickjs = static_library('quickjs', sources,
dependencies: [threads_dep, dl_dep, m_dep],
implicit_include_directories: false,
install: false,
)

quickjs_dep = declare_dependency(
link_with: quickjs,
include_directories: include_directories('.'),
Expand Down
Loading

0 comments on commit 841fca1

Please sign in to comment.