-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
osx: JIT support #1744
osx: JIT support #1744
Conversation
c4a9979
to
2733317
Compare
@jianchun @curtisman review please. |
void PDataManager::RegisterPdata(RUNTIME_FUNCTION* pdataStart, _In_ const ULONG_PTR functionStart, _In_ const ULONG_PTR functionEnd, _Out_ PVOID* pdataTable, ULONG entryCount, ULONG maxEntryCount) | ||
void PDataManager::RegisterPdata(RUNTIME_FUNCTION* pdataStart, | ||
_In_ const ULONG_PTR functionStart, _In_ const ULONG_PTR functionEnd, | ||
_Out_ PVOID* pdataTable, ULONG entryCount, ULONG maxEntryCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should use 4-space indentation
} | ||
} | ||
} | ||
DEFINE_DYNAMICPROFILEINFO_RECORDMODULUSOPTYPE_FNC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks weird. How about removing the "inline" keyword from old implementation instead?
@@ -12,6 +12,10 @@ CompileAssert(false) | |||
#include "XDataAllocator.h" | |||
#include "Core/DelayLoadLibrary.h" | |||
|
|||
#ifndef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: #ifndef ...
not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed not needed. However this is an xplat header file [for now]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to recall you had this same include elsewhere without #ifndef _WIN32
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From PlatformAgnostic maybe ? My approach is to keep enabling anything non-Windows on lib files to prevent Full project breaks.
} \ | ||
Assert(OpCodeUtil::EncodedSize((Js::OpCode)op, SmallLayout) \ | ||
== (currentOffset - offset)); \ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to other comment, putting the code to multiple places with a macro looks weird. Please try other cleaner solution e.g. moving the template instantiation to header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed weird. Tried other things [i.e. remove inline / use it from header ].. Older Clang behaves strange :/ Actually, we already define those in multiple places (using include
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried simply removing inline
fixes both cases: #1790
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that, I do recall it fails on my test machine.. will take CI as the base and remove the inlines
--*/ | ||
|
||
#include "pal/dbgmsg.h" | ||
SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know nothing about these big changes in PAL. Did you work on these changes, or did you sync them to dotnet coreCLR latest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some I had to update + sync to PAL.
extern void mac_fde_wrapper(const char *dataStart, mac_fde_reg_op reg_op) | ||
{ | ||
for(const char *head = dataStart, *last = dataStart + CC_FDE_SIZE; | ||
head != last; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest avoid the last
check. FDE is not of fixed size. The check may mislead some to think it is. The CIE/FDE data is guaranteed to terminate from the break
in the loop body below. If for any reason the data is wrong and does not, it makes no difference whether it hangs/crashes here or crashes later on. Hanging/crashing here is better in my opinion because it is closer to the source of problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee here for a meaningful hang or crash. Indeed FDE is not a fixed size and shouldn't be bigger than the defined size above. + if it is bigger, see assert below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My biggest complain is about the misleading for
loop. It reads as if it would loop some fixed size and end at last
. Actually no, it ends at a terminator and break from inside the loop body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does and I see your complain. I would rather add a comment there instead of removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer self-explanatory code instead of comment. head != last
is meaningless. It is almost always true.
{ | ||
const char *op = head; | ||
// Get Length of record [ Read 4 bytes ] | ||
const uint32_t* op_data = (const uint32_t*)op; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const uint32_t* op_data [](start = 8, length = 23)
Why not const uint32_t length = ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be... op -> cast to -> op_data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the pointer op_data
was not as straightforward. Just do const uint32_t length = *(const uint32_t*)op;
and use length
.
break; | ||
} | ||
// if it's not 0xffffffff, | ||
// there we have the length of the CIE or FDE record. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Comment is not very clear (as code not checking 0xFFFFFFFF). We actually ignored 0xFFFFFFFF which identifies extended length. Our records are small so we never need extended length.
} | ||
// if it's not 0xffffffff, | ||
// there we have the length of the CIE or FDE record. | ||
head += 4; // get next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
head += 4; // get next [](start = 8, length = 22)
nit: Please comment it is to read next 4 bytes and non zero value identifies FDE (zero is CIE).
extern "C" void __register_frame(const void* ehframe); | ||
extern "C" void __deregister_frame(const void* ehframe); | ||
|
||
#if defined(_AMD64_) && !defined(DISABLE_JIT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!defined(DISABLE_JIT) [](start = 24, length = 21)
Please use ENABLE_NATIVE_CODEGEN
instead of !defined(DISABLE_JIT)
. The former is used more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we define DISABLE_JIT
in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENABLE_NATIVE_CODEGEN
existed from the beginning of this project and used everywhere. DISABLE_JIT
used rarely (haven't checked so not sure about history, might be added recently, maybe we should not have added it). I prefer the former for overall consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall DISABLE_JIT
is used while enabling JIT on linux. Since we have it and naming explains the intention, I prefer keeping it. If we want to remove them all, that's something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok if you insist. Just want to note that another reason I prefer ENABLE_NATIVE_CODEGEN
is it is positive. Easier to read and understand than double negative !defined(DISABLE_JIT)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this part. ENABLE_NATIVE_CODEGEN is a subset of DISABLE_JIT. ENABLE_NATIVE_CODEGEN is generally meant for JIT-related code directly. DISABLE_JIT was added as part of doing the Interpreter-only version of ChakraCore last year- it implies !ENABLE_NATIVE_CODEGEN but also disables other things like dynamic interpreter thunks, interpreter profiling etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @digitalinfinity for explanation, now I understand. !defined(DISABLE_JIT)
here is fine to me.
typedef void(*mac_fde_reg_op)(const void*addr); | ||
void mac_fde_wrapper(const char *dataStart, mac_fde_reg_op reg_op); | ||
#define __REGISTER_FRAME(addr) mac_fde_wrapper((char*)addr, __register_frame) | ||
#define __DEREGISTER_FRAME(addr) mac_fde_wrapper((char*)addr, __deregister_frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Use (const char*)addr
to be consistent with signature.
e00b064
to
4816a60
Compare
@dotnet-bot test Ubuntu ubuntu_linux_debug_static |
@dotnet-bot test Ubuntu ubuntu_linux_test_static |
@dotnet-bot test Ubuntu ubuntu_linux_release |
d13c2a2
to
3350b7c
Compare
This PR; - Enables JIT on macOS - Fixes / improvements to xplat exception handling
} | ||
else | ||
{ | ||
divideTypeInfo[profileId] = divideTypeInfo[profileId].Merge(ValueType::Float); | ||
divideTypeInfo[profileId] = divideTypeInfo[profileId] | ||
.Merge(ValueType::Float); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: DynamicProfileInfo.cpp contains some formatting changes that are unnecessary (changes when you originally put them into a macro?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80 chars. since it is updated, left it.
// jmp _ZN2Js18JavascriptFunction17CallAsmJsFunctionIiEET_PNS_16RecyclableObjectEPFPvS4_NS_8CallInfoEzEjPS5_ | ||
//??$CallAsmJsFunction@T__m128@@@JavascriptFunction@Js@@SA?AT__m128@@PEAVRecyclableObject@1@PEAXIPEAPEAX@Z ENDP | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Why moving this section... here they are closer to next implementation.
Also you deleted __m128 version. Commented out currently, maybe needed in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
osx linker. ordering issues. we add that easily when we need it. it is keep showing up on my auto searches as if I forgot that..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@obastemur Thanks for making this change! Left 2 nit comments (can ignore).
@jianchun Thanks for the review |
Merge pull request #1744 from obastemur:xoj This PR; - Enables JIT on macOS - Fixes / improvements to xplat exception handling
This PR;