Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/c4b8857789e3f79a2ae0f7abe108999bf323b01a
...commit
http://git.netsurf-browser.org/netsurf.git/commit/c4b8857789e3f79a2ae0f7abe108999bf323b01a
...tree
http://git.netsurf-browser.org/netsurf.git/tree/c4b8857789e3f79a2ae0f7abe108999bf323b01a
The branch, master has been updated
via c4b8857789e3f79a2ae0f7abe108999bf323b01a (commit)
via 20432237883a04677f30f1758979fa0a4b9111e3 (commit)
from f8f802cda5f54c0c2b1acd51efc08aa7d4afad1b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c4b8857789e3f79a2ae0f7abe108999bf323b01a
commit c4b8857789e3f79a2ae0f7abe108999bf323b01a
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>
Add low memory handler to purge unused slabs on OS3
TODO: find some way to purge NetSurf's memory cache safely from another
process
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e5b5c59..6dca47a 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -5543,6 +5543,11 @@ int main(int argc, char** argv)
/* Open splash window */
Object *splash_window = ami_gui_splash_open();
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ struct Interupt *memhandler = ami_memory_init();
+#endif
+
ami_object_init();
if (ami_open_resources() == false) { /* alloc message ports */
@@ -5743,6 +5748,11 @@ int main(int argc, char** argv)
ami_object_fini();
ami_bitmap_fini();
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ ami_memory_fini(memhandler);
+#endif
+
LOG("Closing screen");
ami_gui_close_screen(scrn, locked_screen, FALSE);
if(nsscreentitle) FreeVec(nsscreentitle);
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index d86f73d..abf849d 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -17,8 +17,11 @@
*/
#ifndef __amigaos4__
+#include <proto/exec.h>
+#include <exec/interrupts.h>
#include <stdlib.h>
#include "amiga/memory.h"
+#include "amiga/os3support.h"
#include "utils/log.h"
ULONG __slab_max_size = 2048; /* Enable clib2's slab allocator */
@@ -60,5 +63,32 @@ void ami_memory_slab_dump(void)
{
__get_slab_usage(ami_memory_slab_callback);
}
+
+static ASM ULONG ami_memory_handler(REG(a0, struct MemHandlerData *mhd),
REG(a1, void *userdata), REG(a6, struct ExecBase *execbase))
+{
+ __free_unused_slabs();
+
+ return MEM_ALL_DONE;
+}
+
+struct Interrupt *ami_memory_init(void)
+{
+ struct Interrupt *memhandler = malloc(sizeof(struct Interrupt));
+
+ memhandler->is_Node.ln_Pri = 1;
+ memhandler->is_Node.ln_Name = "NetSurf slab memory handler";
+ memhandler->is_Data = NULL;
+ memhandler->is_Code = (APTR)&ami_memory_handler;
+ AddMemHandler(memhandler);
+
+ return memhandler;
+}
+
+void ami_memory_fini(struct Interrupt *memhandler)
+{
+ RemMemHandler(memhandler);
+ free(memhandler);
+}
+
#endif
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index 3d92350..a87a3ea 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -57,9 +57,11 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
#endif
-/* clib2 slab allocator stats */
+/* clib2 slab allocator */
#ifndef __amigaos4__
void ami_memory_slab_dump(void);
+struct Interrupt *ami_memory_init(void);
+void ami_memory_fini(struct Interrupt *memhandler);
#endif
#endif //AMIGA_MEMORY_H
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=20432237883a04677f30f1758979fa0a4b9111e3
commit 20432237883a04677f30f1758979fa0a4b9111e3
Author: Chris Young <[email protected]>
Commit: Chris Young <[email protected]>
Reduce frequency of diskfont open/close
diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c
index d3b9c32..22a0f4a 100644
--- a/frontends/amiga/font.c
+++ b/frontends/amiga/font.c
@@ -115,6 +115,8 @@ void ami_font_fini(void)
{
if(nsoption_bool(bitmap_fonts) == false) {
ami_font_bullet_fini();
+ } else {
+ ami_font_diskfont_fini();
}
}
diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c
index 313e992..8593f81 100644
--- a/frontends/amiga/font_diskfont.c
+++ b/frontends/amiga/font_diskfont.c
@@ -39,6 +39,9 @@
#define MAX_FONT_NAME_SIZE 33
+static plot_font_style_t *prev_fstyle = NULL;
+static struct TextFont *prev_font = NULL;
+
static struct TextFont *ami_font_bm_open(struct RastPort *rp, const
plot_font_style_t *fstyle)
{
struct TextFont *bmfont = NULL;
@@ -46,6 +49,15 @@ static struct TextFont *ami_font_bm_open(struct RastPort
*rp, const plot_font_st
char *fontname;
char font[MAX_FONT_NAME_SIZE];
+ if((prev_fstyle != NULL) && (prev_font != NULL) &&
+ (fstyle->family == prev_fstyle->family) &&
+ (fstyle->size == prev_fstyle->size) &&
+ (fstyle->flags == prev_fstyle->flags) &&
+ (fstyle->weight == prev_fstyle->weight)) {
+ LOG("(using current font)");
+ return prev_font;
+ }
+
if(rp == NULL) return NULL;
tattr.ta_Flags = 0;
@@ -87,16 +99,19 @@ static struct TextFont *ami_font_bm_open(struct RastPort
*rp, const plot_font_st
tattr.ta_Name = font;
tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE;
LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
+
+ if(prev_font != NULL) CloseFont(prev_font);
+
if((bmfont = OpenDiskFont(&tattr))) {
SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
}
- return bmfont;
-}
+ if(prev_fstyle != NULL) {
+ memcpy(prev_fstyle, fstyle, sizeof(plot_font_style_t));
+ prev_font = bmfont;
+ }
-static void ami_font_bm_close(struct TextFont *bmfont)
-{
- CloseFont(bmfont);
+ return bmfont;
}
static size_t ami_font_bm_convert_local_to_utf8_offset(const char *utf8string,
size_t length, UWORD offset)
@@ -125,15 +140,12 @@ static nserror amiga_bm_nsfont_width(const
plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
*width = TextLength(glob->rp, localtext, (UWORD)strlen(localtext));
free(localtext);
- ami_font_bm_close(bmfont);
-
return NSERROR_OK;
}
@@ -164,7 +176,6 @@ static nserror amiga_bm_nsfont_position_in_string(const
plot_font_style_t *fstyl
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -174,7 +185,6 @@ static nserror amiga_bm_nsfont_position_in_string(const
plot_font_style_t *fstyl
*actual_x = extent.te_Extent.MaxX;
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -218,7 +228,6 @@ static nserror amiga_bm_nsfont_split(const
plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -252,7 +261,6 @@ static nserror amiga_bm_nsfont_split(const
plot_font_style_t *fstyle,
}
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -273,8 +281,6 @@ static ULONG amiga_bm_nsfont_text(struct RastPort *rp,
const char *string, ULONG
free(localtext);
}
- ami_font_bm_close(bmfont);
-
return 0;
}
@@ -289,5 +295,14 @@ void ami_font_diskfont_init(void)
{
/* Set up table */
ami_nsfont = &ami_font_diskfont_table;
+
+ /* Alloc space to hold currently open font - doesn't matter if this
fails */
+ prev_fstyle = calloc(1, sizeof(plot_font_style_t));
+}
+
+void ami_font_diskfont_fini(void)
+{
+ if(prev_font != NULL) CloseFont(prev_font);
+ if(prev_fstyle != NULL) free(prev_fstyle);
}
diff --git a/frontends/amiga/font_diskfont.h b/frontends/amiga/font_diskfont.h
index de19e94..1c891d2 100644
--- a/frontends/amiga/font_diskfont.h
+++ b/frontends/amiga/font_diskfont.h
@@ -19,5 +19,6 @@
#ifndef AMIGA_FONT_DISKFONT_H
#define AMIGA_FONT_DISKFONT_H
void ami_font_diskfont_init(void);
+void ami_font_diskfont_fini(void);
#endif
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/font.c | 2 ++
frontends/amiga/font_diskfont.c | 43 ++++++++++++++++++++++++++-------------
frontends/amiga/font_diskfont.h | 1 +
frontends/amiga/gui.c | 10 +++++++++
frontends/amiga/memory.c | 30 +++++++++++++++++++++++++++
frontends/amiga/memory.h | 4 +++-
6 files changed, 75 insertions(+), 15 deletions(-)
diff --git a/frontends/amiga/font.c b/frontends/amiga/font.c
index d3b9c32..22a0f4a 100644
--- a/frontends/amiga/font.c
+++ b/frontends/amiga/font.c
@@ -115,6 +115,8 @@ void ami_font_fini(void)
{
if(nsoption_bool(bitmap_fonts) == false) {
ami_font_bullet_fini();
+ } else {
+ ami_font_diskfont_fini();
}
}
diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c
index 313e992..8593f81 100644
--- a/frontends/amiga/font_diskfont.c
+++ b/frontends/amiga/font_diskfont.c
@@ -39,6 +39,9 @@
#define MAX_FONT_NAME_SIZE 33
+static plot_font_style_t *prev_fstyle = NULL;
+static struct TextFont *prev_font = NULL;
+
static struct TextFont *ami_font_bm_open(struct RastPort *rp, const
plot_font_style_t *fstyle)
{
struct TextFont *bmfont = NULL;
@@ -46,6 +49,15 @@ static struct TextFont *ami_font_bm_open(struct RastPort
*rp, const plot_font_st
char *fontname;
char font[MAX_FONT_NAME_SIZE];
+ if((prev_fstyle != NULL) && (prev_font != NULL) &&
+ (fstyle->family == prev_fstyle->family) &&
+ (fstyle->size == prev_fstyle->size) &&
+ (fstyle->flags == prev_fstyle->flags) &&
+ (fstyle->weight == prev_fstyle->weight)) {
+ LOG("(using current font)");
+ return prev_font;
+ }
+
if(rp == NULL) return NULL;
tattr.ta_Flags = 0;
@@ -87,16 +99,19 @@ static struct TextFont *ami_font_bm_open(struct RastPort
*rp, const plot_font_st
tattr.ta_Name = font;
tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE;
LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
+
+ if(prev_font != NULL) CloseFont(prev_font);
+
if((bmfont = OpenDiskFont(&tattr))) {
SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE);
}
- return bmfont;
-}
+ if(prev_fstyle != NULL) {
+ memcpy(prev_fstyle, fstyle, sizeof(plot_font_style_t));
+ prev_font = bmfont;
+ }
-static void ami_font_bm_close(struct TextFont *bmfont)
-{
- CloseFont(bmfont);
+ return bmfont;
}
static size_t ami_font_bm_convert_local_to_utf8_offset(const char *utf8string,
size_t length, UWORD offset)
@@ -125,15 +140,12 @@ static nserror amiga_bm_nsfont_width(const
plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
*width = TextLength(glob->rp, localtext, (UWORD)strlen(localtext));
free(localtext);
- ami_font_bm_close(bmfont);
-
return NSERROR_OK;
}
@@ -164,7 +176,6 @@ static nserror amiga_bm_nsfont_position_in_string(const
plot_font_style_t *fstyl
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -174,7 +185,6 @@ static nserror amiga_bm_nsfont_position_in_string(const
plot_font_style_t *fstyl
*actual_x = extent.te_Extent.MaxX;
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -218,7 +228,6 @@ static nserror amiga_bm_nsfont_split(const
plot_font_style_t *fstyle,
if(bmfont == NULL) return NSERROR_INVALID;
if(utf8_to_local_encoding(string, length, &localtext) != NSERROR_OK) {
- ami_font_bm_close(bmfont);
return NSERROR_INVALID;
}
@@ -252,7 +261,6 @@ static nserror amiga_bm_nsfont_split(const
plot_font_style_t *fstyle,
}
free(localtext);
- ami_font_bm_close(bmfont);
return NSERROR_OK;
}
@@ -273,8 +281,6 @@ static ULONG amiga_bm_nsfont_text(struct RastPort *rp,
const char *string, ULONG
free(localtext);
}
- ami_font_bm_close(bmfont);
-
return 0;
}
@@ -289,5 +295,14 @@ void ami_font_diskfont_init(void)
{
/* Set up table */
ami_nsfont = &ami_font_diskfont_table;
+
+ /* Alloc space to hold currently open font - doesn't matter if this
fails */
+ prev_fstyle = calloc(1, sizeof(plot_font_style_t));
+}
+
+void ami_font_diskfont_fini(void)
+{
+ if(prev_font != NULL) CloseFont(prev_font);
+ if(prev_fstyle != NULL) free(prev_fstyle);
}
diff --git a/frontends/amiga/font_diskfont.h b/frontends/amiga/font_diskfont.h
index de19e94..1c891d2 100644
--- a/frontends/amiga/font_diskfont.h
+++ b/frontends/amiga/font_diskfont.h
@@ -19,5 +19,6 @@
#ifndef AMIGA_FONT_DISKFONT_H
#define AMIGA_FONT_DISKFONT_H
void ami_font_diskfont_init(void);
+void ami_font_diskfont_fini(void);
#endif
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index e5b5c59..6dca47a 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -5543,6 +5543,11 @@ int main(int argc, char** argv)
/* Open splash window */
Object *splash_window = ami_gui_splash_open();
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ struct Interupt *memhandler = ami_memory_init();
+#endif
+
ami_object_init();
if (ami_open_resources() == false) { /* alloc message ports */
@@ -5743,6 +5748,11 @@ int main(int argc, char** argv)
ami_object_fini();
ami_bitmap_fini();
+#ifndef __amigaos4__
+ /* OS3 low memory handler */
+ ami_memory_fini(memhandler);
+#endif
+
LOG("Closing screen");
ami_gui_close_screen(scrn, locked_screen, FALSE);
if(nsscreentitle) FreeVec(nsscreentitle);
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index d86f73d..abf849d 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -17,8 +17,11 @@
*/
#ifndef __amigaos4__
+#include <proto/exec.h>
+#include <exec/interrupts.h>
#include <stdlib.h>
#include "amiga/memory.h"
+#include "amiga/os3support.h"
#include "utils/log.h"
ULONG __slab_max_size = 2048; /* Enable clib2's slab allocator */
@@ -60,5 +63,32 @@ void ami_memory_slab_dump(void)
{
__get_slab_usage(ami_memory_slab_callback);
}
+
+static ASM ULONG ami_memory_handler(REG(a0, struct MemHandlerData *mhd),
REG(a1, void *userdata), REG(a6, struct ExecBase *execbase))
+{
+ __free_unused_slabs();
+
+ return MEM_ALL_DONE;
+}
+
+struct Interrupt *ami_memory_init(void)
+{
+ struct Interrupt *memhandler = malloc(sizeof(struct Interrupt));
+
+ memhandler->is_Node.ln_Pri = 1;
+ memhandler->is_Node.ln_Name = "NetSurf slab memory handler";
+ memhandler->is_Data = NULL;
+ memhandler->is_Code = (APTR)&ami_memory_handler;
+ AddMemHandler(memhandler);
+
+ return memhandler;
+}
+
+void ami_memory_fini(struct Interrupt *memhandler)
+{
+ RemMemHandler(memhandler);
+ free(memhandler);
+}
+
#endif
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index 3d92350..a87a3ea 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -57,9 +57,11 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
#endif
-/* clib2 slab allocator stats */
+/* clib2 slab allocator */
#ifndef __amigaos4__
void ami_memory_slab_dump(void);
+struct Interrupt *ami_memory_init(void);
+void ami_memory_fini(struct Interrupt *memhandler);
#endif
#endif //AMIGA_MEMORY_H
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org