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

Forward Porting fixes in Pharo-10 #859

Open
wants to merge 16 commits into
base: pharo-12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Change log

## What's Changed
* Redo 294 by @guillep in https://github.com/pharo-project/pharo-vm/pull/829
* Making it loadable in P12 by @guillep in https://github.com/pharo-project/pharo-vm/pull/825
* Added test on extended store and pop by @guillep in https://github.com/pharo-project/pharo-vm/pull/520
* Update build version to P12 by @guillep in https://github.com/pharo-project/pharo-vm/pull/826
* Improving log of old space limit error reporting by @tesonep in https://github.com/pharo-project/pharo-vm/pull/833
* a better comment support for Slang by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/838
* a first version of Slang with no type conflict and an exception if one appear by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/819
* remove unused cast and expression by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/837
* fix warnings related to multiple include of the same header file by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/840
* Fix a lot of unused expression by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/832
* add a comment explaining why declareCVarsIn: is empty in some subclasses by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/842
* small change in dead code elimination to considers a method with only comments empty by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/843
* small change in copyWithoutReturn to handle CCoerce by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/836
* Remove hostname lookup on network initialization by @guillep in https://github.com/pharo-project/pharo-vm/pull/845
* Update SDL2 version in OSX (Intel & Apple) by @tesonep in https://github.com/pharo-project/pharo-vm/pull/849
* Adding option for pin behaviour by @tesonep in https://github.com/pharo-project/pharo-vm/pull/844

**Full Changelog**: https://github.com/pharo-project/pharo-vm/compare/v10.3.0...v10.3.1

## v10.3.0

* New harmonize rule by @RenaudFondeur in https://github.com/pharo-project/pharo-vm/pull/817
Expand Down
22 changes: 3 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extractVCSInformation(GIT_COMMIT_HASH GIT_DESCRIBE GIT_COMMIT_DATE)

set(VERSION_MAJOR 10)
set(VERSION_MINOR 3)
set(VERSION_PATCH_NUMBER 0)
set(VERSION_PATCH_NUMBER 1)

if(BUILD_IS_RELEASE)
set(VERSION_PATCH "${VERSION_PATCH_NUMBER}")
Expand Down Expand Up @@ -198,7 +198,6 @@ if(MSVC)
set(OS_TYPE "Win32")
get_platform_name(VM_TARGET_OS)
message(STATUS "Building for ${VM_TARGET_OS}")
set(CMAKE_CURRENT_SOURCE_DIR_TO_OUT ${CMAKE_CURRENT_SOURCE_DIR})

# Define WIN32_LEAN_AND_MEAN to exclude APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets
# They can be included if needed
Expand All @@ -212,17 +211,6 @@ elseif(WIN)
unset(UNIX)
unset(UNIX CACHE)

# transform the path into a windows path with unix backslashes C:/bla/blu
# this is the path required to send as argument to libraries outside of the control of cygwin (like pharo itself)
execute_process(
COMMAND cygpath ${CMAKE_CURRENT_SOURCE_DIR} --mixed
OUTPUT_VARIABLE CMAKE_CURRENT_SOURCE_DIR_TO_OUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND cygpath ${CMAKE_CURRENT_BINARY_DIR} --mixed
OUTPUT_VARIABLE CMAKE_CURRENT_BINARY_DIR_TO_OUT
OUTPUT_STRIP_TRAILING_WHITESPACE)

set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
set(CMAKE_SHARED_MODULE_PREFIX "")
Expand All @@ -247,10 +235,6 @@ elseif(WIN)

elseif(UNIX)

# Use the default path to send as argument of extrernal apps (like pharo itself)
set(CMAKE_CURRENT_SOURCE_DIR_TO_OUT ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CURRENT_BINARY_DIR_TO_OUT ${CMAKE_CURRENT_BINARY_DIR})

set(COMMON_FLAGS "-Wall -Werror=implicit-function-declaration")

add_compile_definitions(LSB_FIRST=1)
Expand All @@ -273,9 +257,9 @@ endif()
# If we are generating sources, set the binary dir as the generation source dir, as vmmaker will generate the C files here. (we do not alter the source directory)
# Otherwise set it to by default to the current binary dir, parametrizable
if(${GENERATE_SOURCES})
set(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR_TO_OUT})
set(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR_TO_OUT} CACHE STRING "Source directory where to find the generated source. Default value is CMAKE_CURRENT_BINARY_DIR")
set(GENERATED_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "Source directory where to find the generated source. Default value is CMAKE_CURRENT_BINARY_DIR")
endif()

if (${FEATURE_COMPILE_INLINE_MEMORY_ACCESSORS})
Expand Down
16 changes: 12 additions & 4 deletions cmake/vmmaker.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set(PLUGIN_GENERATED_FILES
if(GENERATE_SOURCES)

#Setting vmmaker directory and image
set( VMMAKER_DIR "${CMAKE_CURRENT_BINARY_DIR_TO_OUT}/build/vmmaker")
set( VMMAKER_DIR "${CMAKE_CURRENT_BINARY_DIR}/build/vmmaker")

# If we are generating the vmmaker image, set a the image path
# Otherwise set it with a default, but parametrizable
Expand Down Expand Up @@ -115,15 +115,23 @@ if(GENERATE_SOURCES)
)
endif()

