Change 33369 by [EMAIL PROTECTED] on 2008/02/25 12:48:22

        Ensure that constant folding runs with IN_PERL_RUNTIME true, by copying
        the current compiling cop to a different address. This ensures that
        lexical hints are correctly honoured, and allows us to fold sprintf.

Affected files ...

... //depot/perl/op.c#995 edit
... //depot/perl/opcode.h#152 edit
... //depot/perl/opcode.pl#176 edit

Differences ...

==== //depot/perl/op.c#995 (text) ====
Index: perl/op.c
--- perl/op.c#994~33368~        2008-02-25 03:47:03.000000000 -0800
+++ perl/op.c   2008-02-25 04:48:22.000000000 -0800
@@ -2428,6 +2428,7 @@
     OP *old_next;
     SV * const oldwarnhook = PL_warnhook;
     SV * const olddiehook  = PL_diehook;
+    COP not_compiling;
     dJMPENV;
 
     PERL_ARGS_ASSERT_FOLD_CONSTANTS;
@@ -2492,6 +2493,13 @@
     oldscope = PL_scopestack_ix;
     create_eval_scope(G_FAKINGEVAL);
 
+    /* Verify that we don't need to save it:  */
+    assert(PL_curcop == &PL_compiling);
+    StructCopy(&PL_compiling, &not_compiling, COP);
+    PL_curcop = &not_compiling;
+    /* The above ensures that we run with all the correct hints of the
+       currently compiling COP, but that IN_PERL_RUNTIME is not true. */
+    assert(IN_PERL_RUNTIME);
     PL_warnhook = PERL_WARNHOOK_FATAL;
     PL_diehook  = NULL;
     JMPENV_PUSH(ret);
@@ -2525,6 +2533,7 @@
     JMPENV_POP;
     PL_warnhook = oldwarnhook;
     PL_diehook  = olddiehook;
+    PL_curcop = &PL_compiling;
 
     if (PL_scopestack_ix > oldscope)
        delete_eval_scope();

==== //depot/perl/opcode.h#152 (text+w) ====
Index: perl/opcode.h
--- perl/opcode.h#151~33356~    2008-02-23 00:19:00.000000000 -0800
+++ perl/opcode.h       2008-02-25 04:48:22.000000000 -0800
@@ -1667,7 +1667,7 @@
        0x0022281c,     /* vec */
        0x0122291c,     /* index */
        0x0122291c,     /* rindex */
-       0x0004280d,     /* sprintf */
+       0x0004280f,     /* sprintf */
        0x00042805,     /* formline */
        0x0001379e,     /* ord */
        0x0001378e,     /* chr */

==== //depot/perl/opcode.pl#176 (xtext) ====
Index: perl/opcode.pl
--- perl/opcode.pl#175~33364~   2008-02-25 00:02:50.000000000 -0800
+++ perl/opcode.pl      2008-02-25 04:48:22.000000000 -0800
@@ -773,7 +773,7 @@
 index          index                   ck_index        isT@    S S S?
 rindex         rindex                  ck_index        isT@    S S S?
 
-sprintf                sprintf                 ck_fun          mst@    S L
+sprintf                sprintf                 ck_fun          fmst@   S L
 formline       formline                ck_fun          ms@     S L
 ord            ord                     ck_fun          ifsTu%  S?
 chr            chr                     ck_fun          fsTu%   S?
End of Patch.

Reply via email to