Ver código fonte

Fixes IRASTTranslator >> visitSequenceNode: for aliasing

Nicolas Petton 11 anos atrás
pai
commit
7c87c50011
2 arquivos alterados com 24 adições e 15 exclusões
  1. 16 10
      js/Compiler-IR.js
  2. 8 5
      st/Compiler-IR.st

+ 16 - 10
js/Compiler-IR.js

@@ -596,16 +596,21 @@ fn: function (aNode){
 var self=this;
 function $IRSequence(){return smalltalk.IRSequence||(typeof IRSequence=="undefined"?nil:IRSequence)}
 return smalltalk.withContext(function($ctx1) { 
-var $2,$1;
+var $2,$3,$1;
 $1=self._withSequence_do_(_st($IRSequence())._new(),(function(){
 return smalltalk.withContext(function($ctx2) {
 return _st(_st(aNode)._nodes())._do_((function(each){
 var instruction;
 return smalltalk.withContext(function($ctx3) {
+$2=_st(each)._shouldBeAliased();
+if(smalltalk.assert($2)){
+instruction=self._alias_(each);
+} else {
 instruction=self._visit_(each);
+};
 instruction;
-$2=_st(instruction)._isVariable();
-if(! smalltalk.assert($2)){
+$3=_st(instruction)._isVariable();
+if(! smalltalk.assert($3)){
 return _st(self._sequence())._add_(instruction);
 };
 }, function($ctx3) {$ctx3.fillBlock({each:each,instruction:instruction},$ctx2,2)})}));
@@ -613,8 +618,8 @@ return _st(self._sequence())._add_(instruction);
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},smalltalk.IRASTTranslator)})},
 args: ["aNode"],
-source: "visitSequenceNode: aNode\x0a\x09^ self\x0a\x09\x09withSequence: IRSequence new\x0a\x09\x09do: [\x0a\x09\x09\x09aNode nodes do: [ :each | | instruction |\x0a\x09\x09\x09\x09instruction := self visit: each.\x0a\x09\x09\x09\x09instruction isVariable ifFalse: [\x0a\x09\x09\x09\x09\x09self sequence add: instruction ]]]",
-messageSends: ["withSequence:do:", "new", "do:", "nodes", "visit:", "ifFalse:", "isVariable", "add:", "sequence"],
+source: "visitSequenceNode: aNode\x0a\x09^ self\x0a\x09\x09withSequence: IRSequence new\x0a\x09\x09do: [\x0a\x09\x09\x09aNode nodes do: [ :each | | instruction |\x0a\x09\x09\x09\x09instruction := each shouldBeAliased\x0a\x09\x09\x09\x09\x09ifTrue: [ self alias: each ]\x0a\x09\x09\x09\x09\x09ifFalse: [ self visit: each ].\x0a\x09\x09\x09\x09instruction isVariable ifFalse: [\x0a\x09\x09\x09\x09\x09self sequence add: instruction ]]]",
+messageSends: ["withSequence:do:", "new", "do:", "nodes", "ifTrue:ifFalse:", "shouldBeAliased", "alias:", "visit:", "ifFalse:", "isVariable", "add:", "sequence"],
 referencedClasses: ["IRSequence"]
 }),
 smalltalk.IRASTTranslator);
@@ -3011,7 +3016,7 @@ self._visitSuperSend_(anIRSend);
 };
 return self}, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},smalltalk.IRJSTranslator)})},
 args: ["anIRSend"],
-source: "visitIRSend: anIRSend\x0a\x09anIRSend classSend\x0a\x09\x09ifNil: [ self visitSend: anIRSend ]\x0a\x09\x09ifNotNil: [ self visitSuperSend: anIRSend ].\x0a\x09\x22anIRSend index > 1 ifTrue: [ \x0a\x09\x09self stream nextPutSendIndexFor: anIRSend ].\x22",
+source: "visitIRSend: anIRSend\x0a\x09anIRSend classSend\x0a\x09\x09ifNil: [ self visitSend: anIRSend ]\x0a\x09\x09ifNotNil: [ self visitSuperSend: anIRSend ].\x0a\x09\x09\x0a\x22\x09(anIRSend method sendIndexes at: anIRSend selector) size > 1 \x0a\x09\x09ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]\x22",
 messageSends: ["ifNil:ifNotNil:", "classSend", "visitSend:", "visitSuperSend:"],
 referencedClasses: []
 }),
