Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] refactor pp_tied #13874

Closed
p5pRT opened this issue May 27, 2014 · 6 comments
Closed

[PATCH] refactor pp_tied #13874

p5pRT opened this issue May 27, 2014 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented May 27, 2014

Migrated from rt.perl.org#121969 (status was 'resolved')

Searchable as RT121969$

@p5pRT
Copy link
Author

p5pRT commented May 27, 2014

From @bulk88

Created by @bulk88

See attached patch.

Perl Info

Flags:
       category=core
       severity=low

Site configuration information for perl 5.20.0:

Configured by Owner at Sat May 17 23:49:31 2014.

Summary of my perl5 (revision 5 version 20 subversion 0) configuration:
     Local Commit: 5b1fb5914dd2ffb35ae3286bcf8e8ee236940710
     Ancestor: e023b52d29900981e0c68349b3ec306d85c0716d
     Platform:
       osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
       uname=''
       config_args='undef'
       hint=recommended, useposix=true, d_sigaction=undef
       useithreads=define, usemultiplicity=define
       use64bitint=undef, use64bitall=undef, uselongdouble=undef
       usemymalloc=n, bincompat5005=undef
     Compiler:
       cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL
-DWIN32 -D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
       optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL',
       cppflags='-DWIN32'
       ccversion='13.10.6030', gccversion='', gccosandvers=''
       intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
       d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
       ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
       alignbytes=8, prototype=define
     Linker and Libraries:
       ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'
       libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib"
       libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
       perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
       libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl520.lib
       gnulibc_version=''
     Dynamic Linking:
       dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
       cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf -ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'

Locally applied patches:
       RC1
       602f5d5ad824f3fd87b13b2613c3ff8ea5321bf8
       7e81d5c4f446d69f52760d5f05e193bbed8cd3db
       5b1fb5914dd2ffb35ae3286bcf8e8ee236940710


@INC for perl 5.20.0:
       C:/perl519/site/lib
       C:/perl519/lib
       .


Environment for perl 5.20.0:
       HOME (unset)
       LANG (unset)
       LANGUAGE (unset)
       LD_LIBRARY_PATH (unset)
       LOGDIR (unset)
       PATH=C:\perl519\bin;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
       PERL_BADLANG (unset)
       SHELL (unset)





@p5pRT
Copy link
Author

p5pRT commented May 27, 2014

From @bulk88

0001-refactor-pp_tied.patch
From 45753263334050eb7b0da59d7dc0b31f9ffc66db Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 27 May 2014 17:14:20 -0400
Subject: [PATCH] refactor pp_tied

remove some redundant code regarding stack handling

-removed:
  -4/-8 pop on SP
  +4/+8 push on SP
  PUTBACK

function's machine code size dropped from 0xC5 to 0xBD bytes on VC2003
---
 pp_sys.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/pp_sys.c b/pp_sys.c
index 9f97177..175fad3 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1003,21 +1003,23 @@ PP(pp_tied)
     dVAR;
     dSP;
     const MAGIC *mg;
-    SV *sv = POPs;
+    dTOPss;
     const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
 		? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
     if (isGV_with_GP(sv) && !SvFAKE(sv) && !(sv = MUTABLE_SV(GvIOp(sv))))
-	RETPUSHUNDEF;
+	goto ret_undef;
 
     if (SvTYPE(sv) == SVt_PVLV && LvTYPE(sv) == 'y' &&
-	!(sv = defelem_target(sv, NULL))) RETPUSHUNDEF;
+	!(sv = defelem_target(sv, NULL))) goto ret_undef;
 
     if ((mg = SvTIED_mg(sv, how))) {
-	PUSHs(SvTIED_obj(sv, mg));
-	RETURN;
+	SETs(SvTIED_obj(sv, mg));
+	return NORMAL; /* PUTBACK not needed, pp_tied never moves SP */
     }
-    RETPUSHUNDEF;
+    ret_undef:
+    SETs(&PL_sv_undef);
+    return NORMAL;
 }
 
 PP(pp_dbmopen)
-- 
1.7.9.msysgit.0

@p5pRT
Copy link
Author

p5pRT commented May 28, 2014

From @bulk88

On Tue May 27 14​:16​:49 2014, bulk88 wrote​:

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.20.0.

-----------------------------------------------------------------
[Please describe your issue here]

See attached patch.

Interesting trivia, in Strawberry Perl 5.18, GCC optimize out the -4 and +4 to SP (and that is across function calls), it didn't optimize out the PUTBACK. Quite interesting the GCC optimizer looks so many lines back/forwards.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

From @tonycoz

On Tue May 27 14​:16​:49 2014, bulk88 wrote​:

See attached patch.

Thanks, applied as b3cf482.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT p5pRT closed this as completed Jun 4, 2014
@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2014

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant