Bug 1550757 - Create new DLL for sharing VR code r=kip
☠☠ backed out by 76bbedc1ec1a ☠ ☠
authorthomasmo <thomasmo@mozilla.com>
Tue, 14 May 2019 18:07:26 +0000
changeset 532715 af0fd51dc41a2c7e0271a932079ac4652d5f5b03
parent 532714 556e4f98beeb3442f8d588be05ae6afdaff44d13
child 532716 76bbedc1ec1ae367906390c01a8ca008d7944cac
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1550757
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1550757 - Create new DLL for sharing VR code r=kip This change introduces a new dll, vrhost, to make it easier to share VR code across multiple process. An executable, vrtesthost, is also added for testing purposes to validate the DLL loads in a minimal environment. Differential Revision: https://phabricator.services.mozilla.com/D30653
gfx/vr/moz.build
gfx/vr/vrhost/moz.build
gfx/vr/vrhost/testhost/moz.build
gfx/vr/vrhost/testhost/testhost.cpp
gfx/vr/vrhost/vrhost.cpp
gfx/vr/vrhost/vrhost.def
gfx/vr/vrhost/vrhostex.h
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
--- a/gfx/vr/moz.build
+++ b/gfx/vr/moz.build
@@ -64,16 +64,23 @@ SOURCES += [
 
 if CONFIG['OS_TARGET'] == 'Android':
     LOCAL_INCLUDES += ['/widget/android']
 else:
     DIRS += [
         'service',
     ]
 
+# Only target x64 for vrhost
+if CONFIG['OS_ARCH'] == 'WINNT':
+    if CONFIG['HAVE_64BIT_BUILD']:
+        DIRS += [
+            'vrhost'
+        ]
+
 IPDL_SOURCES = [
     'ipc/PVR.ipdl',
     'ipc/PVRGPU.ipdl',
     'ipc/PVRLayer.ipdl',
     'ipc/PVRManager.ipdl',
 ]
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/moz.build
@@ -0,0 +1,22 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+SOURCES += [
+  'vrhost.cpp'
+]
+
+EXPORTS.vrhost = [
+  'vrhostex.h'
+]
+
+DEFFILE = 'vrhost.def'
+
+DIRS += [
+  'testhost'
+]
+
+# Use SharedLibrary to generate the dll
+SharedLibrary('vrhost')
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/testhost/moz.build
@@ -0,0 +1,16 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+SOURCES += [
+  'testhost.cpp'
+]
+
+USE_LIBS += [
+  'vrhost'
+]
+
+# Use Progam to generate the executable
+Program('vrtesthost')
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/testhost/testhost.cpp
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <windows.h>
+#include "vrhost/vrhostex.h"
+
+int main() {
+  HINSTANCE hVR = ::LoadLibrary("vrhost.dll");
+  if (hVR != nullptr) {
+    PFN_SAMPLE lpfnSample = (PFN_SAMPLE)GetProcAddress(hVR, "SampleExport");
+    if (lpfnSample != nullptr) {
+      lpfnSample();
+    }
+
+    ::FreeLibrary(hVR);
+    hVR = nullptr;
+  }
+
+  return 0;
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/vrhost.cpp
@@ -0,0 +1,13 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// vrhost.cpp
+// Definition of functions that are exported from this dll
+
+#include "vrhostex.h"
+#include <stdio.h>
+
+void SampleExport() { printf("vrhost.cpp hello world"); }
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/vrhost.def
@@ -0,0 +1,7 @@
+;+# This Source Code Form is subject to the terms of the Mozilla Public
+;+# License, v. 2.0. If a copy of the MPL was not distributed with this
+;+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+LIBRARY        vrhost.dll
+
+EXPORTS        SampleExport      PRIVATE
new file mode 100644
--- /dev/null
+++ b/gfx/vr/vrhost/vrhostex.h
@@ -0,0 +1,14 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// vrhostex.h
+// This file declares the functions and their typedefs for functions exported
+// by vrhost.dll
+
+#pragma once
+
+// void SampleExport();
+typedef void (*PFN_SAMPLE)();
\ No newline at end of file
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3619,20 +3619,19 @@ bool Debugger::findSweepGroupEdges(JSRun
     }
 
     for (auto e = dbg->debuggeeZones.all(); !e.empty(); e.popFront()) {
       Zone* debuggeeZone = e.front();
       if (!debuggeeZone->isGCMarking()) {
         continue;
       }
 
-
       if (!debuggerZone->addSweepGroupEdgeTo(debuggeeZone) ||
           !debuggeeZone->addSweepGroupEdgeTo(debuggerZone)) {
-          return false;
+        return false;
       }
     }
   }
 
   return true;
 }
 
 const ClassOps Debugger::classOps_ = {nullptr, /* addProperty */
@@ -8915,18 +8914,17 @@ void ScriptedOnPopHandler::drop() {
   js_free(this);
 }
 
 void ScriptedOnPopHandler::trace(JSTracer* tracer) {
   TraceEdge(tracer, &object_, "OnStepHandlerFunction.object");
 }
 
 bool ScriptedOnPopHandler::onPop(JSContext* cx, HandleDebuggerFrame frame,
-                                 ResumeMode& resumeMode,
-                                 MutableHandleValue vp,
+                                 ResumeMode& resumeMode, MutableHandleValue vp,
                                  HandleSavedFrame exnStack) {
   Debugger* dbg = frame->owner();
 
   // Make it possible to distinguish 'return' from 'await' completions.
   // Bug 1470558 will investigate a more robust solution.
   bool isAfterAwait = false;
   AbstractFramePtr referent = DebuggerFrame::getReferent(frame);
   if (resumeMode == ResumeMode::Return && referent &&
@@ -9387,24 +9385,21 @@ static bool EvaluateInEnv(JSContext* cx,
     if (!script) {
       return false;
     }
   }
 
   return ExecuteKernel(cx, script, *env, NullValue(), frame, rval.address());
 }
 
-static bool DebuggerGenericEval(JSContext* cx,
-                                const mozilla::Range<const char16_t> chars,
-                                HandleObject bindings,
-                                const EvalOptions& options,
-                                ResumeMode& resumeMode,
-                                MutableHandleValue value,
-                                MutableHandleSavedFrame exnStack, Debugger* dbg,
-                                HandleObject envArg, FrameIter* iter) {
+static bool DebuggerGenericEval(
+    JSContext* cx, const mozilla::Range<const char16_t> chars,
+    HandleObject bindings, const EvalOptions& options, ResumeMode& resumeMode,
+    MutableHandleValue value, MutableHandleSavedFrame exnStack, Debugger* dbg,
+    HandleObject envArg, FrameIter* iter) {
   // Either we're specifying the frame, or a global.
   MOZ_ASSERT_IF(iter, !envArg);
   MOZ_ASSERT_IF(!iter, envArg && IsGlobalLexicalEnvironment(envArg));
 
   // Gather keys and values of bindings, if any. This must be done in the
   // debugger compartment, since that is where any exceptions must be thrown.
   RootedIdVector keys(cx);
   RootedValueVector values(cx);
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -1659,24 +1659,21 @@ class DebuggerObject : public NativeObje
   static MOZ_MUST_USE bool deleteProperty(JSContext* cx,
                                           HandleDebuggerObject object,
                                           HandleId id, ObjectOpResult& result);
   static MOZ_MUST_USE bool call(JSContext* cx, HandleDebuggerObject object,
                                 HandleValue thisv, Handle<ValueVector> args,
                                 MutableHandleValue result);
   static MOZ_MUST_USE bool forceLexicalInitializationByName(
       JSContext* cx, HandleDebuggerObject object, HandleId id, bool& result);
-  static MOZ_MUST_USE bool executeInGlobal(JSContext* cx,
-                                           HandleDebuggerObject object,
-                                           mozilla::Range<const char16_t> chars,
-                                           HandleObject bindings,
-                                           const EvalOptions& options,
-                                           ResumeMode& resumeMode,
-                                           MutableHandleValue value,
-                                           MutableHandleSavedFrame exnStack);
+  static MOZ_MUST_USE bool executeInGlobal(
+      JSContext* cx, HandleDebuggerObject object,
+      mozilla::Range<const char16_t> chars, HandleObject bindings,
+      const EvalOptions& options, ResumeMode& resumeMode,
+      MutableHandleValue value, MutableHandleSavedFrame exnStack);
   static MOZ_MUST_USE bool makeDebuggeeValue(JSContext* cx,
                                              HandleDebuggerObject object,
                                              HandleValue value,
                                              MutableHandleValue result);
   static MOZ_MUST_USE bool unsafeDereference(JSContext* cx,
                                              HandleDebuggerObject object,
                                              MutableHandleObject result);
   static MOZ_MUST_USE bool unwrap(JSContext* cx, HandleDebuggerObject object,