Problem compiling method source - genPushLiteral: out of range
Hello everyone, I'm trying to move some of our code from VA Smalltalk over to Pharo using a self-made importer and have encountered the following issue I need help with: A few of our methods are very large in size. For example, we have a method that creates a huge Dictionary with specific keys and values on startup and stores it in a class variable for immediate access. This method works fine in VA Smalltalk, but if I attempt to compile the same source code in Pharo (programmatically or via copy paste using the interface) I'm getting '*Error: genPushLiteral: index index 256 is out of range 0 to 255*' in OpalEncoderForV3PlusClosures. I'm getting the same error for some other methods. If I understand this correctly, the method simply exceeds the maximum number of literals, but it works fine in VA Smalltalk. Is there a way to increase this limit or bypass this issue without having to rework our implementation? Offtopic: Does anybody if there is a package which adds a support layer for imported VA Smalltalk code? I know there is one for Pharo->VA on VASTGoodies but I couldn't find one for the other way around. Kind regards, Patrick Scherer
The limitation is inherit in the object format/ instruction set, you can find some previous discussions at http://forum.world.st/Max-source-method-length-Max-string-length-Max-change-... and http://forum.world.st/More-than-256-literals-referenced-td4676669.html#a4676... One alternative is to change the compiler to create a literal array to hold all literals > 255 and rewrite accesses to indexes above 254 as something like genPushLiteral: 255 pushLiteral #at: pushConst: X messageSend , but as long as we're talking about a single digit number of cases, and not translating 200+ UI specs, it is probably a lot easier (albeit, maybe a little slower) to rewrite the code in a way which works in both dialects without using a large number of literals, say: MyClass class >> #initializeStaticVals dict := Dictionary new. initializerPairs := #( Key1 2 Key2 4 ). 1 to: initializerPairs size by: 2 do: [:ix | dict at: (initializerPairs at: ix) put: (initializerPairs at: ix +1)]. MyClassVar := dict. (Haven't seen a support layer package for VA, sorry) Cheers, Henry -- View this message in context: http://forum.world.st/Problem-compiling-method-source-genPushLiteral-out-of-... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
On 18 Aug 2017, at 11:34, Patrick Scherer <patrick.scherer@hrworks.de> wrote:
Hello everyone,
I'm trying to move some of our code from VA Smalltalk over to Pharo using a self-made importer and have encountered the following issue I need help with:
A few of our methods are very large in size. For example, we have a method that creates a huge Dictionary with specific keys and values on startup and stores it in a class variable for immediate access. This method works fine in VA Smalltalk, but if I attempt to compile the same source code in Pharo (programmatically or via copy paste using the interface) I'm getting 'Error: genPushLiteral: index index 256 is out of range 0 to 255' in OpalEncoderForV3PlusClosures. I'm getting the same error for some other methods.
If I understand this correctly, the method simply exceeds the maximum number of literals, but it works fine in VA Smalltalk. Is there a way to increase this limit or bypass this issue without having to rework our implementation?
Hello, Can you try to change (in the preferences) the Bytecode Backend to âSistaV1â (this is the new byte code set that will be the default at some point in the future). Marcus
participants (3)
-
Henrik Sperre Johansen -
Marcus Denker -
Patrick Scherer