Browse Source

Merge branch 'master' into dag

# Conflicts:
#	src/Compiler-Inlining.js
Herbert Vojčík 8 years ago
parent
commit
ff0a6c15bb

+ 3 - 11
src/Compiler-IR.js

@@ -3926,15 +3926,7 @@ self._visitSuperSend_(anIRSend);
 } else {
 self._visitSend_(anIRSend);
 };
-$2=$recv($recv(sends).__gt((1)))._and_((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-return $recv($recv(anIRSend)._index()).__lt(sends);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
-//>>excludeEnd("ctx");
-}));
+$2=$recv($recv(anIRSend)._index()).__lt(sends);
 if($core.assert($2)){
 $recv(self._stream())._nextPutSendIndexFor_(anIRSend);
 };
@@ -3945,10 +3937,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anIRSend"],
-source: "visitIRSend: anIRSend\x0a\x09| sends superclass |\x0a\x09sends := (anIRSend method sendIndexes at: anIRSend selector) size.\x0a\x09\x0a\x09anIRSend isSuperSend\x0a\x09\x09ifTrue: [ self visitSuperSend: anIRSend ]\x0a\x09\x09ifFalse: [ self visitSend: anIRSend ].\x0a\x09\x09\x0a\x09(sends > 1 and: [ anIRSend index < sends ])\x0a\x09\x09ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]",
+source: "visitIRSend: anIRSend\x0a\x09| sends superclass |\x0a\x09sends := (anIRSend method sendIndexes at: anIRSend selector) size.\x0a\x09\x0a\x09anIRSend isSuperSend\x0a\x09\x09ifTrue: [ self visitSuperSend: anIRSend ]\x0a\x09\x09ifFalse: [ self visitSend: anIRSend ].\x0a\x09\x09\x0a\x09anIRSend index < sends\x0a\x09\x09ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["size", "at:", "sendIndexes", "method", "selector", "ifTrue:ifFalse:", "isSuperSend", "visitSuperSend:", "visitSend:", "ifTrue:", "and:", ">", "<", "index", "nextPutSendIndexFor:", "stream"]
+messageSends: ["size", "at:", "sendIndexes", "method", "selector", "ifTrue:ifFalse:", "isSuperSend", "visitSuperSend:", "visitSend:", "ifTrue:", "<", "index", "nextPutSendIndexFor:", "stream"]
 }),
 $globals.IRJSTranslator);
 

+ 1 - 1
src/Compiler-IR.st

@@ -956,7 +956,7 @@ visitIRSend: anIRSend
 		ifTrue: [ self visitSuperSend: anIRSend ]
 		ifFalse: [ self visitSend: anIRSend ].
 		
-	(sends > 1 and: [ anIRSend index < sends ])
+	anIRSend index < sends
 		ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]
 !
 

+ 5 - 6
src/Compiler-Inlining.js

@@ -646,7 +646,7 @@ return $recv(localReturn)._add_(each);
 //>>excludeEnd("ctx");
 }));
 $recv(anIRNonLocalReturn)._replaceWith_(localReturn);
-return localReturn;
+return self._visitIRReturn_(localReturn);
 };
 $7=(
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -663,10 +663,10 @@ return $7;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anIRNonLocalReturn"],
-source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09| localReturn |\x0a\x09anIRNonLocalReturn scope canInlineNonLocalReturns ifTrue: [\x0a\x09\x09anIRNonLocalReturn scope methodScope removeNonLocalReturn: anIRNonLocalReturn scope.\x0a\x09\x09localReturn := IRReturn new\x0a\x09\x09\x09scope: anIRNonLocalReturn scope;\x0a\x09\x09\x09yourself.\x0a\x09\x09anIRNonLocalReturn dagChildren do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
+source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09| localReturn |\x0a\x09anIRNonLocalReturn scope canInlineNonLocalReturns ifTrue: [\x0a\x09\x09anIRNonLocalReturn scope methodScope removeNonLocalReturn: anIRNonLocalReturn scope.\x0a\x09\x09localReturn := IRReturn new\x0a\x09\x09\x09scope: anIRNonLocalReturn scope;\x0a\x09\x09\x09yourself.\x0a\x09\x09anIRNonLocalReturn dagChildren do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ self visitIRReturn: localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
 referencedClasses: ["IRReturn"],
 //>>excludeEnd("ide");
-messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "dagChildren", "add:", "replaceWith:", "visitIRNonLocalReturn:"]
+messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "dagChildren", "add:", "replaceWith:", "visitIRReturn:", "visitIRNonLocalReturn:"]
 }),
 $globals.IRInliner);
 
@@ -1558,15 +1558,14 @@ var self=this;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 $recv(anIRInstruction)._replaceWith_(anIRSend);
-self._inlineSend_(anIRSend);
-return anIRSend;
+return self._inlineSend_(anIRSend);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"inlineSend:andReplace:",{anIRSend:anIRSend,anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anIRSend", "anIRInstruction"],
-source: "inlineSend: anIRSend andReplace: anIRInstruction\x0a\x09anIRInstruction replaceWith: anIRSend.\x0a\x09self inlineSend: anIRSend.\x0a\x09^ anIRSend",
+source: "inlineSend: anIRSend andReplace: anIRInstruction\x0a\x09anIRInstruction replaceWith: anIRSend.\x0a\x09^ self inlineSend: anIRSend",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: ["replaceWith:", "inlineSend:"]

+ 2 - 3
src/Compiler-Inlining.st

@@ -191,7 +191,7 @@ visitIRNonLocalReturn: anIRNonLocalReturn
 		anIRNonLocalReturn dagChildren do: [ :each |
 			localReturn add: each ].
 		anIRNonLocalReturn replaceWith: localReturn.
-		^ localReturn ].
+		^ self visitIRReturn: localReturn ].
 	^ super visitIRNonLocalReturn: anIRNonLocalReturn
 !
 
