@@ -29,8 +29,6 @@ export type Compiled = (t: JThread, f: Frame) => number;
2929const THRESHOLD = 500 ;
3030const BACKEDGE_THRESHOLD = 2000 ;
3131const MAX_CODE = 6000 ;
32- // compiled frames nested on one JS stack before calls go through the run loop
33- const MAX_DIRECT = 120 ;
3432const MAX_FALLBACKS = 5000 ;
3533// callees inlined as regions: bytecode outside throw-only blocks (HotSpot's
3634// MaxInlineSize), nesting, and bytecode inlined into one compiled method
@@ -191,20 +189,6 @@ const runtime = {
191189 f . sp = sp ;
192190 return f ;
193191 } ,
194- // the pushed frame of a direct call to compiled m, or null when the call
195- // goes through the run loop: the stack is too deep or the monitor is taken
196- enter ( t : JThread , m : JMethod , recv : JObject | null ) : Frame | null {
197- if ( t . frames . length - t . base >= MAX_DIRECT || t . frames . length >= t . stackLimit ) return null ;
198- let lock : JObject | null = null ;
199- if ( m . isSynchronized ) {
200- lock = m . isStatic ? t . vm . mirror ( m . cls ) : recv ! ;
201- if ( ! t . vm . tryMonitorEnter ( t , lock ) ) return null ;
202- }
203- const f = t . directFrame ( m ) ;
204- f . lock = lock ;
205- t . frames . push ( f ) ;
206- return f ;
207- } ,
208192 // A call that is not direct: a native's result, PUSHED once a native that
209193 // must wait is on the stack, or INTERPRET for the run loop to make the call.
210194 slowCall ( t : JThread , m : JMethod , args : any [ ] ) : any {
@@ -295,7 +279,6 @@ const runtime = {
295279 } ,
296280 // raises exc from the run loop, once every compiled caller has spilled
297281 * rethrow ( exc : JObject ) : Generator < never , void , unknown > { throw new JavaThrow ( exc ) ; } ,
298- MAX_DIRECT ,
299282} ;
300283
301284// ---- analysis ----------------------------------------------------------------
@@ -1187,7 +1170,7 @@ function genInvoke(
11871170 const res = ( v : string ) => ( ret === "V" ? "" : `s${ base } =${ v } ;` ) ;
11881171 // compiled callee: direct call
11891172 const recv = target . isStatic ? "null" : args [ 0 ] ;
1190- parts . push ( `if(tm.jit!==null&&(cf=rt .enter(t, tm,${ recv } ))!==null){` ) ;
1173+ parts . push ( `if(tm.jit!==null&&(cf=t .enter(tm,${ recv } ))!==null){` ) ;
11911174 parts . push ( `r=tm.jit(t,cf${ args . map ( ( x ) => "," + x ) . join ( "" ) } );if(r!==0){t.unpool(cf);${ exit ( pc , base , EXIT_SUSPEND ) } }` ) ;
11921175 parts . push ( `${ res ( "t.ret" ) } }` ) ;
11931176 // a native callee runs here; anything else goes through the interpreter
@@ -1233,14 +1216,14 @@ function genPolymorphic(g: Gen, pc: number, next: number, d: number, target: JMe
12331216 const cell = K ( [ null , null ] ) ;
12341217 const push = target . ret === "V" ? "" : `s${ base } =t.ret;` ;
12351218 return `if(${ args [ 0 ] } !==null&&${ args [ 0 ] } ===${ cell } [0]){f.pc=${ pc } ;tm=${ cell } [1];` +
1236- `if(tm.jit!==null&&tm.cls.state===${ INITIALIZED } &&(cf=rt .enter(t, tm,null))!==null){` +
1219+ `if(tm.jit!==null&&tm.cls.state===${ INITIALIZED } &&(cf=t .enter(tm,null))!==null){` +
12371220 `r=tm.jit(t,cf${ args . map ( ( x ) => "," + x ) . join ( "" ) } );if(r!==0){t.unpool(cf);${ exit ( pc , base , EXIT_SUSPEND ) } }${ push } }` +
12381221 `else{${ call ( pc , d ) } }}else{rt.vhTarget(t,${ cell } ,${ args [ 0 ] } ,${ K ( link . appendix ) } );${ code } }` ;
12391222 }
12401223 }
12411224 const push = target . ret === "V" ? "" : `s${ base } =t.ret;` ;
12421225 return `f.pc=${ pc } ;${ select } ` +
1243- `if(tm.jit!==null&&tm.cls.state===${ INITIALIZED } &&(cf=rt .enter(t, tm,${ callArgs [ 0 ] ?? "null" } ))!==null){` +
1226+ `if(tm.jit!==null&&tm.cls.state===${ INITIALIZED } &&(cf=t .enter(tm,${ callArgs [ 0 ] ?? "null" } ))!==null){` +
12441227 `r=tm.jit(t,cf${ callArgs . map ( ( x ) => "," + x ) . join ( "" ) } );if(r!==0){t.unpool(cf);${ exit ( pc , base , EXIT_SUSPEND ) } }` +
12451228 `${ push } }else{${ call ( pc , d ) } }` ;
12461229}
0 commit comments