From 6b0f34b801a4a0da0d1960d6a2bc10026f15329d Mon Sep 17 00:00:00 2001 From: Taras Bereznyak Date: Fri, 21 Aug 2020 20:54:46 +0300 Subject: [PATCH] Resolve #47, #48, #51 --- builtinImpl.mpl | 3 ++- codeNode.mpl | 31 +++++++++++++++++++------------ debugWriter.mpl | 20 ++++++++++++-------- processSubNodes.mpl | 11 ++++++++++- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/builtinImpl.mpl b/builtinImpl.mpl index ec6139b..144198f 100644 --- a/builtinImpl.mpl +++ b/builtinImpl.mpl @@ -1188,7 +1188,7 @@ staticityOfBinResult: [ result: @processor.@varForCallTrace FALSE dynamic @processor @block createRefNoOp @processor @block createAllocIR Dynamic @processor @block makeStaticity; result @processor @block createGetCallTrace - result @block push + result @processor @block derefAndPush TRUE @block.!hasCallTrace ] "mplBuiltinGetCallTrace" @declareBuiltin ucall @@ -1542,6 +1542,7 @@ staticityOfBinResult: [ block.astArrayIndex @processor @block printAstArrayTree ] "mplBuiltinPrintMatchingTree" @declareBuiltin ucall + [ debugMemory [ ("compilerMaxAllocationSize=" getMemoryMetrics.memoryMaxAllocationSize LF) printList diff --git a/codeNode.mpl b/codeNode.mpl index b170253..ff1ce2f 100644 --- a/codeNode.mpl +++ b/codeNode.mpl @@ -2777,24 +2777,31 @@ addNamesFromModule: [ finalizeListNode: [ struct: Struct; + validOutputCount: block.stack.size; + processor compilable [ i: 0 dynamic; + [ i block.stack.size < [ curRef: i @block.@stack.at; + curRef getVar.data.getTag VarInvalid = [ + i @validOutputCount set + FALSE + ] [ + newField: Field; + processor.specialNames.emptyNameInfo @newField.@nameInfo set - newField: Field; - processor.specialNames.emptyNameInfo @newField.@nameInfo set + curRef getVar.temporary [ + curRef @newField.@refToVar set + ] [ + @curRef TRUE dynamic @processor @block createRef @newField.@refToVar set + @curRef makeVarPtrCaptured + ] if - curRef getVar.temporary [ - curRef @newField.@refToVar set - ] [ - @curRef TRUE dynamic @processor @block createRef @newField.@refToVar set - @curRef makeVarPtrCaptured + newField @struct.@fields.pushBack + i 1 + @i set processor compilable ] if - - newField @struct.@fields.pushBack - i 1 + @i set processor compilable ] && ] loop ] when @@ -2809,7 +2816,7 @@ finalizeListNode: [ i: 0 dynamic; [ - i block.stack.size < [ + i validOutputCount < [ curFieldRef: i @struct.@fields.at.@refToVar; curFieldRef isVirtual [ @@ -2826,7 +2833,7 @@ finalizeListNode: [ ] && ] loop - @block.@stack.clear + block.stack.size validOutputCount - @block.@stack.shrink refToStruct @block.@stack.pushBack ] when ]; diff --git a/debugWriter.mpl b/debugWriter.mpl index bcb4575..f427d89 100644 --- a/debugWriter.mpl +++ b/debugWriter.mpl @@ -128,7 +128,9 @@ getPointerTypeDebugDeclaration: [ var: refToVar getVar; debugDeclarationIndex: refToVar @processor getMplSchema.dbgTypeDeclarationId copy; [debugDeclarationIndex -1 = ~] "Pointee has no type debug info!" assert - "DW_TAG_pointer_type" makeStringView debugDeclarationIndex processor.options.pointerSize 0ix cast 0 cast @processor addDerivedTypeInfo + index: "DW_TAG_pointer_type" makeStringView debugDeclarationIndex processor.options.pointerSize 0ix cast 0 cast @processor addDerivedTypeInfo; + + index ]; addMemberInfo: [ @@ -147,17 +149,16 @@ addMemberInfo: [ name: field.nameInfo processor.nameManager.getText; name "" = [ - ("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"f" fieldNumber "\", scope: !" block.funcDbgIndex + ("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"f" fieldNumber "\"" ", file: !" processor.positions.last.file.debugId ", line: " processor.positions.last.line ", baseType: !" debugDeclarationIndex ", size: " fsize 8 * ", offset: " offset 8 * ")") assembleString ] [ - ("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"" name "\", scope: !" block.funcDbgIndex + ("!" index " = !DIDerivedType(tag: DW_TAG_member, name: \"" name "\"" ", file: !" processor.positions.last.file.debugId ", line: " processor.positions.last.line ", baseType: !" debugDeclarationIndex ", size: " fsize 8 * ", offset: " offset 8 * ")") assembleString ] if addDebugString - index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert offset fsize + @offset set index @@ -213,15 +214,13 @@ getTypeDebugDeclaration: [ "}" @newDebugInfo.cat @newDebugInfo move addDebugString - index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert index: processor.debugInfo.lastId copy; processor.debugInfo.lastId 1 + @processor.@debugInfo.@lastId set ("!" index " = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !" processor.positions.last.file.debugId - ", name: \"" refToVar @processor block getDebugType "\", line: " processor.positions.last.line ", size: " refToVar @processor getStorageSize 0ix cast 0 cast 8 * ", elements: !" index 1 - + ", name: \"" refToVar @processor block getDebugType "\", size: " refToVar @processor getStorageSize 0ix cast 0 cast 8 * ", elements: !" index 1 - ")") assembleString addDebugString - index block.funcDbgIndex @processor.@debugInfo.@locationIds.insert index ] [ [FALSE] "Unknown type in getTypeDebugDeclaration!" assert @@ -508,13 +507,18 @@ correctUnitInfo: [ clearUnusedDebugInfo: [ processor:; + clearString: [ + s:; + String @s set + ]; + processor.debugInfo.locationIds [ pair:; locId: pair.key; funcDbgId: pair.value; debugString: funcDbgId 4 + processor.debugInfo.strings.at; debugString.size 0 = [ - String locId 4 + @processor.@debugInfo.@strings.at set + locId 4 + @processor.@debugInfo.@strings.at clearString ] when ] each diff --git a/processSubNodes.mpl b/processSubNodes.mpl index 9ad225e..d0f1041 100644 --- a/processSubNodes.mpl +++ b/processSubNodes.mpl @@ -838,7 +838,15 @@ applyNodeChanges: [ addAppliedVar: [ stackEntry: cacheEntry: appliedVars: ;;; - [stackEntry cacheEntry variablesAreSame] "Applied vars has different type!" assert + [stackEntry cacheEntry variablesAreSame + [ + ( + "Stack entry type is " stackEntry @processor @block getMplType LF + "cache entry type is " cacheEntry @processor @block getMplType LF + ) printList + FALSE + ] || + ] "Applied vars has different type!" assert stackEntry noMatterToCopy ~ [ [stackEntry getVar.host.id block.id =] "Stack entry is not from here!" assert @@ -2215,6 +2223,7 @@ processDynamicLoop: [ successBeforeCaptures: processor.result.success copy; TRUE @processor.@result.@success set + newNode: newNodeIndex processor.blocks.at.get; processor.result.passErrorThroughPRE ~ [