@@ -88,7 +88,10 @@ function postInstantiate(extendedExports, instance) {
88
88
const __pin = exports . __pin || F_NOEXPORTRUNTIME ;
89
89
const __unpin = exports . __unpin || F_NOEXPORTRUNTIME ;
90
90
const __collect = exports . __collect || F_NOEXPORTRUNTIME ;
91
- const __rtti_base = exports . __rtti_base || ~ 0 ; // oob if not present
91
+ const __rtti_base = exports . __rtti_base ;
92
+ const getRttiCount = __rtti_base
93
+ ? function ( arr ) { return arr [ __rtti_base >>> 2 ] ; }
94
+ : F_NOEXPORTRUNTIME ;
92
95
93
96
extendedExports . __new = __new ;
94
97
extendedExports . __pin = __pin ;
@@ -98,7 +101,7 @@ function postInstantiate(extendedExports, instance) {
98
101
/** Gets the runtime type info for the given id. */
99
102
function getInfo ( id ) {
100
103
const U32 = new Uint32Array ( memory . buffer ) ;
101
- const count = U32 [ __rtti_base >>> 2 ] ;
104
+ const count = getRttiCount ( U32 ) ;
102
105
if ( ( id >>>= 0 ) >= count ) throw Error ( `invalid id: ${ id } ` ) ;
103
106
return U32 [ ( __rtti_base + 4 >>> 2 ) + id * 2 ] ;
104
107
}
@@ -113,7 +116,7 @@ function postInstantiate(extendedExports, instance) {
113
116
/** Gets the runtime base id for the given id. */
114
117
function getBase ( id ) {
115
118
const U32 = new Uint32Array ( memory . buffer ) ;
116
- const count = U32 [ __rtti_base >>> 2 ] ;
119
+ const count = getRttiCount ( U32 ) ;
117
120
if ( ( id >>>= 0 ) >= count ) throw Error ( `invalid id: ${ id } ` ) ;
118
121
return U32 [ ( __rtti_base + 4 >>> 2 ) + id * 2 + 1 ] ;
119
122
}
@@ -284,7 +287,7 @@ function postInstantiate(extendedExports, instance) {
284
287
function __instanceof ( ptr , baseId ) {
285
288
const U32 = new Uint32Array ( memory . buffer ) ;
286
289
let id = U32 [ ptr + ID_OFFSET >>> 2 ] ;
287
- if ( id <= U32 [ __rtti_base >>> 2 ] ) {
290
+ if ( id <= getRttiCount ( U32 ) ) {
288
291
do {
289
292
if ( id == baseId ) return true ;
290
293
id = getBase ( id ) ;
0 commit comments