Bug 1528296 - remove unused function call r=vporof
authoryulia <ystartsev@mozilla.com>
Wed, 13 Mar 2019 16:52:10 +0000
changeset 521744 f87bb852e074
parent 521743 b7cc6eee1f24
child 521745 be6699d71bec
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof
bugs1528296
milestone67.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 1528296 - remove unused function call r=vporof Differential Revision: https://phabricator.services.mozilla.com/D22497
devtools/server/actors/utils/function-call.js
devtools/server/actors/utils/moz.build
devtools/shared/fronts/function-call.js
devtools/shared/fronts/moz.build
devtools/shared/specs/function-call.js
devtools/shared/specs/index.js
devtools/shared/specs/moz.build
deleted file mode 100644
--- a/devtools/server/actors/utils/function-call.js
+++ /dev/null
@@ -1,279 +0,0 @@
-/* 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/. */
-"use strict";
-
-const {Cu} = require("chrome");
-const protocol = require("devtools/shared/protocol");
-
-const { functionCallSpec } = require("devtools/shared/specs/function-call");
-const { KNOWN_METHODS } = require("devtools/shared/fronts/function-call");
-
-/**
- * This actor contains information about a function call, like the function
- * type, name, stack, arguments, returned value etc.
- */
-exports.FunctionCallActor = protocol.ActorClassWithSpec(functionCallSpec, {
-  /**
-   * Creates the function call actor.
-   *
-   * @param DebuggerServerConnection conn
-   *        The server connection.
-   * @param DOMWindow window
-   *        The content window.
-   * @param string global
-   *        The name of the global object owning this function, like
-   *        "CanvasRenderingContext2D" or "WebGLRenderingContext".
-   * @param object caller
-   *        The object owning the function when it was called.
-   *        For example, in `foo.bar()`, the caller is `foo`.
-   * @param number type
-   *        Either METHOD_FUNCTION, METHOD_GETTER or METHOD_SETTER.
-   * @param string name
-   *        The called function's name.
-   * @param array stack
-   *        The called function's stack, as a list of { name, file, line } objects.
-   * @param number timestamp
-   *        The performance.now() timestamp when the function was called.
-   * @param array args
-   *        The called function's arguments.
-   * @param any result
-   *        The value returned by the function call.
-   * @param boolean holdWeak
-   *        Determines whether or not FunctionCallActor stores a weak reference
-   *        to the underlying objects.
-   */
-  initialize: function(
-    conn,
-    [window, global, caller, type, name, stack, timestamp, args, result],
-    holdWeak
-  ) {
-    protocol.Actor.prototype.initialize.call(this, conn);
-
-    this.details = {
-      global: global,
-      type: type,
-      name: name,
-      stack: stack,
-      timestamp: timestamp,
-    };
-
-    // Store a weak reference to all objects so we don't
-    // prevent natural GC if `holdWeak` was passed into
-    // setup as truthy.
-    if (holdWeak) {
-      const weakRefs = {
-        window: Cu.getWeakReference(window),
-        caller: Cu.getWeakReference(caller),
-        args: Cu.getWeakReference(args),
-        result: Cu.getWeakReference(result),
-      };
-
-      Object.defineProperties(this.details, {
-        window: { get: () => weakRefs.window.get() },
-        caller: { get: () => weakRefs.caller.get() },
-        args: { get: () => weakRefs.args.get() },
-        result: { get: () => weakRefs.result.get() },
-      });
-    } else {
-      // Otherwise, hold strong references to the objects.
-      this.details.window = window;
-      this.details.caller = caller;
-      this.details.args = args;
-      this.details.result = result;
-    }
-
-    // The caller, args and results are string names for now. It would
-    // certainly be nicer if they were Object actors. Make this smarter, so
-    // that the frontend can inspect each argument, be it object or primitive.
-    // Bug 978960.
-    this.details.previews = {
-      caller: this._generateStringPreview(caller),
-      args: this._generateArgsPreview(args),
-      result: this._generateStringPreview(result),
-    };
-  },
-
-  /**
-   * Customize the marshalling of this actor to provide some generic information
-   * directly on the Front instance.
-   */
-  form: function() {
-    return {
-      actor: this.actorID,
-      type: this.details.type,
-      name: this.details.name,
-      file: this.details.stack[0].file,
-      line: this.details.stack[0].line,
-      timestamp: this.details.timestamp,
-      callerPreview: this.details.previews.caller,
-      argsPreview: this.details.previews.args,
-      resultPreview: this.details.previews.result,
-    };
-  },
-
-  /**
-   * Gets more information about this function call, which is not necessarily
-   * available on the Front instance.
-   */
-  getDetails: function() {
-    const { type, name, stack, timestamp } = this.details;
-
-    // Since not all calls on the stack have corresponding owner files (e.g.
-    // callbacks of a requestAnimationFrame etc.), there's no benefit in
-    // returning them, as the user can't jump to the Debugger from them.
-    for (let i = stack.length - 1; ;) {
-      if (stack[i].file) {
-        break;
-      }
-      stack.pop();
-      i--;
-    }
-
-    // XXX: Use grips for objects and serialize them properly, in order
-    // to add the function's caller, arguments and return value. Bug 978957.
-    return {
-      type: type,
-      name: name,
-      stack: stack,
-      timestamp: timestamp,
-    };
-  },
-
-  /**
-   * Serializes the arguments so that they can be easily be transferred
-   * as a string, but still be useful when displayed in a potential UI.
-   *
-   * @param array args
-   *        The source arguments.
-   * @return string
-   *         The arguments as a string.
-   */
-  _generateArgsPreview: function(args) {
-    const { global, name, caller } = this.details;
-
-    // Get method signature to determine if there are any enums
-    // used in this method.
-    let methodSignatureEnums;
-
-    const knownGlobal = KNOWN_METHODS[global];
-    if (knownGlobal) {
-      const knownMethod = knownGlobal[name];
-      if (knownMethod) {
-        const isOverloaded = typeof knownMethod.enums === "function";
-        if (isOverloaded) {
-          methodSignatureEnums = knownMethod.enums(args);
-        } else {
-          methodSignatureEnums = knownMethod.enums;
-        }
-      }
-    }
-
-    const serializeArgs = () => args.map((arg, i) => {
-      // XXX: Bug 978960.
-      if (arg === undefined) {
-        return "undefined";
-      }
-      if (arg === null) {
-        return "null";
-      }
-      if (typeof arg == "function") {
-        return "Function";
-      }
-      if (typeof arg == "object") {
-        return "Object";
-      }
-      // If this argument matches the method's signature
-      // and is an enum, change it to its constant name.
-      if (methodSignatureEnums && methodSignatureEnums.has(i)) {
-        return getBitToEnumValue(global, caller, arg);
-      }
-      return arg + "";
-    });
-
-    return serializeArgs().join(", ");
-  },
-
-  /**
-   * Serializes the data so that it can be easily be transferred
-   * as a string, but still be useful when displayed in a potential UI.
-   *
-   * @param object data
-   *        The source data.
-   * @return string
-   *         The arguments as a string.
-   */
-  _generateStringPreview: function(data) {
-    // XXX: Bug 978960.
-    if (data === undefined) {
-      return "undefined";
-    }
-    if (data === null) {
-      return "null";
-    }
-    if (typeof data == "function") {
-      return "Function";
-    }
-    if (typeof data == "object") {
-      return "Object";
-    }
-    return data + "";
-  },
-});
-
-/**
- * A lookup table for cross-referencing flags or properties with their name
- * assuming they look LIKE_THIS most of the time.
- *
- * For example, when gl.clear(gl.COLOR_BUFFER_BIT) is called, the actual passed
- * argument's value is 16384, which we want identified as "COLOR_BUFFER_BIT".
- */
-var gEnumRegex = /^[A-Z][A-Z0-9_]+$/;
-var gEnumsLookupTable = {};
-
-// These values are returned from errors, or empty values,
-// and need to be ignored when checking arguments due to the bitwise math.
-var INVALID_ENUMS = [
-  "INVALID_ENUM", "NO_ERROR", "INVALID_VALUE", "OUT_OF_MEMORY", "NONE",
-];
-
-function getBitToEnumValue(type, object, arg) {
-  let table = gEnumsLookupTable[type];
-
-  // If mapping not yet created, do it on the first run.
-  if (!table) {
-    table = gEnumsLookupTable[type] = {};
-
-    for (const key in object) {
-      if (key.match(gEnumRegex)) {
-        // Maps `16384` to `"COLOR_BUFFER_BIT"`, etc.
-        table[object[key]] = key;
-      }
-    }
-  }
-
-  // If a single bit value, just return it.
-  if (table[arg]) {
-    return table[arg];
-  }
-
-  // Otherwise, attempt to reduce it to the original bit flags:
-  // `16640` -> "COLOR_BUFFER_BIT | DEPTH_BUFFER_BIT"
-  const flags = [];
-  for (let flag in table) {
-    if (INVALID_ENUMS.includes(table[flag])) {
-      continue;
-    }
-
-    // Cast to integer as all values are stored as strings
-    // in `table`
-    flag = flag | 0;
-    if (flag && (arg & flag) === flag) {
-      flags.push(table[flag]);
-    }
-  }
-
-  // Cache the combined bitmask value
-  table[arg] = flags.join(" | ") || arg;
-  return table[arg];
-}
--- a/devtools/server/actors/utils/moz.build
+++ b/devtools/server/actors/utils/moz.build
@@ -9,16 +9,15 @@ DevToolsModules(
     'actor-registry-utils.js',
     'actor-registry.js',
     'breakpoint-actor-map.js',
     'closest-scripts.js',
     'css-grid-utils.js',
     'dbg-source.js',
     'event-breakpoints.js',
     'event-loop.js',
-    'function-call.js',
     'make-debugger.js',
     'shapes-utils.js',
     'stack.js',
     'TabSources.js',
     'track-change-emitter.js',
     'walker-search.js',
 )
