Giter VIP home page Giter VIP logo

Comments (3)

Y-Less avatar Y-Less commented on July 17, 2024

Handy function:

stock bool:IsJITASMJumpCapable() {
	#emit lctrl 6
	#emit MOVE.alt
	#emit lctrl 8
	#emit neq
	#emit retn
	return false; // make compiler happy
}

Of course, that will fail if by some remote chance the assembly address of the lctrl 6 instruction is identical to the amx address - but presumably code would then fall back on the generic implementation anyway, so not too much harm done in that unlikely scenario. Relies on the fact that lctrl 8 would be a NO-OP without the JIT (or an older version of the JIT).

from samp-plugin-jit.

Y-Less avatar Y-Less commented on July 17, 2024

This will also help solve #26 since I beleve the problem there is this: When calling a function using SCTRL 6 to jump straight to it, I manually push the return address on to the stack (as CALL would do). However, the return address pushed is one based on the return value of LCTRL 6, so is an AMX address not an x86 address. When the function ends it executes the JIT compiled RETN, which pops an x86 address off the stack and jumps to it. This is why when debugging it was at strange addresses - they are valid AMX addresses being returned to by compiled code.

With this modification, the dynamic call code in YSI and amx_assembly would become:

	#emit lctrl 6
	#emit add.c 0x24
	#emit lctrl 8
	#emit push.pri
	#emit load.s.pri address
	#emit sctrl 6

Again, because LCTRL 8 is a no-op wthout the JIT plugin, this will work in both cases. The add.c must come between then lctrls so that the address is modified in countable cell numbers before being translated to an x86 address.

from samp-plugin-jit.

Y-Less avatar Y-Less commented on July 17, 2024

Another handy function I've put in amx_assembly\amx_base.inc:

stock GetAmxJITBaseAddress() {
	// Only works when the jit is installed, otherwise returns 0.  The code is
	// so short, checking if it had been done before would have been longer than
	// just repeating the calculation.
	#emit zero.pri
	#emit lctrl 8
	#emit retn
	return 0;
}

from samp-plugin-jit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.