@@ -3638,16 +3643,17 @@ var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=self;
+_st($1)._nextPutAll_(";");
+_st($1)._lf();
 _st($1)._nextPutAll_(_st(_st(anIRSend)._scope())._alias());
 _st($1)._nextPutAll_(".sendIdx[\x22");
 _st($1)._nextPutAll_(_st(anIRSend)._selector());
 _st($1)._nextPutAll_("\x22]=");
-_st($1)._nextPutAll_(_st(_st(anIRSend)._index())._asString());
-$2=_st($1)._nextPutAll_(";");
+$2=_st($1)._nextPutAll_(_st(_st(anIRSend)._index())._asString());
 return self}, function($ctx1) {$ctx1.fill(self,"nextPutSendIndexFor:",{anIRSend:anIRSend},smalltalk.JSStream)})},
 args: ["anIRSend"],
-source: "nextPutSendIndexFor: anIRSend\x0a\x09self \x0a\x09\x09nextPutAll: anIRSend scope alias;\x0a\x09\x09nextPutAll: '.sendIdx[\x22';\x0a\x09\x09nextPutAll: anIRSend selector;\x0a\x09\x09nextPutAll: '\x22]=';\x0a\x09\x09nextPutAll: anIRSend index asString;\x0a\x09\x09nextPutAll: ';'",
-messageSends: ["nextPutAll:", "alias", "scope", "selector", "asString", "index"],
+source: "nextPutSendIndexFor: anIRSend\x0a\x09self \x0a\x09\x09nextPutAll: ';'; lf;\x0a\x09\x09nextPutAll: anIRSend scope alias;\x0a\x09\x09nextPutAll: '.sendIdx[\x22';\x0a\x09\x09nextPutAll: anIRSend selector;\x0a\x09\x09nextPutAll: '\x22]=';\x0a\x09\x09nextPutAll: anIRSend index asString",
+messageSends: ["nextPutAll:", "lf", "alias", "scope", "selector", "asString", "index"],
 referencedClasses: []
 }),
 smalltalk.JSStream);

+ 8 - 5
st/Compiler-IR.st

@@ -233,7 +233,9 @@ visitSequenceNode: aNode
 		withSequence: IRSequence new
 		do: [
 			aNode nodes do: [ :each | | instruction |
-				instruction := self visit: each.
+				instruction := each shouldBeAliased
+					ifTrue: [ self alias: each ]
+					ifFalse: [ self visit: each ].
 				instruction isVariable ifFalse: [
 					self sequence add: instruction ]]]
 !
@@ -985,8 +987,9 @@ visitIRSend: anIRSend
 	anIRSend classSend
 		ifNil: [ self visitSend: anIRSend ]
 		ifNotNil: [ self visitSuperSend: anIRSend ].
-	"anIRSend index > 1 ifTrue: [ 
-		self stream nextPutSendIndexFor: anIRSend ]."
+		
+"	(anIRSend method sendIndexes at: anIRSend selector) size > 1 
+		ifTrue: [ self stream nextPutSendIndexFor: anIRSend ]"
 !
 
 visitIRSequence: anIRSequence
@@ -1230,12 +1233,12 @@ nextPutReturnWith: aBlock
 
 nextPutSendIndexFor: anIRSend
 	self 
+		nextPutAll: ';'; lf;
 		nextPutAll: anIRSend scope alias;
 		nextPutAll: '.sendIdx["';
 		nextPutAll: anIRSend selector;
 		nextPutAll: '"]=';
-		nextPutAll: anIRSend index asString;
-		nextPutAll: ';'
+		nextPutAll: anIRSend index asString
 !
 
 nextPutSequenceWith: aBlock