wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-06-2009, 02:50 AM   #1
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default The Op Limit

So, in regards to the Op limit (which is.. 8191?), is that how many individual actions can be done per thread, or what? If so, what defines the opening of a thread?

For example, say (for whatever absurd reason) I had a function that, say, did 4 functions (let's say, SetUnitX/Y for 2 units), and then called a 5th function that had a loop which looped about 8189 times and called one function (like a TSA) every iteration, and then did some more stuff following the conclusion of that function. Would this hit the op limit? Or would the calling of the function (or the opening of the loop) start a new thread and reset the counter for the op limit?

Sorry if this is "common knowledge". I know next-to-nothing about the workings of programming anything (such as threads).
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt


Last edited by darkwulfv : 04-06-2009 at 02:51 AM.
darkwulfv is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-06-2009, 04:47 AM   #2
Here-b-Trollz
Corkscrew Chainsaw!!!
 
Join Date: Jun 2006
Posts: 711

Here-b-Trollz has a spectacular aura about (149)

Hero Contest #2 - 2nd Place

Default

TSA is actually a common method to AVOID hitting the op-limit, as it puts the thread on sleep, so you reset the op-count upon picking it back up.

As to what the actual 'op-limit' is, I'm not sure that that's every actually been tested out or verified. It doesn't really matter because most (<-- this word could actually be replaced with all, unless you're doing something stupid like leaving a loop running without an exitwhen, in which case you will crash no matter what, as opposed to exitwhen i==9999999999, which would likely hit the limit somewhere along the way, though technically it's possible to reach the end) functions will cause noticeable lag on-screen before they hit the op-limit and crash.
__________________
By reading this signature, you agree that I cannot be held accountable for anything that I might say or do.
Here-b-Trollz is offline   Reply With Quote
Old 04-06-2009, 06:46 AM   #3
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

When you load a map, warcraft reads the jass file from disk and compiles it to a bytecode format. Bytecode ops are things like allocate a variable, multiply two registers, or call a native. A typical line of jass is 1-6 ops. Each instance of the virtual machine (new one on event, TriggerExecute, TriggerEvaluate, ExecuteFunc, TriggerSleepAction) has a limit at 300000 ops of continuous execution, at which point the VM returns.

1.21 and earlier versions of war3err can trace bytecode
1.22 and later versions of war3err can dump a function's bytecode with
Collapse JASS:
    call Cheat("GetBytecode funcname")

Sample chunk of executing bytecode:
Code:
bench :: 0 4:integer 217 0xe:read 3796:sw
bench :: 0 0 217 0x13:push 0
bench :: 0 0 0 0x15:callnative 2070:StopWatchMark
bench :: 0 0 0 0x11:set 3798:t1
bench :: 0 4:integer 218 0xc:literal 1000
bench :: 0 0 218 0x17:typecast 0
bench :: 0 0 218 0x13:push 0
bench :: 0 5:real 219 0xe:read 3798:t1
bench :: 0 0 219 0x13:push 0
bench :: 0 5:real 220 0xe:read 3797:t0
bench :: 0 0 221 0x14:setreg 0
bench :: 220 221 221 0x21:subtract 0
bench :: 0 0 222 0x14:setreg 0
bench :: 221 222 222 0x22:multiply 0
bench :: 0 0 222 0x13:push 0
bench :: 0 0 0 0x15:callnative 596:R2S
bench :: 0 0 0 0x13:push 0
bench :: 0 0 0 0x16:call 2547:BJDebugMsg
BJDebugMsg :: 0 1 6:string 0x8:pop 2077:msg
BJDebugMsg :: 0 0 4:integer 0x5:local 92:i
BJDebugMsg :: 0 4:integer 186 0xc:literal 0
BJDebugMsg :: 0 0 186 0x11:set 92:i
BJDebugMsg :: 0 0 0 0x28:jump target 1
BJDebugMsg :: 0 4:integer 187 0xe:read 92:i

The (full?) list of ops:
Code:
enum OPCODES { OP_ENDPROGRAM=0x1,
	OP_FUNCTION=0x3, // _ _ rettype funcname
	OP_ENDFUNCTION=0x4,
	OP_LOCAL=0x5, // _ _ type name
	OP_GLOBAL=0x6,OP_CONSTANT=0x7,
	OP_POPFUNCARG=0x8, // _ srcargi type destvar
	OP_CLEANSTACK=0xB, // _ _ nargs _
	OP_LITERAL=0xC, // _ type destreg srcvalue
	OP_SETRET=0xD, // _ srcreg _ _
	OP_GETVAR=0xE, // _ type destreg srcvar
	OP_CODE=0xF,
	OP_GETARRAY=0x10,
	OP_SETVAR=0x11,	// _ _ srcreg destvar
	OP_SETARRAY=0x12,
	OP_PUSH=0x13, // _ _ srcreg _
	OP_SETRIGHT=0x14,
	OP_NATIVE=0x15, // _ _ _ fn
	OP_JASSCALL=0x16, // _ _ _ fn
	OP_I2R=0x17,
	OP_AND = 0x18,
	OP_OR = 0x19,
	OP_EQUAL=0x1A,
	OP_NOTEQUAL=0x1B,		// check
	OP_LESSEREQUAL=0x1C,OP_GREATEREQUAL=0x1D,
	OP_LESSER=0x1E,OP_GREATER=0x1F,
	OP_ADD=0x20,OP_SUB,OP_MUL,OP_DIV,
	OP_MODULO = 0x24,              // unused
	OP_NEGATE=0x25,
	OP_NOT = 0x26,
	OP_RETURN=0x27,	// _ _ _ _
	OP_JUMPTARGET=0x28,
	OP_JUMPIFTRUE=0x29,OP_JUMPIFFALSE=0x2A,
	OP_JUMP=0x2B
}

The binary bytecode format:
Code:
typedef struct opcode {
    unsigned char r1,r2,r3;  // register arguments and types
    unsigned char optype;  // one of OPCODES
    int arg;  // values, targets, names
} opcode;
__________________
PipeDream is offline   Reply With Quote
Old 04-06-2009, 12:06 PM   #4
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

Okay, so a TSA will actually reset the Op limit for a thread and I wouldn't have to worry about that? Neat. Thanks.

And thanks PipeDream for the in-depth bytecode explanation that made no sense to me. =p
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt

darkwulfv is offline   Reply With Quote
Old 04-10-2009, 11:06 PM   #5
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

TSA means ?
Troll-Brain is offline   Reply With Quote
Old 04-11-2009, 12:26 AM   #6
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

TriggerSleepAction
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 04-11-2009, 12:41 AM   #7
Tom_Kazansky
User
 
Tom_Kazansky's Avatar
 
Join Date: Apr 2009
Posts: 74

Tom_Kazansky is on a distinguished road (13)

Send a message via Yahoo to Tom_Kazansky
Default

Hi, I'm just wondering: my map at its initialization (starts from 0s elapsed time) often hits the Op Limit, so I use PolledWait2 (Vex's PolledWait) then it is ok.
But is TSA better than PolledWait in this case ? ( a native and a function ) (the "wait" is about 0.1)
Tom_Kazansky is offline   Reply With Quote
Old 04-11-2009, 01:07 AM   #8
Blackroot
User
 
Join Date: Apr 2006
Posts: 260

Blackroot will become famous soon enough (40)Blackroot will become famous soon enough (40)

Spell Making Session 14 Winner

Default

What pipe dream basically said is that one function can crash the op limit if it's obsurd (and will cause an overflow error or crash when compiling) but more to the point; each call to a single operator adds one to the op limit. (The operators as the op-codes he listed - which should be apparant as to what the jass-equivalent operator is)

Moreover; you can't reach the thread limit without the use of a loop. It would require a massive chunk of code to reach without one; the only real use of the op-limit it to avoid infinite loops.
Blackroot is offline   Reply With Quote
Old 04-11-2009, 05:31 AM   #9
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Yes, TriggerSleepAction(0.0) is better than PolledWait/2 for that application.

All other uses of TriggerSleepAction/PolledWait are best off as timers.
__________________
PipeDream is offline   Reply With Quote
Old 04-11-2009, 08:22 AM
Litany
This message has been deleted by Litany.
Old 04-11-2009, 11:17 AM   #10
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Agreed here, waits will cause the code to run after map loading, while starting new threads with ExecuteFunc or .execute() gets everything done before the map starts, thus avoiding any map start lag.
__________________
Anitarf is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 10:11 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services