- Preserve bootstrapper state across thread switches (fixes issue 143).
authoriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 26 Jan 2009 18:09:46 +0000 (18:09 +0000)
committeriposva@chromium.org <iposva@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 26 Jan 2009 18:09:46 +0000 (18:09 +0000)
- Make sure stack guards are properly setup even when preemption is active.
- Fix missing v8::Locker and v8::Unlocker use in d8.cc.
- Threads forked in d8 do get their own context setup.

Review URL: http://codereview.chromium.org/18581

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1161 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/bootstrapper.cc
src/bootstrapper.h
src/d8.cc
src/execution.cc
src/execution.h
src/runtime.cc
src/top.cc
src/v8threads.cc
tools/v8.xcodeproj/project.pbxproj

index 970acd3..7928a5e 100644 (file)
@@ -265,6 +265,11 @@ class Genesis BASE_EMBEDDED {
   Genesis* previous() { return previous_; }
   static Genesis* current() { return current_; }
 
+  // Support for thread preemption.
+  static int ArchiveSpacePerThread();
+  static char* ArchiveState(char* to);
+  static char* RestoreState(char* from);
+
  private:
   Handle<Context> global_context_;
 
@@ -1466,4 +1471,45 @@ Genesis::Genesis(Handle<Object> global_object,
   result_ = global_context_;
 }
 
+
+// Support for thread preemption.
+
+// Reserve space for statics needing saving and restoring.
+int Bootstrapper::ArchiveSpacePerThread() {
+  return Genesis::ArchiveSpacePerThread();
+}
+
+
+// Archive statics that are thread local.
+char* Bootstrapper::ArchiveState(char* to) {
+  return Genesis::ArchiveState(to);
+}
+
+
+// Restore statics that are thread local.
+char* Bootstrapper::RestoreState(char* from) {
+  return Genesis::RestoreState(from);
+}
+
+
+// Reserve space for statics needing saving and restoring.
+int Genesis::ArchiveSpacePerThread() {
+  return sizeof(current_);
+}
+
+
+// Archive statics that are thread local.
+char* Genesis::ArchiveState(char* to) {
+  *reinterpret_cast<Genesis**>(to) = current_;
+  current_ = NULL;
+  return to + sizeof(current_);
+}
+
+
+// Restore statics that are thread local.
+char* Genesis::RestoreState(char* from) {
+  current_ = *reinterpret_cast<Genesis**>(from);
+  return from + sizeof(current_);
+}
+
 } }  // namespace v8::internal
index 1314bfd..ac4dd8d 100644 (file)
@@ -68,6 +68,11 @@ class Bootstrapper : public AllStatic {
   class FixupFlagsIsPCRelative: public BitField<bool, 0, 1> {};
   class FixupFlagsUseCodeObject: public BitField<bool, 1, 1> {};
   class FixupFlagsArgumentsCount: public BitField<uint32_t, 2, 32-2> {};
+  
+  // Support for thread preemption.
+  static int ArchiveSpacePerThread();
+  static char* ArchiveState(char* to);
+  static char* RestoreState(char* from);
 };
 
 }}  // namespace v8::internal
