зеркало из https://github.com/mozilla/pluotsorbet.git
Merge pull request #1838 from marco-c/boehm_heuristics
Use Boehm's GC heuristics instead of our own
This commit is contained in:
Коммит
d5b8ae2c04
4
Makefile
4
Makefile
|
@ -86,7 +86,7 @@ else
|
|||
endif
|
||||
|
||||
ifeq ($(RELEASE),1)
|
||||
CLOSURE_FLAGS =
|
||||
CLOSURE_FLAGS =
|
||||
else
|
||||
CLOSURE_FLAGS = --formatting PRETTY_PRINT
|
||||
endif
|
||||
|
@ -340,7 +340,7 @@ bld/native.js: Makefile vm/native/native.cpp vm/native/Boehm.js/.libs/$(BOEHM_LI
|
|||
emcc -DNDEBUG -Ivm/native/Boehm.js/include/ vm/native/Boehm.js/.libs/$(BOEHM_LIB) -Oz -O3 \
|
||||
vm/native/native.cpp jit/relooper/Relooper.cpp -o native.raw.js --memory-init-file 0 \
|
||||
-s TOTAL_STACK=16*1024 -s TOTAL_MEMORY=$(ASMJS_TOTAL_MEMORY) -DGC_INITIAL_HEAP_SIZE=$(GC_INITIAL_HEAP_SIZE) \
|
||||
-s 'EXPORTED_FUNCTIONS=["_main", "_lAdd", "_lNeg", "_lSub", "_lShl", "_lShr", "_lUshr", "_lMul", "_lDiv", "_lRem", "_lCmp", "_gcMallocUncollectable", "_gcFree", "_gcMalloc", "_gcMallocAtomic", "_gcRegisterDisappearingLink", "_gcUnregisterDisappearingLink", "_registerFinalizer", "_forceCollection", "_getUsedHeapSize", "_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_set_block_code","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render", "_rl_set_asm_js_mode"]' \
|
||||
-s 'EXPORTED_FUNCTIONS=["_main", "_lAdd", "_lNeg", "_lSub", "_lShl", "_lShr", "_lUshr", "_lMul", "_lDiv", "_lRem", "_lCmp", "_gcMallocUncollectable", "_gcFree", "_gcMalloc", "_gcMallocAtomic", "_gcRegisterDisappearingLink", "_gcUnregisterDisappearingLink", "_registerFinalizer", "_forceCollection", "_collectALittle", "_getUsedHeapSize", "_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_set_block_code","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render", "_rl_set_asm_js_mode"]' \
|
||||
-s 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=["memcpy", "memset", "malloc", "free", "puts"]' \
|
||||
-s NO_EXIT_RUNTIME=1 -s NO_BROWSER=1 -s NO_FILESYSTEM=1 --post-js jit/relooper/glue.js
|
||||
echo "var RELOOPER_BUFFER_SIZE = 1024 * 512;" > bld/native.js
|
||||
|
|
4
int.ts
4
int.ts
|
@ -623,9 +623,7 @@ module J2ME {
|
|||
// we consistently stay in compiled code. Most code unwinds often enough that we can
|
||||
// force collection here since at the end of an unwind all frames are
|
||||
// stored back on the heap.
|
||||
if (getFreeMemory() < Constants.FREE_MEMORY_TARGET) {
|
||||
ASM._forceCollection();
|
||||
}
|
||||
ASM._collectALittle();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,6 +131,10 @@ extern "C" {
|
|||
GC_gcollect();
|
||||
}
|
||||
|
||||
void collectALittle(void) {
|
||||
GC_collect_a_little();
|
||||
}
|
||||
|
||||
int getUsedHeapSize(void) {
|
||||
GC_word heapSize;
|
||||
GC_word freeBytes;
|
||||
|
|
|
@ -405,7 +405,7 @@ module J2ME {
|
|||
this._runtimeId = RuntimeTemplate._nextRuntimeId++;
|
||||
this._nextHashCode = (this._runtimeId << 24) | 1; // Increase by one so the first hashcode isn't zero.
|
||||
}
|
||||
|
||||
|
||||
preInitializeClasses(ctx: Context) {
|
||||
var prevCtx = $ ? $.ctx : null;
|
||||
var preInit = CLASSES.preInitializedClasses;
|
||||
|
@ -666,15 +666,6 @@ module J2ME {
|
|||
TWO_PWR_32_DBL = 4294967296,
|
||||
TWO_PWR_63_DBL = 9223372036854776000,
|
||||
|
||||
// The target amount of free memory (in bytes) before garbage collection is forced on unwind.
|
||||
// Note: This number was chosen through ad-hoc testing of a midlet, which showed
|
||||
// that the midlet OOMed once less than ~3MB of memory was available, presumably
|
||||
// because compiled codeis allocating more than that before unwinding. It would be
|
||||
// useful to have more insight into which code allocates memory, and in what chunks,
|
||||
// so we can set this to the maximum amount of memory needed by compiled code.
|
||||
// But this value seems to work ok in the meantime.
|
||||
FREE_MEMORY_TARGET = 4 * 1024 * 1024, // 4MiB
|
||||
|
||||
// The size in bytes of the header in the memory allocated to the object.
|
||||
OBJ_HDR_SIZE = 8,
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче