Skip to content

Commit 6b9ad09

Browse files
author
Jianchun Xu
committed
linux: partially builds lib/Parser
This enables partially building lib/Parser. - Changed many lib/Runtime headers as lib/Parser includes "Runtime.h". Also changed some lib/Common headers and pulled in a few PAL headers to make it build. - vtinfo.h: clang doesn't allow class initialization list ```Base(v), __VA_ARGS__``` if ```__VA_ARGS__``` is empty. Added an ```..._INIT``` version for extra initialization list. - Added symbol ENABLE_GLOBALIZATION, ENABLE_SCRIPT_DEBUGGING, ENABLE_SCRIPT_PROFILING to #ifdef out features on Linux for now. Those need revisit in future. - Added emmintrin.h include, #ifdef out conflicting __m128i from palrt.h. - Added overloaded versions of InterlockedExchangeAdd and InterlockedExchangeSubtract, needed by our code. - Forward enum declarations are not allowed unless the delcarations specifies enum storage type. Added storage type or int by default. - "static" template method specializations are not allowed in class body. Moved specializations out of class and removed "static" keyword. - "default", "and", "or", "xor", "not" are keywords not allowed as enum members. Renamed. - function default parameter value is not allowed in implementation. Removed or moved to declaration.
1 parent b083cc4 commit 6b9ad09

101 files changed

Lines changed: 1832 additions & 1483 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.

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
5656

5757
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
5858
set(IS_64BIT_BUILD 1)
59-
add_definitions(-D_M_X64)
59+
add_definitions(-D_M_X64 -D_M_AMD64)
6060
endif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
6161

6262
add_definitions("-fms-extensions")
@@ -89,6 +89,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
8989
-Wno-invalid-noreturn
9090
-Wno-null-arithmetic
9191
-Wno-tautological-undefined-compare
92+
-Wno-address-of-temporary # vtinfo.h, VirtualTableInfo<T>::RegisterVirtualTable
9293
)
9394
endif(CLR_CMAKE_PLATFORM_UNIX)
9495

@@ -104,8 +105,11 @@ if(CLR_CMAKE_PLATFORM_UNIX)
104105
endif(CLR_CMAKE_PLATFORM_UNIX)
105106

106107

107-
include_directories("pal")
108-
include_directories("pal/inc")
109-
include_directories("pal/inc/rt")
110-
include_directories(lib/Common)
108+
include_directories(
109+
lib/Common
110+
lib/Common/PlaceHolder
111+
pal
112+
pal/inc
113+
pal/inc/rt
114+
)
111115
add_subdirectory (lib)

lib/Backend/LowerMDShared.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ LowererMD::LoadInputParamCount(IR::Instr * instrInsert, int adjust, bool needFla
522522

523523
// Mask off call flags from callinfo
524524
instr = IR::Instr::New(Js::OpCode::AND, dstOpnd, dstOpnd,
525-
IR::IntConstOpnd::New((Js::CallFlags_ExtraArg << Js::CallInfo::ksizeofCount) | 0x00FFFFFF, TyUint32, this->m_func, true), this->m_func);
525+
IR::IntConstOpnd::New((Js::CallFlags_ExtraArg << static_cast<unsigned>(Js::CallInfo::ksizeofCount)) | 0x00FFFFFF, TyUint32, this->m_func, true), this->m_func);
526526
instrInsert->InsertBefore(instr);
527527

528528
// Shift and mask the "calling eval" bit and subtract it from the incoming count.

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory (Common)
2+
add_subdirectory (Parser)

lib/Common/Common.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
#include "CommonMinMemory.h"
88

9-
#ifdef _WIN32
10-
typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
11-
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
12-
#endif
13-
14-
#include <wchar.h>
15-
169
// === C Runtime Header Files ===
1710
#include <stdarg.h>
1811
#include <float.h>
@@ -25,6 +18,10 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
2518
#include <time.h>
2619

2720
#ifdef _WIN32
21+
typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
22+
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
23+
24+
#include <wchar.h>
2825
#include <io.h>
2926
#endif
3027

lib/Common/Common/vtinfo.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,34 @@ INT_PTR const VirtualTableInfo<T>::Address = VirtualTableInfo<T>::RegisterVirtua
113113
friend class VirtualTableInfo<T>; \
114114
DEFINE_VTABLE_CTOR_NOBASE_ABSTRACT(T)
115115

