зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1499507 - Use AUTO_PROFILER_LABEL_DYNAMIC_FAST for WebIDL APIs. r=bzbarsky
This means that our binary does not need to include concatenated strings such as "set CanvasRenderingContext2D.fillStyle". It only needs to contain the individual strings "CanvasRenderingContext2D" and "fillStyle" which are most likely already present in the binary. This change reduces the binary size on macOS x64 by around 200KB. Here's a diff of the impact on the code generated for Attr_Binding::get_specified in the Mac build. This change makes us generate slightly more code, which is very much offset by the reduction in the amount of strings we ship. @@ -15,22 +15,23 @@ movl 0x10(%rbx), %r12d cmpl (%rbx), %r12d jae loc_xxxxx movq 0x8(%rbx), %rax movq %r12, %rcx shlq $0x5, %rcx - leaq aGetAttrspecifi, %rdx ; "get Attr.specified" + leaq aAttr, %rdx ; "Attr" movq %rdx, (%rax,%rcx) - movq $0x0, 0x8(%rax,%rcx) + leaq aSpecified, %rdx ; "specified" + movq %rdx, 0x8(%rax,%rcx) leaq -40(%rbp), %rdx movq %rdx, 0x10(%rax,%rcx) - movl $0x71, 0x1c(%rax,%rcx) + movl $0x3a1, 0x1c(%rax,%rcx) leal 0x1(%r12), %eax movl %eax, 0x10(%rbx) movq %r15, %rdi call __ZNK7mozilla3dom4Attr9SpecifiedEv ; mozilla::dom::Attr::Specified() const movzxl %al, %eax movabsq $0xfff9000000000000, %rcx orq %rax, %rcx Depends on D9204 Differential Revision: https://phabricator.services.mozilla.com/D9205 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
24f3fd501e
Коммит
b2c3ca5adb
|
@ -1586,12 +1586,6 @@ class CGAbstractMethod(CGThing):
|
|||
maybeNewline = " " if self.inline else "\n"
|
||||
return ' '.join(decorators) + maybeNewline
|
||||
|
||||
def _auto_profiler_label(self):
|
||||
profiler_label_and_jscontext = self.profiler_label_and_jscontext()
|
||||
if profiler_label_and_jscontext:
|
||||
return 'AUTO_PROFILER_LABEL_FAST("%s", DOM, %s);' % profiler_label_and_jscontext
|
||||
return None
|
||||
|
||||
def declare(self):
|
||||
if self.inline:
|
||||
return self._define(True)
|
||||
|
@ -1616,9 +1610,9 @@ class CGAbstractMethod(CGThing):
|
|||
def definition_prologue(self, fromDeclare):
|
||||
prologue = "%s%s%s(%s)\n{\n" % (self._template(), self._decorators(),
|
||||
self.name, self._argstring(fromDeclare))
|
||||
profiler_label = self._auto_profiler_label()
|
||||
profiler_label = self.auto_profiler_label()
|
||||
if profiler_label:
|
||||
prologue += " %s\n\n" % profiler_label
|
||||
prologue += indent(profiler_label) + "\n"
|
||||
|
||||
return prologue
|
||||
|
||||
|
@ -1632,7 +1626,7 @@ class CGAbstractMethod(CGThing):
|
|||
Override this method to return a pair of (descriptive string, name of a
|
||||
JSContext* variable) in order to generate a profiler label for this method.
|
||||
"""
|
||||
def profiler_label_and_jscontext(self):
|
||||
def auto_profiler_label(self):
|
||||
return None # Override me!
|
||||
|
||||
class CGAbstractStaticMethod(CGAbstractMethod):
|
||||
|
@ -1875,13 +1869,17 @@ class CGClassConstructor(CGAbstractStaticMethod):
|
|||
constructorName=ctorName)
|
||||
return preamble + "\n" + callGenerator.define()
|
||||
|
||||
def profiler_label_and_jscontext(self):
|
||||
def auto_profiler_label(self):
|
||||
name = self._ctor.identifier.name
|
||||
if name != "constructor":
|
||||
ctorName = name
|
||||
else:
|
||||
ctorName = self.descriptor.interface.identifier.name
|
||||
return ("%s constructor" % ctorName, "cx")
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST("${ctorName}", "constructor", DOM, cx, 0);
|
||||
""",
|
||||
ctorName=ctorName)
|
||||
|
||||
# Encapsulate the constructor in a helper method to share genConstructorBody with CGJSImplMethod.
|
||||
class CGConstructNavigatorObject(CGAbstractMethod):
|
||||
|
@ -8671,17 +8669,9 @@ class CGAbstractStaticBindingMethod(CGAbstractStaticMethod):
|
|||
""")
|
||||
return unwrap + self.generate_code().define()
|
||||
|
||||
def profiler_label_and_jscontext(self):
|
||||
# Our args are JSNativeArguments() which contain a "JSContext* cx"
|
||||
# argument. We let our subclasses choose the label.
|
||||
return (self.profiler_label(), "cx")
|
||||
|
||||
def generate_code(self):
|
||||
assert False # Override me
|
||||
|
||||
def profiler_label(self):
|
||||
assert False # Override me
|
||||
|
||||
|
||||
def MakeNativeName(name):
|
||||
return name[0].upper() + IDLToCIdentifier(name[1:])
|
||||
|
@ -8708,10 +8698,17 @@ class CGSpecializedMethod(CGAbstractStaticMethod):
|
|||
return CGMethodCall(nativeName, self.method.isStatic(), self.descriptor,
|
||||
self.method).define()
|
||||
|
||||
def profiler_label_and_jscontext(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
method_name = self.method.identifier.name
|
||||
return ("%s.%s" % (interface_name, method_name), "cx")
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${method_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
method_name=method_name)
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, method):
|
||||
|
@ -8968,10 +8965,17 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
|
|||
self.method)
|
||||
return CGMethodCall(nativeName, True, self.descriptor, self.method)
|
||||
|
||||
def profiler_label(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
method_name = self.method.identifier.name
|
||||
return "%s.%s" % (interface_name, method_name)
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${method_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
method_name=method_name)
|
||||
|
||||
|
||||
class CGSpecializedGetter(CGAbstractStaticMethod):
|
||||
|
@ -9075,10 +9079,17 @@ class CGSpecializedGetter(CGAbstractStaticMethod):
|
|||
cgGetterCall(self.attr.type, nativeName,
|
||||
self.descriptor, self.attr).define())
|
||||
|
||||
def profiler_label_and_jscontext(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
attr_name = self.attr.identifier.name
|
||||
return ("get %s.%s" % (interface_name, attr_name), "cx")
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${attr_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
attr_name=attr_name)
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, attr):
|
||||
|
@ -9138,10 +9149,17 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
|
|||
return CGGetterCall(self.attr.type, nativeName, self.descriptor,
|
||||
self.attr)
|
||||
|
||||
def profiler_label(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
attr_name = self.attr.identifier.name
|
||||
return "get %s.%s" % (interface_name, attr_name)
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${attr_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
attr_name=attr_name)
|
||||
|
||||
|
||||
class CGSpecializedSetter(CGAbstractStaticMethod):
|
||||
|
@ -9165,10 +9183,17 @@ class CGSpecializedSetter(CGAbstractStaticMethod):
|
|||
return CGSetterCall(self.attr.type, nativeName, self.descriptor,
|
||||
self.attr).define()
|
||||
|
||||
def profiler_label_and_jscontext(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
attr_name = self.attr.identifier.name
|
||||
return ("set %s.%s" % (interface_name, attr_name), "cx")
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${attr_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
attr_name=attr_name)
|
||||
|
||||
@staticmethod
|
||||
def makeNativeName(descriptor, attr):
|
||||
|
@ -9199,10 +9224,17 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
|
|||
self.attr)
|
||||
return CGList([checkForArg, call])
|
||||
|
||||
def profiler_label(self):
|
||||
def auto_profiler_label(self):
|
||||
interface_name = self.descriptor.interface.identifier.name
|
||||
attr_name = self.attr.identifier.name
|
||||
return "set %s.%s" % (interface_name, attr_name)
|
||||
return fill(
|
||||
"""
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
|
||||
"${interface_name}", "${attr_name}", DOM, cx,
|
||||
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER));
|
||||
""",
|
||||
interface_name=interface_name,
|
||||
attr_name=attr_name)
|
||||
|
||||
|
||||
class CGSpecializedForwardingSetter(CGSpecializedSetter):
|
||||
|
|
Загрузка…
Ссылка в новой задаче