зеркало из https://github.com/mozilla/gecko-dev.git
bug 362390. Various fixes to get Tamarin working with latest Adobe Flash player. Some fixes from Flash source code brought over. r: edwsmith
This commit is contained in:
Родитель
0736e0c82d
Коммит
726b9a0426
|
@ -94,9 +94,6 @@ namespace MMgc
|
|||
// get detailed info on each size class allocators
|
||||
const bool dumpSizeClassState = false;
|
||||
|
||||
// Expand, don't collect, until we hit this threshold
|
||||
const size_t GC::collectThreshold = 256;
|
||||
|
||||
/**
|
||||
* Free Space Divisor. This value may be tuned for optimum
|
||||
* performance. The FSD is based on the Boehm collector.
|
||||
|
@ -163,12 +160,6 @@ namespace MMgc
|
|||
};
|
||||
const size_t kLargestAlloc = 1968;
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
// dump memory profile after sweeps
|
||||
const bool GC::enableMemoryProfiling = false;
|
||||
#endif
|
||||
|
||||
GC::GC(GCHeap *gcheap)
|
||||
: disableThreadCheck(false),
|
||||
#ifdef MMGC_DRC
|
||||
|
@ -223,7 +214,9 @@ namespace MMgc
|
|||
largeEmptyPageList(NULL),
|
||||
sweepStart(0),
|
||||
heapSizeAtLastAlloc(gcheap->GetTotalHeapSize()),
|
||||
finalizedValue(true)
|
||||
finalizedValue(true),
|
||||
// Expand, don't collect, until we hit this threshold
|
||||
collectThreshold(256)
|
||||
{
|
||||
// sanity check for all our types
|
||||
GCAssert (sizeof(int8) == 1);
|
||||
|
@ -637,7 +630,7 @@ bail:
|
|||
int heapSize = heap->GetUsedHeapSize();
|
||||
|
||||
#ifdef MEMORY_INFO
|
||||
if(enableMemoryProfiling) {
|
||||
if(heap->enableMemoryProfiling) {
|
||||
GCDebugMsg(false, "Pre sweep memory info:\n");
|
||||
DumpMemoryInfo();
|
||||
}
|
||||
|
@ -694,7 +687,7 @@ bail:
|
|||
SAMPLE_CHECK();
|
||||
|
||||
#ifdef MEMORY_INFO
|
||||
if(enableMemoryProfiling) {
|
||||
if(heap->enableMemoryProfiling) {
|
||||
GCDebugMsg(false, "Post sweep memory info:\n");
|
||||
DumpMemoryInfo();
|
||||
}
|
||||
|
@ -1558,7 +1551,7 @@ bail:
|
|||
|
||||
void GC::DumpMemoryInfo()
|
||||
{
|
||||
if(enableMemoryProfiling)
|
||||
if(heap->enableMemoryProfiling)
|
||||
{
|
||||
DumpFatties();
|
||||
if (dumpSizeClassState)
|
||||
|
|
|
@ -421,7 +421,7 @@ namespace MMgc
|
|||
*/
|
||||
int ISD;
|
||||
|
||||
const static size_t collectThreshold;
|
||||
size_t collectThreshold;
|
||||
|
||||
bool gcstats;
|
||||
|
||||
|
@ -434,13 +434,6 @@ namespace MMgc
|
|||
|
||||
bool incremental;
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* turn on memory profiling
|
||||
*/
|
||||
const static bool enableMemoryProfiling;
|
||||
#endif
|
||||
|
||||
// -- Interface
|
||||
GC(GCHeap *heap);
|
||||
~GC();
|
||||
|
|
|
@ -55,10 +55,10 @@ namespace MMgc
|
|||
// happening too frequently
|
||||
const bool decommitStress = false;
|
||||
|
||||
void GCHeap::Init(GCMallocFuncPtr m, GCFreeFuncPtr f)
|
||||
void GCHeap::Init(GCMallocFuncPtr m, GCFreeFuncPtr f, int initialSize)
|
||||
{
|
||||
GCAssert(instance == NULL);
|
||||
instance = new GCHeap(m,f);
|
||||
instance = new GCHeap(m,f, initialSize);
|
||||
}
|
||||
|
||||
void GCHeap::Destroy()
|
||||
|
@ -68,12 +68,15 @@ namespace MMgc
|
|||
instance = NULL;
|
||||
}
|
||||
|
||||
const int GCHeap::kInitialHeapSize = 128;
|
||||
|
||||
GCHeap::GCHeap(GCMallocFuncPtr m, GCFreeFuncPtr f)
|
||||
GCHeap::GCHeap(GCMallocFuncPtr m, GCFreeFuncPtr f, int initialSize)
|
||||
: heapVerbose(false),
|
||||
kNativePageSize(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// dump memory profile after sweeps
|
||||
enableMemoryProfiling = false;
|
||||
#endif
|
||||
|
||||
#if defined(_MAC) || defined(MMGC_ARM)
|
||||
m_malloc = m ? m : malloc;
|
||||
m_free = f ? f : free;
|
||||
|
@ -120,7 +123,7 @@ namespace MMgc
|
|||
#endif
|
||||
|
||||
// Create the initial heap
|
||||
ExpandHeap(kInitialHeapSize);
|
||||
ExpandHeap(initialSize);
|
||||
|
||||
decommitTicks = 0;
|
||||
decommitThresholdTicks = kDecommitThresholdMillis * GC::GetPerformanceFrequency() / 1000;
|
||||
|
|
|
@ -81,9 +81,6 @@ namespace MMgc
|
|||
/** Size of a block */
|
||||
const static int kBlockSize = 4096;
|
||||
|
||||
/** Initial heap size, in blocks */
|
||||
const static int kInitialHeapSize;
|
||||
|
||||
/** Default size of address space reserved per region */
|
||||
const static int kDefaultReserve = 4096;
|
||||
|
||||
|
@ -116,10 +113,17 @@ namespace MMgc
|
|||
|
||||
bool heapVerbose;
|
||||
|
||||
#ifdef _DEBUG
|
||||
/**
|
||||
* turn on memory profiling
|
||||
*/
|
||||
bool enableMemoryProfiling;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Init must be called to set up the GCHeap singleton
|
||||
*/
|
||||
static void Init(GCMallocFuncPtr malloc = NULL, GCFreeFuncPtr free = NULL);
|
||||
static void Init(GCMallocFuncPtr malloc = NULL, GCFreeFuncPtr free = NULL, int initialSize=128);
|
||||
|
||||
/**
|
||||
* Destroy the GCHeap singleton
|
||||
|
@ -239,7 +243,7 @@ namespace MMgc
|
|||
|
||||
// -- Implementation
|
||||
static GCHeap *instance;
|
||||
GCHeap(GCMallocFuncPtr m, GCFreeFuncPtr f);
|
||||
GCHeap(GCMallocFuncPtr m, GCFreeFuncPtr f, int initialSize);
|
||||
~GCHeap();
|
||||
|
||||
// Heap regions
|
||||
|
|
|
@ -358,7 +358,7 @@ namespace MMgc
|
|||
traceIndex = GetStackTraceIndex(skip);
|
||||
}
|
||||
|
||||
if(GC::enableMemoryProfiling && memtype)
|
||||
if(GCHeap::GetGCHeap()->enableMemoryProfiling && memtype)
|
||||
{
|
||||
// if an allocation is tagged with MMGC_MEM_TYPE its a sub
|
||||
// allocation of a "master" type and this flag prevents it
|
||||
|
@ -386,7 +386,7 @@ namespace MMgc
|
|||
|
||||
// save these off so we can save the vtable (which is assigned after memory is
|
||||
// allocated)
|
||||
if(GC::enableMemoryProfiling)
|
||||
if(GCHeap::GetGCHeap()->enableMemoryProfiling)
|
||||
{
|
||||
if(memtag || memtype) {
|
||||
if(memtag)
|
||||
|
|
|
@ -36,11 +36,6 @@ namespace avmplus
|
|||
{
|
||||
using namespace MMgc;
|
||||
|
||||
#ifdef DEBUGGER
|
||||
bool AvmCore::sampling = false;
|
||||
bool AvmCore::autoStartSampling = false;
|
||||
#endif
|
||||
|
||||
BEGIN_NATIVE_CLASSES(AvmCore)
|
||||
NATIVE_CLASS(abcclass_Object, ObjectClass, ScriptObject)
|
||||
NATIVE_CLASS(abcclass_Class, ClassClass, ClassClosure)
|
||||
|
@ -106,6 +101,11 @@ namespace avmplus
|
|||
AvmAssert (sizeof(uintptr) == 4);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGGER
|
||||
sampling = false;
|
||||
autoStartSampling = false;
|
||||
#endif
|
||||
|
||||
// set default mode flags
|
||||
#ifdef AVMPLUS_VERBOSE
|
||||
verbose = false;
|
||||
|
|
|
@ -94,9 +94,9 @@ const int kBufferPadding = 16;
|
|||
Debugger *debugger;
|
||||
Profiler *profiler;
|
||||
bool allocationTracking;
|
||||
static bool sampling;
|
||||
bool sampling;
|
||||
// call startSampling in AvmCore ctor
|
||||
static bool autoStartSampling;
|
||||
bool autoStartSampling;
|
||||
|
||||
bool samplingNow;
|
||||
int takeSample;
|
||||
|
|
|
@ -380,6 +380,73 @@ namespace avmplus
|
|||
}
|
||||
|
||||
#ifdef AVMPLUS_ROSETTA
|
||||
/*-*-------------------------------------------------------------------------
|
||||
/ Function
|
||||
/ LoadFrameworkBundle
|
||||
/
|
||||
/ Purpose
|
||||
/ Samething as GetSharedLibrary but for OS X and for non-CFM.
|
||||
/
|
||||
/ Entry
|
||||
/ framework => A CFStringRef to the name of the framework you want to load.
|
||||
/ bundlePtr => if non NULL upon return it will contain the reference to the framework you loaded.
|
||||
/--------------------------------------------*/
|
||||
static OSStatus LoadFrameworkBundle( CFStringRef framework, CFBundleRef *bundlePtr )
|
||||
{
|
||||
OSStatus err;
|
||||
FSRef frameworksFolderRef;
|
||||
CFURLRef baseURL;
|
||||
CFURLRef bundleURL;
|
||||
|
||||
// clear out the result
|
||||
*bundlePtr = NULL;
|
||||
|
||||
baseURL = NULL;
|
||||
bundleURL = NULL;
|
||||
|
||||
err = ::FSFindFolder( kOnAppropriateDisk, kFrameworksFolderType, true, &frameworksFolderRef );
|
||||
if( err == noErr )
|
||||
{
|
||||
baseURL = ::CFURLCreateFromFSRef( kCFAllocatorSystemDefault, &frameworksFolderRef );
|
||||
if( !baseURL )
|
||||
err = coreFoundationUnknownErr;
|
||||
}
|
||||
|
||||
if( !err )
|
||||
{
|
||||
bundleURL = ::CFURLCreateCopyAppendingPathComponent( kCFAllocatorSystemDefault, baseURL, framework, false );
|
||||
if( !bundleURL )
|
||||
err = coreFoundationUnknownErr;
|
||||
}
|
||||
|
||||
if( !err )
|
||||
{
|
||||
*bundlePtr = ::CFBundleCreate( kCFAllocatorSystemDefault, bundleURL );
|
||||
if( !*bundlePtr)
|
||||
err = coreFoundationUnknownErr;
|
||||
}
|
||||
|
||||
if( !err && !::CFBundleLoadExecutable( *bundlePtr ) )
|
||||
err = coreFoundationUnknownErr;
|
||||
|
||||
// Clean up.
|
||||
if( err && *bundlePtr )
|
||||
{
|
||||
::CFRelease( *bundlePtr );
|
||||
*bundlePtr = NULL;
|
||||
}
|
||||
|
||||
if( bundleURL != NULL )
|
||||
::CFRelease( bundleURL );
|
||||
|
||||
if( baseURL != NULL)
|
||||
::CFRelease( baseURL );
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
typedef int (*f_sysctlnametomib)(const char *name, int *mibp, size_t *sizep);
|
||||
|
||||
bool GenericGuard::rosetta = false;
|
||||
|
||||
/**
|
||||
|
@ -398,18 +465,31 @@ namespace avmplus
|
|||
return -1;
|
||||
}
|
||||
} else {
|
||||
int mib[CTL_MAXNAME];
|
||||
size_t len = CTL_MAXNAME;
|
||||
if (sysctlnametomib(name, mib, &len) == -1) {
|
||||
AvmAssertMsg(false, "sysctlbyname_with_pid(0): sysctlnametomib failed");
|
||||
return -1;
|
||||
}
|
||||
mib[len] = pid;
|
||||
len++;
|
||||
if (sysctl(mib, len, oldp, oldlenp, newp, newlen) == -1) {
|
||||
AvmAssertMsg(false, "sysctlbyname_with_pid(0): sysctl failed");
|
||||
return -1;
|
||||
}
|
||||
int mib[CTL_MAXNAME];
|
||||
size_t len = CTL_MAXNAME;
|
||||
|
||||
CFBundleRef sysBundle;
|
||||
if ( LoadFrameworkBundle( CFSTR("System.framework"), &sysBundle ) == noErr ) {
|
||||
f_sysctlnametomib p_sysctlnametomib = (f_sysctlnametomib)CFBundleGetFunctionPointerForName( sysBundle, CFSTR("sysctlnametomib") );
|
||||
if ( p_sysctlnametomib ) {
|
||||
if (p_sysctlnametomib(name, mib, &len) == -1) {
|
||||
AvmAssertMsg(false, "sysctlbyname_with_pid(0): sysctlnametomib failed");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
AvmAssertMsg(false, "CFBundleGetFunctionPointerForName(0): CFBundleGetFunctionPointerForName failed");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
AvmAssertMsg(false, "LoadFrameworkBundle(0): LoadFrameworkBundle failed");
|
||||
return -1;
|
||||
}
|
||||
mib[len] = pid;
|
||||
len++;
|
||||
if (sysctl(mib, len, oldp, oldlenp, newp, newlen) == -1) {
|
||||
AvmAssertMsg(false, "sysctlbyname_with_pid(0): sysctl failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ namespace avmplus
|
|||
class GenericGuard
|
||||
{
|
||||
public:
|
||||
void disable() { registerHandler(); }
|
||||
void enable() { unregisterHandler(); }
|
||||
void enable() { registerHandler(); }
|
||||
void disable() { unregisterHandler(); }
|
||||
|
||||
#ifdef AVMPLUS_MACH_EXCEPTIONS
|
||||
static void staticInit();
|
||||
|
|
|
@ -193,11 +193,11 @@ namespace avmplus
|
|||
FakeCallStackNode::FakeCallStackNode(AvmCore *core, const char *name)
|
||||
{
|
||||
this->core = core;
|
||||
if(AvmCore::sampling && core && core->fakeMethodInfos && core->builtinPool)
|
||||
if(core && core->sampling && core->fakeMethodInfos && core->builtinPool)
|
||||
{
|
||||
this->core = core;
|
||||
// have to turn sampling off during allocations to avoid recursion
|
||||
AvmCore::sampling = false;
|
||||
core->sampling = false;
|
||||
Stringp s = core->internAllocAscii(name);
|
||||
Atom a = core->fakeMethodInfos->get(s->atom());
|
||||
AbstractFunction *af = (AbstractFunction*)AvmCore::atomToGCObject(a);
|
||||
|
@ -210,7 +210,7 @@ namespace avmplus
|
|||
af->pool = core->builtinPool;
|
||||
}
|
||||
initialize(NULL, af, NULL, NULL, 0, NULL, NULL);
|
||||
AvmCore::sampling = true;
|
||||
core->sampling = true;
|
||||
core->sampleCheck();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -38,6 +38,9 @@ namespace avmplus
|
|||
|
||||
int String::Length(const wchar *str)
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
int len = 0;
|
||||
while (*str) {
|
||||
len++;
|
||||
|
@ -48,6 +51,9 @@ namespace avmplus
|
|||
|
||||
int String::Length(const char *str)
|
||||
{
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
int len = 0;
|
||||
while (*str) {
|
||||
len++;
|
||||
|
|
Загрузка…
Ссылка в новой задаче