Skip to content

Commit 105b8f2

Browse files
committed
Experimental: Introduce "lite" ChakraCore build
Initial attempt to produce a ChakraCore build with a small binary footprint, trading off with performance and some functionality. Lite build currently will disable - JIT, - Script debugging - Valid pointer table in the recycler - Intl - ETW Add support to build without script debug Add support to not use precomputed valid pointer table saving memory/binary size. Disable page heap support in recycler for release build Disable unused script profiling code in ChakraCore Also fix the OOPJIT IDL to include CommonDefines.h On Windows, current lite build is about 50% of the normal build on x86 and 51% on x64 x86 Core 5516288 bytes Lite 2765312 bytes x64 Core 7315968 bytes Lite 3742720 bytes
1 parent fd8d6c4 commit 105b8f2

80 files changed

Lines changed: 786 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Build/Chakra.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
%(PreprocessorDefinitions);
3131
DISABLE_JIT=1
3232
</PreprocessorDefinitions>
33+
<PreprocessorDefinitions Condition="'$(BuildScriptDebug)'=='false'">
34+
%(PreprocessorDefinitions);
35+
BUILD_WITHOUT_SCRIPT_DEBUG=1
36+
</PreprocessorDefinitions>
37+
<PreprocessorDefinitions Condition="'$(BuildLite)'=='true'">
38+
%(PreprocessorDefinitions);
39+
CHAKRACORE_LITE
40+
</PreprocessorDefinitions>
3341
<PreprocessorDefinitions Condition="'$(IntlICU)'=='true'">
3442
%(PreprocessorDefinitions);
3543
INTL_ICU=1

Build/Common.Build.Default.props

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<Import Project="$(ChakraDevConfigDir)\Chakra.Build.user.props" Condition="exists('$(ChakraDevConfigDir)\Chakra.Build.user.props')"/>
2929
</ImportGroup>
3030

31+
<!-- Configurations -->
32+
<PropertyGroup Condition="'$(BuildLite)'=='true'">
33+
<BuildJIT>false</BuildJIT>
34+
<BuildScriptDebug>false</BuildScriptDebug>
35+
</PropertyGroup>
3136
<!-- Common build settings -->
3237
<PropertyGroup>
3338
<DebugBuild />
@@ -62,7 +67,9 @@
6267
<OutBaseDir Condition="'$(OutBaseDir)'!=''">$(OutBaseDir)\$(SolutionName)</OutBaseDir>
6368
<OutBaseDir Condition="'$(OutBaseDir)'==''">$(SolutionDir)VcBuild</OutBaseDir>
6469
<OutBaseDir Condition="'$(Clang)'!=''">$(OutBaseDir).$(Clang)</OutBaseDir>
65-
<OutBaseDir Condition="'$(BuildJIT)'=='false'">$(OutBaseDir).NoJIT</OutBaseDir>
70+
<OutBaseDir Condition="'$(BuildLite)'=='true'">$(OutBaseDir).Lite</OutBaseDir>
71+
<OutBaseDir Condition="'$(BuildLite)'!='true' and '$(BuildJIT)'=='false'">$(OutBaseDir).NoJIT</OutBaseDir>
72+
<OutBaseDir Condition="'$(BuildLite)'!='true' and '$(BuildScriptDebug)'=='false'">$(OutBaseDir).NoScriptDebug</OutBaseDir>
6673
<OutBaseDir Condition="'$(ForceSWB)'=='true'">$(OutBaseDir).SWB</OutBaseDir>
6774
<IntBaseDir Condition="'$(IntBaseDir)'==''">$(OutBaseDir)</IntBaseDir>
6875
</PropertyGroup>

