Commit 257f3ec5 authored by rjw's avatar rjw
Browse files

WebFoundation:

        Fixed 3127225.  Provide new SPI to get available system memory.
        (Also currently unused SPI to get number of processors.)

        Reviewed by gramps.

        * Misc.subproj/WebSystemBits.h:
        * Misc.subproj/WebSystemBits.m:
        (initCapabilities):
        (WebSystemMainMemory):
        (WebSystemProcessors):
        * WebFoundation.exp:
        * WebFoundation.pbproj/project.pbxproj:

WebCore:
        Fixed 3127225.  Set WebCore object cache size when first bridge is created.

        Reviewed by gramps.

        * kwq/WebCoreBridge.h:
        * kwq/WebCoreBridge.mm:
        (-[WebCoreBridge init]):

WebKit:
        Fixed 3127225.  Scale page cache based on available memory.
        Also added support for setting WebCore object cache size via
        a preference.
        Fixed 3126267.  Increase CG glyph cache size if font smoothing
        is turned on.

        Reviewed by gramps.

        * History.subproj/WebBackForwardList.m:
        (+[WebBackForwardList pageCacheSize]):
        * Misc.subproj/WebKitLogging.h:
        * Misc.subproj/WebKitLogging.m:
        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge getObjectCacheSize]):
        * WebCoreSupport.subproj/WebTextRendererFactory.m:
        (getAppDefaultValue):
        (getUserDefaultValue):
        (getLCDScaleParameters):
        * WebView.subproj/WebPreferences.m:
        (+[WebPreferences load]):
        (-[WebPreferences _pageCacheSize]):
        (-[WebPreferences _objectCacheSize]):
        * WebView.subproj/WebPreferencesPrivate.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8829e5d8