deleted file mode 100644
--- a/devtools/shared/fronts/function-call.js
+++ /dev/null
@@ -1,208 +0,0 @@
-/* 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/. */
-"use strict";
-
-const { functionCallSpec } = require("devtools/shared/specs/function-call");
-const { FrontClassWithSpec, registerFront } = require("devtools/shared/protocol");
-
-/**
- * The corresponding Front object for the FunctionCallActor.
- */
-class FunctionCallFront extends FrontClassWithSpec(functionCallSpec) {
-  /**
-   * Adds some generic information directly to this instance,
-   * to avoid extra roundtrips.
-   */
-  form(form) {
-    this.actorID = form.actor;
-    this.type = form.type;
-    this.name = form.name;
-    this.file = form.file;
-    this.line = form.line;
-    this.timestamp = form.timestamp;
-    this.callerPreview = form.callerPreview;
-    this.argsPreview = form.argsPreview;
-    this.resultPreview = form.resultPreview;
-  }
-}
-
-exports.FunctionCallFront = FunctionCallFront;
-registerFront(FunctionCallFront);
-
-/**
- * Constants.
- */
-exports.METHOD_FUNCTION = 0;
-exports.GETTER_FUNCTION = 1;
-exports.SETTER_FUNCTION = 2;
-
-const CanvasRenderingContext2D = {
-  drawWindow: {
-    enums: new Set([6]),
-  },
-};
-
-const WebGLRenderingContext = {
-  activeTexture: {
-    enums: new Set([0]),
-  },
-  bindBuffer: {
-    enums: new Set([0]),
-  },
-  bindFramebuffer: {
-    enums: new Set([0]),
-  },
-  bindRenderbuffer: {
-    enums: new Set([0]),
-  },
-  bindTexture: {
-    enums: new Set([0]),
-  },
-  blendEquation: {
-    enums: new Set([0]),
-  },
-  blendEquationSeparate: {
-    enums: new Set([0, 1]),
-  },
-  blendFunc: {
-    enums: new Set([0, 1]),
-  },
-  blendFuncSeparate: {
-    enums: new Set([0, 1, 2, 3]),
-  },
-  bufferData: {
-    enums: new Set([0, 1, 2]),
-  },
-  bufferSubData: {
-    enums: new Set([0, 1]),
-  },
-  checkFramebufferStatus: {
-    enums: new Set([0]),
-  },
-  clear: {
-    enums: new Set([0]),
-  },
-  compressedTexImage2D: {
-    enums: new Set([0, 2]),
-  },
-  compressedTexSubImage2D: {
-    enums: new Set([0, 6]),
-  },
-  copyTexImage2D: {
-    enums: new Set([0, 2]),
-  },
-  copyTexSubImage2D: {
-    enums: new Set([0]),
-  },
-  createShader: {
-    enums: new Set([0]),
-  },
-  cullFace: {
-    enums: new Set([0]),
-  },
-  depthFunc: {
-    enums: new Set([0]),
-  },
-  disable: {
-    enums: new Set([0]),
-  },
-  drawArrays: {
-    enums: new Set([0]),
-  },
-  drawElements: {
-    enums: new Set([0, 2]),
-  },
-  enable: {
-    enums: new Set([0]),
-  },
-  framebufferRenderbuffer: {
-    enums: new Set([0, 1, 2]),
-  },
-  framebufferTexture2D: {
-    enums: new Set([0, 1, 2]),
-  },
-  frontFace: {
-    enums: new Set([0]),
-  },
-  generateMipmap: {
-    enums: new Set([0]),
-  },
-  getBufferParameter: {
-    enums: new Set([0, 1]),
-  },
-  getParameter: {
-    enums: new Set([0]),
-  },
-  getFramebufferAttachmentParameter: {
-    enums: new Set([0, 1, 2]),
-  },
-  getProgramParameter: {
-    enums: new Set([1]),
-  },
-  getRenderbufferParameter: {
-    enums: new Set([0, 1]),
-  },
-  getShaderParameter: {
-    enums: new Set([1]),
-  },
-  getShaderPrecisionFormat: {
-    enums: new Set([0, 1]),
-  },
-  getTexParameter: {
-    enums: new Set([0, 1]),
-  },
-  getVertexAttrib: {
-    enums: new Set([1]),
-  },
-  getVertexAttribOffset: {
-    enums: new Set([1]),
-  },
-  hint: {
-    enums: new Set([0, 1]),
-  },
-  isEnabled: {
-    enums: new Set([0]),
-  },
-  pixelStorei: {
-    enums: new Set([0]),
-  },
-  readPixels: {
-    enums: new Set([4, 5]),
-  },
-  renderbufferStorage: {
-    enums: new Set([0, 1]),
-  },
-  stencilFunc: {
-    enums: new Set([0]),
-  },
-  stencilFuncSeparate: {
-    enums: new Set([0, 1]),
-  },
-  stencilMaskSeparate: {
-    enums: new Set([0]),
-  },
-  stencilOp: {
-    enums: new Set([0, 1, 2]),
-  },
-  stencilOpSeparate: {
-    enums: new Set([0, 1, 2, 3]),
-  },
-  texImage2D: {
-    enums: args => args.length > 6 ? new Set([0, 2, 6, 7]) : new Set([0, 2, 3, 4]),
-  },
-  texParameterf: {
-    enums: new Set([0, 1]),
-  },
-  texParameteri: {
-    enums: new Set([0, 1, 2]),
-  },
-  texSubImage2D: {
-    enums: args => args.length === 9 ? new Set([0, 6, 7]) : new Set([0, 4, 5]),
-  },
-  vertexAttribPointer: {
-    enums: new Set([2]),
-  },
-};
-
-exports.KNOWN_METHODS = { CanvasRenderingContext2D, WebGLRenderingContext };
--- a/devtools/shared/fronts/moz.build
+++ b/devtools/shared/fronts/moz.build
@@ -16,17 +16,16 @@ DevToolsModules(
     'actor-registry.js',
     'animation.js',
     'changes.js',
     'css-properties.js',
     'csscoverage.js',
     'device.js',
     'emulation.js',
     'framerate.js',
-    'function-call.js',
     'highlighters.js',
     'inspector.js',
     'layout.js',
     'memory.js',
     'node.js',
     'perf.js',
     'performance-recording.js',
     'performance.js',
deleted file mode 100644
--- a/devtools/shared/specs/function-call.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/* 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/. */
-"use strict";
-
-const protocol = require("devtools/shared/protocol");
-const { RetVal, generateActorSpec } = protocol;
-
-/**
- * Type describing a single function call in a stack trace.
- */
-protocol.types.addDictType("call-stack-item", {
-  name: "string",
-  file: "string",
-  line: "number",
-});
-
-/**
- * Type describing an overview of a function call.
- */
-protocol.types.addDictType("call-details", {
-  type: "number",
-  name: "string",
-  stack: "array:call-stack-item",
-});
-
-const functionCallSpec = generateActorSpec({
-  typeName: "function-call",
-
-  methods: {
-    getDetails: {
-      response: { info: RetVal("call-details") },
-    },
-  },
-});
-
-exports.functionCallSpec = functionCallSpec;
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -79,21 +79,16 @@ const Types = exports.__TypesForTests = 
     spec: "devtools/shared/specs/frame",
     front: null,
   },
   {
     types: ["framerate"],
     spec: "devtools/shared/specs/framerate",
     front: "devtools/shared/fronts/framerate",
   },
-  {
-    types: ["function-call"],
-    spec: "devtools/shared/specs/function-call",
-    front: "devtools/shared/fronts/function-call",
-  },
   /* heap snapshot has old fashion client and no front */
   {
     types: ["heapSnapshotFile"],
     spec: "devtools/shared/specs/heap-snapshot-file",
     front: null,
   },
   {
     types: ["highlighter", "customhighlighter"],
--- a/devtools/shared/specs/moz.build
+++ b/devtools/shared/specs/moz.build
@@ -17,17 +17,16 @@ DevToolsModules(
     'changes.js',
     'css-properties.js',
     'csscoverage.js',
     'device.js',
     'emulation.js',
     'environment.js',
     'frame.js',
     'framerate.js',
-    'function-call.js',
     'heap-snapshot-file.js',
     'highlighters.js',
     'index.js',
     'inspector.js',
     'layout.js',
     'memory.js',
     'network-event.js',
     'network-monitor.js',