bin/ChakraCore/ChakraCore.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<ProjectReference Include="..\..\lib\Runtime\ByteCode\Chakra.Runtime.ByteCode.vcxproj">
158158
<Project>{706083f7-6aa4-4558-a153-6352ef9110f5}</Project>
159159
</ProjectReference>
160-
<ProjectReference Include="..\..\lib\Runtime\Debug\Chakra.Runtime.Debug.vcxproj">
160+
<ProjectReference Include="..\..\lib\Runtime\Debug\Chakra.Runtime.Debug.vcxproj" Condition="'$(BuildScriptDebug)'!='false'">
161161
<Project>{8C61E4E7-F0D6-420D-A352-3E6E50D406DD}</Project>
162162
</ProjectReference>
163163
<ProjectReference Include="..\..\lib\Runtime\Language\Chakra.Runtime.Language.vcxproj">

bin/ch/ch.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
66
#include "Core/AtomLockGuids.h"
7-
#include <CommonPal.h>
87
#ifdef _WIN32
98
#include <winver.h>
109
#include <process.h>

bin/ch/stdafx.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@
2424
#define IfFalseGo(expr) do { if(!(expr)) { hr = E_FAIL; goto Error; } } while(0)
2525
#define IfFalseGoLabel(expr, label) do { if(!(expr)) { hr = E_FAIL; goto label; } } while(0)
2626

27-
#define WIN32_LEAN_AND_MEAN 1
28-
2927
#include "CommonDefines.h"
3028
#include <map>
3129
#include <string>
3230

33-
#ifdef _WIN32
34-
#include <windows.h>
35-
#else
3631
#include <CommonPal.h>
37-
#endif // _WIN32
3832

3933
#include <stdarg.h>
4034
#ifdef _MSC_VER

lib/Backend/BailOut.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
//-------------------------------------------------------------------------------------------------------
55

66
#include "Backend.h"
7+
#ifdef ENABLE_SCRIPT_DEBUGGING
78
#include "Debug/DebuggingFlags.h"
89
#include "Debug/DiagProbe.h"
910
#include "Debug/DebugManager.h"
11+
#endif
1012
#include "Language/JavascriptFunctionArgIndex.h"
1113

1214
extern const IRType RegTypes[RegNumCount];
@@ -1376,6 +1378,7 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
13761378
// Clear the disable implicit call bit in case we bail from that region
13771379
functionScriptContext->GetThreadContext()->ClearDisableImplicitFlags();
13781380

1381+
#ifdef ENABLE_SCRIPT_DEBUGGING
13791382
bool isInDebugMode = executeFunction->IsInDebugMode();
13801383
AssertMsg(!isInDebugMode || Js::Configuration::Global.EnableJitInDebugMode(),
13811384
"In diag mode we can get here (function has to be JIT'ed) only when EnableJitInDiagMode is true!");
@@ -1446,6 +1449,8 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
14461449
}
14471450
}
14481451
}
1452+
#endif
1453+
14491454
#if defined(DBG_DUMP) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
14501455
char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE];
14511456
#endif
@@ -1735,7 +1740,11 @@ BailOutRecord::BailOutHelper(Js::JavascriptCallStackLayout * layout, Js::ScriptF
17351740
{
17361741
// Following _AddressOfReturnAddress <= real address of "returnAddress". Suffices for RemoteStackWalker to test partially initialized interpreter frame.
17371742
Js::InterpreterStackFrame::PushPopFrameHelper pushPopFrameHelper(newInstance, returnAddress, _AddressOfReturnAddress());
1743+
#ifdef ENABLE_SCRIPT_DEBUGGING
17381744
aReturn = isInDebugMode ? newInstance->DebugProcess() : newInstance->Process();
1745+
#else
1746+
aReturn = newInstance->Process();
1747+
#endif
17391748
// Note: in debug mode we always have to bailout to debug thunk,
17401749
// as normal interpreter thunk expects byte code compiled w/o debugging.
17411750
}
@@ -2736,7 +2745,9 @@ Js::Var BailOutRecord::BailOutForElidedYield(void * framePointer)
27362745
Js::ScriptFunction ** functionRef = (Js::ScriptFunction **)&layout->functionObject;
27372746
Js::ScriptFunction * function = *functionRef;
27382747
Js::FunctionBody * executeFunction = function->GetFunctionBody();
2748+
#ifdef ENABLE_SCRIPT_DEBUGGING
27392749
bool isInDebugMode = executeFunction->IsInDebugMode();
2750+
#endif
27402751

27412752
Js::JavascriptGenerator* generator = static_cast<Js::JavascriptGenerator*>(layout->args[0]);
27422753
Js::InterpreterStackFrame* frame = generator->GetFrame();
@@ -2756,7 +2767,11 @@ Js::Var BailOutRecord::BailOutForElidedYield(void * framePointer)
27562767
{
27572768
// Following _AddressOfReturnAddress <= real address of "returnAddress". Suffices for RemoteStackWalker to test partially initialized interpreter frame.
27582769
Js::InterpreterStackFrame::PushPopFrameHelper pushPopFrameHelper(frame, _ReturnAddress(), _AddressOfReturnAddress());
2770+
#ifdef ENABLE_SCRIPT_DEBUGGING
27592771
aReturn = isInDebugMode ? frame->DebugProcess() : frame->Process();
2772+
#else
2773+
aReturn = frame->Process();
2774+
#endif
27602775
// Note: in debug mode we always have to bailout to debug thunk,
27612776
// as normal interpreter thunk expects byte code compiled w/o debugging.
27622777
}

lib/Backend/JnHelperMethod.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void CheckJnHelperTable(intptr_t const* table)
6565
}
6666
#endif
6767