set(IMAGE_PATH ${VMMAKER_DIR}/image/Pharo12.0-SNAPSHOT-64bit-aa50f9c.image)

convert_cygwin_path_ifNeeded(${IMAGE_PATH} IMAGE_PATH_TO_USE)
convert_cygwin_path_ifNeeded(${VMMAKER_IMAGE} VMMAKER_IMAGE_TO_USE)
convert_cygwin_path_ifNeeded(${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_SOURCE_DIR_OUT)
convert_cygwin_path_ifNeeded(${CMAKE_CURRENT_BINARY_DIR} CMAKE_CURRENT_BINARY_DIR_OUT)

if(GENERATE_VMMAKER)
#Bootstrap VMMaker.image from downloaded plain Pharo image

ExternalProject_Add(
vmmaker

URL https://files.pharo.org/image/120/Pharo12.0-SNAPSHOT.build.1519.sha.aa50f9c.arch.64bit.zip
URL_HASH SHA256=b12270631ffc0c6adcb0b6449565b9abfd8e88a863a894a7320f660c05a0af1e
BUILD_COMMAND ${VMMAKER_VM} --headless ${VMMAKER_DIR}/image/Pharo12.0-SNAPSHOT-64bit-aa50f9c.image --no-default-preferences save VMMaker
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE} --no-default-preferences --save --quit "${CMAKE_CURRENT_SOURCE_DIR_TO_OUT}/scripts/installVMMaker.st" "${CMAKE_CURRENT_SOURCE_DIR_TO_OUT}" "${ICEBERG_DEFAULT_REMOTE}"
BUILD_COMMAND ${VMMAKER_VM} --headless ${IMAGE_PATH_TO_USE} --no-default-preferences save VMMaker
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE_TO_USE} --no-default-preferences --save --quit "${CMAKE_CURRENT_SOURCE_DIR_OUT}/scripts/installVMMaker.st" "${CMAKE_CURRENT_SOURCE_DIR_OUT}" "${ICEBERG_DEFAULT_REMOTE}"
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND ""
Expand All @@ -144,7 +152,7 @@ if(GENERATE_SOURCES)
#Custom command that generates the vm source code from VMMaker into the generated folder
add_custom_command(
OUTPUT ${VMSOURCEFILES} ${PLUGIN_GENERATED_FILES}
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE} --no-default-preferences perform PharoVMMaker generate:outputDirectory: ${FLAVOUR} ${CMAKE_CURRENT_BINARY_DIR_TO_OUT}
COMMAND ${VMMAKER_VM} --headless ${VMMAKER_IMAGE_TO_USE} --no-default-preferences perform PharoVMMaker generate:outputDirectory: ${FLAVOUR} ${CMAKE_CURRENT_BINARY_DIR_OUT}
VERBATIM
DEPENDS vmmaker ${VMMAKER_IMAGE} ${VMMAKER_VM}
COMMENT "Generating VM files for flavour: ${FLAVOUR}")
Expand Down
14 changes: 14 additions & 0 deletions macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ macro(get_full_platform_name_with_osx VARNAME)
endif()
endmacro()

