Issue 13105 in v8: V8: add support for z/OS

21 views
Skip to first unread message

baghd… via monorail

unread,
Jul 25, 2022, 10:24:58 AM7/25/22
to v8-re...@googlegroups.com
Status: Untriaged
Owner: ----
Type: Bug

New issue 13105 by baghd...@ca.ibm.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105

Version: aee4f59521
OS: z/OS
Architecture: s390x

The following changes are required to build V8 on z/OS s390x platform.
These changes will be added on top of the currently supported s390 port of V8;
we will not be adding a new simulator under the V8 CI https://ci.chromium.org/p/v8/g/ports/.

All changes are guarded by V8_OS_ZOS or __MVS__, except in sampler.cc, and the
moving of macros from assembler-s390.h to constants-s390.h, as described below.

Otherwise the z/OS changes will be invisible to the s390x on Linux and the s390x
simulator and any other platform, and will only affect native z/OS on s390x.
This is similar to how AIX support was added to the PowerPC port of V8.


Changes include:

1) Download dependency and build:
a) DEPS
- Download dependency https://github.com/ibmruntimes/zoslib into
third_party/zoslib.
b) BUILD.gn
- Build zoslib, exclude NA source and compiler options, and add
z/OS-specific source files to the build.

2) Define macros, constants and includes:
a) include/v8config.h
- Include zos-base.h and define V8_OS_ZOS, V8_OS_STRING, and
V8_OS_POSIX; zos-base.h is from third_party/zoslib/.
b) src/common/globals.h
- Define V8_DEFAULT_STACK_SIZE_KB and remove sanity-check for the 1MB
stack size limit, as 2MB stack size is used on z/OS.
c) src/flags/flag-definitions.h
- Don't force crash on abort, as it may cause further LE abends during
error handling/stack walking.
d) src/d8/d8-posix.cc
- Exclude NA header.

3) Platform:
a) src/base/platform/platform-posix.cc
- Implement GetRandomMmapAddr() and GetCurrentThreadId().
- Set stack size before starting thread.
- Change for pthread_t being a struct, not int.
- Exclude NA static functions and headers.
b) src/base/platform/platform-zos.cc
- New file, implements MemoryMappedFile class, OS::FOpen(), OS::Allocate(),
OS::Free(), etc.
c) src/heap/base/asm/zos/push_registers_asm.cc
- New file, implements PushAllRegistersAndIterateStack() for z/OS.
d) src/base/debug/stack_trace_zos.cc:
- New file, implements StackTrace class methods and stack dumping
signals thread and handler for z/OS.
e) src/base/platform/time.cc
- Use clock_gettime() in ClockNow(), and ClockNow() in ThreadTicks::Now().
- Return true in ThreadTicks::IsSupported().
f) src/base/sys-info.cc
- Implement NumberOfProcessors() and AmountOfPhysicalMemory() using API from zoslib.
g) src/utils/allocation.cc
- Implement AlignedAllocInternal(), AlignedFree() and ByteReverse16|32|64().
h) src/heap/spaces.cc
src/heap/large-spaces.cc
- Skip shrinkage on z/OS as it doesn't support partial frees.

4) Snapshot:
a) src/snapshot/embedded/embedded-file-writer.cc
a) src/snapshot/embedded/embedded-file-writer.h
- Update WriteBinaryContentsAsInlineAssembly() so a line doesn't exceed
the max length of 72, a z/OS requirement for HLASM, and define
DeclareLabelProlog() and DeclareLabelEpilogue() for the embedded blob
code and data symbols.
b) src/snapshot/embedded/platform-embedded-file-writer-zos.cc
src/snapshot/embedded/platform-embedded-file-writer-zos.h
- New files, implements embedded file writer for z/OS.
c) src/snapshot/embedded/platform-embedded-file-writer-base.h
src/snapshot/embedded/platform-embedded-file-writer-base.cc
- Include src/snapshot/embedded/platform-embedded-file-writer-zos.h,
define EmbeddedTargetOs::kZOS and update
NewPlatformEmbeddedFileWriter() if embedded target is z/OS.

