LCOV - code coverage report
Current view: directory - js/src/methodjit - StubCompiler.h (source / functions) Found Hit Coverage
Test: app.info Lines: 11 11 100.0 %
Date: 2012-06-02 Functions: 6 6 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: set ts=4 sw=4 et tw=99:
       3                 :  *
       4                 :  * ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
      18                 :  * May 28, 2008.
      19                 :  *
      20                 :  * The Initial Developer of the Original Code is
      21                 :  *   Brendan Eich <brendan@mozilla.org>
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   David Anderson <danderson@mozilla.com>
      25                 :  *   David Mandelin <dmandelin@mozilla.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #if !defined(jsstub_compiler_h__) && defined(JS_METHODJIT)
      42                 : #define jsstub_compiler_h__
      43                 : 
      44                 : #include "jscntxt.h"
      45                 : #include "MethodJIT.h"
      46                 : #include "methodjit/FrameState.h"
      47                 : #include "CodeGenIncludes.h"
      48                 : 
      49                 : namespace js {
      50                 : namespace mjit {
      51                 : 
      52                 : class Compiler;
      53                 : 
      54                 : class StubCompiler
      55          134091 : {
      56                 :     typedef JSC::MacroAssembler::Call Call;
      57                 :     typedef JSC::MacroAssembler::Jump Jump;
      58                 :     typedef JSC::MacroAssembler::Label Label;
      59                 : 
      60        16184049 :     struct CrossPatch {
      61         9129137 :         CrossPatch(Jump from, Label to)
      62         9129137 :           : from(from), to(to)
      63         9129137 :         { }
      64                 : 
      65                 :         Jump from;
      66                 :         Label to;
      67                 :     };
      68                 : 
      69          141694 :     struct CrossJumpInScript {
      70          141694 :         CrossJumpInScript(Jump from, jsbytecode *pc, uint32_t inlineIndex)
      71          141694 :           : from(from), pc(pc), inlineIndex(inlineIndex)
      72          141694 :         { }
      73                 : 
      74                 :         Jump from;
      75                 :         jsbytecode *pc;
      76                 :         uint32_t inlineIndex;
      77                 :     };
      78                 : 
      79                 :     JSContext *cx;
      80                 :     Compiler &cc;
      81                 :     FrameState &frame;
      82                 : 
      83                 :   public:
      84                 :     Assembler masm;
      85                 : 
      86                 :   private:
      87                 :     uint32_t generation;
      88                 :     uint32_t lastGeneration;
      89                 : 
      90                 :     Vector<CrossPatch, 64, mjit::CompilerAllocPolicy> exits;
      91                 :     Vector<CrossPatch, 64, mjit::CompilerAllocPolicy> joins;
      92                 :     Vector<CrossJumpInScript, 64, mjit::CompilerAllocPolicy> scriptJoins;
      93                 :     Vector<Jump, 8, SystemAllocPolicy> jumpList;
      94                 : 
      95                 :   public:
      96                 :     StubCompiler(JSContext *cx, mjit::Compiler &cc, FrameState &frame);
      97                 : 
      98         1423141 :     size_t size() {
      99         1423141 :         return masm.size();
     100                 :     }
     101                 : 
     102                 :     uint8_t *buffer() {
     103                 :         return masm.buffer();
     104                 :     }
     105                 : 
     106                 :     /*
     107                 :      * Force a frame sync and return a label before the syncing code.
     108                 :      * A Jump may bind to the label with leaveExitDirect().
     109                 :      */
     110                 :     JSC::MacroAssembler::Label syncExit(Uses uses);
     111                 : 
     112                 :     /*
     113                 :      * Sync the exit, and state that code will be immediately outputted
     114                 :      * to the out-of-line buffer.
     115                 :      */
     116                 :     JSC::MacroAssembler::Label syncExitAndJump(Uses uses);
     117                 : 
     118                 :     /* Exits from the fast path into the slow path. */
     119                 :     JSC::MacroAssembler::Label linkExit(Jump j, Uses uses);
     120                 :     void linkExitForBranch(Jump j);
     121                 :     void linkExitDirect(Jump j, Label L);
     122                 : 
     123                 :     void leave();
     124                 :     void leaveWithDepth(uint32_t depth);
     125                 : 
     126                 :     /*
     127                 :      * Rejoins slow-path code back to the fast-path. The invalidation param
     128                 :      * specifies how many stack slots below sp must not be reloaded from
     129                 :      * registers.
     130                 :      */
     131                 :     void rejoin(Changes changes);
     132                 :     void linkRejoin(Jump j);
     133                 : 
     134                 :     /* Finish all native code patching. */
     135                 :     void fixCrossJumps(uint8_t *ncode, size_t offset, size_t total);
     136                 :     bool jumpInScript(Jump j, jsbytecode *target);
     137                 :     unsigned crossJump(Jump j, Label l);
     138                 : 
     139                 :     Call emitStubCall(void *ptr, RejoinState rejoin, Uses uses);
     140                 :     Call emitStubCall(void *ptr, RejoinState rejoin, Uses uses, int32_t slots);
     141                 : 
     142                 :     void patchJoin(unsigned i, bool script, Assembler::Address address, AnyRegisterID reg);
     143                 : };
     144                 : 
     145                 : } /* namepsace mjit */
     146                 : } /* namespace js */
     147                 : 
     148                 : #endif /* jsstub_compiler_h__ */
     149                 : 

Generated by: LCOV version 1.7