@@ -403,8 +403,7 @@ inlineSend: anIRSend
 
 inlineSend: anIRSend andReplace: anIRInstruction
 	anIRInstruction replaceWith: anIRSend.
-	self inlineSend: anIRSend.
-	^ anIRSend
+	^ self inlineSend: anIRSend
 !
 
 inlinedSend: inlinedSend withBlock: anIRInstruction

+ 6 - 8
src/Compiler-Interpreter.js

@@ -385,15 +385,13 @@ var $1,$2,$3,$receiver;
 $1=self._isBlockContext();
 if($core.assert($1)){
 $2=self._outerContext();
-return $recv($2)._ifNotNil_((function(context){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
+if(($receiver = $2) == null || $receiver.isNil){
+return $2;
+} else {
+var context;
+context=$receiver;
 return $recv(context)._ast();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({context:context},$ctx1,2)});
-//>>excludeEnd("ctx");
-}));
+};
 };
 $3=self["@ast"];
 if(($receiver = $3) == null || $receiver.isNil){

+ 10 - 29
src/Compiler-Semantic.js

@@ -2375,10 +2375,11 @@ selector: "visitSendNode:",
 protocol: 'visiting',
 fn: function (aNode){
 var self=this;
+var sends;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$3,$4,$2,$5,$6,$7,$9,$10,$8,$receiver;
+var $1,$3,$4,$2,$5,$receiver;
 $1=$recv(aNode)._superSend();
 if(!$core.assert($1)){
 $3=$recv($globals.IRSendInliner)._inlinedSelectors();
@@ -2399,37 +2400,17 @@ $recv(receiver)._shouldBeAliased_(true);
 };
 };
 };
-$6=self._messageSends();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["messageSends"]=1;
-//>>excludeEnd("ctx");
-$7=$recv(aNode)._selector();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["selector"]=2;
-//>>excludeEnd("ctx");
-$recv($6)._at_ifAbsentPut_($7,(function(){
+sends=$recv(self._messageSends())._at_ifAbsentPut_($recv(aNode)._selector(),(function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-return $recv($globals.Set)._new();
+return $recv($globals.OrderedCollection)._new();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)});
 //>>excludeEnd("ctx");
 }));
-$9=self._messageSends();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["messageSends"]=2;
-//>>excludeEnd("ctx");
-$10=$recv(aNode)._selector();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["selector"]=3;
-//>>excludeEnd("ctx");
-$8=$recv($9)._at_($10);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["at:"]=1;
-//>>excludeEnd("ctx");
-$recv($8)._add_(aNode);
-$recv(aNode)._index_($recv($recv(self._messageSends())._at_($recv(aNode)._selector()))._size());
+$recv(sends)._add_(aNode);
+$recv(aNode)._index_($recv(sends)._size());
 (
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.supercall = true,
@@ -2440,15 +2421,15 @@ $ctx1.supercall = false;
 //>>excludeEnd("ctx");;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
+}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,sends:sends},$globals.SemanticAnalyzer)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aNode"],
-source: "visitSendNode: aNode\x0a\x0a\x09aNode superSend ifFalse: [ \x0a\x09\x09(IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true.\x0a\x09\x09\x09aNode receiver ifNotNil: [ :receiver |\x0a\x09\x09\x09\x09receiver shouldBeAliased: true ] ] ].\x0a\x0a\x09self messageSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09(self messageSends at: aNode selector) add: aNode.\x0a\x0a\x09aNode index: (self messageSends at: aNode selector) size.\x0a\x0a\x09super visitSendNode: aNode",
-referencedClasses: ["IRSendInliner", "Set"],
+source: "visitSendNode: aNode\x0a\x0a\x09| sends |\x0a\x09aNode superSend ifFalse: [ \x0a\x09\x09(IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true.\x0a\x09\x09\x09aNode receiver ifNotNil: [ :receiver |\x0a\x09\x09\x09\x09receiver shouldBeAliased: true ] ] ].\x0a\x0a\x09sends := self messageSends at: aNode selector ifAbsentPut: [ OrderedCollection new ].\x0a\x09sends add: aNode.\x0a\x0a\x09aNode index: sends size.\x0a\x0a\x09super visitSendNode: aNode",
+referencedClasses: ["IRSendInliner", "OrderedCollection"],
 //>>excludeEnd("ide");
-messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "ifNotNil:", "receiver", "shouldBeAliased:", "at:ifAbsentPut:", "messageSends", "new", "add:", "at:", "index:", "size", "visitSendNode:"]
+messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "ifNotNil:", "receiver", "shouldBeAliased:", "at:ifAbsentPut:", "messageSends", "new", "add:", "index:", "size", "visitSendNode:"]
 }),
 $globals.SemanticAnalyzer);
 

+ 4 - 3
src/Compiler-Semantic.st

@@ -583,16 +583,17 @@ visitReturnNode: aNode
 
 visitSendNode: aNode
 
+	| sends |
 	aNode superSend ifFalse: [ 
 		(IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [
 			aNode shouldBeInlined: true.
 			aNode receiver ifNotNil: [ :receiver |
 				receiver shouldBeAliased: true ] ] ].
 
-	self messageSends at: aNode selector ifAbsentPut: [ Set new ].
-	(self messageSends at: aNode selector) add: aNode.
+	sends := self messageSends at: aNode selector ifAbsentPut: [ OrderedCollection new ].
+	sends add: aNode.
 
-	aNode index: (self messageSends at: aNode selector) size.
+	aNode index: sends size.
 
 	super visitSendNode: aNode
 !