116-
#define DEFINE_VTABLE_CTOR_ABSTRACT(T, Base, ...) \
116+
#define DEFINE_VTABLE_CTOR_ABSTRACT(T, Base) \
117+
T(VirtualTableInfoCtorEnum v) : Base(v) {}
118+
119+
#define DEFINE_VTABLE_CTOR_ABSTRACT_INIT(T, Base, ...) \
117120
T(VirtualTableInfoCtorEnum v) : Base(v), __VA_ARGS__ {}
118121

122+
119123
#define DEFINE_VTABLE_CTOR(T, Base) \
120124
friend class VirtualTableInfo<T>; \
121125
DEFINE_VTABLE_CTOR_ABSTRACT(T, Base) \
122126
DEFINE_VALIDATE_VTABLE_REGISTERED(T);
123127

128+
#define DEFINE_VTABLE_CTOR_MEMBER_INIT(T, Base, Member) \
129+
friend class VirtualTableInfo<T>; \
130+
T(VirtualTableInfoCtorEnum v) : Base(v), Member(v) {} \
131+
DEFINE_VALIDATE_VTABLE_REGISTERED(T);
132+
133+
124134
// Used by non-RecyclableObject
125-
#define DEFINE_VTABLE_CTOR_NO_REGISTER(T, Base, ...) \
135+
#define DEFINE_VTABLE_CTOR_NO_REGISTER(T, Base) \
126136
friend class VirtualTableInfo<T>; \
127-
DEFINE_VTABLE_CTOR_ABSTRACT(T, Base, __VA_ARGS__) \
137+
DEFINE_VTABLE_CTOR_ABSTRACT(T, Base) \
128138
enum RegisterVTableEnum { RegisterVTable = 0 };
129139

130-
#define DEFINE_VTABLE_CTOR_MEMBER_INIT(T, Base, Member) \
140+
#define DEFINE_VTABLE_CTOR_INIT_NO_REGISTER(T, Base, ...) \
131141
friend class VirtualTableInfo<T>; \
132-
T(VirtualTableInfoCtorEnum v) : Base(v), Member(v) {} \
133-
DEFINE_VALIDATE_VTABLE_REGISTERED(T);
142+
DEFINE_VTABLE_CTOR_ABSTRACT_INIT(T, Base, __VA_ARGS__) \
143+
enum RegisterVTableEnum { RegisterVTable = 0 };
134144

135145

136146
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS

lib/Common/CommonDefines.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,27 @@
9292
#define BYTECODE_BRANCH_ISLAND // Byte code short branch and branch island
9393

9494
// Language features
95+
// xplat-todo: revisit these features
96+
#ifdef _WIN32
9597
#define ENABLE_INTL_OBJECT // Intl support
98+
#endif
9699
#define ENABLE_ES6_CHAR_CLASSIFIER // ES6 Unicode character classifier support
97100

98101
// Type system features
99102
#define PERSISTENT_INLINE_CACHES // *** TODO: Won't build if disabled currently
100103
#define SUPPORT_FIXED_FIELDS_ON_PATH_TYPES // *** TODO: Won't build if disabled currently
101104

105+
// xplat-todo: revisit these features
106+
#ifdef _WIN32
107+
// dep: TIME_ZONE_INFORMATION, DaylightTimeHelper, Windows.Globalization
108+
#define ENABLE_GLOBALIZATION
109+
// dep: IDebugDocumentContext
110+
#define ENABLE_SCRIPT_DEBUGGING
111+
// dep: IActiveScriptProfilerCallback, IActiveScriptProfilerHeapEnum
112+
#define ENABLE_SCRIPT_PROFILING
113+
// xplat-todo: change DISABLE_SEH to ENABLE_SEH and move here
114+
#endif
115+
102116
// GC features
103117

104118
// Concurrent and Partial GC are disabled on non-Windows builds

lib/Common/CommonPal.h

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ typedef wchar_t wchar16;
3232
#include "pal.h"
3333
#include "inc/rt/palrt.h"
3434
#include "inc/rt/no_sal2.h"
35+
#include "inc/rt/oaidl.h"
36+
#include <emmintrin.h>
3537

3638
typedef char16_t wchar16;
3739
#define CH_WSTR(s) u##s
@@ -87,7 +89,8 @@ inline int get_cpuid(int cpuInfo[4], int function_id)
8789
#undef sprintf_s
8890

