瀏覽代碼

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 11 年之前
父節點
當前提交
7cdcb5f45e
共有 1 個文件被更改,包括 10 次插入0 次删除
  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;