68+
#ifdef ENABLE_SCRIPT_DEBUGGING
6869
static intptr_t const helperMethodWrappers[] = {
6970
reinterpret_cast<intptr_t>(&Js::HelperMethodWrapper0),
7071
reinterpret_cast<intptr_t>(&Js::HelperMethodWrapper1),
@@ -84,6 +85,7 @@ static intptr_t const helperMethodWrappers[] = {
8485
reinterpret_cast<intptr_t>(&Js::HelperMethodWrapper15),
8586
reinterpret_cast<intptr_t>(&Js::HelperMethodWrapper16),
8687
};
88+
#endif
8789

8890
///----------------------------------------------------------------------------
8991
///
@@ -97,7 +99,7 @@ intptr_t
9799
GetMethodAddress(ThreadContextInfo * context, IR::HelperCallOpnd* opnd)
98100
{
99101
Assert(opnd);
100-
102+
#ifdef ENABLE_SCRIPT_DEBUGGING
101103
#if defined(_M_ARM32_OR_ARM64)
102104
#define LowererMDFinal LowererMD
103105
#else
@@ -120,7 +122,7 @@ GetMethodAddress(ThreadContextInfo * context, IR::HelperCallOpnd* opnd)
120122
AssertMsg(FALSE, "Unsupported arg count (need to implement).");
121123
}
122124
}
123-
125+
#endif
124126
return GetMethodOriginalAddress(context, opnd->m_fnHelper);
125127
}
126128

lib/Backend/Lower.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "Backend.h"
6+
#ifdef ENABLE_SCRIPT_DEBUGGING
67
#include "Debug/DebuggingFlags.h"
78
#include "Debug/DiagProbe.h"
89
#include "Debug/DebugManager.h"
10+
#endif
911

1012
// Parser includes
1113
#include "RegexCommon.h"
@@ -2656,9 +2658,11 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
26562658
LowerBailOnNegative(instr);
26572659
break;
26582660

2661+
#ifdef ENABLE_SCRIPT_DEBUGGING
26592662
case Js::OpCode::BailForDebugger:
26602663
instrPrev = this->LowerBailForDebugger(instr);
26612664
break;
2665+
#endif
26622666