8991
// PAL LoadLibraryExW not supported
90-
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0
92+
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0
93+
#define FACILITY_JSCRIPT 2306
9194

9295
// _countof
9396
#if defined _M_X64 || defined _M_ARM || defined _M_ARM64
@@ -113,6 +116,7 @@ extern "C++"
113116
#endif
114117
// _countof
115118

119+
#define ARRAYSIZE(A) _countof(A)
116120

117121
//
118122
// Singly linked list structure. Can be used as either a list head, or
@@ -191,6 +195,36 @@ PALIMPORT VOID PALAPI InitializeSListHead(IN OUT PSLIST_HEADER ListHead);
191195
PALIMPORT PSLIST_ENTRY PALAPI InterlockedPushEntrySList(IN OUT PSLIST_HEADER ListHead, IN OUT PSLIST_ENTRY ListEntry);
192196
PALIMPORT PSLIST_ENTRY PALAPI InterlockedPopEntrySList(IN OUT PSLIST_HEADER ListHead);
193197

198+
199+
// Use overloaded versions of InterlockedExchangeAdd
200+
#define InterlockedExchangeAdd __InterlockedExchangeAdd
201+
inline long InterlockedExchangeAdd(
202+
IN OUT long volatile *Addend,
203+
IN long Value)
204+
{
205+
return __sync_fetch_and_add(Addend, Value);
206+
}
207+
inline unsigned long InterlockedExchangeAdd(
208+
IN OUT unsigned long volatile *Addend,
209+
IN unsigned long Value)
210+
{
211+
return __sync_fetch_and_add(Addend, Value);
212+
}
213+
214+
inline long InterlockedExchangeSubtract(
215+
IN OUT long volatile *Addend,
216+
IN long Value)
217+
{
218+
return __sync_fetch_and_sub(Addend, Value);
219+
}
220+
inline unsigned long InterlockedExchangeSubtract(
221+
IN OUT unsigned long volatile *Addend,
222+
IN unsigned long Value)
223+
{
224+
return __sync_fetch_and_sub(Addend, Value);
225+
}
226+
227+
194228
// xplat-todo: implement these for JIT and Concurrent/Partial GC
195229
uintptr_t _beginthreadex(
196230
void *security,
@@ -243,11 +277,3 @@ errno_t rand_s(unsigned int* randomValue);
243277
#else
244278
#define _NOEXCEPT noexcept
245279
#endif
246-
247-
// xplat-todo: can we get rid of this for clang?
248-
// Including xmmintrin.h right now creates a ton of
249-
// compile errors, so temporarily defining this for clang
250-
// to avoid including that header
251-
#ifndef _MSC_VER
252-
#define _MM_HINT_T0 3
253-
#endif

lib/Common/Core/Api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma intrinsic(memcpy)
88
extern void __stdcall js_memcpy_s(__bcount(sizeInBytes) void *dst, size_t sizeInBytes, __in_bcount(count) const void *src, size_t count);
9-
extern void __stdcall js_wmemcpy_s(__ecount(sizeInWords) wchar_t *dst, size_t sizeInWords, __in_ecount(count) const wchar_t *src, size_t count);
9+
extern void __stdcall js_wmemcpy_s(__ecount(sizeInWords) wchar16 *dst, size_t sizeInWords, __in_ecount(count) const wchar16 *src, size_t count);
1010

1111
// A virtualized thread id. The physical thread on which an instance of the runtime is executed can change but a
1212
// ThreadContextId should be invariant.

lib/Common/Core/CmdParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ class CmdLineArgsParser : private ICmdLineArgsParser
7575
void ParseNumberPairSet(Js::NumberPairSet * numberPairSet);
7676
void PrintUsage();
7777

78-
wchar_t CurChar()
78+
wchar16 CurChar()
7979
{
8080
return this->pszCurrentArg[0];
8181
}
8282

83-
wchar_t PeekChar()
83+
wchar16 PeekChar()
8484
{
8585
return this->pszCurrentArg[1];
8686
}

lib/Common/Core/CommonTypedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Copyright (C) Microsoft. All rights reserved.
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
5-
typedef wchar_t wchar;
5+
typedef wchar16 wchar;
66
typedef unsigned int uint;
77
typedef unsigned short ushort;
88
typedef unsigned long ulong;

0 commit comments

Comments
 (0)