This repository has been archived by the owner. It is now read-only.

Removed optimization from transform return #3

Merged
merged 3 commits into from Aug 4, 2011

Conversation

Projects
None yet
2 participants
@dafrito
Contributor

dafrito commented Aug 3, 2011

This is a one-commit fix removes an optimization that breaks some specially crafted tables. I wasn't
sure how to correct it without removing it.


This optimization would normally remove an unnecessary variable, such as
the one in the following generated PIR:

set $P18, $P17[k_Foo]
new $P19, "LuaNil"
.tailcall $P18()

In the above snippet, $P19 is not used, so it can be removed without
harm. However, there are instances where this variable is used. Consider
the following code:

function Foo()
return 42
end

return { Foo() }

In this case, the following PIR should be generated:

new $P21, "LuaNil"
($P21 :slurpy) = $P20()
.tailcall tconstruct($P18, $P19, $P21 :flat)

In this case, the register that initially contains a nil value is
actually used, so it cannot be optimized away.

dafrito added some commits Aug 3, 2011

transform return: Removed an optimization that broke some table literals
This optimization would normally remove an unnecessary variable, such as
the one in the following generated PIR:

set $P18, $P17[k_Foo]
new $P19, "LuaNil"
.tailcall $P18()

In the above snippet, $P19 is not used, so it can be removed without
harm. However, there are instances where this variable is used. Consider
the following code:

function Foo()
	return 42
end

return { Foo() }

In this case, the following PIR should be generated:

new $P21, "LuaNil"
($P21 :slurpy) = $P20()
.tailcall tconstruct($P18, $P19, $P21 :flat)

In this case, the register that initially contains a nil value is
actually used, so it cannot be optimized away.
luaaux.pir: Changed encoding to utf8
This fixes a "Lossy conversion to single byte encoding" error when
trying to run a Lua program with Unicode characters.

A simple test is the following snippet:

print "∙";
Allow installable_luap to display Unicode characters
installable_luap fails to display Unicode characters. Consider the following snippet:

print "∙";

This yields the following error:

./installable_luap Unicode.lua
Invalid character in ASCII string
current instr.: 'parrot;PCT;HLLCompiler;evalfiles' pc 1468 (compilers/pct/src/PCT/HLLCompiler.pir:756)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1719 (compilers/pct/src/PCT/HLLCompiler.pir:875)
called from Sub 'main' pc 27 (luap.pir:27)

This patch fixes the problem for installable_luap, but it remains for installable_lua

fperrad added a commit that referenced this pull request Aug 4, 2011

Merge pull request #3 from dafrito/master
Removed optimization from transform return

@fperrad fperrad merged commit 3806339 into fperrad:master Aug 4, 2011

@fperrad

This comment has been minimized.

Show comment
Hide comment
@fperrad

fperrad Aug 4, 2011

Owner

merged, thanks.

Owner

fperrad commented Aug 4, 2011

merged, thanks.

@dafrito

This comment has been minimized.

Show comment
Hide comment
@dafrito

dafrito Aug 4, 2011

Contributor

Sorry that some Unicode commits snuck in this branch. I knew I shouldn't have been working off master; I'll work in separate feature branches for future pull requests.

Contributor

dafrito commented Aug 4, 2011

Sorry that some Unicode commits snuck in this branch. I knew I shouldn't have been working off master; I'll work in separate feature branches for future pull requests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.