[svn:parrot] r48245 - trunk/runtime/parrot/library

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Sun Aug 1 06:29:58 UTC 2010


Author: pmichaud
Date: Sun Aug  1 06:29:58 2010
New Revision: 48245
URL: https://trac.parrot.org/parrot/changeset/48245

Log:
[p6object]:  Use pre-allocated true/false Boolean values for .ACCEPTS results; this should get a comparable speedup to r48242 (avoiding creating a new PMC) while preserving bool semantics.

Modified:
   trunk/runtime/parrot/library/P6object.pir

Modified: trunk/runtime/parrot/library/P6object.pir
==============================================================================
--- trunk/runtime/parrot/library/P6object.pir	Sun Aug  1 06:29:50 2010	(r48244)
+++ trunk/runtime/parrot/library/P6object.pir	Sun Aug  1 06:29:58 2010	(r48245)
@@ -86,6 +86,12 @@
     $P2.'register'($P0)
     $P3 = $P2.'register'($P1)
     setattribute $P3, 'protoobject', $P3
+
+    $P0 = new ['Boolean']
+    set_hll_global ['P6protoobject'], 'False', $P0
+    $P0 = new ['Boolean']
+    assign $P0, 1
+    set_hll_global ['P6protoobject'], 'True', $P0
 .end
 
 
@@ -794,32 +800,29 @@
 
     # Perl6Object (legacy) and Mu accept anything.
     $S0 = parrotclass
-    if $S0 == 'Perl6Object' goto accept_anyway
-    if $S0 == 'Mu' goto accept_anyway
+    if $S0 == 'Perl6Object' goto accept
+    if $S0 == 'Mu' goto accept
 
     # Otherwise, just try a normal check.
     $I0 = can topic, 'HOW'
-    unless $I0 goto end
+    unless $I0 goto reject
     topicwhat = topic.'WHAT'()
     $I0 = isa topicwhat, parrotclass
-    if $I0 goto end
+    if $I0 goto accept
     $I0 = does topic, parrotclass
-    if $I0 goto end
+    if $I0 goto accept
 
     # If this fails, and we want Any, and it's something form outside
     # of the Perl 6 world, we'd best just accept it.
-    unless $S0 == 'Any' goto end
+    unless $S0 == 'Any' goto reject
     $I0 = isa topicwhat, 'Mu'
-    unless $I0 goto accept_anyway
-    $I0 = 0
-    goto end
-
-  accept_anyway:
-    $I0 = 1
+    unless $I0 goto accept
+  reject:
+    $P0 = get_global 'False'
+    .return ($P0)
 
-  end:
-    $P0 = new ['Boolean']
-    assign $P0, $I0
+  accept:
+    $P0 = get_global 'True'
     .return ($P0)
 .end
 


More information about the parrot-commits mailing list