Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Copy-on-write in the PHP language

Published: 21 January 2009 Publication History
  • Get Citation Alerts
  • Abstract

    PHP is a popular language for server-side applications. In PHP, assignment to variables copies the assigned values, according to its so-called copy-on-assignment semantics. In contrast, a typical PHP implementation uses a copy-on-write scheme to reduce the copy overhead by delaying copies as much as possible. This leads us to ask if the semantics and implementation of PHP coincide, and actually this is not the case in the presence of sharings within values. In this paper, we describe the copy-on-assignment semantics with three possible strategies to copy values containing sharings. The current PHP implementation has inconsistencies with these semantics, caused by its naïve use of copy-on-write. We fix this problem by the novel mostly copy-on-write scheme, making the copy-on-write implementations faithful to the semantics. We prove that our copy-on-write implementations are correct, using bisimulation with the copy-on-assignment semantics.

    References

    [1]
    A. Aasa, S. Holmström, and C. Nilsson. An efficiency comparison of some representations of purely functional arrays. BIT, 28(3):490--503, 1988.
    [2]
    H. G. Baker. Shallow binding in LISP 1.5. Communications of the ACM, 21(7):565--569, 1978.
    [3]
    H. P. Barendregt, M. C. J. D. Eekelen, J. R. W. Glauert, J. R. Kennaway, M. J. Plasmeijer, and M. R. Sleep. Term graph reduction. In Volume II: Parallel Languages on PARLE: Parallel Architectures and Languages Europe, pages 141--158, 1987.
    [4]
    E. Barendsen and S. Smetsers. Graph rewriting and copying. Technical Report 92-20, University of Nijmegen, 1992.
    [5]
    A. Bloss. Update analysis and the efficient implementation of functional aggregates. In FPCA '89: Proceedings of the fourth international conference on Functional programming languages and computer architecture, pages 26--38, New York, NY, USA, 1989. ACM.
    [6]
    S. Conchon and J.-C. Filliâtre. A persistent union-find data structure. In ML '07: Proceedings of the 2007 workshop on Workshop on ML, pages 37--46, New York, NY, USA, 2007. ACM.
    [7]
    R. Cytron, J. Ferrante, B. K. Rosen, M. N. Wegman, and F. K. Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems, 13(4):451--490, October 1991.
    [8]
    M. Hofmann. A type system for bounded space and functional in-place update. Nordic J. of Computing, 7(4):258--289, 2000.
    [9]
    P. Hudak and A. Bloss. The aggregate update problem in functional programming systems. In POPL, pages 300--314, 1985.
    [10]
    Y. Minamide. Static approximation of dynamically generated Web pages. In Proceedings of the 14th International World Wide Web Conference, pages 432--441. ACM Press, 2005.
    [11]
    M. Odersky. How to make destructive updates less destructive. In POPL '91: Proceedings of the 18th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 25--36, 1991.
    [12]
    M. E. O'Neill and F. W. Burton. A new method for functional arrays. Journal of Functional Programming, 7(5):487--514, Sept. 1997.
    [13]
    A. D. Robison. The Illinois functional programming interpreter. In SIGPLAN '87: Papers of the Symposium on Interpreters and interpretive techniques, pages 64--73, 1987.
    [14]
    J. T. Schwartz. Optimization of very high level languages, parts I, II. Comput. Lang., 1(2-3):161--218, 1975.
    [15]
    N. Shankar. Static analysis for safe destructive updates in a functional language. In Proc. of LOPSTER 2001, 11th International Workshop on Logic Based Program Synthesis and Transformation, Paphos, Cyprus, November 28-30, 2001, LNCS 2372, pages 1--24, 2001.
    [16]
    D. N. Turner, P. Wadler, and C. Mossin. Once upon a type. In Functional Programming Languages and Computer Architecture, San Diego, California, 1995.
    [17]
    P. Wadler. Linear types can change the world! In IFIP TC 2 Working Conference on Programming Concepts and Methods, pages 347--359, 1990.

    Cited By

    View all
    • (2022)PeachPie: Mature PHP to CLI compilerJournal of Computer Languages10.1016/j.cola.2022.10115273(101152)Online publication date: Dec-2022
    • (2018)A practical type system for safe aliasingProceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3276604.3276612(133-146)Online publication date: 24-Oct-2018
    • (2017)Static optimization in PHP 7Proceedings of the 26th International Conference on Compiler Construction10.1145/3033019.3033026(65-75)Online publication date: 5-Feb-2017
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 44, Issue 1
    POPL '09
    January 2009
    453 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1594834
    Issue’s Table of Contents
    • cover image ACM Conferences
      POPL '09: Proceedings of the 36th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
      January 2009
      464 pages
      ISBN:9781605583792
      DOI:10.1145/1480881
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 21 January 2009
    Published in SIGPLAN Volume 44, Issue 1

    Check for updates

    Author Tags

    1. graph rewriting
    2. php

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)8
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 27 Jul 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2022)PeachPie: Mature PHP to CLI compilerJournal of Computer Languages10.1016/j.cola.2022.10115273(101152)Online publication date: Dec-2022
    • (2018)A practical type system for safe aliasingProceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3276604.3276612(133-146)Online publication date: 24-Oct-2018
    • (2017)Static optimization in PHP 7Proceedings of the 26th International Conference on Compiler Construction10.1145/3033019.3033026(65-75)Online publication date: 5-Feb-2017
    • (2016)mmapcopyProceedings of the 31st Annual ACM Symposium on Applied Computing10.1145/2851613.2851736(1832-1837)Online publication date: 4-Apr-2016
    • (2014)The hiphop virtual machineACM SIGPLAN Notices10.1145/2714064.266019949:10(777-790)Online publication date: 15-Oct-2014
    • (2014)An Executable Formal Semantics of PHPProceedings of the 28th European Conference on ECOOP 2014 --- Object-Oriented Programming - Volume 858610.1007/978-3-662-44202-9_23(567-592)Online publication date: 1-Aug-2014
    • (2018)A practical type system for safe aliasingProceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3276604.3276612(133-146)Online publication date: 24-Oct-2018
    • (2017)Static optimization in PHP 7Proceedings of the 26th International Conference on Compiler Construction10.1145/3033019.3033026(65-75)Online publication date: 5-Feb-2017
    • (2016)mmapcopyProceedings of the 31st Annual ACM Symposium on Applied Computing10.1145/2851613.2851736(1832-1837)Online publication date: 4-Apr-2016
    • (2014)The hiphop virtual machineACM SIGPLAN Notices10.1145/2714064.266019949:10(777-790)Online publication date: 15-Oct-2014
    • Show More Cited By

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media