summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorspv420 <unomilliono@gmail.com>2022-04-23 19:52:15 -0400
committerspv420 <unomilliono@gmail.com>2022-04-23 19:52:15 -0400
commit6deccac7338dda3534a104cec0792edad52c1c9c (patch)
treeb3df6f56435840d4537fa5bd18127130b6714f24 /src
parent041f9cf118b7084c2735be229d58ae77f19526e8 (diff)
implement symbol cache
Diffstat (limited to 'src')
-rw-r--r--src/js/primitives/call.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/js/primitives/call.js b/src/js/primitives/call.js
index b1b9f98..996f5a8 100644
--- a/src/js/primitives/call.js
+++ b/src/js/primitives/call.js
@@ -1,6 +1,7 @@
var gettimeofday_lazy_addy = 0x34d63d3c;
var atan2_lazy_addy = 0x346afc84;
var reserve_addr = 0x1a0000;
+var sym_cache = {};
var slide = 0x0;
var base = 0x0;
//var slid = 0x0;
@@ -85,8 +86,14 @@ function calls4arg(sym, r0, r1, r2, r3) {
* this calls dlsym with the first arg, then uses the address it returns
* to call. so you can call with a symbol name instead of an address
*/
- var dlsym_addy = read_u32(reserve_addr + 24 + slid);
- var shc_slide = read_u32(reserve_addr + 20 + slid);
- var addy = call4arg(dlsym_addy + shc_slide, 0xfffffffe, sptr(sym), 0, 0);
+
+ if (sym in sym_cache) {
+ var addy = sym_cache[sym];
+ } else {
+ var dlsym_addy = read_u32(reserve_addr + 24 + slid);
+ var shc_slide = read_u32(reserve_addr + 20 + slid);
+ var addy = call4arg(dlsym_addy + shc_slide, 0xfffffffe, sptr(sym), 0, 0);
+ sym_cache[sym] = addy;
+ }
return call4arg(addy, r0, r1, r2, r3);
}