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







Comments