{"action":"opened","issue":{"url":"https://api.github.com/repos/eclipse/omr/issues/1815","repository_url":"https://api.github.com/repos/eclipse/omr","labels_url":"https://api.github.com/repos/eclipse/omr/issues/1815/labels{/name}","comments_url":"https://api.github.com/repos/eclipse/omr/issues/1815/comments","events_url":"https://api.github.com/repos/eclipse/omr/issues/1815/events","html_url":"https://github.com/eclipse/omr/issues/1815","id":266236295,"number":1815,"title":"Data snippet with size of power 2 only can be requested on IBM Z","user":{"login":"r30shah","id":22353051,"avatar_url":"https://avatars2.githubusercontent.com/u/22353051?v=4","gravatar_id":"","url":"https://api.github.com/users/r30shah","html_url":"https://github.com/r30shah","followers_url":"https://api.github.com/users/r30shah/followers","following_url":"https://api.github.com/users/r30shah/following{/other_user}","gists_url":"https://api.github.com/users/r30shah/gists{/gist_id}","starred_url":"https://api.github.com/users/r30shah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r30shah/subscriptions","organizations_url":"https://api.github.com/users/r30shah/orgs","repos_url":"https://api.github.com/users/r30shah/repos","events_url":"https://api.github.com/users/r30shah/events{/privacy}","received_events_url":"https://api.github.com/users/r30shah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-17T18:45:38Z","updated_at":"2017-10-17T18:45:38Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"We had a recent discussion that from [Pull Request](https://github.com/eclipse/openj9/pull/310) regarding to allocating writable data snippets. I was implementing an onsite cache in `openj9` for `instanceOf` node where I cache the `objectClass/castClass` for which we failed all inlined tests and went to helper. To implement cache I am using writable data snippets and currently hitting a limitation where I can request snippet with power of 2 size only. \r\nI have checked function that estimates/emits snippet body. In the emit snippet body I see following loop from `omr/compiler/z/codegen/OMRCodeGenerator.cpp:8210`\r\n```\r\nfor (exp = self()->constantDataSnippetExponent(); exp > 0; exp--)\r\n      {\r\n      size = 1 << exp;\r\n      first = true;\r\n      for (auto writeableiterator = _writableList.begin(); writeableiterator != _writableList.end(); ++writeableiterator)\r\n         {\r\n       if (maxSize < (*writeableiterator)->getConstantSize())\r\n            maxSize = size;\r\n\r\n         if (HANDLE_CONSTANT_SNIPPET((*writeableiterator), size))\r\n            {\r\n            if (first)\r\n               {\r\n               first = false;\r\n               self()->setBinaryBufferCursor((uint8_t *) (((uintptrj_t) (self()->getBinaryBufferCursor() + size - 1) / size) * size));\r\n               }\r\n            codeOffset = (*writeableiterator)->emitSnippetBody();\r\n            if (codeOffset != NULL)\r\n               {\r\n               self()->setBinaryBufferCursor(codeOffset);\r\n               }\r\n            }\r\n         }\r\n      }\r\n```\r\nWhere it will emit the snippet body only when `HANDLE_CONSTANT_SNIPPET((*writeableiterator), size)` returns `true`. Please note that size is defined as `1<<exp` at the beginning of loop.\r\nIf you see definition of this function-like macro,\r\n```\r\n#define HANDLE_CONSTANT_SNIPPET(cursor, pow2Size) \\\r\n                      (cursor->getConstantSize() == pow2Size)\r\n```\r\nwhich returns true only if the snippet size is equal to pow2Size. That is why currently we only can have snippet size in power of two.\r\nThere is no good explanation of this in the code for `S390ConstantDataSnippet`. \r\nI am opening up this issue, to know if this is a design choice and if yes we should document this with appropriate reason in constructor for `S390ConstantDataSnippet` with `ASSERT` when consumer of this class does not follow the restriction otherwise if it is bug we should fix this.  "}}
{"actor":{"display_login":"r30shah"}}