nogc.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // nogc.cc - Implement null garbage collector.
  2. /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2007
  3. Free Software Foundation
  4. This file is part of libgcj.
  5. This software is copyrighted work licensed under the terms of the
  6. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  7. details. */
  8. #include <config.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <gcj/cni.h>
  12. #include <jvm.h>
  13. // Total amount of memory allocated.
  14. static long total = 0;
  15. void *
  16. _Jv_BuildGCDescr(jclass)
  17. {
  18. return 0;
  19. }
  20. void *
  21. _Jv_AllocObj (jsize size, jclass klass)
  22. {
  23. total += size;
  24. void *obj = calloc (size, 1);
  25. if (!obj) _Jv_ThrowNoMemory();
  26. *((_Jv_VTable **) obj) = klass->vtable;
  27. return obj;
  28. }
  29. void *
  30. _Jv_AllocPtrFreeObj (jsize size, jclass klass)
  31. {
  32. total += size;
  33. void *obj = calloc (size, 1);
  34. if (!obj) _Jv_ThrowNoMemory();
  35. *((_Jv_VTable **) obj) = klass->vtable;
  36. return obj;
  37. }
  38. void *
  39. _Jv_AllocArray (jsize size, jclass klass)
  40. {
  41. total += size;
  42. void *obj = calloc (size, 1);
  43. if (!obj) _Jv_ThrowNoMemory();
  44. *((_Jv_VTable **) obj) = klass->vtable;
  45. return obj;
  46. }
  47. void *
  48. _Jv_AllocBytes (jsize size)
  49. {
  50. total += size;
  51. void *obj = calloc (size, 1);
  52. if (!obj) _Jv_ThrowNoMemory();
  53. return obj;
  54. }
  55. void *
  56. _Jv_AllocRawObj (jsize size)
  57. {
  58. total += size;
  59. return calloc (size, 1);
  60. }
  61. _Jv_ClosureList **
  62. _Jv_ClosureListFinalizer ()
  63. {
  64. _Jv_ClosureList **clpp;
  65. clpp = (_Jv_ClosureList **)_Jv_AllocBytes (sizeof (*clpp));
  66. return clpp;
  67. }
  68. void
  69. _Jv_RegisterFinalizer (void *, _Jv_FinalizerFunc *)
  70. {
  71. // FIXME: should actually register so that finalizers can be run on
  72. // exit.
  73. }
  74. void
  75. _Jv_RunFinalizers (void)
  76. {
  77. }
  78. void
  79. _Jv_RunAllFinalizers (void)
  80. {
  81. // FIXME: should still run all finalizers.
  82. }
  83. void
  84. _Jv_GCInitializeFinalizers (void (*) (void))
  85. {
  86. }
  87. void
  88. _Jv_RunGC (void)
  89. {
  90. }
  91. long
  92. _Jv_GCTotalMemory (void)
  93. {
  94. return total;
  95. }
  96. long
  97. _Jv_GCFreeMemory (void)
  98. {
  99. return 0;
  100. }
  101. void
  102. _Jv_GCSetInitialHeapSize (size_t)
  103. {
  104. }
  105. void
  106. _Jv_GCSetMaximumHeapSize (size_t)
  107. {
  108. }
  109. void
  110. _Jv_DisableGC (void)
  111. {
  112. }
  113. void
  114. _Jv_EnableGC (void)
  115. {
  116. }
  117. void
  118. _Jv_InitGC (void)
  119. {
  120. }
  121. void
  122. _Jv_GCRegisterDisappearingLink (jobject *)
  123. {
  124. }
  125. jboolean
  126. _Jv_GCCanReclaimSoftReference (jobject)
  127. {
  128. // For now, always reclaim soft references. FIXME.
  129. return true;
  130. }
  131. #ifdef JV_HASH_SYNCHRONIZATION
  132. void *
  133. _Jv_AllocTraceOne (jsize size /* includes vtable slot */)
  134. {
  135. void *obj = calloc(size, 1);
  136. if (!obj) _Jv_ThrowNoMemory();
  137. return result;
  138. }
  139. void *
  140. _Jv_AllocTraceTwo (jsize size /* includes vtable slot */)
  141. {
  142. void *obj = calloc(size, 1);
  143. if (!obj) _Jv_ThrowNoMemory();
  144. return result;
  145. }
  146. #endif /* JV_HASH_SYNCHRONIZATION */
  147. void
  148. _Jv_SuspendThread (_Jv_Thread_t *thread)
  149. {
  150. }
  151. void
  152. _Jv_ResumeThread (_Jv_Thread_t *thread)
  153. {
  154. }
  155. int
  156. _Jv_IsThreadSuspended (_Jv_Thread_t *thread)
  157. {
  158. return 0;
  159. }