js/src/jit/shared/CodeGenerator-shared-inl.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_shared_CodeGenerator_shared_inl_h
     8 #define jit_shared_CodeGenerator_shared_inl_h
    10 #include "jit/shared/CodeGenerator-shared.h"
    12 namespace js {
    13 namespace jit {
    15 static inline int32_t
    16 ToInt32(const LAllocation *a)
    17 {
    18     if (a->isConstantValue())
    19         return a->toConstant()->toInt32();
    20     if (a->isConstantIndex())
    21         return a->toConstantIndex()->index();
    22     MOZ_ASSUME_UNREACHABLE("this is not a constant!");
    23 }
    24 static inline double
    25 ToDouble(const LAllocation *a)
    26 {
    27     return a->toConstant()->toNumber();
    28 }
    30 static inline Register
    31 ToRegister(const LAllocation &a)
    32 {
    33     JS_ASSERT(a.isGeneralReg());
    34     return a.toGeneralReg()->reg();
    35 }
    37 static inline Register
    38 ToRegister(const LAllocation *a)
    39 {
    40     return ToRegister(*a);
    41 }
    43 static inline Register
    44 ToRegister(const LDefinition *def)
    45 {
    46     return ToRegister(*def->output());
    47 }
    49 static inline Register
    50 ToTempRegisterOrInvalid(const LDefinition *def)
    51 {
    52     if (def->isBogusTemp())
    53         return InvalidReg;
    54     return ToRegister(def);
    55 }
    57 static inline Register
    58 ToTempUnboxRegister(const LDefinition *def)
    59 {
    60     return ToTempRegisterOrInvalid(def);
    61 }
    63 static inline Register
    64 ToRegisterOrInvalid(const LDefinition *a)
    65 {
    66     return a ? ToRegister(a) : InvalidReg;
    67 }
    69 static inline FloatRegister
    70 ToFloatRegister(const LAllocation &a)
    71 {
    72     JS_ASSERT(a.isFloatReg());
    73     return a.toFloatReg()->reg();
    74 }
    76 static inline FloatRegister
    77 ToFloatRegister(const LAllocation *a)
    78 {
    79     return ToFloatRegister(*a);
    80 }
    82 static inline FloatRegister
    83 ToFloatRegister(const LDefinition *def)
    84 {
    85     return ToFloatRegister(*def->output());
    86 }
    88 static inline AnyRegister
    89 ToAnyRegister(const LAllocation &a)
    90 {
    91     JS_ASSERT(a.isGeneralReg() || a.isFloatReg());
    92     if (a.isGeneralReg())
    93         return AnyRegister(ToRegister(a));
    94     return AnyRegister(ToFloatRegister(a));
    95 }
    97 static inline AnyRegister
    98 ToAnyRegister(const LAllocation *a)
    99 {
   100     return ToAnyRegister(*a);
   101 }
   103 static inline AnyRegister
   104 ToAnyRegister(const LDefinition *def)
   105 {
   106     return ToAnyRegister(def->output());
   107 }
   109 static inline Int32Key
   110 ToInt32Key(const LAllocation *a)
   111 {
   112     if (a->isConstant())
   113         return Int32Key(ToInt32(a));
   114     return Int32Key(ToRegister(a));
   115 }
   117 static inline ValueOperand
   118 GetValueOutput(LInstruction *ins)
   119 {
   120 #if defined(JS_NUNBOX32)
   121     return ValueOperand(ToRegister(ins->getDef(TYPE_INDEX)),
   122                         ToRegister(ins->getDef(PAYLOAD_INDEX)));
   123 #elif defined(JS_PUNBOX64)
   124     return ValueOperand(ToRegister(ins->getDef(0)));
   125 #else
   126 #error "Unknown"
   127 #endif
   128 }
   130 static inline ValueOperand
   131 GetTempValue(const Register &type, const Register &payload)
   132 {
   133 #if defined(JS_NUNBOX32)
   134     return ValueOperand(type, payload);
   135 #elif defined(JS_PUNBOX64)
   136     (void)type;
   137     return ValueOperand(payload);
   138 #else
   139 #error "Unknown"
   140 #endif
   141 }
   143 void
   144 CodeGeneratorShared::saveLive(LInstruction *ins)
   145 {
   146     JS_ASSERT(!ins->isCall());
   147     LSafepoint *safepoint = ins->safepoint();
   148     masm.PushRegsInMask(safepoint->liveRegs());
   149 }
   151 void
   152 CodeGeneratorShared::restoreLive(LInstruction *ins)
   153 {
   154     JS_ASSERT(!ins->isCall());
   155     LSafepoint *safepoint = ins->safepoint();
   156     masm.PopRegsInMask(safepoint->liveRegs());
   157 }
   159 void
   160 CodeGeneratorShared::restoreLiveIgnore(LInstruction *ins, RegisterSet ignore)
   161 {
   162     JS_ASSERT(!ins->isCall());
   163     LSafepoint *safepoint = ins->safepoint();
   164     masm.PopRegsInMaskIgnore(safepoint->liveRegs(), ignore);
   165 }
   167 void
   168 CodeGeneratorShared::saveLiveVolatile(LInstruction *ins)
   169 {
   170     JS_ASSERT(!ins->isCall());
   171     LSafepoint *safepoint = ins->safepoint();
   172     RegisterSet regs = RegisterSet::Intersect(safepoint->liveRegs(), RegisterSet::Volatile());
   173     masm.PushRegsInMask(regs);
   174 }
   176 void
   177 CodeGeneratorShared::restoreLiveVolatile(LInstruction *ins)
   178 {
   179     JS_ASSERT(!ins->isCall());
   180     LSafepoint *safepoint = ins->safepoint();
   181     RegisterSet regs = RegisterSet::Intersect(safepoint->liveRegs(), RegisterSet::Volatile());
   182     masm.PopRegsInMask(regs);
   183 }
   185 } // ion
   186 } // js
   188 #endif /* jit_shared_CodeGenerator_shared_inl_h */

mercurial