hqlstack.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef _HQLSTACK_HPP_
  14. #define _HQLSTACK_HPP_
  15. #include "jlib.hpp"
  16. #include "jstream.hpp"
  17. #include "jexcept.hpp"
  18. #include "jmisc.hpp"
  19. #include "deftype.hpp"
  20. #include "defvalue.hpp"
  21. #include "hqlexpr.hpp"
  22. #define DEFAULTSTACKSIZE 256
  23. #define INCREMENTALSIZE 128
  24. #define MAXARGS 32
  25. #ifdef __64BIT__
  26. #define ALIGNMENT 8
  27. #define REGSIZE 8
  28. #define MMXREGSIZE 8
  29. #define MAXFPREGS 8
  30. #else
  31. #define ALIGNMENT 4
  32. #endif
  33. #define align(x) ((x + ALIGNMENT - 1) & ~(ALIGNMENT-1))
  34. class FuncCallStack {
  35. private:
  36. unsigned tos;
  37. unsigned sp;
  38. char* stackbuf;
  39. char* toFree[MAXARGS];
  40. int numToFree;
  41. #ifdef __64BIT__
  42. // ARMFIX: If this is related to VFP registers in procedure call
  43. // than both ARM32 and ARM64 use it and we'll need to account for it
  44. double fpRegs[MAXFPREGS];
  45. unsigned numFpRegs;
  46. #endif
  47. public:
  48. FuncCallStack(int size = DEFAULTSTACKSIZE);
  49. virtual ~FuncCallStack();
  50. unsigned getSp();
  51. char* getMem();
  52. #ifdef __64BIT__
  53. void * getFloatMem() { return numFpRegs?&fpRegs:NULL; }
  54. #endif
  55. int push(ITypeInfo* argType, IValue* paramValue);
  56. int push(char* & val);
  57. int pushPtr(void * val);
  58. int pushRef(unsigned& val);
  59. int pushRef(char*& val);
  60. void assure(int inclen);
  61. protected:
  62. int push(unsigned len, const void * data);
  63. };
  64. #endif