js/src/jit/x64/Architecture-x64.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef jit_x64_Architecture_x64_h
     8 #define jit_x64_Architecture_x64_h
    10 #include "assembler/assembler/MacroAssembler.h"
    12 namespace js {
    13 namespace jit {
    15 // In bytes: slots needed for potential memory->memory move spills.
    16 //   +8 for cycles
    17 //   +8 for gpr spills
    18 //   +8 for double spills
    19 static const uint32_t ION_FRAME_SLACK_SIZE     = 24;
    21 #ifdef _WIN64
    22 static const uint32_t ShadowStackSpace = 32;
    23 #else
    24 static const uint32_t ShadowStackSpace = 0;
    25 #endif
    27 class Registers {
    28   public:
    29     typedef JSC::X86Registers::RegisterID Code;
    31     static const char *GetName(Code code) {
    32         static const char * const Names[] = { "rax", "rcx", "rdx", "rbx",
    33                                               "rsp", "rbp", "rsi", "rdi",
    34                                               "r8",  "r9",  "r10", "r11",
    35                                               "r12", "r13", "r14", "r15" };
    36         return Names[code];
    37     }
    39     static Code FromName(const char *name) {
    40         for (size_t i = 0; i < Total; i++) {
    41             if (strcmp(GetName(Code(i)), name) == 0)
    42                 return Code(i);
    43         }
    44         return Invalid;
    45     }
    47     static const Code StackPointer = JSC::X86Registers::esp;
    48     static const Code Invalid = JSC::X86Registers::invalid_reg;
    50     static const uint32_t Total = 16;
    51     static const uint32_t Allocatable = 14;
    53     static const uint32_t AllMask = (1 << Total) - 1;
    55     static const uint32_t ArgRegMask =
    56 # if !defined(_WIN64)
    57         (1 << JSC::X86Registers::edi) |
    58         (1 << JSC::X86Registers::esi) |
    59 # endif
    60         (1 << JSC::X86Registers::edx) |
    61         (1 << JSC::X86Registers::ecx) |
    62         (1 << JSC::X86Registers::r8) |
    63         (1 << JSC::X86Registers::r9);
    65     static const uint32_t VolatileMask =
    66         (1 << JSC::X86Registers::eax) |
    67         (1 << JSC::X86Registers::ecx) |
    68         (1 << JSC::X86Registers::edx) |
    69 # if !defined(_WIN64)
    70         (1 << JSC::X86Registers::esi) |
    71         (1 << JSC::X86Registers::edi) |
    72 # endif
    73         (1 << JSC::X86Registers::r8) |
    74         (1 << JSC::X86Registers::r9) |
    75         (1 << JSC::X86Registers::r10) |
    76         (1 << JSC::X86Registers::r11);
    78     static const uint32_t NonVolatileMask =
    79         (1 << JSC::X86Registers::ebx) |
    80 #if defined(_WIN64)
    81         (1 << JSC::X86Registers::esi) |
    82         (1 << JSC::X86Registers::edi) |
    83 #endif
    84         (1 << JSC::X86Registers::ebp) |
    85         (1 << JSC::X86Registers::r12) |
    86         (1 << JSC::X86Registers::r13) |
    87         (1 << JSC::X86Registers::r14) |
    88         (1 << JSC::X86Registers::r15);
    90     static const uint32_t WrapperMask = VolatileMask;
    92     static const uint32_t SingleByteRegs = VolatileMask | NonVolatileMask;
    94     static const uint32_t NonAllocatableMask =
    95         (1 << JSC::X86Registers::esp) |
    96         (1 << JSC::X86Registers::r11);      // This is ScratchReg.
    98     // Registers that can be allocated without being saved, generally.
    99     static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
   101     static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
   103     // Registers returned from a JS -> JS call.
   104     static const uint32_t JSCallMask =
   105         (1 << JSC::X86Registers::ecx);
   107     // Registers returned from a JS -> C call.
   108     static const uint32_t CallMask =
   109         (1 << JSC::X86Registers::eax);
   110 };
   112 // Smallest integer type that can hold a register bitmask.
   113 typedef uint16_t PackedRegisterMask;
   115 class FloatRegisters {
   116   public:
   117     typedef JSC::X86Registers::XMMRegisterID Code;
   119     static const char *GetName(Code code) {
   120         static const char * const Names[] = { "xmm0",  "xmm1",  "xmm2",  "xmm3",
   121                                               "xmm4",  "xmm5",  "xmm6",  "xmm7",
   122                                               "xmm8",  "xmm9",  "xmm10", "xmm11",
   123                                               "xmm12", "xmm13", "xmm14", "xmm15" };
   124         return Names[code];
   125     }
   127     static Code FromName(const char *name) {
   128         for (size_t i = 0; i < Total; i++) {
   129             if (strcmp(GetName(Code(i)), name) == 0)
   130                 return Code(i);
   131         }
   132         return Invalid;
   133     }
   135     static const Code Invalid = JSC::X86Registers::invalid_xmm;
   137     static const uint32_t Total = 16;
   138     static const uint32_t Allocatable = 15;
   140     static const uint32_t AllMask = (1 << Total) - 1;
   142     static const uint32_t VolatileMask =
   143 #if defined(_WIN64)
   144         (1 << JSC::X86Registers::xmm0) |
   145         (1 << JSC::X86Registers::xmm1) |
   146         (1 << JSC::X86Registers::xmm2) |
   147         (1 << JSC::X86Registers::xmm3) |
   148         (1 << JSC::X86Registers::xmm4) |
   149         (1 << JSC::X86Registers::xmm5);
   150 #else
   151         AllMask;
   152 #endif
   154     static const uint32_t NonVolatileMask = AllMask & ~VolatileMask;
   156     static const uint32_t WrapperMask = VolatileMask;
   158     static const uint32_t NonAllocatableMask =
   159         (1 << JSC::X86Registers::xmm15);    // This is ScratchFloatReg.
   161     static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
   162 };
   164 } // namespace jit
   165 } // namespace js
   167 #endif /* jit_x64_Architecture_x64_h */

mercurial