3636import com .oracle .truffle .api .dsl .TypeSystemReference ;
3737import com .oracle .truffle .api .frame .VirtualFrame ;
3838import com .oracle .truffle .api .interop .TruffleObject ;
39+ import com .oracle .truffle .api .library .CachedLibrary ;
3940import com .oracle .truffle .api .object .DynamicObject ;
4041import com .oracle .truffle .api .profiles .ConditionProfile ;
42+ import com .oracle .truffle .api .profiles .ValueProfile ;
43+ import com .oracle .truffle .r .runtime .data .VectorDataLibrary ;
4144import com .oracle .truffle .r .runtime .data .nodes .attributes .GetAttributeNode ;
4245import com .oracle .truffle .r .runtime .data .nodes .attributes .IterableAttributeNode ;
4346import com .oracle .truffle .r .runtime .data .nodes .attributes .IterableAttributeNodeGen ;
@@ -314,19 +317,28 @@ private static byte doInternalIdenticalSlowpath(RFunction x, RFunction y, boolea
314317 return identicalRecursiveAttrNode .execute (x , y , numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
315318 }
316319
317- @ Specialization (guards = "!vectorsLists(x, y)" )
320+ @ Specialization (guards = "!vectorsLists(x, y)" , limit = "getGenericDataLibraryCacheSize()" )
318321 protected static byte doInternalIdenticalGeneric (RAbstractVector x , RAbstractVector y , boolean numEq , boolean singleNA , boolean attribAsSet , boolean ignoreBytecode , boolean ignoreEnvironment ,
319322 boolean ignoreSrcref , int depth ,
323+ @ CachedLibrary ("x.getData()" ) VectorDataLibrary xDataLib ,
324+ @ CachedLibrary ("y.getData()" ) VectorDataLibrary yDataLib ,
325+ @ Cached ("createClassProfile()" ) ValueProfile xClassProfile ,
326+ @ Cached ("createClassProfile()" ) ValueProfile yClassProfile ,
320327 @ Cached ("createBinaryProfile()" ) ConditionProfile vecLengthProfile ,
321328 @ Cached ("createBinaryProfile()" ) ConditionProfile differentTypesProfile ,
322329 @ Cached ("createBinaryProfile()" ) ConditionProfile isDoubleProfile ,
323330 @ Cached (value = "createOrGet(depth)" , uncached = "getUncached()" ) IdenticalRecursiveAttrNode identicalRecursiveAttrNode ) {
324- if (vecLengthProfile .profile (x .getLength () != y .getLength ()) || differentTypesProfile .profile (x .getRType () != y .getRType ())) {
331+ RAbstractVector xProfiled = xClassProfile .profile (x );
332+ RAbstractVector yProfiled = yClassProfile .profile (y );
333+ Object xData = xProfiled .getData ();
334+ Object yData = yProfiled .getData ();
335+ int xLen = xDataLib .getLength (xData );
336+ if (vecLengthProfile .profile (xLen != yDataLib .getLength (yData )) || differentTypesProfile .profile (xProfiled .getRType () != yProfiled .getRType ())) {
325337 return RRuntime .LOGICAL_FALSE ;
326338 } else {
327- for (int i = 0 ; i < x . getLength () ; i ++) {
328- Object xValue = x .getDataAtAsObject (i );
329- Object yValue = y .getDataAtAsObject (i );
339+ for (int i = 0 ; i < xLen ; i ++) {
340+ Object xValue = xDataLib .getDataAtAsObject (xData , i );
341+ Object yValue = yDataLib .getDataAtAsObject (yData , i );
330342 if (isDoubleProfile .profile (xValue instanceof Double )) {
331343 if (identical ((double ) xValue , (double ) yValue , numEq , singleNA ) == RRuntime .LOGICAL_FALSE ) {
332344 return RRuntime .LOGICAL_FALSE ;
@@ -336,28 +348,40 @@ protected static byte doInternalIdenticalGeneric(RAbstractVector x, RAbstractVec
336348 }
337349 }
338350 }
339- return identicalRecursiveAttrNode .execute (x , y , numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
351+ return identicalRecursiveAttrNode .execute (xProfiled , yProfiled , numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
340352 }
341353
342354 static IdenticalInternal createOrGet (int depth ) {
343355 return isCached (depth ) ? IdenticalInternal .create () : IdenticalInternalNodeGen .getUncached ();
344356 }
345357
346- @ Specialization
358+ @ Specialization ( limit = "getTypedVectorDataLibraryCacheSize()" )
347359 protected byte doInternalIdenticalGeneric (RAbstractListBaseVector x , RAbstractListBaseVector y , boolean numEq , boolean singleNA , boolean attribAsSet , boolean ignoreBytecode ,
348360 boolean ignoreEnvironment , boolean ignoreSrcref , int depth ,
361+ @ CachedLibrary ("x.getData()" ) VectorDataLibrary xDataLib ,
362+ @ CachedLibrary ("y.getData()" ) VectorDataLibrary yDataLib ,
363+ @ Cached ("createClassProfile()" ) ValueProfile xClassProfile ,
364+ @ Cached ("createClassProfile()" ) ValueProfile yClassProfile ,
365+ @ Cached ("createBinaryProfile()" ) ConditionProfile vecLengthProfile ,
366+ @ Cached ("createBinaryProfile()" ) ConditionProfile differentTypesProfile ,
349367 @ Cached (value = "createOrGet(depth)" , uncached = "getUncached()" ) IdenticalInternal identicalRecursiveNode ,
350368 @ Cached (value = "createOrGet(depth)" , uncached = "getUncached()" ) IdenticalRecursiveAttrNode identicalRecursiveAttrNode ) {
351- if (x .getLength () != y .getLength ()) {
369+ RAbstractVector xProfiled = xClassProfile .profile (x );
370+ RAbstractVector yProfiled = yClassProfile .profile (y );
371+ Object xData = xProfiled .getData ();
372+ Object yData = yProfiled .getData ();
373+ int xLen = xDataLib .getLength (xData );
374+ if (vecLengthProfile .profile (xLen != yDataLib .getLength (yData )) || differentTypesProfile .profile (xProfiled .getRType () != yProfiled .getRType ())) {
352375 return RRuntime .LOGICAL_FALSE ;
353376 }
354- for (int i = 0 ; i < x .getLength (); i ++) {
355- byte res = identicalRecursiveNode .executeByte (x .getDataAt (i ), y .getDataAt (i ), numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
377+ for (int i = 0 ; i < xLen ; i ++) {
378+ byte res = identicalRecursiveNode .executeByte (xDataLib .getElementAt (xData , i ), yDataLib .getElementAt (yData , i ), numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment ,
379+ ignoreSrcref , depth + 1 );
356380 if (res == RRuntime .LOGICAL_FALSE ) {
357381 return RRuntime .LOGICAL_FALSE ;
358382 }
359383 }
360- return identicalRecursiveAttrNode .execute (x , y , numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
384+ return identicalRecursiveAttrNode .execute (xProfiled , yProfiled , numEq , singleNA , attribAsSet , ignoreBytecode , ignoreEnvironment , ignoreSrcref , depth + 1 );
361385 }
362386
363387 @ Specialization
0 commit comments