5) Codegen:
a) src/codegen/s390/constants-s390.h
src/codegen/s390/macro-assembler-s390.cc
src/codegen/s390/macro-assembler-s390.h
src/codegen/s390/register-s390.h
src/codegen/s390/assembler-s390.cc
src/codegen/s390/assembler-s390.h
src/compiler/backend/s390/code-generator-s390.cc
- Call JS code using a function descriptor as required on z/OS.
- Support XPLINK ABI in builtins for z/OS; shuffle XPLINK arguments
coming from C to JS arguments. Add support for calling z/OS XPLINK
C/C++ from JS codegen.
- Enable support for native regexp codegen for z/OS. Arguments are
shuffled from z/OS XPLINK ABI to LoZ ABI on function entry and vice
versa on return.
- Implement supportsCPUFeature(), supportsSTFLE() and ProbeImpl().
- Handle nop pseudo instructions for basr, bras, brasl call types.
- Move define of ABI_USES_FUNCTION_DESCRIPTORS (1 for z/OS, 0 LoZ) and
related macros from assembler-s390.h to constants-s390.h, so that
for z/OS they're defined when checked, as in simulator.h
(which includes simulator-s390.h that includes constants-s390.h).
b) src/diagnostics/objects-debug.cc
- Don't check for instruction start alignment, as no code alignment is
required on z/OS. The start of each function and labels are aligned
on a half-word binary.

6) Execution:
a) src/execution/execution.cc
- Save LE stack pointer to restore on signal while in JS.
b) src/execution/isolate.cc
- Allow more overflow stack space as z/OS XPLINK uses larger frames.
- Ensure thread has enough stack guard.
c) src/execution/simulator.h
- Create a pseudo function descriptor to ensure correct dispatch to
generated code.

7) Regexp:
a) src/regexp/s390/regexp-macro-assembler-s390.cc
- Enable regexp support:
- Add support for native regexp codegen.
- Shuffle arguments from z/OS XPLINK ABI to LoZ ABI on function
entry and vice versa on return.
- Don't inline LoadCurrentCharacterUnchecked() due to a runtime
error, revisit when clang compiler is available.

8) Builtins:
a) src/builtins/s390/builtins-s390.cc
- Add support for XPLINK ABI in builtins:
- Add support for shuffling XPLINK arguments coming from C to JS.
- Add support for calling z/OS XPLINK C/C++ from JS codegen.

9) Adjust for pthread_t being a struct (not int):
a) src/base/platform/platform.h
src/libsampler/sampler.h

10) libsampler:
a) src/libsampler/sampler.cc
- Implement FillRegisterState() to set the state's registers (pc, sp,
fp, lr) with the given context in the signal handler.
- Adjust for pthread_t being a struct (not int);
this change adds an inline ThreadKey() and applies on all
platforms; not guarded so as not to clutter the code with #if/#else.

11) tools:
a) tools/testrunner/local/statusfile.py
- Add "zos" to VARIABLES.
b) tools/testrunner/local/utils.py
- Return "zos" in GuessOS() if platform.system() is "OS/390"
- Uupdate IsS390SimdSupported() to return true on z13 or higher.

12) test:
a) test/cctest/cctest-utils.h
- Define GET_STACK_POINTER_TO(sp_addr) macro for z/OS.

13) Misc:
a) src/base/platform/semaphore.h
- Include zos-semaphore.h to use semaphore functions from zoslib.
b) src/compiler/code-assembler.h
src/compiler/linkage.h
src/compiler/raw-machine-assembler.h
- Contains only updates to comments related to function descriptors.

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

mfara… via monorail

unread,
Jul 25, 2022, 10:32:49 AM7/25/22
to v8-re...@googlegroups.com
Updates:
Labels: Type-FeatureRequest

Comment #1 on issue 13105 by mfara...@redhat.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c1

(No comment was entered for this change.)

baghd… via monorail

unread,
Jul 25, 2022, 11:43:10 AM7/25/22
to v8-re...@googlegroups.com

Comment #2 on issue 13105 by baghd...@ca.ibm.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c2

IBM z/OS: https://www.ibm.com/it-infrastructure/z/zos

ecmzi… via monorail

unread,
Aug 22, 2022, 12:28:29 PM8/22/22
to v8-re...@googlegroups.com
Updates:
Cc: hpa...@chromium.org
Labels: Priority-3

Comment #3 on issue 13105 by ecmzi...@chromium.org: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c3

@hpayer: PTAL, thanks!

hpa… via monorail

