skip to main content
research-article

Copy-on-write in the PHP language

Published:21 January 2009Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. H. G. Baker. Shallow binding in LISP 1.5. Communications of the ACM, 21(7):565--569, 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  4. E. Barendsen and S. Smetsers. Graph rewriting and copying. Technical Report 92-20, University of Nijmegen, 1992.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Hofmann. A type system for bounded space and functional in-place update. Nordic J. of Computing, 7(4):258--289, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. P. Hudak and A. Bloss. The aggregate update problem in functional programming systems. In POPL, pages 300--314, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. T. Schwartz. Optimization of very high level languages, parts I, II. Comput. Lang., 1(2-3):161--218, 1975.Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. D. N. Turner, P. Wadler, and C. Mossin. Once upon a type. In Functional Programming Languages and Computer Architecture, San Diego, California, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. P. Wadler. Linear types can change the world! In IFIP TC 2 Working Conference on Programming Concepts and Methods, pages 347--359, 1990.Google ScholarGoogle Scholar

Index Terms

  1. Copy-on-write in the PHP language

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • 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

      Copyright © 2009 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 21 January 2009

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!