60
60
import com .oracle .graal .python .builtins .objects .PNone ;
61
61
import com .oracle .graal .python .builtins .objects .cell .CellBuiltins ;
62
62
import com .oracle .graal .python .builtins .objects .cell .PCell ;
63
+ import com .oracle .graal .python .builtins .objects .foreign .ForeignObjectBuiltins .ForeignGetattrNode ;
63
64
import com .oracle .graal .python .builtins .objects .frame .PFrame ;
64
65
import com .oracle .graal .python .builtins .objects .function .PArguments ;
65
66
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
95
96
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
96
97
import com .oracle .graal .python .nodes .function .builtins .PythonVarargsBuiltinNode ;
97
98
import com .oracle .graal .python .nodes .object .GetClassNode ;
99
+ import com .oracle .graal .python .nodes .object .IsForeignObjectNode ;
98
100
import com .oracle .graal .python .runtime .exception .PException ;
99
101
import com .oracle .graal .python .runtime .exception .PythonErrorType ;
100
102
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
@@ -423,7 +425,7 @@ public abstract static class GetattributeNode extends GetAttrBuiltinNode {
423
425
@ Child private ReadAttributeFromObjectNode readFromDict = ReadAttributeFromObjectNode .createForceType ();
424
426
@ Child private CallSlotDescrGet callGetSlotNode ;
425
427
@ Child private GetTypeNode getType ;
426
- @ Child private GetObjectNode getObject ;
428
+ @ Child private GetObjectNode getObject = GetObjectNodeGen . create () ;
427
429
@ Child private ObjectBuiltins .GetAttributeNode objectGetattributeNode ;
428
430
@ Child private GetMroNode getMroNode ;
429
431
@ Child private IsSameTypeNode isSameTypeNode ;
@@ -444,7 +446,9 @@ Object get(VirtualFrame frame, SuperObject self, Object attr,
444
446
@ Cached GetObjectTypeNode getObjectType ,
445
447
@ Cached CastToTruffleStringCheckedNode castToTruffleStringNode ,
446
448
@ Cached InlinedConditionProfile hasDescrGetProfile ,
447
- @ Cached InlinedConditionProfile getObjectIsStartObjectProfile ) {
449
+ @ Cached InlinedConditionProfile getObjectIsStartObjectProfile ,
450
+ @ Cached IsForeignObjectNode isForeignObjectNode ,
451
+ @ Cached ForeignGetattrNode foreignGetattrNode ) {
448
452
Object startType = getObjectType .execute (inliningTarget , self );
449
453
if (startType == null ) {
450
454
return genericGetAttr (frame , self , attr );
@@ -465,12 +469,13 @@ Object get(VirtualFrame frame, SuperObject self, Object attr,
465
469
getType = insert (GetTypeNodeGen .create ());
466
470
}
467
471
472
+ Object type = getType .executeCached (self );
468
473
PythonAbstractClass [] mro = getMro (startType );
469
474
/* No need to check the last one: it's gonna be skipped anyway. */
470
475
int i = 0 ;
471
476
int n = mro .length ;
472
477
for (i = 0 ; i + 1 < n ; i ++) {
473
- if (isSameType (getType . executeCached ( self ) , mro [i ])) {
478
+ if (isSameType (type , mro [i ])) {
474
479
break ;
475
480
}
476
481
}
@@ -493,22 +498,28 @@ Object get(VirtualFrame frame, SuperObject self, Object attr,
493
498
CompilerDirectives .transferToInterpreterAndInvalidate ();
494
499
callGetSlotNode = insert (CallSlotDescrGet .create ());
495
500
}
496
- if (getObject == null ) {
497
- CompilerDirectives .transferToInterpreterAndInvalidate ();
498
- getObject = insert (GetObjectNodeGen .create ());
499
- }
501
+ Object object = getObject .executeCached (self );
500
502
Object obj ;
501
- if (getObjectIsStartObjectProfile .profile (inliningTarget , getObject . executeCached ( self ) == startType )) {
503
+ if (getObjectIsStartObjectProfile .profile (inliningTarget , object == startType )) {
502
504
obj = PNone .NO_VALUE ;
503
505
} else {
504
- obj = self . getObject () ;
506
+ obj = object ;
505
507
}
506
508
res = callGetSlotNode .executeCached (frame , resSlots .tp_descr_get (), res , obj , startType );
507
509
}
508
510
return res ;
509
511
}
510
512
}
511
513
514
+ Object object = getObject .executeCached (self );
515
+ if (isForeignObjectNode .execute (inliningTarget , object )) {
516
+ try {
517
+ return foreignGetattrNode .execute (inliningTarget , object , stringAttr );
518
+ } catch (PException e ) {
519
+ // continue to genericGetAttr()
520
+ }
521
+ }
522
+
512
523
return genericGetAttr (frame , self , stringAttr );
513
524
}
514
525
0 commit comments