unread,
Oct 31, 2022, 9:43:30 AM10/31/22
to v8-re...@googlegroups.com
Updates:
Cc: mlip...@chromium.org

Comment #4 on issue 13105 by hpa...@chromium.org: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c4

The main concern discussed in the previous issue https://bugs.chromium.org/p/v8/issues/detail?id=12597 was that it sounded like a cross-cutting change. Can you provide the patch with all changes necessary to clearly see the diff? That would simplify the discussion.

baghd… via monorail

unread,
Nov 10, 2022, 11:09:17 AM11/10/22
to v8-re...@googlegroups.com

Comment #5 on issue 13105 by baghd...@ca.ibm.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c5

Please find attached the patch as requested. It applies as of yesterday's commit 606c5c4c3a.

Attachments:
s390x-zos-patch.diff 68.2 KB

ecmzi… via monorail

unread,
Jan 11, 2023, 4:41:29 AM1/11/23
to v8-re...@googlegroups.com

Comment #6 on issue 13105 by ecmzi...@chromium.org: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c6

Has anyone already had the time to look at the patch? It would be great if we could at least assign an owner to this request that will follow up. Thanks!

john.… via monorail

unread,
Jan 13, 2023, 2:55:18 PM1/13/23
to v8-re...@googlegroups.com

Comment #7 on issue 13105 by john....@broadcom.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c7

Is it possible to get a confirmation on which compiler version IBM used for this patch? I assume its :

IBM C for Open Enterprise Languages on z/OS 1
# Confirm xlclang is OEL 1.0.0 (aka __COMPILER_VER__=42040001)

Based upon the cmakeport lib sources here:https://github.com/ZOSOpenTools/cmakeport

baghd… via monorail

unread,
Jan 13, 2023, 4:32:14 PM1/13/23
to v8-re...@googlegroups.com

Comment #8 on issue 13105 by baghd...@ca.ibm.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c8

For this patch, we use IBM C/C++ for Open Enterprise Languages on z/OS 2.0 (__COMPILER_VER__=0x50000000), (llvm-based clang). cmakeport is built with xlclang, a different compiler that doesn't support the patch here.

baghd… via monorail

unread,
Mar 6, 2023, 1:24:57 PM3/6/23
to v8-re...@googlegroups.com

Comment #10 on issue 13105 by baghd...@ca.ibm.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c10

Any feedback on the patch attached (per hpa...@chromium.org's request https://bugs.chromium.org/p/v8/issues/detail?id=13105#c4)?

john.… via monorail

unread,
May 4, 2023, 9:18:04 AM5/4/23
to v8-re...@googlegroups.com

Comment #11 on issue 13105 by john....@broadcom.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c11

Since I don't have the depot_tools changes for this patch. Could you please detail how you are building this patch?

For instance, I have downloaded your patch applied it to the commit hash provided.

I can't fetch the v8 code via depot_tools as described in the docs. However, I am trying to modify the files enough so that it does not stop immediately. With that said, it looks like on osx, v8/buildtools/mac/gn is a binary. Whereas on depot_tools/gn is a bash script that calls depot_tools/gn.py. How are you building gn as a binary executable?

john.… via monorail

unread,
May 4, 2023, 2:38:35 PM5/4/23
to v8-re...@googlegroups.com

Comment #12 on issue 13105 by john....@broadcom.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c12

Ahh, I now understand that v8/builtools/mac/gn or v8/buildtools/zos/gn comes from https://gn.googlesource.com/gn/

john.… via monorail

unread,
May 25, 2023, 10:17:57 AM5/25/23
to v8-re...@googlegroups.com

Comment #13 on issue 13105 by john....@broadcom.com: V8: add support for z/OS
https://bugs.chromium.org/p/v8/issues/detail?id=13105#c13

I've been trying to get this patch working. I'm new to this project, but I'm working on two approaches.

1. Get depot_tools to work to pull the code and such. With that said, it does pull the v8 source from a public git but fails when its parsing DEPS. I haven't modified your patch to update DEPS yet. With that said, I noticed your patch does not modify that file and says to download and build zoslib in the original comments here. This leads to approach 2.
2. Simply pull the commit hash you specify and apply the patch. The first step is to build zoslib as mentioned above. However this fails. See here: https://github.com/ibmruntimes/zoslib/issues/21

Any help is appreciated.
Reply all
Reply to author
Forward
0 new messages