mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
a few changes on yengine heap control
This commit is contained in:
@@ -3426,19 +3426,35 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
}
|
||||
}
|
||||
|
||||
// If doing local vars, each var goes in its own var frame,
|
||||
// to make sure no code before this point can reference it.
|
||||
if(currentStmtBlock != null)
|
||||
// If doing local vars, each var goes in its own var frame,
|
||||
// to make sure no code before this point can reference it.
|
||||
if (currentStmtBlock != null)
|
||||
{
|
||||
tokenScript.PushVarFrame(true);
|
||||
}
|
||||
|
||||
// Can't be same name already in block.
|
||||
if(!tokenScript.AddVarEntry(tokenDeclVar))
|
||||
/*
|
||||
ScriptConst scriptConst = ScriptConst.Lookup(tokenDeclVar.name.val);
|
||||
if (scriptConst != null)
|
||||
{
|
||||
ErrorMsg(tokenDeclVar, "reserved constant name " + tokenDeclVar.name.val);
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
// Can't be same name already in block.
|
||||
if (!tokenScript.AddVarEntry(tokenDeclVar))
|
||||
{
|
||||
ErrorMsg(tokenDeclVar, "duplicate variable " + tokenDeclVar.name.val);
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
if (TokenDeclInline.inlineFunctions.HasAnyExact(tokenDeclVar.name.val))
|
||||
{
|
||||
ErrorMsg(tokenDeclVar, "reserved name " + tokenDeclVar.name.val);
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
return tokenDeclVar;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,14 +232,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
return (found.Count > 0) ? found.ToArray() : null;
|
||||
}
|
||||
|
||||
public bool HasAnyExact(string name)
|
||||
{
|
||||
return master.TryGetValue(name, out Dictionary<ArgTypes, TDVEntry> typedic);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find exact matching function/variable
|
||||
* @param name = name of function to look for
|
||||
* @param argTypes = argument types the function was declared with
|
||||
* null to look for a variable
|
||||
* @returns null: no matching function/variable found
|
||||
* else: the matching function/variable
|
||||
*/
|
||||
* @brief Find exact matching function/variable
|
||||
* @param name = name of function to look for
|
||||
* @param argTypes = argument types the function was declared with
|
||||
* null to look for a variable
|
||||
* @returns null: no matching function/variable found
|
||||
* else: the matching function/variable
|
||||
*/
|
||||
|
||||
public TokenDeclVar FindExact(string name, TokenType[] argTypes)
|
||||
{
|
||||
// Look for list of stuff that matches the given name.
|
||||
|
||||
@@ -507,21 +507,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
|
||||
protected int heapLimit;
|
||||
public int m_localsHeapUsed;
|
||||
public int m_arraysHeapUsed;
|
||||
|
||||
public virtual int UpdateLocalsHeapUse(int olduse, int newuse)
|
||||
{
|
||||
int newtotal = Interlocked.Add(ref m_localsHeapUsed, newuse - olduse);
|
||||
if (newtotal + glblVars.arraysHeapUse > heapLimit)
|
||||
throw new OutOfHeapException(m_arraysHeapUsed + newtotal + olduse - newuse, newtotal, heapLimit);
|
||||
throw new OutOfHeapException(glblVars.arraysHeapUse + newtotal + olduse - newuse, newtotal + glblVars.arraysHeapUse, heapLimit);
|
||||
return newuse;
|
||||
}
|
||||
// not in use
|
||||
public virtual int UpdateArraysHeapUse(int olduse, int newuse)
|
||||
{
|
||||
//int newtotal = Interlocked.Add(ref m_arraysheapUsed, newuse - olduse);
|
||||
if(newuse + glblVars.arraysHeapUse > heapLimit)
|
||||
throw new OutOfHeapException(m_arraysHeapUsed + newuse + olduse - newuse, newuse, heapLimit);
|
||||
throw new OutOfHeapException(glblVars.arraysHeapUse, glblVars.arraysHeapUse + newuse, heapLimit);
|
||||
return newuse;
|
||||
}
|
||||
|
||||
@@ -530,11 +528,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
Interlocked.Add(ref m_localsHeapUsed, delta);
|
||||
}
|
||||
|
||||
public virtual void AddArraysHeapUse(int delta)
|
||||
{
|
||||
Interlocked.Add(ref m_arraysHeapUsed, delta);
|
||||
}
|
||||
|
||||
public int xmrHeapLeft()
|
||||
{
|
||||
return heapLimit - m_localsHeapUsed - glblVars.arraysHeapUse;
|
||||
|
||||
@@ -87,7 +87,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
m_StackLeft = stackSize;
|
||||
m_HeapSize = heapSize;
|
||||
m_localsHeapUsed = 0;
|
||||
m_arraysHeapUsed = 0;
|
||||
m_CompilerErrors = errors;
|
||||
m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID);
|
||||
|
||||
@@ -901,7 +900,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
glblVars.iarSDTClObjs = XMRInstArrays.noSDTClObjs;
|
||||
glblVars.iarSDTIntfObjs = XMRInstArrays.noSDTIntfObjs;
|
||||
|
||||
AddArraysHeapUse(heapsz);
|
||||
CheckRunLockInvariants(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -877,7 +877,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
m_ResetCount++; // has been reset once more
|
||||
|
||||
m_localsHeapUsed = 0;
|
||||
m_arraysHeapUsed = 0;
|
||||
glblVars.Clear();
|
||||
|
||||
// Tell next call to 'default state_entry()' to reset all global
|
||||
|
||||
Reference in New Issue
Block a user