index 8939e60..8407e7a 100644 (file)
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -385,6 +385,7 @@ void Shell::OnExit() {
 
 
 static char* ReadChars(const char *name, int* size_out) {
+  v8::Unlocker unlocker;  // Release the V8 lock while reading files.
   FILE* file = i::OS::FOpen(name, "rb");
   if (file == NULL) return NULL;
 
@@ -422,6 +423,7 @@ void Shell::RunShell() {
   while (true) {
     Locker locker;
     HandleScope handle_scope;
+    Context::Scope context_scope(evaluation_context_);
     i::SmartPointer<char> input = editor->Prompt(Shell::kPrompt);
     if (input.is_empty())
       break;
@@ -446,8 +448,24 @@ class ShellThread : public i::Thread {
 
 
 void ShellThread::Run() {
+  // Prepare the context for this thread.
+  Locker locker;
+  HandleScope scope;
+  Handle<ObjectTemplate> global_template = ObjectTemplate::New();
+  global_template->Set(String::New("print"),
+                       FunctionTemplate::New(Shell::Print));
+  global_template->Set(String::New("load"),
+                       FunctionTemplate::New(Shell::Load));
+  global_template->Set(String::New("version"),
+                       FunctionTemplate::New(Shell::Version));
+
+  Persistent<Context> thread_context = Context::New(NULL, global_template);
+  thread_context->SetSecurityToken(Undefined());
+  
+  Context::Scope context_scope(thread_context);
+  
   char* ptr = const_cast<char*>(files_.start());
-  while (ptr != NULL) {
+  while ((ptr != NULL) && (*ptr != '\0')) {
     // For each newline-separated line.
     char *filename = ptr;
     char* next = ::strchr(ptr, '\n');
@@ -457,11 +475,11 @@ void ShellThread::Run() {
     } else {
       ptr = NULL;
     }
-    Locker locker;
-    HandleScope scope;
     Handle<String> str = Shell::ReadFile(filename);
     Shell::ExecuteString(str, String::New(filename), false, false);
   }
+  
+  thread_context.Dispose();
 }
 
 
@@ -473,52 +491,59 @@ int Shell::Main(int argc, char* argv[]) {
   Initialize();
   bool run_shell = (argc == 1);
   i::List<i::Thread*> threads(1);
-  Context::Scope context_scope(evaluation_context_);
-  for (int i = 1; i < argc; i++) {
-    char* str = argv[i];
-    if (strcmp(str, "--shell") == 0) {
-      run_shell = true;
-    } else if (strcmp(str, "-f") == 0) {
-      // Ignore any -f flags for compatibility with other stand-alone
-      // JavaScript engines.
-      continue;
-    } else if (strncmp(str, "--", 2) == 0) {
-      printf("Warning: unknown flag %s.\nTry --help for options\n", str);
-    } else if (strcmp(str, "-e") == 0 && i + 1 < argc) {
-      // Execute argument given to -e option directly.
-      Locker locker;
-      v8::HandleScope handle_scope;
-      v8::Handle<v8::String> file_name = v8::String::New("unnamed");
-      v8::Handle<v8::String> source = v8::String::New(argv[i + 1]);
-      if (!ExecuteString(source, file_name, false, true))
-        return 1;
-      i++;
-    } else if (strcmp(str, "-p") == 0 && i + 1 < argc) {
-      Locker locker;
-      Locker::StartPreemption(10);
-      int size = 0;
-      const char *files = ReadChars(argv[++i], &size);
-      if (files == NULL) return 1;
-      ShellThread *thread =
-        new ShellThread(threads.length(), i::Vector<const char>(files, size));
-      thread->Start();
-      threads.Add(thread);
-    } else {
-      // Use all other arguments as names of files to load and run.
-      Locker locker;
-      HandleScope handle_scope;
-      Handle<String> file_name = v8::String::New(str);
-      Handle<String> source = ReadFile(str);
-      if (source.IsEmpty()) {
-        printf("Error reading '%s'\n", str);
-        return 1;
+
+  {
+    // Acquire the V8 lock once initialization has finished. Since the thread
+    // below may spawn new threads accessing V8 holding the V8 lock here is
+    // mandatory.
+    Locker locker;
+    Context::Scope context_scope(evaluation_context_);
+    for (int i = 1; i < argc; i++) {
+      char* str = argv[i];
+      if (strcmp(str, "--shell") == 0) {
+        run_shell = true;
+      } else if (strcmp(str, "-f") == 0) {
+        // Ignore any -f flags for compatibility with other stand-alone
+        // JavaScript engines.
+        continue;
+      } else if (strncmp(str, "--", 2) == 0) {
+        printf("Warning: unknown flag %s.\nTry --help for options\n", str);
+      } else if (strcmp(str, "-e") == 0 && i + 1 < argc) {
+        // Execute argument given to -e option directly.
+        v8::HandleScope handle_scope;
+        v8::Handle<v8::String> file_name = v8::String::New("unnamed");
+        v8::Handle<v8::String> source = v8::String::New(argv[i + 1]);
+        if (!ExecuteString(source, file_name, false, true))
+          return 1;
+        i++;
+      } else if (strcmp(str, "-p") == 0 && i + 1 < argc) {
+        // Use the lowest possible thread preemption interval to test as many
+        // edgecases as possible.
+        Locker::StartPreemption(1);
+        int size = 0;
+        const char *files = ReadChars(argv[++i], &size);
+        if (files == NULL) return 1;
+        ShellThread *thread =
+            new ShellThread(threads.length(),
+                            i::Vector<const char>(files, size));
+        thread->Start();
+        threads.Add(thread);
+      } else {
+        // Use all other arguments as names of files to load and run.
+        HandleScope handle_scope;
+        Handle<String> file_name = v8::String::New(str);
+        Handle<String> source = ReadFile(str);
+        if (source.IsEmpty()) {
+          printf("Error reading '%s'\n", str);
+          return 1;
+        }
+        if (!ExecuteString(source, file_name, false, true))
+          return 1;
       }
-      if (!ExecuteString(source, file_name, false, true))
-        return 1;
     }
+    if (i::FLAG_debugger)
+      v8::Debug::AddDebugEventListener(HandleDebugEvent);
   }
-  if (i::FLAG_debugger)
-    v8::Debug::AddDebugEventListener(HandleDebugEvent);
   if (run_shell)
     RunShell();
   for (int i = 0; i < threads.length(); i++) {
index cb05314..95f781e 100644 (file)
@@ -191,12 +191,24 @@ StackGuard::ThreadLocal StackGuard::thread_local_;
 
 
 StackGuard::StackGuard() {
+  // NOTE: Overall the StackGuard code assumes that the stack grows towards
+  // lower addresses.
   ExecutionAccess access;
-  if (thread_local_.nesting_++ == 0 &&
-      thread_local_.jslimit_ != kInterruptLimit) {
-    // NOTE: We assume that the stack grows towards lower addresses.
-    ASSERT(thread_local_.jslimit_ == kIllegalLimit);
-    ASSERT(thread_local_.climit_ == kIllegalLimit);
+  if (thread_local_.nesting_++ == 0) {
+    // Initial StackGuard is being set. We will set the stack limits based on
+    // the current stack pointer allowing the stack to grow kLimitSize from
+    // here.
+    
+    // Ensure that either the stack limits are unset (kIllegalLimit) or that
+    // they indicate a pending interruption. The interrupt limit will be
+    // temporarily reset through the code below and reestablished if the
+    // interrupt flags indicate that an interrupt is pending.
+    ASSERT(thread_local_.jslimit_ == kIllegalLimit ||
+           (thread_local_.jslimit_ == kInterruptLimit &&
+            thread_local_.interrupt_flags_ != 0));
+    ASSERT(thread_local_.climit_ == kIllegalLimit ||
+           (thread_local_.climit_ == kInterruptLimit &&
+            thread_local_.interrupt_flags_ != 0));
 
     thread_local_.initial_jslimit_ = thread_local_.jslimit_ =
         GENERATED_CODE_STACK_LIMIT(kLimitSize);
@@ -210,9 +222,11 @@ StackGuard::StackGuard() {
       set_limits(kInterruptLimit, access);
     }
   }
-  // make sure we have proper limits setup
+  // Ensure that proper limits have been set.
   ASSERT(thread_local_.jslimit_ != kIllegalLimit &&
          thread_local_.climit_ != kIllegalLimit);
+  ASSERT(thread_local_.initial_jslimit_ != kIllegalLimit &&
+         thread_local_.initial_climit_ != kIllegalLimit);
 }
 
 
index bd37525..d5f2fb6 100644 (file)
@@ -228,7 +228,12 @@ class StackGuard BASE_EMBEDDED {
 class StackLimitCheck BASE_EMBEDDED {
  public:
   bool HasOverflowed() const {
-    return reinterpret_cast<uintptr_t>(this) < StackGuard::climit();
+    // Stack has overflowed in C++ code only if stack pointer exceeds the C++
+    // stack guard and the limits are not set to interrupt values.
+    // TODO(214): Stack overflows are ignored if a interrupt is pending. This
+    // code should probably always use the initial C++ limit.
+    return (reinterpret_cast<uintptr_t>(this) < StackGuard::climit()) &&
+           StackGuard::IsStackOverflow();
   }
 };
 
index 6417cb9..18d6c03 100644 (file)
@@ -3778,7 +3778,9 @@ static Object* Runtime_StackGuard(Arguments args) {
   ASSERT(args.length() == 1);
 
   // First check if this is a real stack overflow.
-  if (StackGuard::IsStackOverflow()) return Runtime_StackOverflow(args);
+  if (StackGuard::IsStackOverflow()) {
+    return Runtime_StackOverflow(args);
+  }
 
   return Execution::HandleStackGuardInterrupt();
 }
index d339591..76c608e 100644 (file)
@@ -37,7 +37,7 @@
 namespace v8 { namespace internal {
 
 ThreadLocalTop Top::thread_local_;
-Mutex* Top::break_access_;
+Mutex* Top::break_access_ = OS::CreateMutex();
 StackFrame::Id Top::break_frame_id_;
 int Top::break_count_;
 int Top::break_id_;
@@ -225,7 +225,6 @@ void Top::Initialize() {
 
   InitializeThreadLocal();
 
-  break_access_ = OS::CreateMutex();
   break_frame_id_ = StackFrame::NO_ID;
   break_count_ = 0;
   break_id_ = 0;
index 46be3d3..dd36c43 100644 (file)
@@ -28,6 +28,7 @@
 #include "v8.h"
 
 #include "api.h"
+#include "bootstrapper.h"
 #include "debug.h"
 #include "execution.h"
 #include "v8threads.h"
@@ -119,6 +120,11 @@ bool ThreadManager::RestoreThread() {
     Thread::SetThreadLocal(thread_state_key, NULL);
     return true;
   }
+  
+  // Make sure that the preemption thread cannot modify the thread state while
+  // it is being archived or restored.
+  ExecutionAccess access;
+  
   // If there is another thread that was lazily archived then we have to really
   // archive it now.
   if (lazily_archived_thread_.IsValid()) {
@@ -135,6 +141,7 @@ bool ThreadManager::RestoreThread() {
   from = Debug::RestoreDebug(from);
   from = StackGuard::RestoreStackGuard(from);
   from = RegExpStack::RestoreStack(from);
+  from = Bootstrapper::RestoreState(from);
   Thread::SetThreadLocal(thread_state_key, NULL);
   state->Unlink();
   state->LinkInto(ThreadState::FREE_LIST);
@@ -160,7 +167,8 @@ static int ArchiveSpacePerThread() {
                             Top::ArchiveSpacePerThread() +
                           Debug::ArchiveSpacePerThread() +
                      StackGuard::ArchiveSpacePerThread() +
-                    RegExpStack::ArchiveSpacePerThread();
+                    RegExpStack::ArchiveSpacePerThread() +
+                   Bootstrapper::ArchiveSpacePerThread();
 }
 
 
@@ -242,6 +250,7 @@ void ThreadManager::EagerlyArchiveThread() {
   to = Debug::ArchiveDebug(to);
   to = StackGuard::ArchiveStackGuard(to);
   to = RegExpStack::ArchiveStack(to);
+  to = Bootstrapper::ArchiveState(to);
   lazily_archived_thread_.Initialize(ThreadHandle::INVALID);
   lazily_archived_thread_state_ = NULL;
 }
index 685a86c..aa1790d 100644 (file)
@@ -16,6 +16,7 @@
                                7BF8919B0E7309AD000BAF8A /* PBXTargetDependency */,
                                7BF891970E73099F000BAF8A /* PBXTargetDependency */,
                                7BF891990E73099F000BAF8A /* PBXTargetDependency */,
+                               893988100F2A3647007D5254 /* PBXTargetDependency */,
                                896FD03E0E78D731003DFB6A /* PBXTargetDependency */,
                                896FD0400E78D735003DFB6A /* PBXTargetDependency */,
                        );
                890A14020EE9C4B400E49346 /* regexp-macro-assembler-irregexp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 89A15C750EE466D000B48DEB /* regexp-macro-assembler-irregexp.cc */; };
                890A14030EE9C4B500E49346 /* regexp-macro-assembler-tracer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 89A15C770EE466D000B48DEB /* regexp-macro-assembler-tracer.cc */; };
                890A14040EE9C4B700E49346 /* regexp-macro-assembler.cc in Sources */ = {isa = PBXBuildFile; fileRef = 89A15C790EE466D000B48DEB /* regexp-macro-assembler.cc */; };
+               893988060F2A35FA007D5254 /* libjscre.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 897FF1BF0E719CB600D62E90 /* libjscre.a */; };
+               893988070F2A35FA007D5254 /* libv8.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8970F2F00E719FB2006AE7B5 /* libv8.a */; };
+               8939880D0F2A362A007D5254 /* d8.cc in Sources */ = {isa = PBXBuildFile; fileRef = 89A15C920EE46A1700B48DEB /* d8.cc */; };
+               893988160F2A3688007D5254 /* d8-debug.cc in Sources */ = {isa = PBXBuildFile; fileRef = 893988150F2A3686007D5254 /* d8-debug.cc */; };
+               893988330F2A3B8F007D5254 /* d8-js.cc in Sources */ = {isa = PBXBuildFile; fileRef = 893988320F2A3B8B007D5254 /* d8-js.cc */; };
                893CCE640E71D83700357A03 /* code-stubs.cc in Sources */ = {isa = PBXBuildFile; fileRef = 897FF1110E719B8F00D62E90 /* code-stubs.cc */; };
                8944AD100F1D4D500028D560 /* regexp-stack.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8944AD0E0F1D4D3A0028D560 /* regexp-stack.cc */; };
                8944AD110F1D4D570028D560 /* regexp-stack.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8944AD0E0F1D4D3A0028D560 /* regexp-stack.cc */; };
                        remoteGlobalIDString = 897FF1BE0E719CB600D62E90;
                        remoteInfo = jscre;
                };
+               893988000F2A35FA007D5254 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 8915B8680E719336009C4E19 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 897FF1BE0E719CB600D62E90;
+                       remoteInfo = jscre;
+               };
+               893988020F2A35FA007D5254 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 8915B8680E719336009C4E19 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 8970F2EF0E719FB2006AE7B5;
+                       remoteInfo = v8;
+               };
+               8939880F0F2A3647007D5254 /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 8915B8680E719336009C4E19 /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 893987FE0F2A35FA007D5254;
+                       remoteInfo = d8_shell;
+               };
                896FD03B0E78D71F003DFB6A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 8915B8680E719336009C4E19 /* Project object */;
 /* Begin PBXFileReference section */
                8900116B0E71CA2300F91F35 /* libraries.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libraries.cc; sourceTree = "<group>"; };
                893986D40F29020C007D5254 /* apiutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apiutils.h; sourceTree = "<group>"; };
+               8939880B0F2A35FA007D5254 /* v8_shell */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = v8_shell; sourceTree = BUILT_PRODUCTS_DIR; };
+               893988150F2A3686007D5254 /* d8-debug.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "d8-debug.cc"; path = "../src/d8-debug.cc"; sourceTree = "<group>"; };
+               893988320F2A3B8B007D5254 /* d8-js.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "d8-js.cc"; sourceTree = "<group>"; };
                8944AD0E0F1D4D3A0028D560 /* regexp-stack.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "regexp-stack.cc"; sourceTree = "<group>"; };
                8944AD0F0F1D4D3A0028D560 /* regexp-stack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "regexp-stack.h"; sourceTree = "<group>"; };
                89471C7F0EB23EE400B6874B /* flag-definitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "flag-definitions.h"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
+               893988050F2A35FA007D5254 /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               893988060F2A35FA007D5254 /* libjscre.a in Frameworks */,
+                               893988070F2A35FA007D5254 /* libv8.a in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                8970F2EE0E719FB2006AE7B5 /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        isa = PBXGroup;
                        children = (
                                89A15C910EE46A1700B48DEB /* d8-readline.cc */,
+                               893988150F2A3686007D5254 /* d8-debug.cc */,
                                89A15C920EE46A1700B48DEB /* d8.cc */,
                                89A15C930EE46A1700B48DEB /* d8.h */,
                                89A15C940EE46A1700B48DEB /* d8.js */,
                                897F767A0E71B4CC007ACF34 /* v8_shell */,
                                89F23C870E78D5B2006B2466 /* libv8-arm.a */,
                                89F23C950E78D5B6006B2466 /* v8_shell-arm */,
+                               8939880B0F2A35FA007D5254 /* v8_shell */,
                        );
                        name = Products;
                        sourceTree = "<group>";
                89A9C1630E71C8E300BE6CCA /* generated */ = {
                        isa = PBXGroup;
                        children = (
+                               893988320F2A3B8B007D5254 /* d8-js.cc */,
                                8900116B0E71CA2300F91F35 /* libraries.cc */,
                        );
                        path = generated;
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
+               893987FE0F2A35FA007D5254 /* d8_shell */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 893988080F2A35FA007D5254 /* Build configuration list for PBXNativeTarget "d8_shell" */;
+                       buildPhases = (
+                               893988220F2A376C007D5254 /* ShellScript */,
+                               893988030F2A35FA007D5254 /* Sources */,
+                               893988050F2A35FA007D5254 /* Frameworks */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                               893987FF0F2A35FA007D5254 /* PBXTargetDependency */,
+                               893988010F2A35FA007D5254 /* PBXTargetDependency */,
+                       );
+                       name = d8_shell;
+                       productName = v8_shell;
+                       productReference = 8939880B0F2A35FA007D5254 /* v8_shell */;
+                       productType = "com.apple.product-type.tool";
+               };
                8970F2EF0E719FB2006AE7B5 /* v8 */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 8970F2F70E719FC1006AE7B5 /* Build configuration list for PBXNativeTarget "v8" */;
                                897FF1BE0E719CB600D62E90 /* jscre */,
                                8970F2EF0E719FB2006AE7B5 /* v8 */,
                                897F76790E71B4CC007ACF34 /* v8_shell */,
+                               893987FE0F2A35FA007D5254 /* d8_shell */,
                                89F23C3C0E78D5B2006B2466 /* v8-arm */,
                                89F23C880E78D5B6006B2466 /* v8_shell-arm */,
                        );
 /* End PBXProject section */
 
 /* Begin PBXShellScriptBuildPhase section */
+               893988220F2A376C007D5254 /* ShellScript */ = {
+                       isa = PBXShellScriptBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                       );
+                       inputPaths = (
+                       );
+                       outputPaths = (
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+                       shellPath = /bin/sh;
+                       shellScript = "set -ex\nJS_FILES=\"d8.js\"\\\n\" macros.py\"\n\nV8ROOT=\"${SRCROOT}/..\"\n\nSRC_DIR=\"${V8ROOT}/src\"\n\nNATIVE_JS_FILES=\"\"\n\nfor i in ${JS_FILES} ; do\n  NATIVE_JS_FILES+=\"${SRC_DIR}/${i} \"\ndone\n\nV8_GENERATED_SOURCES_DIR=\"${CONFIGURATION_TEMP_DIR}/generated\"\nmkdir -p \"${V8_GENERATED_SOURCES_DIR}\"\n\nD8_CC=\"${V8_GENERATED_SOURCES_DIR}/d8-js.cc\"\nD8_EMPTY_CC=\"${V8_GENERATED_SOURCES_DIR}/d8-js-empty.cc\"\n\npython \"${V8ROOT}/tools/js2c.py\" \\\n  \"${D8_CC}.new\" \\\n  \"${D8_EMPTY_CC}.new\" \\\n  \"D8\" \\\n  ${NATIVE_JS_FILES}\n\n# Only use the new files if they're different from the existing files (if any),\n# preserving the existing files' timestamps when there are no changes.  This\n# minimizes unnecessary build activity for a no-change build.\n\nif ! diff -q \"${D8_CC}.new\" \"${D8_CC}\" >& /dev/null ; then\n  mv \"${D8_CC}.new\" \"${D8_CC}\"\nelse\n  rm \"${D8_CC}.new\"\nfi\n\nif ! diff -q \"${D8_EMPTY_CC}.new\" \"${D8_EMPTY_CC}\" >& /dev/null ; then\n  mv \"${D8_EMPTY_CC}.new\" \"${D8_EMPTY_CC}\"\nelse\n  rm \"${D8_EMPTY_CC}.new\"\nfi\n";
+               };
                89EA6FB50E71AA1F00F59E1B /* ShellScript */ = {
                        isa = PBXShellScriptBuildPhase;
                        buildActionMask = 2147483647;
 /* End PBXShellScriptBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
+               893988030F2A35FA007D5254 /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               8939880D0F2A362A007D5254 /* d8.cc in Sources */,
+                               893988160F2A3688007D5254 /* d8-debug.cc in Sources */,
+                               893988330F2A3B8F007D5254 /* d8-js.cc in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                8970F2ED0E719FB2006AE7B5 /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        target = 897FF1BE0E719CB600D62E90 /* jscre */;
                        targetProxy = 7BF8919A0E7309AD000BAF8A /* PBXContainerItemProxy */;
                };
+               893987FF0F2A35FA007D5254 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 897FF1BE0E719CB600D62E90 /* jscre */;
+                       targetProxy = 893988000F2A35FA007D5254 /* PBXContainerItemProxy */;
+               };
+               893988010F2A35FA007D5254 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 8970F2EF0E719FB2006AE7B5 /* v8 */;
+                       targetProxy = 893988020F2A35FA007D5254 /* PBXContainerItemProxy */;
+               };
+               893988100F2A3647007D5254 /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 893987FE0F2A35FA007D5254 /* d8_shell */;
+                       targetProxy = 8939880F0F2A3647007D5254 /* PBXContainerItemProxy */;
+               };
                896FD03C0E78D71F003DFB6A /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 89F23C3C0E78D5B2006B2466 /* v8-arm */;
                        };
                        name = Release;
                };
+               893988090F2A35FA007D5254 /* Debug */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               HEADER_SEARCH_PATHS = ../src;
+                               PRODUCT_NAME = v8_shell;
+                       };
+                       name = Debug;
+               };
+               8939880A0F2A35FA007D5254 /* Release */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               HEADER_SEARCH_PATHS = ../src;
+                               PRODUCT_NAME = v8_shell;
+                       };
+                       name = Release;
+               };
                8970F2F10E719FB2006AE7B5 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                        defaultConfigurationIsVisible = 0;
                        defaultConfigurationName = Release;
                };
+               893988080F2A35FA007D5254 /* Build configuration list for PBXNativeTarget "d8_shell" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               893988090F2A35FA007D5254 /* Debug */,
+                               8939880A0F2A35FA007D5254 /* Release */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Release;
+               };
                8970F2F70E719FC1006AE7B5 /* Build configuration list for PBXNativeTarget "v8" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (