src: change kIsolateSlot to 3
authorCheng Zhao <zcbenz@gmail.com>
Sun, 10 Aug 2014 02:46:11 +0000 (10:46 +0800)
committerFedor Indutny <fedor@indutny.com>
Wed, 13 Aug 2014 09:58:51 +0000 (13:58 +0400)
The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
and the size of isolate's slots is 4 by default, so using 3 should hopefully
make node work independently when embedded into other application.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
src/env.h

index fba0ce9..4a26dd1 100644 (file)
--- a/src/env.h
+++ b/src/env.h
@@ -37,8 +37,8 @@
 // a nightmare so let's make the preprocessor generate them for us.
 //
 // Make sure that any macros defined here are undefined again at the bottom
-// of context-inl.h. The sole exception is NODE_CONTEXT_EMBEDDER_DATA_INDEX,
-// it may have been defined externally.
+// of context-inl.h. The exceptions are NODE_CONTEXT_EMBEDDER_DATA_INDEX
+// and NODE_ISOLATE_SLOT, they may have been defined externally.
 namespace node {
 
 // Pick an index that's hopefully out of the way when we're embedded inside
@@ -49,6 +49,14 @@ namespace node {
 #define NODE_CONTEXT_EMBEDDER_DATA_INDEX 32
 #endif
 
+// The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
+// and the size of isolate's slots is 4 by default, so using 3 should
+// hopefully make node work independently when embedded into other
+// application.
+#ifndef NODE_ISOLATE_SLOT
+#define NODE_ISOLATE_SLOT 3
+#endif
+
 // Strings are per-isolate primitives but Environment proxies them
 // for the sake of convenience.
 #define PER_ISOLATE_STRING_PROPERTIES(V)                                      \
@@ -430,7 +438,7 @@ class Environment {
 #undef V
 
  private:
-  static const int kIsolateSlot = 0;
+  static const int kIsolateSlot = NODE_ISOLATE_SLOT;
 
   class GCInfo;
   class IsolateData;