Copy-on-write in the PHP language

  • Authors:
  • Akihiko Tozawa;Michiaki Tatsubori;Tamiya Onodera;Yasuhiko Minamide

  • Affiliations:
  • IBM Research, Tokyo Research Laboratory, Tokyo, Japan;IBM Research, Tokyo Research Laboratory, Tokyo, Japan;IBM Research, Tokyo Research Laboratory, Tokyo, Japan;University of Tsukuba, Tsukuba, Japan

  • Venue:
  • Proceedings of the 36th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
  • Year:
  • 2009

Quantified Score

Hi-index 0.02

Visualization

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.