Drop "LTO mode" from qjsc
This commit is contained in:
parent
bebdfcea48
commit
f03ab48a85
2 changed files with 6 additions and 102 deletions
|
@ -206,22 +206,9 @@ target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
|
||||||
#
|
#
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND NOT MINGW)
|
if(BUILD_EXAMPLES AND NOT MINGW)
|
||||||
list(APPEND HELLO_OPTS
|
|
||||||
-fno-string-normalize
|
|
||||||
-fno-map
|
|
||||||
-fno-promise
|
|
||||||
-fno-typedarray
|
|
||||||
-fno-typedarray
|
|
||||||
-fno-regexp
|
|
||||||
-fno-json
|
|
||||||
-fno-eval
|
|
||||||
-fno-proxy
|
|
||||||
-fno-date
|
|
||||||
-fno-module-loader
|
|
||||||
)
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT hello.c
|
OUTPUT hello.c
|
||||||
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o ./hello.c ${HELLO_OPTS} ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
|
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.js
|
||||||
DEPENDS qjsc
|
DEPENDS qjsc
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMENT "Compile hello.js to a C file with bytecode embeddee"
|
COMMENT "Compile hello.js to a C file with bytecode embeddee"
|
||||||
|
@ -235,19 +222,9 @@ if(BUILD_EXAMPLES AND NOT MINGW)
|
||||||
target_compile_definitions(hello PRIVATE ${qjs_defines})
|
target_compile_definitions(hello PRIVATE ${qjs_defines})
|
||||||
target_link_libraries(hello ${qjs_libs})
|
target_link_libraries(hello ${qjs_libs})
|
||||||
|
|
||||||
list(APPEND HELLO_MODULE_OPTS
|
|
||||||
-fno-string-normalize
|
|
||||||
-fno-map
|
|
||||||
-fno-typedarray
|
|
||||||
-fno-regexp
|
|
||||||
-fno-json
|
|
||||||
-fno-eval
|
|
||||||
-fno-proxy
|
|
||||||
-fno-date
|
|
||||||
)
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT hello_module.c
|
OUTPUT hello_module.c
|
||||||
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o ./hello_module.c ${HELLO_MODULE_OPTS} -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
|
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/qjsc" -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_module.js
|
||||||
DEPENDS qjsc
|
DEPENDS qjsc
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMENT "Compile hello_module.js to a C file with bytecode embeddee"
|
COMMENT "Compile hello_module.js to a C file with bytecode embeddee"
|
||||||
|
|
79
qjsc.c
79
qjsc.c
|
@ -47,35 +47,13 @@ typedef struct namelist_t {
|
||||||
int size;
|
int size;
|
||||||
} namelist_t;
|
} namelist_t;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *option_name;
|
|
||||||
const char *init_name;
|
|
||||||
} FeatureEntry;
|
|
||||||
|
|
||||||
static namelist_t cname_list;
|
static namelist_t cname_list;
|
||||||
static namelist_t cmodule_list;
|
static namelist_t cmodule_list;
|
||||||
static namelist_t init_module_list;
|
static namelist_t init_module_list;
|
||||||
static uint64_t feature_bitmap;
|
|
||||||
static FILE *outfile;
|
static FILE *outfile;
|
||||||
static BOOL byte_swap;
|
static BOOL byte_swap;
|
||||||
static const char *c_ident_prefix = "qjsc_";
|
static const char *c_ident_prefix = "qjsc_";
|
||||||
|
|
||||||
#define FE_ALL (-1)
|
|
||||||
|
|
||||||
static const FeatureEntry feature_list[] = {
|
|
||||||
{ "date", "Date" },
|
|
||||||
{ "eval", "Eval" },
|
|
||||||
{ "string-normalize", "StringNormalize" },
|
|
||||||
{ "regexp", "RegExp" },
|
|
||||||
{ "json", "JSON" },
|
|
||||||
{ "proxy", "Proxy" },
|
|
||||||
{ "map", "MapSet" },
|
|
||||||
{ "typedarray", "TypedArrays" },
|
|
||||||
{ "promise", "Promise" },
|
|
||||||
#define FE_MODULE_LOADER 9
|
|
||||||
{ "module-loader", NULL },
|
|
||||||
{ "bigint", "BigInt" },
|
|
||||||
};
|
|
||||||
|
|
||||||
void namelist_add(namelist_t *lp, const char *name, const char *short_name,
|
void namelist_add(namelist_t *lp, const char *name, const char *short_name,
|
||||||
int flags)
|
int flags)
|
||||||
|
@ -349,20 +327,6 @@ void help(void)
|
||||||
"-S n set the maximum stack size to 'n' bytes (default=%d)\n",
|
"-S n set the maximum stack size to 'n' bytes (default=%d)\n",
|
||||||
JS_GetVersion(),
|
JS_GetVersion(),
|
||||||
JS_DEFAULT_STACK_SIZE);
|
JS_DEFAULT_STACK_SIZE);
|
||||||
#ifdef CONFIG_LTO
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
printf("-flto use link time optimization\n");
|
|
||||||
printf("-fno-[");
|
|
||||||
for(i = 0; i < countof(feature_list); i++) {
|
|
||||||
if (i != 0)
|
|
||||||
printf("|");
|
|
||||||
printf("%s", feature_list[i].option_name);
|
|
||||||
}
|
|
||||||
printf("]\n"
|
|
||||||
" disable selected language features (smaller code size)\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +343,6 @@ int main(int argc, char **argv)
|
||||||
FILE *fo;
|
FILE *fo;
|
||||||
JSRuntime *rt;
|
JSRuntime *rt;
|
||||||
JSContext *ctx;
|
JSContext *ctx;
|
||||||
BOOL use_lto;
|
|
||||||
int module;
|
int module;
|
||||||
OutputTypeEnum output_type;
|
OutputTypeEnum output_type;
|
||||||
size_t stack_size;
|
size_t stack_size;
|
||||||
|
@ -388,11 +351,9 @@ int main(int argc, char **argv)
|
||||||
out_filename = NULL;
|
out_filename = NULL;
|
||||||
output_type = OUTPUT_C;
|
output_type = OUTPUT_C;
|
||||||
cname = NULL;
|
cname = NULL;
|
||||||
feature_bitmap = FE_ALL;
|
|
||||||
module = -1;
|
module = -1;
|
||||||
byte_swap = FALSE;
|
byte_swap = FALSE;
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
use_lto = FALSE;
|
|
||||||
stack_size = 0;
|
stack_size = 0;
|
||||||
memset(&dynamic_module_list, 0, sizeof(dynamic_module_list));
|
memset(&dynamic_module_list, 0, sizeof(dynamic_module_list));
|
||||||
|
|
||||||
|
@ -401,7 +362,7 @@ int main(int argc, char **argv)
|
||||||
namelist_add(&cmodule_list, "os", "os", 0);
|
namelist_add(&cmodule_list, "os", "os", 0);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt(argc, argv, "ho:N:f:mxevM:p:S:D:");
|
c = getopt(argc, argv, "ho:N:mxevM:p:S:D:");
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
@ -416,29 +377,6 @@ int main(int argc, char **argv)
|
||||||
case 'N':
|
case 'N':
|
||||||
cname = optarg;
|
cname = optarg;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
p = optarg;
|
|
||||||
if (!strcmp(optarg, "lto")) {
|
|
||||||
use_lto = TRUE;
|
|
||||||
} else if (strstart(p, "no-", &p)) {
|
|
||||||
use_lto = TRUE;
|
|
||||||
for(i = 0; i < countof(feature_list); i++) {
|
|
||||||
if (!strcmp(p, feature_list[i].option_name)) {
|
|
||||||
feature_bitmap &= ~((uint64_t)1 << i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == countof(feature_list))
|
|
||||||
goto bad_feature;
|
|
||||||
} else {
|
|
||||||
bad_feature:
|
|
||||||
fprintf(stderr, "unsupported feature: %s\n", optarg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
module = 1;
|
module = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -531,18 +469,9 @@ int main(int argc, char **argv)
|
||||||
fprintf(fo,
|
fprintf(fo,
|
||||||
"static JSContext *JS_NewCustomContext(JSRuntime *rt)\n"
|
"static JSContext *JS_NewCustomContext(JSRuntime *rt)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" JSContext *ctx = JS_NewContextRaw(rt);\n"
|
" JSContext *ctx = JS_NewContext(rt);\n"
|
||||||
" if (!ctx)\n"
|
" if (!ctx)\n"
|
||||||
" return NULL;\n");
|
" return NULL;\n");
|
||||||
/* add the basic objects */
|
|
||||||
fprintf(fo, " JS_AddIntrinsicBaseObjects(ctx);\n");
|
|
||||||
for(i = 0; i < countof(feature_list); i++) {
|
|
||||||
if ((feature_bitmap & ((uint64_t)1 << i)) &&
|
|
||||||
feature_list[i].init_name) {
|
|
||||||
fprintf(fo, " JS_AddIntrinsic%s(ctx);\n",
|
|
||||||
feature_list[i].init_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* add the precompiled modules (XXX: could modify the module
|
/* add the precompiled modules (XXX: could modify the module
|
||||||
loader instead) */
|
loader instead) */
|
||||||
for(i = 0; i < init_module_list.count; i++) {
|
for(i = 0; i < init_module_list.count; i++) {
|
||||||
|
@ -574,10 +503,8 @@ int main(int argc, char **argv)
|
||||||
(unsigned int)stack_size);
|
(unsigned int)stack_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the module loader if necessary */
|
/* add the module loader */
|
||||||
if (feature_bitmap & (1 << FE_MODULE_LOADER)) {
|
|
||||||
fprintf(fo, " JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);\n");
|
fprintf(fo, " JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);\n");
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fo,
|
fprintf(fo,
|
||||||
" ctx = JS_NewCustomContext(rt);\n"
|
" ctx = JS_NewCustomContext(rt);\n"
|
||||||
|
|
Loading…
Reference in a new issue