Explorar el Código

Document rules for initialization/cleanup of ZTS globals.

Transfer stesie's comment from the c3512587acf2f6aeeb80d7cc753f08a784c4c86b
commit message so that future additions to v8js_globals maintain the
proper ZTS behavior.
C. Scott Ananian hace 11 años
padre
commit
7cdcb5f45e
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      v8js.cc

+ 10 - 0
v8js.cc

@@ -1670,6 +1670,16 @@ static PHP_MINFO_FUNCTION(v8js)
  */
 static PHP_GINIT_FUNCTION(v8js)
 {
+	/*
+	  If ZTS is disabled, the v8js_globals instance is declared right
+	  in the BSS and hence automatically initialized by C++ compiler.
+	  Most of the variables are just zeroed.
+
+	  If ZTS is enabled however, v8js_globals just points to a freshly
+	  allocated, uninitialized piece of memory, hence we need to
+	  initialize all fields on our own.  Likewise on shutdown we have to
+	  run the destructors manually.
+	*/
 #ifdef ZTS
 	v8js_globals->extensions = NULL;
 	v8js_globals->v8_initialized = 0;