|
|
| version 1.11, 2016/03/31 21:46:20 | version 1.22, 2026/04/25 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b memory parser class. | Parser: @b memory parser class. |
| Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru) | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| #include "pa_common.h" | #include "pa_common.h" |
| #include "pa_vmemory.h" | #include "pa_vmemory.h" |
| #include "pa_request.h" | #include "pa_request.h" |
| #include "pa_vmethod_frame.h" | |
| volatile const char * IDENT_MEMORY_C="$Id$" IDENT_PA_VMEMORY_H; | volatile const char * IDENT_MEMORY_C="$Id$" IDENT_PA_VMEMORY_H; |
| Line 23 public: // Methoded | Line 24 public: // Methoded |
| DECLARE_CLASS_VAR(memory, new MMemory); | DECLARE_CLASS_VAR(memory, new MMemory); |
| #undef GC_DEBUG | |
| #ifdef GC_DEBUG | |
| extern "C" GC_API void GC_print_backtrace(void *); | |
| void *debug_print_backtrace=0; | |
| #endif | |
| static void _compact(Request& r, MethodParams&) { | static void _compact(Request& r, MethodParams&) { |
| r.wipe_unused_execution_stack(); | r.wipe_unused_execution_stack(); |
| #ifndef PA_DEBUG_DISABLE_GC | pa_gc_collect(true); |
| { | } |
| int saved=GC_dont_gc; | |
| GC_dont_gc=0; | static void _auto_compact(Request& r, MethodParams& params) { |
| GC_gcollect(); | int divisor = params.as_int(0, "frequency must be int", r); |
| GC_dont_gc=saved; | if(divisor<0 || divisor>5) |
| } | throw Exception(PARSER_RUNTIME, 0, "frequency '%d' is out of range 0..5", divisor); |
| #ifdef GC_DEBUG | pa_gc_set_free_space_divisor(divisor); |
| if(debug_print_backtrace) | } |
| GC_print_backtrace(debug_print_backtrace); | |
| #endif | |
| #endif | |
| } | |
| // constructor | // constructor |
| MMemory::MMemory(): Methoded("memory") { | MMemory::MMemory(): Methoded("memory") { |
| // ^compact[] | // ^compact[] |
| add_native_method("compact", Method::CT_STATIC, _compact, 0, 0); | add_native_method("compact", Method::CT_STATIC, _compact, 0, 0); |
| // ^auto-compact(N) | |
| add_native_method("auto-compact", Method::CT_STATIC, _auto_compact, 1, 1); | |
| } | } |