macro(convert_cygwin_path_ifNeeded INPUT OUTVARNAME)
# transform the path into a windows path with unix backslashes C:/bla/blu
# this is the path required to send as argument to libraries outside of the control of cygwin (like pharo itself)
if(WIN AND NOT MSVC)
execute_process(
COMMAND cygpath ${INPUT} --mixed
OUTPUT_VARIABLE ${OUTVARNAME}
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(${OUTVARNAME} ${INPUT})
endif()

endmacro()

# Add a third party dependency taken from the given URL
macro(add_third_party_dependency_with_baseurl NAME BASEURL)

Expand Down
24 changes: 16 additions & 8 deletions smalltalksrc/Melchor/CCodeGeneratorGlobalStructure.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,26 @@ CCodeGeneratorGlobalStructure >> emitGlobalStructFlagOn: aStream [
{ #category : 'CAST translation' }
CCodeGeneratorGlobalStructure >> generateCASTSetFieldTo: aTSendNode [

| structType fieldName fieldVale setFieldStatements |
| structType fieldName fieldVale setFieldStatements structClass |
self assert: aTSendNode arguments size = 2.

fieldName := aTSendNode arguments first.
fieldVale := aTSendNode arguments second.

structType := self structTypeFor: aTSendNode receiver.


setFieldStatements := (structType asClassInEnvironment:
self class environment) allSlots collect: [
structClass := structType asClassInEnvironment: self class environment.

"If the field name is known at compile time, we can just use the accessor, we don't need to compare by the name"
fieldName isConstant
ifTrue: [
self assert: (structClass hasSlotNamed: fieldName value).

^ (TSendNode
receiver: aTSendNode receiver
selector: fieldName value , ':'
arguments: { fieldVale }) asCASTIn: self ].

setFieldStatements := structClass allSlots collect: [
:slot |
| comparison |
comparison := TSendNode
Expand Down Expand Up @@ -237,7 +246,7 @@ CCodeGeneratorGlobalStructure >> generateCASTWithFieldsDoSeparatedBy: aTSendNode
self assert: aTSendNode arguments second arguments size = 0.

fieldBlock := aTSendNode arguments first.
blockSeparatorStatements := aTSendNode arguments second statements.
blockSeparatorStatements := aTSendNode arguments second statements reject: [ :e | e isConstant and: [ e value isNil ] ].

structType := self structTypeFor: aTSendNode receiver.

Expand All @@ -257,8 +266,7 @@ CCodeGeneratorGlobalStructure >> generateCASTWithFieldsDoSeparatedBy: aTSendNode
do: [ :fieldArgs |
allRewrittenStatements addAll:
(self bindBlock: fieldBlock withArgs: fieldArgs) ]
separatedBy: [
allRewrittenStatements addAll: blockSeparatorStatements ].
separatedBy: [ allRewrittenStatements addAll: blockSeparatorStatements ].

^ CCompoundStatementNode statements:
(allRewrittenStatements collect: [ :e | e asCASTIn: self ])
Expand Down
16 changes: 13 additions & 3 deletions smalltalksrc/Slang/SlangStructType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,19 @@ SlangStructType class >> voidStructTypeCache [
{ #category : 'macros' }
SlangStructType >> setField: fieldName to: fieldValue [

| slot |
slot := self class slotNamed: fieldName.
slot write: fieldValue to: self
self class
slotNamed: fieldName
ifFound: [ :slot | slot write: fieldValue to: self ]
]

{ #category : 'macros' }
SlangStructType >> withFieldsDo: forEachBlock [

<inline: #always>

self class allSlots
do: [ :aSlot | forEachBlock value: aSlot name value: (aSlot read: self) ]
separatedBy: [ ]
]

{ #category : 'macros' }
Expand Down
3 changes: 2 additions & 1 deletion smalltalksrc/Slang/TStatementListNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ TStatementListNode >> copyWithoutReturn [
newStmtsListNode
replaceChild: actualLast
with: actualLast copyWithoutReturn ].
^ newStmtsListNode]
^ newStmtsListNode
]

{ #category : 'declarations' }
TStatementListNode >> declarationAt: aString ifPresent: aFullBlockClosure [
Expand Down
66 changes: 66 additions & 0 deletions smalltalksrc/VMMaker/AbstractComposedImageAccess.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,44 @@ AbstractComposedImageAccess >> permSpaceMetadataFileNameInImage: imageFileName [
^ self permSpaceFileName: 'permSpace.ston' inImage: imageFileName into: buffer bufferSize: 255
]

{ #category : 'file primitives' }
AbstractComposedImageAccess >> readLineFrom: file into: lineBuffer ofSize: bufferSize [

<var: #lineBuffer type: 'char*'>
<var: #file type: #sqImageFile>

self
cCode: [
| idx aCharacter |

idx := 0.

aCharacter := self fgetc: file.

[ aCharacter = -1 ]
whileFalse: [
aCharacter = 10
ifTrue: [ aCharacter := -1 ]
ifFalse: [
aCharacter = 13
ifTrue: [
aCharacter := self fgetc: file.
aCharacter ~= 13 ifTrue: [ self ungetc: aCharacter _: file ].
aCharacter := -1 ]
ifFalse: [
lineBuffer at: idx put: aCharacter.
idx := idx + 1.
bufferSize = (idx + 1)
ifTrue: [ aCharacter := -1 ]
ifFalse: [ aCharacter := self fgetc: file].
]
]].

lineBuffer at: idx put: 0.
]
inSmalltalk: [ lineBuffer contents: file nextLine].
]

{ #category : 'segments' }
AbstractComposedImageAccess >> segmentDataFile: segmentIndex inImage: imageFileName [

Expand Down Expand Up @@ -209,3 +247,31 @@ AbstractComposedImageAccess >> segmentMetadataFile: segmentIndex inImage: imageF
^ self segmentFileName: segmentIndex withExtension: '.ston' inImage: imageFileName into: buffer bufferSize: 255.

]

{ #category : 'file primitives' }
AbstractComposedImageAccess >> sscanf: aString _: format _: varHolder [

<doNotGenerate>
(format = self headFormat)
ifTrue: [
^ varHolder contents: (aString substrings: ' ') first ].

self error.
]

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

<doNotGenerate>

(format = self fieldFormat)
ifTrue: [
| dataArray |
dataArray := line substrings: '#:, '.
dataArray first = '}' ifTrue: [ ^ self ].
varHolder1 contents: dataArray second.
varHolder2 contents: dataArray third asInteger.
^ self ].

self error
]
Loading