2002-12-13 Richard Williamson <rjw@apple.com>
Fixed 3127225. Set WebCore object cache size when first bridge is created.
Reviewed by gramps.
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge init]):
2002-12-13 Darin Adler <darin@apple.com>
Reviewed by John.
......
2002-12-13 Richard Williamson <rjw@apple.com>
Fixed 3127225. Set WebCore object cache size when first bridge is created.
Reviewed by gramps.
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge init]):
2002-12-13 Darin Adler <darin@apple.com>
Reviewed by John.
......
......@@ -244,6 +244,8 @@ enum FrameBorderStyle {
- (BOOL)saveDocumentToPageCache:(id)documentInfo;
- (int)getObjectCacheSize;
@end
// This interface definition allows those who hold a WebCoreBridge * to call all the methods
......
......@@ -49,6 +49,7 @@
#import "WebCoreTextRendererFactory.h"
#import "KWQCharsets.h"
#import "KWQFrame.h"
#import "loader.h"
#import "WebCoreDOMPrivate.h"
......@@ -99,13 +100,21 @@ NSString *WebCoreElementStringKey = @"WebElementString";
@implementation WebCoreBridge
static bool initializedObjectCacheSize = FALSE;
- init
{
[super init];
_part = new KWQKHTMLPart;
_part->setBridge(self);
if (!initializedObjectCacheSize){
khtml::Cache::setSize([self getObjectCacheSize]);
initializedObjectCacheSize = TRUE;
}
return self;
}
......
2002-12-13 Richard Williamson <rjw@apple.com>
Fixed 3127225. Scale page cache based on available memory.
Also added support for setting WebCore object cache size via
a preference.
Fixed 3126267. Increase CG glyph cache size if font smoothing
is turned on.
Reviewed by gramps.
* History.subproj/WebBackForwardList.m:
(+[WebBackForwardList pageCacheSize]):
* Misc.subproj/WebKitLogging.h:
* Misc.subproj/WebKitLogging.m:
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge getObjectCacheSize]):
* WebCoreSupport.subproj/WebTextRendererFactory.m:
(getAppDefaultValue):
(getUserDefaultValue):
(getLCDScaleParameters):
* WebView.subproj/WebPreferences.m:
(+[WebPreferences load]):
(-[WebPreferences _pageCacheSize]):
(-[WebPreferences _objectCacheSize]):
* WebView.subproj/WebPreferencesPrivate.h:
2002-12-13 Chris Blumenberg <cblu@apple.com>
Fixed: 3105486 - c|net news.com site seems to have lost its favicon again
......
......@@ -4,9 +4,11 @@
*/
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebHistoryItemPrivate.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebPreferencesPrivate.h>
#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebSystemBits.h>
@implementation WebBackForwardList
......@@ -202,11 +204,32 @@ + (void)setPageCacheSize: (unsigned)size
pageCacheSize = size;
}
#ifndef NDEBUG
static BOOL loggedPageCacheSize = NO;
#endif
+ (unsigned)pageCacheSize
{
if (!pageCacheSizeModified)
return [[WebPreferences standardPreferences] _pageCacheSize];
if (!pageCacheSizeModified){
unsigned s;
vm_size_t memSize = WebSystemMainMemory();
unsigned multiplier = 1;
s = [[WebPreferences standardPreferences] _pageCacheSize];
if (memSize > 1024 * 1024 * 1024)
multiplier = 4;
else if (memSize > 512 * 1024 * 1024)
multiplier = 2;
#ifndef NDEBUG
if (!loggedPageCacheSize){
LOG (CacheSizes, "Page cache size set to %d pages.", s * multiplier);
loggedPageCacheSize = YES;
}
#endif
return s * multiplier;
}
return pageCacheSize;
}
......
......@@ -25,4 +25,5 @@ extern WebLogChannel WebKitLogEvents;
extern WebLogChannel WebKitLogView;
extern WebLogChannel WebKitLogRedirect;
extern WebLogChannel WebKitLogPageCache;
\ No newline at end of file
extern WebLogChannel WebKitLogPageCache;
extern WebLogChannel WebKitLogCacheSizes;
......@@ -22,3 +22,4 @@
WebLogChannel WebKitLogRedirect = { 0x00040000, "WebKitLogLevel", WebLogChannelUninitialized };
WebLogChannel WebKitLogPageCache = { 0x00080000, "WebKitLogLevel", WebLogChannelUninitialized };
WebLogChannel WebKitLogCacheSizes = { 0x00100000, "WebKitLogLevel", WebLogChannelUninitialized };
......@@ -27,7 +27,7 @@
#import <WebKit/WebPluginError.h>
#import <WebKit/WebPluginPackage.h>
#import <WebKit/WebPluginViewFactory.h>
#import <WebKit/WebPreferences.h>
#import <WebKit/WebPreferencesPrivate.h>
#import <WebKit/WebResourceLoadDelegate.h>
#import <WebKit/WebSubresourceClient.h>
#import <WebKit/WebViewPrivate.h>
......@@ -40,6 +40,7 @@
#import <WebFoundation/WebNSURLExtras.h>
#import <WebFoundation/WebResourceHandle.h>
#import <WebFoundation/WebResourceResponse.h>
#import <WebFoundation/WebSystemBits.h>
@interface NSApplication (DeclarationStolenFromAppKit)
......@@ -523,4 +524,30 @@ - (NSView *)viewForJavaAppletWithFrame:(NSRect)theFrame attributes:(NSDictionary
return view;
}
#ifndef NDEBUG
static BOOL loggedObjectCacheSize = NO;
#endif
-(int)getObjectCacheSize
{
vm_size_t memSize = WebSystemMainMemory();
int cacheSize = [[WebPreferences standardPreferences] _objectCacheSize];
int multiplier = 1;
if (memSize > 1024 * 1024 * 1024)
multiplier = 4;
else if (memSize > 512 * 1024 * 1024)
multiplier = 2;
#ifndef NDEBUG
if (!loggedObjectCacheSize){
LOG (CacheSizes, "Object cache size set to %d bytes.", cacheSize * multiplier);
loggedObjectCacheSize = YES;
}
#endif
return cacheSize * multiplier;
}
@end
......@@ -3,12 +3,15 @@
Copyright 2002, Apple, Inc. All rights reserved.
*/
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebTextRendererFactory.h>
#import <WebKit/WebTextRenderer.h>
#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebSystemBits.h>
#import <CoreGraphics/CoreGraphicsPrivate.h>
#import <CoreGraphics/CGFontLCDSupport.h>
#import <mach-o/dyld.h>
......@@ -123,6 +126,87 @@ - (WebGlyphBuffer *)glyphBufferForFont: (NSFont *)font andColor: (NSColor *)colo
return glyphBuffer;
}
static bool
getAppDefaultValue(CFStringRef key, int *v)
{
CFPropertyListRef value;
value = CFPreferencesCopyValue(key, kCFPreferencesCurrentApplication,
kCFPreferencesAnyUser,
kCFPreferencesAnyHost);
if (value == NULL) {
value = CFPreferencesCopyValue(key, kCFPreferencesCurrentApplication,
kCFPreferencesCurrentUser,
kCFPreferencesAnyHost);
if (value == NULL)
return false;
}
if (CFGetTypeID(value) == CFNumberGetTypeID()) {
if (v != NULL)
CFNumberGetValue(value, kCFNumberIntType, v);
} else if (CFGetTypeID(value) == CFStringGetTypeID()) {
if (v != NULL)
*v = CFStringGetIntValue(value);
} else {
CFRelease(value);
return false;
}
CFRelease(value);
return true;
}
static bool
getUserDefaultValue(CFStringRef key, int *v)
{
CFPropertyListRef value;
value = CFPreferencesCopyValue(key, kCFPreferencesAnyApplication,
kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost);
if (value == NULL)
return false;
if (CFGetTypeID(value) == CFNumberGetTypeID()) {
if (v != NULL)
CFNumberGetValue(value, kCFNumberIntType, v);
} else if (CFGetTypeID(value) == CFStringGetTypeID()) {
if (v != NULL)
*v = CFStringGetIntValue(value);
} else {
CFRelease(value);
return false;
}
CFRelease(value);
return true;
}
static int getLCDScaleParameters(void)
{
int mode;
CFStringRef key;
key = CFSTR("AppleFontSmoothing");
if (!getAppDefaultValue(key, &mode)) {
if (!getUserDefaultValue(key, &mode))
return 1;
}
switch (mode) {
case kCGFontSmoothingLCDLight:
case kCGFontSmoothingLCDMedium:
case kCGFontSmoothingLCDStrong:
return 4;
default:
return 1;
}
}
#define MINIMUM_GLYPH_CACHE_SIZE 1536 * 1024
+ (void)createSharedFactory;
{
if (![self sharedFactory]) {
......@@ -141,7 +225,16 @@ + (void)createSharedFactory;
CGFontCache *fontCache;
fontCache = CGFontCacheCreate();
functionPtr1 (fontCache, false);
functionPtr2 (fontCache, 1024*1024);
size_t s;
if (WebSystemMainMemory() > 128 * 1024 * 1024)
s = MINIMUM_GLYPH_CACHE_SIZE*getLCDScaleParameters();
else
s = MINIMUM_GLYPH_CACHE_SIZE;
#ifndef NDEBUG
LOG (CacheSizes, "Glyph cache size set to %d bytes.", s);
#endif
functionPtr2 (fontCache, s);
CGFontCacheRelease(fontCache);
}
}
......
......@@ -34,6 +34,7 @@
#define WebKitAllowAnimatedImageLoopingPreferenceKey @"WebKitAllowAnimatedImageLoopingPreferenceKey"
#define WebKitDisplayImagesKey @"WebKitDisplayImagesKey"
#define WebKitPageCacheSizePreferenceKey @"WebKitPageCacheSizePreferenceKey"
#define WebKitObjectCacheSizePreferenceKey @"WebKitObjectCacheSizePreferenceKey"
@implementation WebPreferences
......@@ -94,14 +95,15 @@ + (void)load
@"1.00", WebKitInitialTimedLayoutDelayPreferenceKey,
@"4096", WebKitInitialTimedLayoutSizePreferenceKey,
@"1.00", WebKitResourceTimedLayoutDelayPreferenceKey,
@"4", WebKitPageCacheSizePreferenceKey,
@"4", WebKitPageCacheSizePreferenceKey,
@"4194304", WebKitObjectCacheSizePreferenceKey,
[NSNumber numberWithBool:YES], WebKitInitialTimedLayoutEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitResourceTimedLayoutEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey,
@"", WebKitUserStyleSheetLocationPreferenceKey,
[NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitJavaEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitJavaScriptEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
[NSNumber numberWithBool:YES], WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey,
[NSNumber numberWithBool:YES], WebKitPluginsEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitAllowAnimatedImagesPreferenceKey,
[NSNumber numberWithBool:YES], WebKitAllowAnimatedImageLoopingPreferenceKey,
......@@ -311,6 +313,11 @@ - (int)_pageCacheSize
return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitPageCacheSizePreferenceKey];
}
- (int)_objectCacheSize
{
return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitObjectCacheSizePreferenceKey];
}
- (BOOL)_initialTimedLayoutEnabled
{
return [[NSUserDefaults standardUserDefaults] boolForKey:WebKitInitialTimedLayoutEnabledPreferenceKey];
......
......@@ -15,5 +15,6 @@
- (BOOL)_resourceTimedLayoutEnabled;
- (NSTimeInterval)_resourceTimedLayoutDelay;
- (int)_pageCacheSize;
- (int)_objectCacheSize;
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment