Skip to content
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

android: ChakraCore compiles to Android ARMv7 #2224

Merged
merged 1 commit into from
Dec 21, 2016

Conversation

obastemur
Copy link
Collaborator

@obastemur obastemur commented Dec 16, 2016

disclaimer: Android is not officially supported.

@obastemur
Copy link
Collaborator Author

obastemur commented Dec 16, 2016

Things left to do;

  • fix linker issues and convert couple of MSVC ASM [done]
  • fix couple of todo items
  • test on ADB

Copy link
Contributor

@digitalinfinity digitalinfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, looks fine to me. Left some comments and didn't review the PAL changes in-depth. Can you also write up something on how to build CC on Android if anyone else wanted to try? Maybe just update our BUILDING file or add it to the wiki?

@@ -254,7 +254,7 @@ AutoSystemInfo::SSE2Available() const
return false; // TODO: xplat support
#endif
#else
#error Unsupported platform.
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave the error here and add an explicit ifdef for ARMv7/Android here so that anyone adding new platform support is aware that this function is something they need to think about

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digitalinfinity if it's not Intel, IMO SSE2Available() should return false. What other possibilities here?

@@ -637,9 +648,9 @@ namespace PlatformAgnostic
#endif
}

__forceinline unsigned char _BitTest(const LONG *_BitBase, int _BitPos)
__forceinline unsigned char _BitTest(LONG *_BitBase, int _BitPos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the const removed here? seems like allowing for const can result in better codegen by the compiler- if it's android specific, I'd prefer doing a const_cast when _bittest is called scoped to Android

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang intrinsic definition has no const.

@@ -621,7 +632,7 @@ namespace PlatformAgnostic
{
__forceinline unsigned char _BitTestAndSet(LONG *_BitBase, int _BitPos)
{
#if defined(__clang__)
#if defined(__clang__) && !defined(_ARM_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My ARM fu is weak, so a basic question here- is ARM the same for Windows ARM vs Android ARM v7? Should it be? I know that Windows supports Thumb2, which I don't know if Android supports so the Windows ARM code might end up being slightly different from the Android ARM- I'm not sure what the macro model here should look like. @pleath @satheeshravi thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, also there are ARMv7 and ARMv8, 32-bit and 64-bit, we need to be careful to cover them correctly.


In reply to: 92870165 [](ancestors = 92870165)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digitalinfinity below code is for x86 (bts is an x86 instruction). and when read the comment, we use intrinsic here for ARM 32 bit instead.

@ThomsonTan intrinsic below should work for ARMv8 too.

// We use a custom calling convention to invoke JavascriptMethod based on
// System V AMD64 ABI. At entry of JavascriptMethod the stack layout is:
// System ABI. At entry of JavascriptMethod the stack layout is:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting- are the calling conventions in the ABIs same for x86/AMD64/ARM on Linux?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddressOfReturnAddress is intrinsic

@@ -75,6 +70,10 @@ inline int _count_args(const T1&, const T2&, const T3&, const T4&, Js::CallInfo
#define CALL_ENTRYPOINT(entryPoint, function, callInfo, ...) \
entryPoint(function, callInfo, nullptr, nullptr, nullptr, nullptr, \
function, callInfo, ##__VA_ARGS__)
#elif defined(_ARM_)
// xplat-todo: fix me
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some more description here? What needs to be fixed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is likely to fail for different targets. I will turn back to here (hence todo note)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated this to fix me ARM

@@ -371,7 +371,9 @@ namespace Js

if (FACILITY_CONTROL == HRESULT_FACILITY(hr) || FACILITY_JSCRIPT == HRESULT_FACILITY(hr))
{
#ifndef __ANDROID__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this change for? Does this function work xplat? It looks like its mostly getting windows specific errors so perhaps the entire if condition shouldn't disabled for Android, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argList != nullptr is wrong. I'm not sure how this works or if it works at all. Clearly it doesn't work with Clang 3.8 abi-arm-android.

entire if condition shouldn't disabled for Android

Sounds Good. Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, shouldn't we consider argList will never be null and keep it as is here?

@@ -1,3 +1,5 @@
if (NOT CC_TARGET_OS_ANDROID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this note- have we cleaned up this file to make sure that it's checking for stuff that ChakraCore actually needs? When I imported the PAL, I didn't bother to clean this up but if our PAL is diverging, can you make a note to clean up this file at some point?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PAL uses this file to feature detect on target. This is not an option when cross-compiling the code.

can you make a note to clean up this file at some point?

Good idea, will do. Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added extra notes

@obastemur
Copy link
Collaborator Author

Can you also write up something on how to build CC on Android if anyone else wanted to try? Maybe just update our BUILDING file or add it to the wiki?

@digitalinfinity we need #2224 (comment) steps are done for anyone to experience ChakraCore literally.

@obastemur obastemur force-pushed the exp branch 5 times, most recently from dbb616d to 1aa8826 Compare December 20, 2016 14:55
@obastemur
Copy link
Collaborator Author

Steps to compile:

  • Download Android NDK and extract
  • Build/android_toolchain.sh
  • ./build.sh --target=android --arch=arm --no-icu --static --debug --no-jit

After some updates to this PR, currently there are only few linker errors left.

@digitalinfinity do you have any additional comments?

@obastemur obastemur force-pushed the exp branch 4 times, most recently from 3d50742 to b95e5d9 Compare December 21, 2016 13:14
@obastemur
Copy link
Collaborator Author

Android ARMv7 linker issues are also fixed (along with the implementation of ChakraCore ASM files)

@obastemur obastemur force-pushed the exp branch 3 times, most recently from 7e01db0 to 467795c Compare December 21, 2016 16:09
@obastemur
Copy link
Collaborator Author

Also targets RaspberryPI (see #2262 for additional requirements)

@obastemur obastemur force-pushed the exp branch 2 times, most recently from 6a6c50b to 7e65d01 Compare December 21, 2016 16:12
@digitalinfinity
Copy link
Contributor

No more comments from my side- thanks @obastemur

@digitalinfinity
Copy link
Contributor

LGTM

@obastemur
Copy link
Collaborator Author

@digitalinfinity @ThomsonTan Thanks for the Reviews!!

@chakrabot chakrabot merged commit 6811584 into chakra-core:master Dec 21, 2016
chakrabot pushed a commit that referenced this pull request Dec 21, 2016
Merge pull request #2224 from obastemur:exp

disclaimer: Android is not officially supported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants