Skip to content

Commit

Permalink
Update PAL to support Apple Silicon
Browse files Browse the repository at this point in the history
- Some material brought in from PAL at github.com/dotnet/
- Various manual changes to fit with existing codebase
- Updated licensing in edited files, latest PAL is copyright .dotNet
- Updated copyright  check scripts to check pal/ files for new text
  • Loading branch information
rhuanjl committed Mar 22, 2023
1 parent cbb9b10 commit 3fb33a8
Show file tree
Hide file tree
Showing 30 changed files with 2,796 additions and 3,489 deletions.
42 changes: 36 additions & 6 deletions THIRD-PARTY-NOTICES.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
ChakraCore uses third party material from the projects listed below.
The original copyright notice and the license under which Microsoft
received such third party material are set forth below. Microsoft
reserves all other rights not expressly granted, whether by
or the ChakraCore Project Contributors received such third party material
are set forth below. Microsoft, and where relevant the ChakraCore Project
Contributors reserve all other rights not expressly granted, whether by
implication, estoppel or otherwise.

In the event that we accidentally failed to list a required notice, please
bring it to our attention. Post an issue or email us: [email protected]
bring it to our attention. Post an issue or message us on discord.

THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
Do Not Translate or Localize

ChakraCore incorporates third party material from the projects listed below.
The original copyright notice and the license under which Microsoft received
such third party material are set forth below. Microsoft reserves all other
rights not expressly granted, whether by implication, estoppel or otherwise.
The original copyright notice and the license under which Microsoft or the
ChakraCore Project Contributors received such third party material are set
forth below. Microsoft, and where relevant the ChakraCore Project Contributors
reserve all other rights not expressly granted, whether by implication, estoppel or otherwise.

1. backbone.suggestions (https://github.com/qloo/backbone.suggestions)
2. BeatDetektor.js
Expand Down Expand Up @@ -48,6 +50,7 @@ rights not expressly granted, whether by implication, estoppel or otherwise.
31. yargs-parser.js (https://github.com/yargs/yargs-parser)
32. camelcase.js (https://github.com/sindresorhus/camelcase)
33. ARES-6 (https://github.com/WebKit/webkit/tree/master/PerformanceTests/ARES-6)
34. PAL (from dotNet)

%% backbone.suggestions NOTICES, INFORMATION, AND LICENSE BEGIN HERE
=========================================
Expand Down Expand Up @@ -2041,3 +2044,30 @@ END OF ARES-6 NOTICES, INFORMATION, AND LICENSE

---------------------------------------------

%% PAL NOTICES, INFORMATION AND LICENSE BEGIN HERE
=========================================
The MIT License (MIT)

Copyright (c) .NET Foundation and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=========================================
END OF PAL NOTICES, INFORMATION, AND LICENSE
13 changes: 11 additions & 2 deletions pal/inc/cclock.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

#ifndef CC_PAL_INC_CCLOCK_H
#define CC_PAL_INC_CCLOCK_H

class CCLock
#if defined(_M_ARM64)
#define CCLOCK_ALIGN __declspec(align(8))
#else
#define CCLOCK_ALIGN
#endif

class CCLOCK_ALIGN CCLock
{
char mutexPtr[64]; // keep mutex implementation opaque to consumer (PAL vs non-PAL)

Expand Down
45 changes: 28 additions & 17 deletions pal/inc/pal.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

//-------------------------------------------------------------------------------------------------------
// ChakraCore/Pal
// Contains portions (c) copyright Microsoft, portions copyright (c) the .NET Foundation and Contributors
// and edits (c) copyright the ChakraCore Contributors.
// See THIRD-PARTY-NOTICES.txt in the project root for .NET Foundation license
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
/*++
Module Name:
Expand Down Expand Up @@ -2907,6 +2909,7 @@ typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY {

#define CONTEXT_CONTROL (CONTEXT_ARM64 | 0x1L)
#define CONTEXT_INTEGER (CONTEXT_ARM64 | 0x2L)
#define CONTEXT_SEGMENTS (CONTEXT_ARM64 | 0x4L)
#define CONTEXT_FLOATING_POINT (CONTEXT_ARM64 | 0x4L)
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_ARM64 | 0x8L)

Expand Down Expand Up @@ -3190,6 +3193,8 @@ PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context,
#define PAL_CS_NATIVE_DATA_SIZE 76
#elif defined(__APPLE__) && defined(__x86_64__)
#define PAL_CS_NATIVE_DATA_SIZE 120
#elif defined(__APPLE__) && defined(_ARM64_)
#define PAL_CS_NATIVE_DATA_SIZE 120
#elif defined(__LINUX__) && defined(__i386__)
#define PAL_CS_NATIVE_DATA_SIZE 56
#elif defined(__LINUX__) && defined(__x86_64__)
Expand Down Expand Up @@ -4713,11 +4718,29 @@ enum {
//
// A function table entry is generated for each frame function.
//
#ifdef _M_ARM64
typedef struct _RUNTIME_FUNCTION {
DWORD BeginAddress;
union {
DWORD UnwindData;
struct {
DWORD Flag : 2;
DWORD FunctionLength : 11;
DWORD RegF : 3;
DWORD RegI : 4;
DWORD H : 1;
DWORD CR : 2;
DWORD FrameSize : 9;
};
};
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
#else
typedef struct _RUNTIME_FUNCTION {
DWORD BeginAddress;
DWORD EndAddress;
DWORD UnwindData;
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;
#endif

PALIMPORT
BOOL
Expand Down Expand Up @@ -5810,11 +5833,6 @@ RtlCaptureContext(
OUT PCONTEXT ContextRecord
);

PALIMPORT
VOID
PALAPI
FlushProcessWriteBuffers();

typedef void (*PAL_ActivationFunction)(CONTEXT *context);
typedef BOOL (*PAL_SafeActivationCheckFunction)(SIZE_T ip, BOOL checkingCurrentThread);

Expand All @@ -5825,13 +5843,6 @@ PAL_SetActivationFunction(
IN PAL_ActivationFunction pActivationFunction,
IN PAL_SafeActivationCheckFunction pSafeActivationCheckFunction);

PALIMPORT
BOOL
PALAPI
PAL_InjectActivation(
IN HANDLE hThread
);

#define VER_PLATFORM_WIN32_WINDOWS 1
#define VER_PLATFORM_WIN32_NT 2
#define VER_PLATFORM_UNIX 10
Expand Down
Loading

0 comments on commit 3fb33a8

Please sign in to comment.