gecko-dev/js/public
Markus Stange 42b0e9f253 Bug 1499507 - Allow the compiler to generate a non-atomic increment instruction for the stack pointer increment. r=njn
This change reduces the binary size on macOS x64 by around 50KB.

Here's a diff of the impact on the code generated for Attr_Binding::get_specified
in the Mac build. It's a bit hard to read because %r12 and %rbx swap their
function, but what happens in this method is that "movq       %r12, %rcx" goes
away, and the two instructions "leal       0x1(%r12) %eax" and
"movl       %eax, 0x10(%rbx)" turn into an "incl       0x10(%r12)".
So the old code was preserving the original value of profilingStack->stackPointer
in a register, and then using it later to compute the incremented stackPointer.
The new code uses an "incl" instruction for the stackPointer increment and
doesn't worry that the stackPointer value might have changed since the stack
size check at the start of the function. (It can't have changed.)

before: %rbx has the ProfilingStack*, %r12 has profilingStack->stackPointer
after: %r12 has the ProfilingStack*, %rbx has profilingStack->stackPointer

@@ -3,37 +3,35 @@
    movq       %rsp, %rbp
    pushq      %r15
    pushq      %r14
    pushq      %r12
    pushq      %rbx
    subq       $0x10, %rsp
    movq       %rcx, %r14
    movq       %rdx, %r15
-   movq       0x80(%rdi), %rbx
-   movq       %rbx, -40(%rbp)
-   testq      %rbx, %rbx
+   movq       0x80(%rdi), %r12
+   movq       %r12, -40(%rbp)
+   testq      %r12, %r12
    je         loc_xxxxx

-   movl       0x10(%rbx), %r12d
-   cmpl       (%rbx), %r12d
+   movl       0x10(%r12), %ebx
+   cmpl       (%r12), %ebx
    jae        loc_xxxxx

-   movq       0x8(%rbx), %rax
-   movq       %r12, %rcx
-   shlq       $0x5, %rcx
-   leaq       aAttr, %rdx                                 ; "Attr"
-   movq       %rdx, (%rax,%rcx)
-   leaq       aSpecified, %rdx                            ; "specified"
-   movq       %rdx, 0x8(%rax,%rcx)
-   leaq       -40(%rbp), %rdx
-   movq       %rdx, 0x10(%rax,%rcx)
-   movl       $0x3a1, 0x1c(%rax,%rcx)
-   leal       0x1(%r12), %eax
-   movl       %eax, 0x10(%rbx)
+   movq       0x8(%r12), %rax
+   shlq       $0x5, %rbx
+   leaq       aAttr, %rcx                                 ; "Attr"
+   movq       %rcx, (%rax,%rbx)
+   leaq       aSpecified, %rcx                            ; "specified"
+   movq       %rcx, 0x8(%rax,%rbx)
+   leaq       -40(%rbp), %rcx
+   movq       %rcx, 0x10(%rax,%rbx)
+   movl       $0x3a1, 0x1c(%rax,%rbx)
+   incl       0x10(%r12)

    movq       %r15, %rdi
    call       __ZNK7mozilla3dom4Attr9SpecifiedEv          ; mozilla::dom::Attr::Specified() const
    movzxl     %al, %eax
    movabsq    $0xfff9000000000000, %rcx
    orq        %rax, %rcx
    movq       %rcx, (%r14)
    movq       -40(%rbp), %rax
@@ -47,11 +45,11 @@
    popq       %rbx
    popq       %r12
    popq       %r14
    popq       %r15
    popq       %rbp
    ret
                         ; endp

-   movq       %rbx, %rdi
+   movq       %r12, %rdi
    call       __ZN14ProfilingStack18ensureCapacitySlowEv  ; ProfilingStack::ensureCapacitySlow()
    jmp        loc_xxxxx

Depends on D9205

Differential Revision: https://phabricator.services.mozilla.com/D9206

--HG--
extra : moz-landing-system : lando
2018-11-06 04:35:13 +00:00
..
AllocPolicy.h Backed out changeset bee1c344cb47 (bug 1491909) for failures in browser/components/extensions/test/xpcshell/test_ext_geckoProfiler_control.js 2018-10-24 04:23:13 +03:00
CallArgs.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
CallNonGenericMethod.h Bug 1489242 - Add {} to example code in comments. r=jorendorff 2018-10-03 14:41:29 +00:00
CharacterEncoding.h Bug 1490609: Add JS_EncodeStringToASCII to CharacterEncoding.h. r=Waldo 2018-09-13 01:34:06 -07:00
Class.h Bug 1489242 - Add {} to example code in comments. r=jorendorff 2018-10-03 14:41:29 +00:00
CompilationAndEvaluation.h Bug 1491137 - Rename JS::CompileFunction that takes const char*/size_t for function text to JS::CompileFunctionUtf8 that asserts consistent |options.utf8|. r=jandem 2018-09-17 11:24:41 -07:00
CompileOptions.h Bug 1491137 - Remove the two setUTF8(bool) CompileOptions functions now that the underlying field they alter is gone. r=jandem 2018-09-18 08:41:41 -07:00
Conversions.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
Date.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
Debug.h Bug 1489242 - Add {} to example code in comments. r=jorendorff 2018-10-03 14:41:29 +00:00
ErrorReport.h Bug 1484385 - Move various error-report-related structures and types into js/public/ErrorReport.h to minimize dependencies (and ultimately to make jsfriendapi.h not depend on jsapi.h). r=jandem 2018-08-20 07:45:44 -07:00
GCAnnotations.h Bug 1479961 - Synthesize call edges from Interpret and EnterJit to all JSNatives, r=jonco 2018-07-24 11:53:42 -07:00
GCAPI.h Bug 1502819 - Number the GC Reason and AbortReason enum items r=jonco 2018-10-29 21:23:57 +11:00
GCHashTable.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
GCPolicyAPI.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
GCVariant.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
GCVector.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
HashTable.h Bug 1477626 - Move js::Hash{Set,Map} into MFBT. r=Waldo 2018-07-26 20:15:49 +10:00
HeapAPI.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
Id.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
Initialization.h bug 1366287 - Part 2.1: Track GMP memory allocation from XPCOM. r=njn 2018-05-11 19:42:49 -07:00
JSON.h Bug 1484421 - Move JSON-related functionality into js/public/JSON.h that isn't #include'd in jsapi.h. r=jandem 2018-08-20 07:54:45 -07:00
LocaleSensitive.h Bug 1484420 - Move locale-related functions into js/public/LocaleSensitive.h that isn't #include'd in jsapi.h. r=anba 2018-08-20 17:11:32 -05:00
MemoryFunctions.h Bug 1484386 - Move various memory-allocation-related functions into js/public/MemoryFunctions.h to (ultimately) minimize dependencies required to use these functions in forthcoming public headers. r=jandem 2018-08-20 07:45:44 -07:00
MemoryMetrics.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
OffThreadScriptCompilation.h Backed out changeset ba122021b8b5 (bug 1481196) 2018-10-04 11:50:55 +01:00
Principals.h Bug 1207696 Part 4e - Don't record various JS atomics, r=jandem. 2018-07-21 14:24:16 +00:00
Printf.h
ProfilingFrameIterator.h Bug 1426124 - Discard JIT frames from native stacks in the profiler; r=jandem,mstange 2018-04-25 10:08:38 -05:00
ProfilingStack.h Bug 1499507 - Allow the compiler to generate a non-atomic increment instruction for the stack pointer increment. r=njn 2018-11-06 04:35:13 +00:00
ProtoKey.h Bug 1385890 - Fix Streams implementation in multiple-global uses. r=baku,tcampbell,jorendorff 2018-10-11 14:18:43 -05:00
Proxy.h Bug 1503994 - Fixup js Proxy doc comments r=jandem 2018-11-05 09:09:45 +00:00
Realm.h Backed out changeset ba122021b8b5 (bug 1481196) 2018-10-04 11:50:55 +01:00
RefCounted.h Bug 1480012 - Generalize JS shell mailbox to Wasm memories and modules. r=luke 2018-08-01 13:21:06 +02:00
RequiredDefines.h
Result.h Bug 1471272 - Add [SMDOC] tags for in-source documentation. r=jandem,nbp 2018-06-28 15:23:25 -04:00
RootingAPI.h Bug 1499507 - Fold the 'profiler is active' check into the 'JSContext has a non-null PseudoStack' check. r=sfink 2018-11-06 04:29:35 +00:00
SavedFrameAPI.h Bug 1484389 - Move various SavedFrame-related functions and data types into js/public/SavedFrameAPI.h so that users aren't forced to depend on jsapi.h or jsfriendapi.h for them. r=jandem 2018-08-20 07:45:44 -07:00
SliceBudget.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
SourceBufferHolder.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
StableStringChars.h Bug 1321014 - Respect MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS for the purpose of identifying GC types and pointers, r=jonco 2018-07-20 18:36:20 -07:00
Stream.h Bug 1501387 - Handlify Streams.h and avoid using const JSObject*. r=tcampbell 2018-10-23 19:02:04 +00:00
StructuredClone.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
SweepingAPI.h Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj 2018-06-02 09:33:26 +02:00
TraceKind.h Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj 2018-06-02 09:33:26 +02:00
TraceLoggerAPI.h Bug 1497018 - Use mozilla::TimeStamp for tracelogger timing r=sfink 2018-11-01 17:56:51 +00:00
TracingAPI.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
TrackedOptimizationInfo.h Bug 1480524 - [Part 2] Remove Ion NewObject stub, and remove limitation on template object dynamic slots for fast path r=jandem 2018-08-07 10:12:59 -04:00
Transcoding.h Bug 1486577 - Move script/function transcoding API into a new public js/Transcoding.h header. r=jandem 2018-08-24 14:44:04 -05:00
TypeDecls.h Bug 1466121 part 2 - Make Compartment and Zone classes instead of structs. r=luke 2018-06-07 16:45:04 +02:00
UbiNode.h Bug 1489242 - Add {} to example code in comments. r=jorendorff 2018-10-03 14:41:29 +00:00
UbiNodeBreadthFirst.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
UbiNodeCensus.h Bug 1481998 - Make mozilla::Hash{Map,Set}'s entry storage allocation lazy. r=luke,sfink 2018-08-10 18:00:29 +10:00
UbiNodeDominatorTree.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
UbiNodePostOrder.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
UbiNodeShortestPaths.h Bug 1488698 - Always use braces for if/for/while statements in js/public. r=jandem 2018-09-06 12:11:07 +02:00
UbiNodeUtils.h Bug 1474383 - JSRuntime hook to construct ubi::Nodes specialized for nsINode instances. r=sfink,jimb,bz 2018-07-06 16:52:42 -07:00
UniquePtr.h Bug 1466168: Remove mozilla::Forward in favor of std::forward. r=froydnj 2018-06-02 09:33:26 +02:00
Utility.h Bug 1321014 - Respect MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS for the purpose of identifying GC types and pointers, r=jonco 2018-07-20 18:36:20 -07:00
Value.h Bug 1321014 - Respect MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS for the purpose of identifying GC types and pointers, r=jonco 2018-07-20 18:36:20 -07:00
Vector.h Bug 1442587 - Part 4: Ban js::Vector<Value>. r=sfink 2018-08-30 15:30:50 -05:00
WeakMapPtr.h
Wrapper.h Bug 1468752 part 2 - Define Wrapper::wrapperHandler in Wrapper.h. r=bz 2018-07-06 12:53:38 +02:00