perf(napi): misc napi optimizations (#30291)
before
```
❯ deno run -A perf-turso.js
cpu: Apple M3 Max
runtime: deno 2.4.3+6ae4eda (aarch64-apple-darwin)
benchmark time (avg) (min … max) p75 p99 p999
--------------------------------------------------------------------------------------- -----------------------------
Statement.get() with bind parameters [expanded] 4'544 ns/iter (4'424 ns … 4'801 ns) 4'599 ns 4'801 ns 4'801 ns
Statement.get() with bind parameters [raw] 4'484 ns/iter (4'409 ns … 4'667 ns) 4'527 ns 4'667 ns 4'667 ns
Statement.run() with bind parameters 5'424 ns/iter (4'833 ns … 4'518 µs) 5'292 ns 8'042 ns 15'292 ns
```
after
```
❯ devdeno run -A perf-turso.js
cpu: Apple M3 Max
runtime: deno 2.4.3 (aarch64-apple-darwin)
benchmark time (avg) (min … max) p75 p99 p999
--------------------------------------------------------------------------------------- -----------------------------
Statement.get() with bind parameters [expanded] 1'141 ns/iter (1'057 ns … 3'223 ns) 1'126 ns 2'910 ns 3'223 ns
Statement.get() with bind parameters [raw] 1'015 ns/iter (975 ns … 1'112 ns) 1'017 ns 1'093 ns 1'112 ns
Statement.run() with bind parameters 1'560 ns/iter (1'295 ns … 8'840 ns) 1'433 ns 8'752 ns 8'840 ns
```
Optimizations are:
- don't log napi entry/exit in release builds (this ends up being very
expensive, as it checks whether logging is enabled twice per call into
NAPI)
- use internalized strings to speed up property accesses (matches node's
behavior as well)
- change order we check value types (matches node now)
- don't unnecessarily validate utf8
- don't get handle scopes when an isolate will do
- reuse handle scope within a function
- use the faster APIs that don't require handle scopes for getting
uint32 / int32 values
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>