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

Composed image format: C translation #388

Merged

Conversation

PalumboN
Copy link
Collaborator

@PalumboN PalumboN commented Feb 22, 2022

Making C translation available for new Composed image Reader/Writer.

  • Refactoring code to be "Slang friendly"
  • Adding special cases for STON files manipulation in Slang
  • Change the "main" load image function wrote in C

The translation works finishes and generate C code, but there is still some issues:

  • Use sscanf_s instead of snprintf to avoid overflows (not working on Mac 🍎 💀)
  • Solve the problem of reading the end of a line in STON file (,\n)
  • memory allocation is broken in C code

Comment on lines 90 to 111
{ #category : #'file primitives' }
AbstractComposedImageAccess >> fscanf: file _: format _: varHolder [

<doNotGenerate>
^ (format = headFormat)
ifTrue: [
varHolder contents: (file nextLine substrings: ' ') first ];
yourself
]

{ #category : #'file primitives' }
AbstractComposedImageAccess >> fscanf: file _: format _: varHolder1 _: varHolder2 [

<doNotGenerate>
^ (format = fieldFormat)
ifTrue: [
| dataArray |
dataArray := file nextLine substrings: '#:,'.
(dataArray first = '}') ifTrue: [ ^false ].
varHolder1 contents: dataArray second trimLineSpaces.
varHolder2 contents: dataArray third trimLineSpaces asInteger ];
yourself
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 is a hack 👎

Copy link
Collaborator Author

@PalumboN PalumboN Feb 22, 2022

Choose a reason for hiding this comment

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

Should we implement it for real? (Read based to a format)


pageSize = getpagesize();
pageMask = ~(pageSize - 1);

heapLimit = valign(max(desiredHeapSize, 1));
heapLimit = valign(max(desiredHeapSize, 1)) + pageSize; // Add 1 page more just in case (G & N)
Copy link
Collaborator Author

@PalumboN PalumboN Feb 22, 2022

Choose a reason for hiding this comment

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

We started to fix this with Guille, but is not working yet.

@PalumboN PalumboN changed the title [WIP] Composed image format: C translation Composed image format: C translation Feb 22, 2022
@PalumboN
Copy link
Collaborator Author

PalumboN commented Feb 24, 2022

Now in CI I have this error (about trampolines (?) ) compiling C code

[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/4/pipeline/210#step-223-log-1271)/builds/workspace/pharo-vm_PR-388/build-StackVM/generated/64/vm/src/gcc3x-interp.c:68322:12: error: assignment to expression with array type

   aJumpBuf = (vmCallbackContext->trampoline);

But I can't reproduce it locally :(

@guillep
Copy link
Member

guillep commented Feb 24, 2022

Now in CI I have this error (about trampolines (?) ) compiling C code

[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/4/pipeline/210#step-223-log-1271)/builds/workspace/pharo-vm_PR-388/build-StackVM/generated/64/vm/src/gcc3x-interp.c:68322:12: error: assignment to expression with array type

   aJumpBuf = (vmCallbackContext->trampoline);

But I can't reproduce it locally :(

Just for the record, we did. It was the non JIT VM that had a different definition of longjmp, together with the C11 upgrade.

@PalumboN 's f58e728 should fix it

@guillep
Copy link
Member

guillep commented Feb 24, 2022

Now it compiles in OSX and linuex but not windows:

error: too many arguments to function call, expected 1, have 2
                        mkdir(imageName, 777);

@PalumboN
Copy link
Collaborator Author

Yes, it seems that mkdir function is different in Windows 😕

@PalumboN
Copy link
Collaborator Author

PalumboN commented Feb 25, 2022

I think that I could solve the problems, but the CI is not building my last commit:

[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1305)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1306)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1307)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1308)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1309)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1310)[](https://ci.inria.fr/pharo-ci-jenkins2/blue/organizations/jenkins/pharo-vm/detail/PR-388/8/pipeline#step-31-log-1311)**IncrementalGC**

**FullGC**



stack page bytes 8192 available headroom 5576 minimum unused headroom 6000



	(Terminated: 15)

[WARN ] 2022-02-25 16:41:40.000 terminateHandler (src/debugUnix.c:98):Exiting with error code 1

script returned exit code 143

It filled the disk again? 😞

hogoww added a commit to hogoww/opensmalltalk-vm that referenced this pull request Feb 26, 2022
hogoww added a commit to hogoww/opensmalltalk-vm that referenced this pull request Feb 26, 2022
…od [ newObjectHash ] 1/20 Test Cases are NOT EQUIVALENT
@tesonep tesonep merged commit 06c0819 into pharo-project:feat/permSpace Mar 29, 2022
@guillep
Copy link
Member

guillep commented Mar 29, 2022

Massive !

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.

3 participants