26632667
case Js::OpCode::BailOnNotObject:
26642668
instrPrev = this->LowerBailOnNotObject(instr);
@@ -11422,6 +11426,7 @@ Lowerer::LowerCondBranchCheckBailOut(IR::BranchInstr * branchInstr, IR::Instr *
1142211426
Assert(branchInstr->m_opcode == Js::OpCode::BrTrue_A || branchInstr->m_opcode == Js::OpCode::BrFalse_A);
1142311427
if (branchInstr->HasBailOutInfo())
1142411428
{
11429+
#ifdef ENABLE_SCRIPT_DEBUGGING
1142511430
IR::BailOutKind debuggerBailOutKind = IR::BailOutInvalid;
1142611431
if (branchInstr->HasAuxBailOut())
1142711432
{
@@ -11432,10 +11437,12 @@ Lowerer::LowerCondBranchCheckBailOut(IR::BranchInstr * branchInstr, IR::Instr *
1143211437
debuggerBailOutKind = branchInstr->GetAuxBailOutKind() & IR::BailOutForDebuggerBits;
1143311438
AssertMsg((debuggerBailOutKind & ~(IR::BailOutIgnoreException | IR::BailOutForceByFlag)) == 0, "Only IR::BailOutIgnoreException|ForceByFlag supported here.");
1143411439
}
11440+
#endif
1143511441

1143611442
IR::Instr * bailOutInstr = this->SplitBailOnImplicitCall(branchInstr, helperCall, branchInstr);
1143711443
IR::Instr* prevInstr = this->LowerBailOnEqualOrNotEqual(bailOutInstr, branchInstr, nullptr, nullptr, isHelper);
1143811444

11445+
#ifdef ENABLE_SCRIPT_DEBUGGING
1143911446
if (debuggerBailOutKind != IR::BailOutInvalid)
1144011447
{
1144111448
// Note that by this time implicit calls bailout is already lowered.
@@ -11462,6 +11469,9 @@ Lowerer::LowerCondBranchCheckBailOut(IR::BranchInstr * branchInstr, IR::Instr *
1146211469
this->LowerBailForDebugger(debuggerBailoutInstr, isHelper);
1146311470
// After lowering this we will have a check which on bailout condition will JMP to $L11.
1146411471
}
11472+
#else
11473+
(prevInstr);
11474+
#endif
1146511475
}
1146611476

1146711477
return m_lowererMD.LowerCondBranch(branchInstr);
@@ -11813,6 +11823,7 @@ Lowerer::LowerBailOnNotBuiltIn(IR::Instr *instr,
1181311823
return prevInstr;
1181411824
}
1181511825

11826+
#ifdef ENABLE_SCRIPT_DEBUGGING
1181611827
IR::Instr *
1181711828
Lowerer::LowerBailForDebugger(IR::Instr* instr, bool isInsideHelper /* = false */)
1181811829
{
@@ -11990,6 +12001,7 @@ Lowerer::LowerBailForDebugger(IR::Instr* instr, bool isInsideHelper /* = false *
1199012001

1199112002
return prevInstr;
1199212003
}
12004+
#endif
1199312005

1199412006
IR::Instr*
1199512007
Lowerer::LowerBailOnException(IR::Instr * instr)

lib/Backend/ServerScriptContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ ServerScriptContext::IsPRNGSeeded() const
271271
return m_isPRNGSeeded;
272272
}
273273

274+
#ifdef ENABLE_SCRIPT_DEBUGGING
274275
intptr_t
275276
ServerScriptContext::GetDebuggingFlagsAddr() const
276277
{
@@ -294,6 +295,7 @@ ServerScriptContext::GetDebugScriptIdWhenSetAddr() const
294295
{
295296
return static_cast<intptr_t>(m_contextData.debugScriptIdWhenSetAddr);
296297
}
298+
#endif
297299

298300
bool
299301
ServerScriptContext::IsClosed() const

lib/Backend/ServerScriptContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ class ServerScriptContext : public ScriptContextInfo
5454
virtual bool IsClosed() const override;
5555
virtual intptr_t GetBuiltinFunctionsBaseAddr() const override;
5656

57+
#ifdef ENABLE_SCRIPT_DEBUGGING
5758
virtual intptr_t GetDebuggingFlagsAddr() const override;
5859
virtual intptr_t GetDebugStepTypeAddr() const override;
5960
virtual intptr_t GetDebugFrameAddressAddr() const override;
6061
virtual intptr_t GetDebugScriptIdWhenSetAddr() const override;
62+
#endif
6163

6264
virtual intptr_t GetAddr() const override;
6365

0 commit comments

Comments
 (0)