Skip to content

Commit ea40648

Browse files
committed
adjust optimization and C++ flags. -Oz produces a 2MB smaller intl binary, but without vectorization (helped by the -O2 inlining), the interpreter hot path might not stay hot in the CPU caches. if using JSC on Android, users probably have a Very Good Reason(tm), but I'm not sure which they care about more: app download size or performance per watt efficiency.
1 parent 5a5ad23 commit ea40648

File tree

3 files changed

+77
-9
lines changed

3 files changed

+77
-9
lines changed
Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,78 @@
1+
diff --git a/webkit/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp b/webkit/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp
2+
index 2e2203099e..9c8917096d 100644
3+
--- a/webkit/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp
4+
+++ b/webkit/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.cpp
5+
@@ -45,6 +45,7 @@ void JSModuleNamespaceObject::finishCreation(JSGlobalObject* globalObject, Abstr
6+
{
7+
VM& vm = globalObject->vm();
8+
auto scope = DECLARE_THROW_SCOPE(vm);
9+
+ UNUSED_PARAM(shouldPreventExtensions);
10+
Base::finishCreation(vm);
11+
ASSERT(inherits(info()));
12+
13+
@@ -208,6 +209,9 @@ bool JSModuleNamespaceObject::put(JSCell* cell, JSGlobalObject* globalObject, Pr
14+
{
15+
VM& vm = globalObject->vm();
16+
auto scope = DECLARE_THROW_SCOPE(vm);
17+
+ UNUSED_PARAM(cell);
18+
+ UNUSED_PARAM(propertyName);
19+
+ UNUSED_PARAM(value);
20+
21+
#if USE(BUN_JSC_ADDITIONS)
22+
auto* thisObject = jsCast<JSModuleNamespaceObject*>(cell);
23+
diff --git a/webkit/Source/JavaScriptCore/runtime/JSModuleRecord.cpp b/webkit/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
24+
index 24cea00a3f..41ccae3c5e 100644
25+
--- a/webkit/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
26+
+++ b/webkit/Source/JavaScriptCore/runtime/JSModuleRecord.cpp
27+
@@ -63,18 +63,18 @@ JSModuleRecord::JSModuleRecord(VM& vm, Structure* structure, const Identifier& m
28+
{
29+
}
30+
31+
-#if USE(BUN_JSC_ADDITIONS)
32+
size_t JSModuleRecord::estimatedSize(JSCell* cell, VM& vm)
33+
{
34+
- const auto& thisObject = jsCast<JSModuleRecord*>(cell);
35+
size_t size = Base::estimatedSize(cell, vm);
36+
+#if USE(BUN_JSC_ADDITIONS)
37+
+ const auto& thisObject = jsCast<JSModuleRecord*>(cell);
38+
const SourceCode& sourceCode = thisObject->sourceCode();
39+
StringView view = sourceCode.provider() ? sourceCode.provider()->source() : StringView();
40+
size += view.length() * (view.is8Bit() ? sizeof(Latin1Character) : sizeof(UChar));
41+
size += sourceCode.memoryCost();
42+
+#endif
43+
return size;
44+
}
45+
-#endif
46+
void JSModuleRecord::destroy(JSCell* cell)
47+
{
48+
JSModuleRecord* thisObject = static_cast<JSModuleRecord*>(cell);
149
diff --git a/webkit/Source/JavaScriptCore/runtime/JSPromise.cpp b/webkit/Source/JavaScriptCore/runtime/JSPromise.cpp
2-
index 09b051775b..c1599e5c9d 100644
50+
index 09b051775b..a0a4a6b10f 100644
351
--- a/webkit/Source/JavaScriptCore/runtime/JSPromise.cpp
452
+++ b/webkit/Source/JavaScriptCore/runtime/JSPromise.cpp
5-
@@ -220,6 +220,7 @@ void JSPromise::fulfillWithNonPromise(JSGlobalObject* lexicalGlobalObject, JSVal
53+
@@ -219,6 +219,7 @@ void JSPromise::fulfillWithNonPromise(JSGlobalObject* lexicalGlobalObject, JSVal
54+
{
655
VM& vm = lexicalGlobalObject->vm();
756
auto scope = DECLARE_THROW_SCOPE(vm);
8-
uint32_t flags = this->flags();
957
+ UNUSED_PARAM(scope);
58+
uint32_t flags = this->flags();
1059
ASSERT_WITH_MESSAGE(!value.inherits<Exception>(), "Promise fulfilled with exception");
1160
ASSERT_WITH_MESSAGE(!value.inherits<JSPromise>(), "Promise fulfilled with another promise");
12-
61+
diff --git a/webkit/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp b/webkit/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp
62+
index be5602f0b7..2f26538268 100644
63+
--- a/webkit/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp
64+
+++ b/webkit/Source/JavaScriptCore/runtime/ModuleProgramExecutable.cpp
65+
@@ -37,10 +37,11 @@ ModuleProgramExecutable::ModuleProgramExecutable(JSGlobalObject* globalObject, c
66+
{
67+
SourceProviderSourceType sourceType = source.provider()->sourceType();
68+
ASSERT(sourceType == SourceProviderSourceType::Module
69+
- #if USE(BUN_JSC_ADDITIONS)
70+
+#if USE(BUN_JSC_ADDITIONS)
71+
|| sourceType == SourceProviderSourceType::BunTranspiledModule
72+
- #endif
73+
+#endif
74+
);
75+
+ UNUSED_PARAM(sourceType);
76+
VM& vm = globalObject->vm();
77+
if (vm.typeProfiler() || vm.controlFlowProfiler())
78+
vm.functionHasExecutedCache()->insertUnexecutedRange(sourceID(), typeProfilingStartOffset(), typeProfilingEndOffset());

scripts/compile/common.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ DEBUG_SYMBOL_LEVEL="-g2"
101101
if [[ "$BUILD_TYPE" = "Release" ]]
102102
then
103103
FRAME_POINTER_FLAG="-fomit-frame-pointer"
104-
CFLAGS_BUILD_TYPE="-DNDEBUG -g0 -Oz -flto=thin"
105-
ICU_CFLAGS_BUILD_TYPE="-Oz -flto=thin"
104+
CFLAGS_BUILD_TYPE="-DNDEBUG -g0 -O2 -flto=thin -fvectorize -fslp-vectorize -funroll-loops"
105+
ICU_CFLAGS_BUILD_TYPE="-O2 -flto=thin -fvectorize -fslp-vectorize -funroll-loops"
106106
else
107107
FRAME_POINTER_FLAG="-fno-omit-frame-pointer"
108108
CFLAGS_BUILD_TYPE=""
@@ -136,6 +136,7 @@ $CFLAGS_BUILD_TYPE \
136136
"
137137

138138
COMMON_CXXFLAGS=" \
139+
-std=c++2b \
139140
"
140141

141142
ICU_CFLAGS="$COMMON_CFLAGS $PLATFORM_CFLAGS $ICU_CFLAGS_BUILD_TYPE"

scripts/start.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ patchAndMakeICU() {
3535

3636
if [[ "$BUILD_TYPE" = "Release" ]]
3737
then
38-
CFLAGS="-Os -flto=thin"
39-
CXXFLAGS="--std=c++11 -flto=thin"
38+
local OPT_FLAGS="-O2 -flto=thin -fvectorize -fslp-vectorize -funroll-loops"
39+
CFLAGS="$OPT_FLAGS"
40+
CXXFLAGS="-std=c++2b $OPT_FLAGS"
4041
LDFLAGS="-flto=thin"
4142
else
4243
CFLAGS="-g2"
43-
CXXFLAGS="--std=c++11"
44+
CXXFLAGS="-std=c++2b"
4445
LDFLAGS=""
4546
fi
4647

0 commit comments

Comments
 (0)