js/src/jit/x86/Architecture-x86.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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_x86_Architecture_x86_h
michael@0 8 #define jit_x86_Architecture_x86_h
michael@0 9
michael@0 10 #include "assembler/assembler/MacroAssembler.h"
michael@0 11
michael@0 12 namespace js {
michael@0 13 namespace jit {
michael@0 14
michael@0 15 // In bytes: slots needed for potential memory->memory move spills.
michael@0 16 // +8 for cycles
michael@0 17 // +4 for gpr spills
michael@0 18 // +8 for double spills
michael@0 19 static const uint32_t ION_FRAME_SLACK_SIZE = 20;
michael@0 20
michael@0 21 // Only Win64 requires shadow stack space.
michael@0 22 static const uint32_t ShadowStackSpace = 0;
michael@0 23
michael@0 24 // These offsets are specific to nunboxing, and capture offsets into the
michael@0 25 // components of a js::Value.
michael@0 26 static const int32_t NUNBOX32_TYPE_OFFSET = 4;
michael@0 27 static const int32_t NUNBOX32_PAYLOAD_OFFSET = 0;
michael@0 28
michael@0 29 ////
michael@0 30 // These offsets are related to bailouts.
michael@0 31 ////
michael@0 32
michael@0 33 // Size of each bailout table entry. On x86 this is a 5-byte relative call.
michael@0 34 static const uint32_t BAILOUT_TABLE_ENTRY_SIZE = 5;
michael@0 35
michael@0 36 class Registers {
michael@0 37 public:
michael@0 38 typedef JSC::X86Registers::RegisterID Code;
michael@0 39
michael@0 40 static const char *GetName(Code code) {
michael@0 41 static const char * const Names[] = { "eax", "ecx", "edx", "ebx",
michael@0 42 "esp", "ebp", "esi", "edi" };
michael@0 43 return Names[code];
michael@0 44 }
michael@0 45
michael@0 46 static Code FromName(const char *name) {
michael@0 47 for (size_t i = 0; i < Total; i++) {
michael@0 48 if (strcmp(GetName(Code(i)), name) == 0)
michael@0 49 return Code(i);
michael@0 50 }
michael@0 51 return Invalid;
michael@0 52 }
michael@0 53
michael@0 54 static const Code StackPointer = JSC::X86Registers::esp;
michael@0 55 static const Code Invalid = JSC::X86Registers::invalid_reg;
michael@0 56
michael@0 57 static const uint32_t Total = 8;
michael@0 58 static const uint32_t Allocatable = 7;
michael@0 59
michael@0 60 static const uint32_t AllMask = (1 << Total) - 1;
michael@0 61
michael@0 62 static const uint32_t ArgRegMask = 0;
michael@0 63
michael@0 64 static const uint32_t VolatileMask =
michael@0 65 (1 << JSC::X86Registers::eax) |
michael@0 66 (1 << JSC::X86Registers::ecx) |
michael@0 67 (1 << JSC::X86Registers::edx);
michael@0 68
michael@0 69 static const uint32_t NonVolatileMask =
michael@0 70 (1 << JSC::X86Registers::ebx) |
michael@0 71 (1 << JSC::X86Registers::esi) |
michael@0 72 (1 << JSC::X86Registers::edi) |
michael@0 73 (1 << JSC::X86Registers::ebp);
michael@0 74
michael@0 75 static const uint32_t WrapperMask =
michael@0 76 VolatileMask |
michael@0 77 (1 << JSC::X86Registers::ebx);
michael@0 78
michael@0 79 static const uint32_t SingleByteRegs =
michael@0 80 (1 << JSC::X86Registers::eax) |
michael@0 81 (1 << JSC::X86Registers::ecx) |
michael@0 82 (1 << JSC::X86Registers::edx) |
michael@0 83 (1 << JSC::X86Registers::ebx);
michael@0 84
michael@0 85 static const uint32_t NonAllocatableMask =
michael@0 86 (1 << JSC::X86Registers::esp);
michael@0 87
michael@0 88 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
michael@0 89
michael@0 90 // Registers that can be allocated without being saved, generally.
michael@0 91 static const uint32_t TempMask = VolatileMask & ~NonAllocatableMask;
michael@0 92
michael@0 93 // Registers returned from a JS -> JS call.
michael@0 94 static const uint32_t JSCallMask =
michael@0 95 (1 << JSC::X86Registers::ecx) |
michael@0 96 (1 << JSC::X86Registers::edx);
michael@0 97
michael@0 98 // Registers returned from a JS -> C call.
michael@0 99 static const uint32_t CallMask =
michael@0 100 (1 << JSC::X86Registers::eax);
michael@0 101 };
michael@0 102
michael@0 103 // Smallest integer type that can hold a register bitmask.
michael@0 104 typedef uint8_t PackedRegisterMask;
michael@0 105
michael@0 106 class FloatRegisters {
michael@0 107 public:
michael@0 108 typedef JSC::X86Registers::XMMRegisterID Code;
michael@0 109
michael@0 110 static const char *GetName(Code code) {
michael@0 111 static const char * const Names[] = { "xmm0", "xmm1", "xmm2", "xmm3",
michael@0 112 "xmm4", "xmm5", "xmm6", "xmm7" };
michael@0 113 return Names[code];
michael@0 114 }
michael@0 115
michael@0 116 static Code FromName(const char *name) {
michael@0 117 for (size_t i = 0; i < Total; i++) {
michael@0 118 if (strcmp(GetName(Code(i)), name) == 0)
michael@0 119 return Code(i);
michael@0 120 }
michael@0 121 return Invalid;
michael@0 122 }
michael@0 123
michael@0 124 static const Code Invalid = JSC::X86Registers::invalid_xmm;
michael@0 125
michael@0 126 static const uint32_t Total = 8;
michael@0 127 static const uint32_t Allocatable = 7;
michael@0 128
michael@0 129 static const uint32_t AllMask = (1 << Total) - 1;
michael@0 130
michael@0 131 static const uint32_t VolatileMask = AllMask;
michael@0 132 static const uint32_t NonVolatileMask = 0;
michael@0 133
michael@0 134 static const uint32_t WrapperMask = VolatileMask;
michael@0 135
michael@0 136 static const uint32_t NonAllocatableMask =
michael@0 137 (1 << JSC::X86Registers::xmm7);
michael@0 138
michael@0 139 static const uint32_t AllocatableMask = AllMask & ~NonAllocatableMask;
michael@0 140 };
michael@0 141
michael@0 142 } // namespace jit
michael@0 143 } // namespace js
michael@0 144
michael@0 145 #endif /* jit_x86_Architecture_x86_h */

mercurial