Updated after rename of section type to section format. Implemented section allocation routines.
--- a/CompiledCodeObject.st Mon Jan 11 21:46:49 2016 +0000
+++ b/CompiledCodeObject.st Tue Jan 19 16:46:20 2016 +0000
@@ -215,13 +215,77 @@
!CompiledCodeObject methodsFor:'allocation'!
-allocateTextSection: sizeInBytes
+allocateTextSection: textSize
"Alocates new text section for the receiver. Throw an error if there's
already a text section allocated for this object."
- self halt: 'Not yet implemented'
+ | failureReason |
+
+ failureReason := nil.
+%{
+ stx_compiled_code_object code_object;
+ INT _textSize;
+
+ if (!( __isSmallInteger( textSize ) && ( _textSize = __intVal( textSize ), (_textSize >= 0) && (_textSize <= UINT32_MAX) ) ) ) {
+ failureReason = @symbol(BadArg1);
+ goto done;
+ }
+ code_object = (stx_compiled_code_object)(__externalAddressVal(self));
+ if (code_object == NULL) {
+ failureReason = @symbol(BadSelf);
+ } else {
+ /* Check whether a text section has been allocated already */
+ uint32_t nSections = stxCompiledCodeObjectGetSectionCount(code_object);
+ uint32_t i;
+ for (i = 0; i < nSections; i++) {
+ stx_compiled_code_object_section code_section;
+ code_section = stxCompiledCodeObjectGetSection ( code_object , i);
+ if (code_section->section_format == SectionFormatText) {
+ failureReason = @symbol(TextAlreadyAllocayed);
+ goto done;
+ }
+ }
+ stxCompiledCodeObjectAllocTextSection(code_object, _textSize, CODE_OBJECT_SECTION_TEXT_NAME);
+ RETURN ( self );
+ }
+ done:;
+%}.
+ self primitiveFailed: failureReason
+
"Created: / 11-01-2016 / 20:18:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+allocateDataSection: dataSize named: dataName
+ "Alocates new data section for the receiver."
+
+ | failureReason |
+
+ failureReason := nil.
+%{
+ stx_compiled_code_object code_object;
+ INT _dataSize;
+
+ if (!( __isSmallInteger( dataSize ) && ( _dataSize = __intVal( dataSize ), (_dataSize >= 0) && (_dataSize <= UINT32_MAX) ) ) ) {
+ failureReason = @symbol(BadArg1);
+ goto done;
+ }
+ if (! (__isString( dataName ))) {
+ failureReason = @symbol(BadArg2);
+ goto done;
+ }
+ code_object = (stx_compiled_code_object)(__externalAddressVal(self));
+ if (code_object == NULL) {
+ failureReason = @symbol(BadSelf);
+ } else {
+ stxCompiledCodeObjectAllocDataSection(code_object, _dataSize, __stringVal( dataName ));
+ RETURN ( self );
+ }
+ done:;
+%}.
+ self primitiveFailed: failureReason
+
+
! !
!CompiledCodeObject methodsFor:'initialization'!
@@ -257,7 +321,7 @@
!CompiledCodeObject methodsFor:'private'!
getSection: index
- | name addr size type |
+ | name addr size format |
%{
if (__isSmallInteger(index)) {
stx_compiled_code_object code_object = (stx_compiled_code_object)(__externalAddressVal(self));
@@ -270,12 +334,12 @@
__PROTECT__(name);
addr = __MKUINT( code_section->section_addr );
__UNPROTECT__(name);
- type = __MKSMALLINT ( code_section->section_type );
+ format = __MKSMALLINT ( code_section->section_format );
}
}
%}.
(name notNil and:[ addr notNil and:[ size notNil ]]) ifTrue:[
- ^ CompiledCodeObjectSection basicNew setObject: self name: name address: addr size: size type: type
+ ^ CompiledCodeObjectSection basicNew setObject: self name: name address: addr size: size format: format
].
self primitiveFailed.
--- a/CompiledCodeObjectSection.st Mon Jan 11 21:46:49 2016 +0000
+++ b/CompiledCodeObjectSection.st Tue Jan 19 16:46:20 2016 +0000
@@ -14,7 +14,7 @@
"{ NameSpace: Smalltalk }"
ExternalBytes subclass:#CompiledCodeObjectSection
- instanceVariableNames:'object name type'
+ instanceVariableNames:'object name format'
classVariableNames:''
poolDictionaries:'CompiledCodeObjectSectionType'
category:'System-Compiler-Interface'
@@ -46,17 +46,17 @@
^ object
!
-type
- ^ type
+format
+ ^ format
! !
!CompiledCodeObjectSection methodsFor:'initialization'!
-setObject: obj name: nm address: addr size: sz type: t
+setObject: obj name: nm address: addr size: sz format: t
self setAddress: addr size: sz.
object := obj.
name := nm.
- type := t
+ format := t
"Created: / 11-12-2015 / 10:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -66,7 +66,7 @@
inspector2TabAssembly
<inspector2Tab>
- type ~~ SectionTypeText ifTrue:[ ^ nil ].
+ format ~~ SectionTypeText ifTrue:[ ^ nil ].
(Smalltalk at: #UDIS86) isNil ifTrue:[
"/ Try to load the package...
[ Smalltalk loadPackage: 'jv:dragonfly/udis86sx' ] on: Error do:[ ^ nil ].
@@ -108,46 +108,13 @@
(addr + size) printOn: aStream base: 16 size: ExternalAddress pointerSize fill: $0.
aStream nextPutAll: ' (size='.
size printOn: aStream.
- aStream nextPutAll: ' type='.
- type printOn: aStream.
+ aStream nextPutAll: ' format='.
+ format printOn: aStream.
aStream nextPutAll: ')'.
"Modified: / 11-01-2016 / 21:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!CompiledCodeObjectSection methodsFor:'testing'!
-
-isDataSection
- ^ type == SectionTypeData
-
- "Created: / 11-12-2015 / 10:35:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isILCsSection
- ^ type == SectionTypeILCs
-
- "Created: / 11-12-2015 / 10:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isLitsSection
- ^ type == SectionTypeLits
-
- "Created: / 11-12-2015 / 10:35:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isSCLsSection
- ^ type == SectionTypeSCLs
-
- "Created: / 11-01-2016 / 21:14:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-isTextSection
- ^ type == SectionTypeText
-
- "Created: / 11-12-2015 / 10:35:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified (format): / 11-01-2016 / 21:14:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
!CompiledCodeObjectSection class methodsFor:'documentation'!
version_HG
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CompiledCodeObjectSectionFormat.st Tue Jan 19 16:46:20 2016 +0000
@@ -0,0 +1,56 @@
+"
+ COPYRIGHT (c) 2006 by eXept Software AG
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+"{ Package: 'jv:dragonfly' }"
+
+"{ NameSpace: Smalltalk }"
+
+SharedPool subclass:#CompiledCodeObjectSectionFormat
+ instanceVariableNames:''
+ classVariableNames:'SectionFormatBytes SectionFormatText SectionFormatOBJVector SectionFormatILCVector SectionFormatINTVector'
+ poolDictionaries:''
+ category:'System-Compiler-Interface'
+!
+
+!CompiledCodeObjectSectionFormat class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 2006 by eXept Software AG
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+! !
+
+!CompiledCodeObjectSectionFormat class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ "/ please change as required (and remove this comment)
+
+ SectionFormatBytes := 0.
+ SectionFormatText := 1.
+ SectionFormatOBJVector := 2.
+ SectionFormatILCVector := 4.
+ SectionFormatINTVector := 5.
+
+ "Modified: / 07-12-2015 / 21:43:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+
+CompiledCodeObjectSectionFormat initialize!
--- a/CompiledCodeObjectSectionType.st Mon Jan 11 21:46:49 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-"
- COPYRIGHT (c) 2006 by eXept Software AG
- All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice. This software may not
- be provided or otherwise made available to, or used by, any
- other person. No title to or ownership of the software is
- hereby transferred.
-"
-"{ Package: 'jv:dragonfly' }"
-
-"{ NameSpace: Smalltalk }"
-
-SharedPool subclass:#CompiledCodeObjectSectionType
- instanceVariableNames:''
- classVariableNames:'SectionTypeData SectionTypeText SectionTypeLits SectionTypeILCs SectionTypeSCLs'
- poolDictionaries:''
- category:'System-Compiler-Interface'
-!
-
-!CompiledCodeObjectSectionType class methodsFor:'documentation'!
-
-copyright
-"
- COPYRIGHT (c) 2006 by eXept Software AG
- All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice. This software may not
- be provided or otherwise made available to, or used by, any
- other person. No title to or ownership of the software is
- hereby transferred.
-"
-! !
-
-!CompiledCodeObjectSectionType class methodsFor:'initialization'!
-
-initialize
- "Invoked at system start or when the class is dynamically loaded."
-
- "/ please change as required (and remove this comment)
-
- SectionTypeData := 0.
- SectionTypeText := 1.
- SectionTypeLits := 2.
- SectionTypeILCs := 4.
- SectionTypeSCLs := 5.
-
- "Modified: / 07-12-2015 / 21:43:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
-
-CompiledCodeObjectSectionType initialize!
--- a/CompiledCodeObjectTests.st Mon Jan 11 21:46:49 2016 +0000
+++ b/CompiledCodeObjectTests.st Tue Jan 19 16:46:20 2016 +0000
@@ -5,7 +5,7 @@
TestCase subclass:#CompiledCodeObjectTests
instanceVariableNames:'jitEnabled'
classVariableNames:''
- poolDictionaries:'CompiledCodeObjectSectionType'
+ poolDictionaries:'CompiledCodeObjectSectionFormat'
category:'System-Compiler-Interface'
!
@@ -76,15 +76,16 @@
self assert: object compiledCode == (self class >> #methodWithConstant).
self assert: object sections size == 2. "/ No literals no ILC's, only code and special cells
self assert: object sections first name = '.text'.
- self assert: object sections first type = SectionTypeText.
+ self assert: object sections first format = SectionFormatText.
self assert: object sections second name = '.stx.codeobj.specialcells'.
- self assert: object sections second type = SectionTypeSCLs.
+ self assert: object sections second format = SectionTypeINTVector.
self ensureCompiled: #methodWithLiteral.
object := (self class >> #methodWithLiteral) codeObject.
self assert: object sections size == 3. "/ No ILC's but literals, code and special cells
+
self ensureCompiled: #methodWithSend.
self assert: object sections size == 3. "/ No literals but ILC, code and special cells
--- a/Make.proto Mon Jan 11 21:46:49 2016 +0000
+++ b/Make.proto Tue Jan 19 16:46:20 2016 +0000
@@ -122,9 +122,9 @@
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
$(OUTDIR)CompiledCodeObject.$(O) CompiledCodeObject.$(H): CompiledCodeObject.st $(INCLUDE_TOP)/stx/libbasic/ExternalAddress.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
-$(OUTDIR)CompiledCodeObjectSectionType.$(O) CompiledCodeObjectSectionType.$(H): CompiledCodeObjectSectionType.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
+$(OUTDIR)CompiledCodeObjectSectionFormat.$(O) CompiledCodeObjectSectionFormat.$(H): CompiledCodeObjectSectionFormat.st $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SharedPool.$(H) $(STCHDR)
$(OUTDIR)jv_dragonfly.$(O) jv_dragonfly.$(H): jv_dragonfly.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
-$(OUTDIR)CompiledCodeObjectSection.$(O) CompiledCodeObjectSection.$(H): CompiledCodeObjectSection.st $(INCLUDE_TOP)/jv/dragonfly/CompiledCodeObjectSectionType.$(H) $(INCLUDE_TOP)/stx/libbasic/ArrayedCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/Collection.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalBytes.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SequenceableCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/UninterpretedBytes.$(H) $(STCHDR)
+$(OUTDIR)CompiledCodeObjectSection.$(O) CompiledCodeObjectSection.$(H): CompiledCodeObjectSection.st $(INCLUDE_TOP)/jv/dragonfly/CompiledCodeObjectSectionFormat.$(H) $(INCLUDE_TOP)/stx/libbasic/ArrayedCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/Collection.$(H) $(INCLUDE_TOP)/stx/libbasic/ExternalBytes.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/SequenceableCollection.$(H) $(INCLUDE_TOP)/stx/libbasic/UninterpretedBytes.$(H) $(STCHDR)
$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/libbasic/CompiledCode.$(H) $(INCLUDE_TOP)/stx/libbasic/ExecutableFunction.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/Make.spec Mon Jan 11 21:46:49 2016 +0000
+++ b/Make.spec Tue Jan 19 16:46:20 2016 +0000
@@ -52,7 +52,7 @@
COMMON_CLASSES= \
CompiledCodeObject \
- CompiledCodeObjectSectionType \
+ CompiledCodeObjectSectionFormat \
jv_dragonfly \
CompiledCodeObjectSection \
@@ -61,7 +61,7 @@
COMMON_OBJS= \
$(OUTDIR_SLASH)CompiledCodeObject.$(O) \
- $(OUTDIR_SLASH)CompiledCodeObjectSectionType.$(O) \
+ $(OUTDIR_SLASH)CompiledCodeObjectSectionFormat.$(O) \
$(OUTDIR_SLASH)jv_dragonfly.$(O) \
$(OUTDIR_SLASH)CompiledCodeObjectSection.$(O) \
$(OUTDIR_SLASH)extensions.$(O) \
--- a/bc.mak Mon Jan 11 21:46:49 2016 +0000
+++ b/bc.mak Tue Jan 19 16:46:20 2016 +0000
@@ -69,9 +69,9 @@
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
$(OUTDIR)CompiledCodeObject.$(O) CompiledCodeObject.$(H): CompiledCodeObject.st $(INCLUDE_TOP)\stx\libbasic\ExternalAddress.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
-$(OUTDIR)CompiledCodeObjectSectionType.$(O) CompiledCodeObjectSectionType.$(H): CompiledCodeObjectSectionType.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
+$(OUTDIR)CompiledCodeObjectSectionFormat.$(O) CompiledCodeObjectSectionFormat.$(H): CompiledCodeObjectSectionFormat.st $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SharedPool.$(H) $(STCHDR)
$(OUTDIR)jv_dragonfly.$(O) jv_dragonfly.$(H): jv_dragonfly.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)
-$(OUTDIR)CompiledCodeObjectSection.$(O) CompiledCodeObjectSection.$(H): CompiledCodeObjectSection.st $(INCLUDE_TOP)\jv\dragonfly\CompiledCodeObjectSectionType.$(H) $(INCLUDE_TOP)\stx\libbasic\ArrayedCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalBytes.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SequenceableCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\UninterpretedBytes.$(H) $(STCHDR)
+$(OUTDIR)CompiledCodeObjectSection.$(O) CompiledCodeObjectSection.$(H): CompiledCodeObjectSection.st $(INCLUDE_TOP)\jv\dragonfly\CompiledCodeObjectSectionFormat.$(H) $(INCLUDE_TOP)\stx\libbasic\ArrayedCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\Collection.$(H) $(INCLUDE_TOP)\stx\libbasic\ExternalBytes.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\SequenceableCollection.$(H) $(INCLUDE_TOP)\stx\libbasic\UninterpretedBytes.$(H) $(STCHDR)
$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\libbasic\CompiledCode.$(H) $(INCLUDE_TOP)\stx\libbasic\ExecutableFunction.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/jv_dragonfly.st Mon Jan 11 21:46:49 2016 +0000
+++ b/jv_dragonfly.st Tue Jan 19 16:46:20 2016 +0000
@@ -63,7 +63,7 @@
^ #(
"<className> or (<className> attributes...) in load order"
CompiledCodeObject
- CompiledCodeObjectSectionType
+ CompiledCodeObjectSectionFormat
#'jv_dragonfly'
CompiledCodeObjectSection
(CompiledCodeObjectTests autoload)
--- a/libInit.cc Mon Jan 11 21:46:49 2016 +0000
+++ b/libInit.cc Tue Jan 19 16:46:20 2016 +0000
@@ -28,7 +28,7 @@
OBJ snd; struct __vmData__ *__pRT__; {
__BEGIN_PACKAGE2__("libjv_dragonfly", _libjv_dragonfly_Init, "jv:dragonfly");
_CompiledCodeObject_Init(pass,__pRT__,snd);
-_CompiledCodeObjectSectionType_Init(pass,__pRT__,snd);
+_CompiledCodeObjectSectionFormat_Init(pass,__pRT__,snd);
_jv_137dragonfly_Init(pass,__pRT__,snd);
_CompiledCodeObjectSection_Init(pass,__pRT__,snd);