a few changes on yengine heap control

This commit is contained in:
UbitUmarov
2022-03-09 21:04:47 +00:00
parent aa164b1bcb
commit 0e5abf6bc1
5 changed files with 37 additions and 25 deletions

View File

@@ -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;
}

View File

@@ -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.

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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