Bug 1550757 - Create new DLL for sharing VR code r=kip
authorthomasmo <thomasmo@mozilla.com>
Fri, 17 May 2019 04:53:16 +0000
changeset 474297 83a094f31fb025b5cb6b196003708b746f0591b6
parent 474296 a056128cc98626d1e89fdb681a39ee5ce4801a1f
child 474298 f41aae1abbbaaddf29087d312cb91fa25578b45b
push id36027
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:24:38 +0000
treeherdermozilla-central@c94c54aff466 [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 since WebVR is only supported on 64bit.
+# Also, only use MSVC compiler for Windows-specific linking
+if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['HAVE_64BIT_BUILD'] and CONFIG['CC_TYPE'] not in ('clang', 'gcc'):
+    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
@@ -3611,20 +3611,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 */
@@ -8907,18 +8906,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 &&
@@ -9379,24 +9377,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,