aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2019-11-18 19:07:03 +0000
committerUbitUmarov2019-11-18 19:07:03 +0000
commit730a35eedc9057948f2c1e1d32012ccb509ab3c5 (patch)
tree28bcb05cfdb30b6d39f085984aa0bb8837834e54 /OpenSim/Region
parentmantis 8551: Simplify Yengine heap usage control (diff)
downloadopensim-SC-730a35eedc9057948f2c1e1d32012ccb509ab3c5.zip
opensim-SC-730a35eedc9057948f2c1e1d32012ccb509ab3c5.tar.gz
opensim-SC-730a35eedc9057948f2c1e1d32012ccb509ab3c5.tar.bz2
opensim-SC-730a35eedc9057948f2c1e1d32012ccb509ab3c5.tar.xz
Yengine: more on constants operations reduction
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs143
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs1
3 files changed, 60 insertions, 86 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
index e29a515..35711c1 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
66 { 66 {
67 public static readonly string OBJECT_CODE_MAGIC = "YObjectCode"; 67 public static readonly string OBJECT_CODE_MAGIC = "YObjectCode";
68 // reserve positive version values for original xmr 68 // reserve positive version values for original xmr
69 public static int COMPILED_VERSION_VALUE = -3; // decremented when compiler or object file changes 69 public static int COMPILED_VERSION_VALUE = -4; // decremented when compiler or object file changes
70 70
71 public static readonly int CALL_FRAME_MEMUSE = 64; 71 public static readonly int CALL_FRAME_MEMUSE = 64;
72 public static readonly int STRING_LEN_TO_MEMUSE = 2; 72 public static readonly int STRING_LEN_TO_MEMUSE = 2;
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
index 0a79f1a..f1e3424 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs
@@ -1339,13 +1339,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1339 { 1339 {
1340 public TokenKwAndAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) 1340 public TokenKwAndAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
1341 { 1341 {
1342 binOpConst = TokenRValConstOps.Null; 1342 binOpConst = TokenRValConstOps.binConstsLogicAndAnd;
1343 unOpConst = TokenRValConstOps.Null; 1343 unOpConst = TokenRValConstOps.Null;
1344 sdtClassOp = false; 1344 sdtClassOp = false;
1345 } 1345 }
1346 public TokenKwAndAndAnd(Token original) : base(original) 1346 public TokenKwAndAndAnd(Token original) : base(original)
1347 { 1347 {
1348 binOpConst = TokenRValConstOps.Null; 1348 binOpConst = TokenRValConstOps.binConstsLogicAndAnd;
1349 unOpConst = TokenRValConstOps.Null; 1349 unOpConst = TokenRValConstOps.Null;
1350 sdtClassOp = false; 1350 sdtClassOp = false;
1351 } 1351 }
@@ -1358,13 +1358,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1358 { 1358 {
1359 public TokenKwOrOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) 1359 public TokenKwOrOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
1360 { 1360 {
1361 binOpConst = TokenRValConstOps.Null; 1361 binOpConst = TokenRValConstOps.binConstsLoginOrOr;
1362 unOpConst = TokenRValConstOps.Null; 1362 unOpConst = TokenRValConstOps.Null;
1363 sdtClassOp = false; 1363 sdtClassOp = false;
1364 } 1364 }
1365 public TokenKwOrOrOr(Token original) : base(original) 1365 public TokenKwOrOrOr(Token original) : base(original)
1366 { 1366 {
1367 binOpConst = TokenRValConstOps.Null; 1367 binOpConst = TokenRValConstOps.binConstsLoginOrOr;
1368 unOpConst = TokenRValConstOps.Null; 1368 unOpConst = TokenRValConstOps.Null;
1369 sdtClassOp = false; 1369 sdtClassOp = false;
1370 } 1370 }
@@ -1457,8 +1457,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1457 } 1457 }
1458 public class TokenKwAndAnd: TokenKw 1458 public class TokenKwAndAnd: TokenKw
1459 { 1459 {
1460 public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1460 public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLogicAndAnd; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
1461 public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1461 public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLogicAndAnd; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
1462 public override string ToString() 1462 public override string ToString()
1463 { 1463 {
1464 return "&&"; 1464 return "&&";
@@ -1466,8 +1466,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1466 } 1466 }
1467 public class TokenKwOrOr: TokenKw 1467 public class TokenKwOrOr: TokenKw
1468 { 1468 {
1469 public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1469 public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLoginOrOr; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
1470 public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1470 public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLoginOrOr; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
1471 public override string ToString() 1471 public override string ToString()
1472 { 1472 {
1473 return "||"; 1473 return "||";
@@ -1574,8 +1574,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1574 } 1574 }
1575 public class TokenKwExclam: TokenKw 1575 public class TokenKwExclam: TokenKw
1576 { 1576 {
1577 public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1577 public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.unOpExclam; sdtClassOp = true; }
1578 public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } 1578 public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.unOpExclam; sdtClassOp = true; }
1579 public override string ToString() 1579 public override string ToString()
1580 { 1580 {
1581 return "!"; 1581 return "!";
@@ -2201,8 +2201,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
2201 double r; 2201 double r;
2202 try 2202 try
2203 { 2203 {
2204 if ((left is int) && (right is int)) 2204 if ((left is int li) && (right is int ri))
2205 { 2205 {
2206 if(li == -2147483648 && ri == -1)
2207 return -2147483648;
2206 return (int)left / (int)right; 2208 return (int)left / (int)right;
2207 } 2209 }
2208 if ((left is double) && (right is int)) 2210 if ((left is double) && (right is int))
@@ -2238,9 +2240,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
2238 double r; 2240 double r;
2239 try 2241 try
2240 { 2242 {
2241 if ((left is int) && (right is int)) 2243 if ((left is int li) && (right is int ri))
2242 { 2244 {
2243 return (int)left % (int)right; 2245 if (li == -2147483648 && ri == -1)
2246 return 0;
2247 return li % ri;
2244 } 2248 }
2245 if ((left is double) && (right is int)) 2249 if ((left is double) && (right is int))
2246 { 2250 {
@@ -2297,98 +2301,30 @@ namespace OpenSim.Region.ScriptEngine.Yengine
2297 { 2301 {
2298 return (int)left & (int)right; 2302 return (int)left & (int)right;
2299 } 2303 }
2300 if((left is int) && (right is double))
2301 {
2302 return (int)left & (int)(double)right;
2303 }
2304 if((left is double) && (right is int))
2305 {
2306 return (int)(double)left & (int)right;
2307 }
2308 if((left is double) && (right is double))
2309 {
2310 return (int)(double)left & (int)(double)right;
2311 }
2312 return null; 2304 return null;
2313 } 2305 }
2314 public static object LSh(object left, object right) 2306 public static object LSh(object left, object right)
2315 { 2307 {
2316 if((left is int) && (right is int)) 2308 if((left is int) && (right is int))
2317 {
2318 return (int)left << (int)right; 2309 return (int)left << (int)right;
2319 }
2320 if((left is int) && (right is double))
2321 {
2322 return (int)left << (int)(double)right;
2323 }
2324 if((left is double) && (right is int))
2325 {
2326 return (int)(double)left << (int)right;
2327 }
2328 if((left is double) && (right is double))
2329 {
2330 return (int)(double)left << (int)(double)right;
2331 }
2332 return null; 2310 return null;
2333 } 2311 }
2334 public static object Or(object left, object right) 2312 public static object Or(object left, object right)
2335 { 2313 {
2336 if((left is int) && (right is int)) 2314 if((left is int) && (right is int))
2337 {
2338 return (int)left | (int)right; 2315 return (int)left | (int)right;
2339 }
2340 if((left is int) && (right is double))
2341 {
2342 return (int)left | (int)(double)right;
2343 }
2344 if((left is double) && (right is int))
2345 {
2346 return (int)(double)left | (int)right;
2347 }
2348 if((left is double) && (right is double))
2349 {
2350 return (int)(double)left | (int)(double)right;
2351 }
2352 return null; 2316 return null;
2353 } 2317 }
2354 public static object RSh(object left, object right) 2318 public static object RSh(object left, object right)
2355 { 2319 {
2356 if((left is int) && (right is int)) 2320 if((left is int) && (right is int))
2357 {
2358 return (int)left >> (int)right; 2321 return (int)left >> (int)right;
2359 }
2360 if((left is int) && (right is double))
2361 {
2362 return (int)left >> (int)(double)right;
2363 }
2364 if((left is double) && (right is int))
2365 {
2366 return (int)(double)left >> (int)right;
2367 }
2368 if((left is double) && (right is double))
2369 {
2370 return (int)(double)left >> (int)(double)right;
2371 }
2372 return null; 2322 return null;
2373 } 2323 }
2374 public static object Xor(object left, object right) 2324 public static object Xor(object left, object right)
2375 { 2325 {
2376 if((left is int) && (right is int)) 2326 if((left is int) && (right is int))
2377 {
2378 return (int)left ^ (int)right; 2327 return (int)left ^ (int)right;
2379 }
2380 if((left is int) && (right is double))
2381 {
2382 return (int)left ^ (int)(double)right;
2383 }
2384 if((left is double) && (right is int))
2385 {
2386 return (int)(double)left ^ (int)right;
2387 }
2388 if((left is double) && (right is double))
2389 {
2390 return (int)(double)left ^ (int)(double)right;
2391 }
2392 return null; 2328 return null;
2393 } 2329 }
2394 public static object Add(object left, object right) 2330 public static object Add(object left, object right)
@@ -2570,12 +2506,49 @@ namespace OpenSim.Region.ScriptEngine.Yengine
2570 return null; 2506 return null;
2571 return (res != 0) ? 1 : 0; 2507 return (res != 0) ? 1 : 0;
2572 } 2508 }
2509
2510 public static object binConstsLogicAndAnd(object left, object right)
2511 {
2512 if ((left is int li) && (right is int ri))
2513 {
2514 if (li == 0)
2515 return 0;
2516 if (ri == 0)
2517 return 0;
2518 return 1;
2519 }
2520 return null;
2521 }
2522
2523 public static object binConstsLoginOrOr(object left, object right)
2524 {
2525 if ((left is int li) && (right is int ri))
2526 {
2527 if (li != 0)
2528 return 1;
2529 if (ri != 0)
2530 return 1;
2531 return 0;
2532 }
2533 return null;
2534 }
2535
2536 public static object unOpExclam(object left)
2537 {
2538 if ((left is int li))
2539 {
2540 if (li == 0)
2541 return 1;
2542 return 0;
2543 }
2544 return null;
2545 }
2573 } 2546 }
2574 2547
2575 /* 2548/*
2576 * Various datatypes. 2549 * Various datatypes.
2577 */ 2550 */
2578 public abstract class TokenType: Token 2551public abstract class TokenType: Token
2579 { 2552 {
2580 2553
2581 public TokenType(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { } 2554 public TokenType(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
index 7e13ae4..3acaef8 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs
@@ -86,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
86 m_StackSize = stackSize; 86 m_StackSize = stackSize;
87 m_StackLeft = stackSize; 87 m_StackLeft = stackSize;
88 m_HeapSize = heapSize; 88 m_HeapSize = heapSize;
89 m_heapUsed = 0;
89 m_CompilerErrors = errors; 90 m_CompilerErrors = errors;
90 m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID); 91 m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID);
91 92