@@ -278,71 +278,95 @@ public static long hash(double receiver) {
278
278
return DefaultPythonDoubleExports .hash (receiver );
279
279
}
280
280
281
- private static class DefaultNodes extends Node {
282
- private static final byte REVERSE_COMP = 0b001;
283
- private static final byte LEFT_COMPARE = 0b010;
284
- private static final byte SUBT_COMPARE = 0b100;
285
-
286
- @ Child private IsSubtypeNode isSubtype ;
287
- @ Child private IsSameTypeNode isSameType ;
288
- @ Child private GetClassNode getClassNode ;
289
- @ Child private PRaiseNode raiseNode ;
290
- @ CompilationFinal byte state = 0 ;
291
-
292
- protected IsSubtypeNode getIsSubtypeNode () {
293
- if (isSubtype == null ) {
294
- CompilerDirectives .transferToInterpreterAndInvalidate ();
295
- reportPolymorphicSpecialize ();
296
- isSubtype = insert (IsSubtypeNode .create ());
281
+ private abstract static class DefaultNodes extends Node {
282
+
283
+ protected abstract IsSubtypeNode getIsSubtypeNode ();
284
+
285
+ protected abstract IsSameTypeNode getIsSameTypeNode ();
286
+
287
+ protected abstract GetClassNode getGetClassNode ();
288
+
289
+ protected abstract PRaiseNode getRaiseNode ();
290
+
291
+ protected abstract void enterReverseCompare ();
292
+
293
+ protected abstract void enterLeftCompare ();
294
+
295
+ protected abstract void enterSubtypeCompare ();
296
+
297
+ private static final class CachedDefaultNodes extends DefaultNodes {
298
+ private static final byte REVERSE_COMP = 0b001;
299
+ private static final byte LEFT_COMPARE = 0b010;
300
+ private static final byte SUBT_COMPARE = 0b100;
301
+
302
+ @ Child private IsSubtypeNode isSubtype ;
303
+ @ Child private IsSameTypeNode isSameType ;
304
+ @ Child private GetClassNode getClassNode ;
305
+ @ Child private PRaiseNode raiseNode ;
306
+ @ CompilationFinal byte state = 0 ;
307
+
308
+ @ Override
309
+ protected IsSubtypeNode getIsSubtypeNode () {
310
+ if (isSubtype == null ) {
311
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
312
+ reportPolymorphicSpecialize ();
313
+ isSubtype = insert (IsSubtypeNode .create ());
314
+ }
315
+ return isSubtype ;
297
316
}
298
- return isSubtype ;
299
- }
300
317
301
- protected IsSameTypeNode getIsSameTypeNode () {
302
- if (isSameType == null ) {
303
- CompilerDirectives .transferToInterpreterAndInvalidate ();
304
- isSameType = insert (IsSameTypeNodeGen .create ());
318
+ @ Override
319
+ protected IsSameTypeNode getIsSameTypeNode () {
320
+ if (isSameType == null ) {
321
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
322
+ isSameType = insert (IsSameTypeNodeGen .create ());
323
+ }
324
+ return isSameType ;
305
325
}
306
- return isSameType ;
307
- }
308
326
309
- private GetClassNode getGetClassNode () {
310
- if (getClassNode == null ) {
311
- CompilerDirectives .transferToInterpreterAndInvalidate ();
312
- getClassNode = insert (GetClassNode .create ());
327
+ @ Override
328
+ protected GetClassNode getGetClassNode () {
329
+ if (getClassNode == null ) {
330
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
331
+ getClassNode = insert (GetClassNode .create ());
332
+ }
333
+ return getClassNode ;
313
334
}
314
- return getClassNode ;
315
- }
316
335
317
- protected PRaiseNode getRaiseNode () {
318
- if (raiseNode == null ) {
319
- CompilerDirectives .transferToInterpreterAndInvalidate ();
320
- raiseNode = insert (PRaiseNode .create ());
336
+ @ Override
337
+ protected PRaiseNode getRaiseNode () {
338
+ if (raiseNode == null ) {
339
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
340
+ raiseNode = insert (PRaiseNode .create ());
341
+ }
342
+ return raiseNode ;
321
343
}
322
- return raiseNode ;
323
- }
324
344
325
- protected void enterReverseCompare () {
326
- if ((state & REVERSE_COMP ) == 0 ) {
327
- CompilerDirectives .transferToInterpreterAndInvalidate ();
328
- reportPolymorphicSpecialize ();
329
- state |= REVERSE_COMP ;
345
+ @ Override
346
+ protected void enterReverseCompare () {
347
+ if ((state & REVERSE_COMP ) == 0 ) {
348
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
349
+ reportPolymorphicSpecialize ();
350
+ state |= REVERSE_COMP ;
351
+ }
330
352
}
331
- }
332
353
333
- protected void enterLeftCompare () {
334
- if ((state & LEFT_COMPARE ) == 0 ) {
335
- CompilerDirectives .transferToInterpreterAndInvalidate ();
336
- reportPolymorphicSpecialize ();
337
- state |= LEFT_COMPARE ;
354
+ @ Override
355
+ protected void enterLeftCompare () {
356
+ if ((state & LEFT_COMPARE ) == 0 ) {
357
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
358
+ reportPolymorphicSpecialize ();
359
+ state |= LEFT_COMPARE ;
360
+ }
338
361
}
339
- }
340
362
341
- protected void enterSubtypeCompare () {
342
- if ((state & SUBT_COMPARE ) == 0 ) {
343
- CompilerDirectives .transferToInterpreterAndInvalidate ();
344
- reportPolymorphicSpecialize ();
345
- state |= SUBT_COMPARE ;
363
+ @ Override
364
+ protected void enterSubtypeCompare () {
365
+ if ((state & SUBT_COMPARE ) == 0 ) {
366
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
367
+ reportPolymorphicSpecialize ();
368
+ state |= SUBT_COMPARE ;
369
+ }
346
370
}
347
371
}
348
372
@@ -359,6 +383,11 @@ protected IsSameTypeNode getIsSameTypeNode() {
359
383
return IsSameTypeNodeGen .getUncached ();
360
384
}
361
385
386
+ @ Override
387
+ protected GetClassNode getGetClassNode () {
388
+ return GetClassNode .getUncached ();
389
+ }
390
+
362
391
@ Override
363
392
protected PRaiseNode getRaiseNode () {
364
393
return PRaiseNode .getUncached ();
@@ -378,7 +407,7 @@ protected void enterSubtypeCompare() {
378
407
}
379
408
380
409
private static DefaultNodes create () {
381
- return new DefaultNodes ();
410
+ return new CachedDefaultNodes ();
382
411
}
383
412
384
413
private static DefaultNodes getUncached () {
0 commit comments