diff options
author | UbitUmarov | 2019-11-22 04:09:05 +0000 |
---|---|---|
committer | UbitUmarov | 2019-11-22 04:09:05 +0000 |
commit | 9b7ad30ee12ee027be6cd93d4e17d67cf0b65966 (patch) | |
tree | b65bb712629d9810c382a0f34e718af9107a6cd8 /OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | |
parent | cosmetics (diff) | |
download | opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.zip opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.gz opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.bz2 opensim-SC-9b7ad30ee12ee027be6cd93d4e17d67cf0b65966.tar.xz |
more changes on YEngine scripts heap usage
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs index 32aea25..2fd9b9b 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
60 | public Delegate[][] iarSDTIntfObjs; | 60 | public Delegate[][] iarSDTIntfObjs; |
61 | 61 | ||
62 | private XMRInstAbstract instance; | 62 | private XMRInstAbstract instance; |
63 | private int arraysHeapUse; | 63 | public int arraysHeapUse; |
64 | 64 | ||
65 | private static readonly XMR_Array[] noArrays = new XMR_Array[0]; | 65 | private static readonly XMR_Array[] noArrays = new XMR_Array[0]; |
66 | private static readonly char[] noChars = new char[0]; | 66 | private static readonly char[] noChars = new char[0]; |
@@ -79,10 +79,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
79 | instance = inst; | 79 | instance = inst; |
80 | } | 80 | } |
81 | 81 | ||
82 | /* | ||
82 | ~XMRInstArrays() | 83 | ~XMRInstArrays() |
83 | { | 84 | { |
84 | arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, 0); | 85 | arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, 0); |
85 | } | 86 | } |
87 | */ | ||
86 | 88 | ||
87 | public void Clear() | 89 | public void Clear() |
88 | { | 90 | { |
@@ -109,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
109 | if (iarVectors != null) | 111 | if (iarVectors != null) |
110 | newheapUse += iarVectors.Length * HeapTrackerObject.HT_VEC; | 112 | newheapUse += iarVectors.Length * HeapTrackerObject.HT_VEC; |
111 | 113 | ||
112 | arraysHeapUse = instance.UpdateHeapUse(0, newheapUse); | 114 | arraysHeapUse = instance.UpdateArraysHeapUse(0, newheapUse); |
113 | } | 115 | } |
114 | 116 | ||
115 | public void AllocVarArrays(XMRInstArSizes ars) | 117 | public void AllocVarArrays(XMRInstArSizes ars) |
@@ -117,13 +119,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
117 | ClearOldArrays(); | 119 | ClearOldArrays(); |
118 | int newuse = arraysHeapUse + | 120 | int newuse = arraysHeapUse + |
119 | ars.iasChars* HeapTrackerObject.HT_CHAR + | 121 | ars.iasChars* HeapTrackerObject.HT_CHAR + |
120 | ars.iasFloats * HeapTrackerObject.HT_SFLT + | 122 | ars.iasFloats * HeapTrackerObject.HT_DOUB + |
121 | ars.iasIntegers * HeapTrackerObject.HT_INT + | 123 | ars.iasIntegers * HeapTrackerObject.HT_INT + |
122 | ars.iasRotations * HeapTrackerObject.HT_ROT + | 124 | ars.iasRotations * HeapTrackerObject.HT_ROT + |
123 | ars.iasVectors * HeapTrackerObject.HT_VEC + | 125 | ars.iasVectors * HeapTrackerObject.HT_VEC + |
124 | ars.iasSDTIntfObjs * HeapTrackerObject.HT_DELE; | 126 | ars.iasSDTIntfObjs * HeapTrackerObject.HT_DELE; |
125 | 127 | ||
126 | arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newuse); | 128 | arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newuse); |
127 | 129 | ||
128 | iarArrays = (ars.iasArrays > 0) ? new XMR_Array[ars.iasArrays] : noArrays; | 130 | iarArrays = (ars.iasArrays > 0) ? new XMR_Array[ars.iasArrays] : noArrays; |
129 | iarChars = (ars.iasChars > 0) ? new char[ars.iasChars] : noChars; | 131 | iarChars = (ars.iasChars > 0) ? new char[ars.iasChars] : noChars; |
@@ -144,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
144 | public void PopList(int index, LSL_List lis) | 146 | public void PopList(int index, LSL_List lis) |
145 | { | 147 | { |
146 | int delta = HeapTrackerObject.Size(lis) - HeapTrackerObject.Size(iarLists[index]); | 148 | int delta = HeapTrackerObject.Size(lis) - HeapTrackerObject.Size(iarLists[index]); |
147 | instance.UpdateHeapUse(0, delta); | 149 | instance.UpdateArraysHeapUse(0, delta); |
148 | Interlocked.Add(ref arraysHeapUse, delta); | 150 | Interlocked.Add(ref arraysHeapUse, delta); |
149 | iarLists[index] = lis; | 151 | iarLists[index] = lis; |
150 | } | 152 | } |
@@ -155,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
155 | public void PopObject(int index, object obj) | 157 | public void PopObject(int index, object obj) |
156 | { | 158 | { |
157 | int delta = HeapTrackerObject.Size(obj) - HeapTrackerObject.Size(iarObjects[index]); | 159 | int delta = HeapTrackerObject.Size(obj) - HeapTrackerObject.Size(iarObjects[index]); |
158 | instance.UpdateHeapUse(0, delta); | 160 | instance.UpdateArraysHeapUse(0, delta); |
159 | Interlocked.Add(ref arraysHeapUse, delta); | 161 | Interlocked.Add(ref arraysHeapUse, delta); |
160 | iarObjects[index] = obj; | 162 | iarObjects[index] = obj; |
161 | } | 163 | } |
@@ -166,7 +168,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
166 | public void PopString(int index, string str) | 168 | public void PopString(int index, string str) |
167 | { | 169 | { |
168 | int delta = HeapTrackerString.Size(str) - HeapTrackerString.Size(iarStrings[index]); | 170 | int delta = HeapTrackerString.Size(str) - HeapTrackerString.Size(iarStrings[index]); |
169 | instance.UpdateHeapUse(0, delta); | 171 | instance.UpdateArraysHeapUse(0, delta); |
170 | Interlocked.Add(ref arraysHeapUse, delta); | 172 | Interlocked.Add(ref arraysHeapUse, delta); |
171 | iarStrings[index] = str; | 173 | iarStrings[index] = str; |
172 | } | 174 | } |
@@ -233,7 +235,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
233 | // others (XMR_Array, XMRSDTypeClObj) keep track of their own heap usage | 235 | // others (XMR_Array, XMRSDTypeClObj) keep track of their own heap usage |
234 | 236 | ||
235 | // update script heap usage, throwing an exception before finalizing changes | 237 | // update script heap usage, throwing an exception before finalizing changes |
236 | arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newheapuse); | 238 | arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newheapuse); |
237 | 239 | ||
238 | iarChars = chrs; | 240 | iarChars = chrs; |
239 | iarFloats = flts; | 241 | iarFloats = flts; |
@@ -258,7 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
258 | } | 260 | } |
259 | if(iarFloats != null) | 261 | if(iarFloats != null) |
260 | { | 262 | { |
261 | newheapuse -= iarFloats.Length * HeapTrackerObject.HT_SFLT; | 263 | newheapuse -= iarFloats.Length * HeapTrackerObject.HT_DOUB; |
262 | iarFloats = null; | 264 | iarFloats = null; |
263 | } | 265 | } |
264 | if(iarIntegers != null) | 266 | if(iarIntegers != null) |
@@ -301,7 +303,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
301 | iarSDTIntfObjs = null; | 303 | iarSDTIntfObjs = null; |
302 | } | 304 | } |
303 | 305 | ||
304 | arraysHeapUse = instance.UpdateHeapUse(arraysHeapUse, newheapuse); | 306 | arraysHeapUse = instance.UpdateArraysHeapUse(arraysHeapUse, newheapuse); |
305 | } | 307 | } |
306 | } | 308 | } |
307 | 309 | ||
@@ -453,35 +455,43 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
453 | \**************************************************/ | 455 | \**************************************************/ |
454 | 456 | ||
455 | protected int heapLimit; | 457 | protected int heapLimit; |
456 | public int m_heapUsed; | 458 | public int m_localsHeapUsed; |
459 | public int m_arraysHeapUsed; | ||
457 | 460 | ||
458 | public virtual int UpdateHeapUse(int olduse, int newuse) | 461 | public virtual int UpdateLocalsHeapUse(int olduse, int newuse) |
462 | { | ||
463 | int newtotal = Interlocked.Add(ref m_localsHeapUsed, newuse - olduse); | ||
464 | if (newtotal + glblVars.arraysHeapUse > heapLimit) | ||
465 | throw new OutOfHeapException(m_arraysHeapUsed + newtotal + olduse - newuse, newtotal, heapLimit); | ||
466 | return newuse; | ||
467 | } | ||
468 | // not in use | ||
469 | public virtual int UpdateArraysHeapUse(int olduse, int newuse) | ||
459 | { | 470 | { |
460 | if (m_heapUsed < 0) | 471 | //int newtotal = Interlocked.Add(ref m_arraysheapUsed, newuse - olduse); |
461 | m_heapUsed = 0; | 472 | if(newuse + glblVars.arraysHeapUse > heapLimit) |
462 | int newtotal = Interlocked.Add(ref m_heapUsed, newuse - olduse); | 473 | throw new OutOfHeapException(m_arraysHeapUsed + newuse + olduse - newuse, newuse, heapLimit); |
463 | if(newtotal > heapLimit) | ||
464 | throw new OutOfHeapException(newtotal + olduse - newuse, newtotal, heapLimit); | ||
465 | return newuse; | 474 | return newuse; |
466 | } | 475 | } |
467 | 476 | ||
468 | public virtual void AddHeapUse(int delta) | 477 | public virtual void AddLocalsHeapUse(int delta) |
478 | { | ||
479 | Interlocked.Add(ref m_localsHeapUsed, delta); | ||
480 | } | ||
481 | |||
482 | public virtual void AddArraysHeapUse(int delta) | ||
469 | { | 483 | { |
470 | Interlocked.Add(ref m_heapUsed, delta); | 484 | Interlocked.Add(ref m_arraysHeapUsed, delta); |
471 | } | 485 | } |
472 | 486 | ||
473 | public int xmrHeapLeft() | 487 | public int xmrHeapLeft() |
474 | { | 488 | { |
475 | if (m_heapUsed < 0) | 489 | return heapLimit - m_localsHeapUsed - glblVars.arraysHeapUse; |
476 | m_heapUsed = 0; | ||
477 | return heapLimit - m_heapUsed; | ||
478 | } | 490 | } |
479 | 491 | ||
480 | public int xmrHeapUsed() | 492 | public int xmrHeapUsed() |
481 | { | 493 | { |
482 | if(m_heapUsed < 0) | 494 | return m_localsHeapUsed + glblVars.arraysHeapUse; |
483 | m_heapUsed = 0; | ||
484 | return m_heapUsed; | ||
485 | } | 495 | } |
486 | 496 | ||
487 | /** | 497 | /** |