LCOV - app.info - js/src/methodjit/ICLabels.h

LCOV - code coverage report
| Current view: | directory - js/src/methodjit - ICLabels.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 169 | 169 | 100.0 %
| Date: | 2012-04-21 | Functions: | 56 | 56 | 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 Mandelin <dmandelin@mozilla.com>
          25                 :  *   David Anderson <danderson@mozilla.com>
          26                 :  *   Chris Leary <cdleary@mozilla.com>
          27                 :  *   Jacob Bramley <Jacob.Bramely@arm.com>
          28                 :  *
          29                 :  * Alternatively, the contents of this file may be used under the terms of
          30                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          31                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          32                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          33                 :  * of those above. If you wish to allow use of your version of this file only
          34                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          35                 :  * use your version of this file under the terms of the MPL, indicate your
          36                 :  * decision by deleting the provisions above and replace them with the notice
          37                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          38                 :  * the provisions above, a recipient may use your version of this file under
          39                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          40                 :  *
          41                 :  * ***** END LICENSE BLOCK ***** */
          42                 :
          43                 : #if !defined jsjaeger_ic_labels_h__ && defined JS_METHODJIT
          44                 : #define jsjaeger_ic_labels_h__
          45                 :
          46                 : #include "methodjit/BaseCompiler.h"
          47                 :
          48                 : class ICOffsetInitializer {
          49                 :   public:
          50                 :     ICOffsetInitializer();
          51                 : };
          52                 :
          53                 : namespace js {
          54                 : namespace mjit {
          55                 : namespace ic {
          56                 :
          57                 : /* GetPropCompiler */
          58                 : struct GetPropLabels : MacroAssemblerTypedefs {
          59                 :     friend class ::ICOffsetInitializer;
          60                 :
          61          445872 :     void setValueLoad(MacroAssembler &masm, Label fastPathRejoin, Label fastValueLoad) {
          62          445872 :         int offset = masm.differenceBetween(fastPathRejoin, fastValueLoad);
          63          445872 :         inlineValueLoadOffset = offset;
          64                 :
          65                 :         /*
          66                 :          * Note: the offset between the type and data loads for x86 is asserted
          67                 :          * in NunboxAssembler::loadValueWithAddressOffsetPatch.
          68                 :          */
          69          445872 :         JS_ASSERT(offset == inlineValueLoadOffset);
          70                 :         (void) offset;
          71          445872 :     }
          72                 :
          73          138873 :     CodeLocationLabel getValueLoad(CodeLocationLabel fastPathRejoin) {
          74          138873 :         return fastPathRejoin.labelAtOffset(inlineValueLoadOffset);
          75                 :     }
          76                 :
          77          445872 :     void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label dslotsLoad) {
          78          445872 :         int offset = masm.differenceBetween(fastPathRejoin, dslotsLoad);
          79          445872 :         setDslotsLoadOffset(offset);
          80          445872 :     }
          81                 :
          82           96847 :     CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin) {
          83           96847 :         return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset());
          84                 :     }
          85                 :
          86          445872 :     void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShape) {
          87          445872 :         int offset = masm.differenceBetween(shapeGuard, inlineShape);
          88          445872 :         setInlineShapeOffset(offset);
          89          445872 :     }
          90                 :
          91          138873 :     CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastShapeGuard) {
          92          138873 :         return fastShapeGuard.dataLabelPtrAtOffset(getInlineShapeOffset());
          93                 :     }
          94                 :
          95                 :     /*
          96                 :      * Note: on x64, the base is the inlineShapeLabel DataLabelPtr, whereas on other
          97                 :      * platforms the base is the shapeGuard.
          98                 :      */
          99                 :     template <typename T>
         100          445872 :     void setInlineShapeJump(MacroAssembler &masm, T base, Label afterJump) {
         101          445872 :         setInlineShapeJumpOffset(masm.differenceBetween(base, afterJump));
         102          445872 :     }
         103                 :
         104                 :     CodeLocationJump getInlineShapeJump(CodeLocationLabel fastShapeGuard) {
         105                 :         return fastShapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
         106                 :     }
         107                 :
         108          392148 :     void setInlineTypeJump(MacroAssembler &masm, Label fastPathStart, Label afterTypeJump) {
         109          392148 :         int offset = masm.differenceBetween(fastPathStart, afterTypeJump);
         110          392148 :         setInlineTypeJumpOffset(offset);
         111          392148 :     }
         112                 :
         113            7688 :     CodeLocationJump getInlineTypeJump(CodeLocationLabel fastPathStart) {
         114            7688 :         return fastPathStart.jumpAtOffset(getInlineTypeJumpOffset());
         115                 :     }
         116                 :
         117           46095 :     void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label shapeJump) {
         118           46095 :         int offset = masm.differenceBetween(stubStart, shapeJump);
         119           46095 :         setStubShapeJumpOffset(offset);
         120           46095 :     }
         121                 :
         122                 :     /* Offset-based interface */
         123                 :
         124          445872 :     void setDslotsLoadOffset(int offset) {
         125          445872 :         dslotsLoadOffset = offset;
         126          445872 :         JS_ASSERT(offset == dslotsLoadOffset);
         127          445872 :     }
         128                 :
         129          445872 :     void setInlineShapeOffset(int offset) {
         130          445872 :         inlineShapeOffset = offset;
         131          445872 :         JS_ASSERT(offset == inlineShapeOffset);
         132          445872 :     }
         133                 :
         134           46095 :     void setStubShapeJumpOffset(int offset) {
         135           46095 :         stubShapeJumpOffset = offset;
         136           46095 :         JS_ASSERT(offset == stubShapeJumpOffset);
         137           46095 :     }
         138                 :
         139           38958 :     int getInlineShapeJumpOffset() {
         140           38958 :         return POST_INST_OFFSET(inlineShapeJumpOffset);
         141                 :     }
         142                 :
         143          445872 :     void setInlineShapeJumpOffset(int offset) {
         144          445872 :         inlineShapeJumpOffset = offset;
         145          445872 :         JS_ASSERT(offset == inlineShapeJumpOffset);
         146          445872 :     }
         147                 :
         148            7688 :     int getInlineTypeJumpOffset() {
         149            7688 :         return POST_INST_OFFSET(inlineTypeJumpOffset);
         150                 :     }
         151                 :
         152          392148 :     void setInlineTypeJumpOffset(int offset) {
         153          392148 :         inlineTypeJumpOffset = offset;
         154          392148 :         JS_ASSERT(offset == inlineTypeJumpOffset);
         155          392148 :      }
         156                 :
         157          138873 :     int getInlineShapeOffset() {
         158          138873 :         return inlineShapeOffset;
         159                 :     }
         160           96847 :     int getDslotsLoadOffset() {
         161           96847 :         return dslotsLoadOffset;
         162                 :     }
         163           23345 :     int getStubShapeJumpOffset() {
         164           23345 :         return POST_INST_OFFSET(stubShapeJumpOffset);
         165                 :     }
         166                 :
         167                 :   private:
         168                 :     /* Offset from storeBack to beginning of 'mov dslots, addr' */
         169                 :     int32_t dslotsLoadOffset : 8;
         170                 :
         171                 :     /* Offset from shapeGuard to end of shape comparison. */
         172                 :     int32_t inlineShapeOffset : 8;
         173                 :
         174                 :     /* Offset from storeBack to end of value load. */
         175                 :     int32_t inlineValueLoadOffset : 8;
         176                 :
         177                 :     /*
         178                 :      * Offset from lastStubStart to end of shape jump.
         179                 :      * TODO: We can redefine the location of lastStubStart to be
         180                 :      * after the jump -- at which point this is always 0.
         181                 :      */
         182                 :     int32_t stubShapeJumpOffset : 8;
         183                 :
         184                 :     /* Offset from the shape guard start to the shape guard jump. */
         185                 :     int32_t inlineShapeJumpOffset : 8;
         186                 :
         187                 :     /* Offset from the fast path to the type guard jump. */
         188                 :     int32_t inlineTypeJumpOffset : 8;
         189                 : };
         190                 :
         191                 : /* SetPropCompiler */
         192                 : struct SetPropLabels : MacroAssemblerTypedefs {
         193                 :     friend class ::ICOffsetInitializer;
         194                 :
         195           33215 :     void setInlineValueStore(MacroAssembler &masm, Label fastPathRejoin, DataLabel32 inlineValueStore) {
         196           33215 :         int offset = masm.differenceBetween(fastPathRejoin, inlineValueStore);
         197           33215 :         setInlineValueStoreOffset(offset);
         198           33215 :     }
         199                 :
         200            6105 :     CodeLocationLabel getInlineValueStore(CodeLocationLabel fastPathRejoin) {
         201            6105 :         return fastPathRejoin.labelAtOffset(getInlineValueStoreOffset());
         202                 :     }
         203                 :
         204           33215 :     void setInlineShapeData(MacroAssembler &masm, Label shapeGuard, DataLabelPtr inlineShapeData) {
         205           33215 :         int offset = masm.differenceBetween(shapeGuard, inlineShapeData);
         206           33215 :         setInlineShapeDataOffset(offset);
         207           33215 :     }
         208                 :
         209            6105 :     CodeLocationDataLabelPtr getInlineShapeData(CodeLocationLabel fastPathStart, int shapeGuardOffset) {
         210            6105 :         return fastPathStart.dataLabelPtrAtOffset(shapeGuardOffset + getInlineShapeDataOffset());
         211                 :     }
         212                 :
         213           33215 :     void setDslotsLoad(MacroAssembler &masm, Label fastPathRejoin, Label beforeLoad) {
         214           33215 :         int offset = masm.differenceBetween(fastPathRejoin, beforeLoad);
         215           33215 :         setDslotsLoadOffset(offset);
         216           33215 :     }
         217                 :
         218            5007 :     CodeLocationInstruction getDslotsLoad(CodeLocationLabel fastPathRejoin, const ValueRemat &vr) {
         219            5007 :         return fastPathRejoin.instructionAtOffset(getDslotsLoadOffset(vr));
         220                 :     }
         221                 :
         222           33215 :     void setInlineShapeJump(MacroAssembler &masm, Label shapeGuard, Label afterJump) {
         223           33215 :         setInlineShapeJumpOffset(masm.differenceBetween(shapeGuard, afterJump));
         224           33215 :     }
         225                 :
         226            4612 :     CodeLocationJump getInlineShapeJump(CodeLocationLabel shapeGuard) {
         227            4612 :         return shapeGuard.jumpAtOffset(getInlineShapeJumpOffset());
         228                 :     }
         229                 :
         230            5345 :     void setStubShapeJump(MacroAssembler &masm, Label stubStart, Label afterShapeJump) {
         231            5345 :         int offset = masm.differenceBetween(stubStart, afterShapeJump);
         232            5345 :         setStubShapeJumpOffset(offset);
         233            5345 :     }
         234                 :
         235             733 :     CodeLocationJump getStubShapeJump(CodeLocationLabel stubStart) {
         236             733 :         return stubStart.jumpAtOffset(getStubShapeJumpOffset());
         237                 :     }
         238                 :
         239                 :   private:
         240                 :
         241                 :     /* Offset-based interface. */
         242                 :
         243           33215 :     void setDslotsLoadOffset(int offset) {
         244           33215 :         dslotsLoadOffset = offset;
         245           33215 :         JS_ASSERT(offset == dslotsLoadOffset);
         246           33215 :     }
         247                 :
         248            5007 :     int getDslotsLoadOffset(const ValueRemat &vr) {
         249                 :         (void) vr;
         250            5007 :         return dslotsLoadOffset;
         251                 :     }
         252                 :
         253           33215 :     void setInlineShapeDataOffset(int offset) {
         254           33215 :         inlineShapeDataOffset = offset;
         255           33215 :         JS_ASSERT(offset == inlineShapeDataOffset);
         256           33215 :     }
         257                 :
         258            5345 :     void setStubShapeJumpOffset(int offset) {
         259            5345 :         stubShapeJumpOffset = offset;
         260            5345 :         JS_ASSERT(offset == stubShapeJumpOffset);
         261            5345 :     }
         262                 :
         263           33215 :     void setInlineValueStoreOffset(int offset) {
         264           33215 :         inlineValueStoreOffset = offset;
         265           33215 :         JS_ASSERT(offset == inlineValueStoreOffset);
         266           33215 :     }
         267                 :
         268           33215 :     void setInlineShapeJumpOffset(int offset) {
         269           33215 :         inlineShapeJumpOffset = offset;
         270           33215 :         JS_ASSERT(offset == inlineShapeJumpOffset);
         271           33215 :     }
         272                 :
         273            4612 :     int getInlineShapeJumpOffset() {
         274            4612 :         return POST_INST_OFFSET(inlineShapeJumpOffset);
         275                 :     }
         276                 :
         277            6105 :     int getInlineShapeDataOffset() {
         278            6105 :         return inlineShapeDataOffset;
         279                 :     }
         280                 :
         281             733 :     int getStubShapeJumpOffset() {
         282             733 :         return POST_INST_OFFSET(stubShapeJumpOffset);
         283                 :     }
         284                 :
         285            6105 :     int getInlineValueStoreOffset() {
         286            6105 :         return inlineValueStoreOffset;
         287                 :     }
         288                 :
         289                 :     /* Offset from storeBack to beginning of 'mov dslots, addr'. */
         290                 :     int32_t dslotsLoadOffset : 8;
         291                 :
         292                 :     /* Offset from shapeGuard to end of shape comparison. */
         293                 :     int32_t inlineShapeDataOffset : 8;
         294                 :
         295                 :     /*
         296                 :      * Offset from lastStubStart to end of shape jump.
         297                 :      * TODO: We can redefine the location of lastStubStart to be
         298                 :      * after the jump -- at which point this is always 0.
         299                 :      */
         300                 :     int32_t stubShapeJumpOffset : 8;
         301                 :
         302                 :     int32_t inlineValueStoreOffset : 8;
         303                 :
         304                 :     /* Offset from shapeGuard to the end of the shape jump. */
         305                 :     int32_t inlineShapeJumpOffset : 8;
         306                 : };
         307                 :
         308                 : /* BindNameCompiler */
         309                 : struct BindNameLabels : MacroAssemblerTypedefs {
         310                 :     friend class ::ICOffsetInitializer;
         311                 :
         312            7166 :     void setInlineJumpOffset(int offset) {
         313            7166 :         inlineJumpOffset = offset;
         314            7166 :         JS_ASSERT(offset == inlineJumpOffset);
         315            7166 :     }
         316                 :
         317            7166 :     void setInlineJump(MacroAssembler &masm, Label shapeGuard, Jump inlineJump) {
         318            7166 :         int offset = masm.differenceBetween(shapeGuard, inlineJump);
         319            7166 :         setInlineJumpOffset(offset);
         320            7166 :     }
         321                 :
         322             987 :     CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
         323             987 :         return fastPathStart.jumpAtOffset(getInlineJumpOffset());
         324                 :     }
         325                 :
         326             987 :     int getInlineJumpOffset() {
         327             987 :         return inlineJumpOffset;
         328                 :     }
         329                 :
         330            1009 :     void setStubJumpOffset(int offset) {
         331            1009 :         stubJumpOffset = offset;
         332            1009 :         JS_ASSERT(offset == stubJumpOffset);
         333            1009 :     }
         334                 :
         335            1009 :     void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
         336            1009 :         int offset = masm.differenceBetween(stubStart, stubJump);
         337            1009 :         setStubJumpOffset(offset);
         338            1009 :     }
         339                 :
         340              22 :     CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
         341              22 :         return lastStubStart.jumpAtOffset(getStubJumpOffset());
         342                 :     }
         343                 :
         344              22 :     int getStubJumpOffset() {
         345              22 :         return stubJumpOffset;
         346                 :     }
         347                 :
         348                 :   private:
         349                 :     /* Offset from shapeGuard to end of shape jump. */
         350                 :     int32_t inlineJumpOffset : 8;
         351                 :
         352                 :     /* Offset from lastStubStart to end of the shape jump. */
         353                 :     int32_t stubJumpOffset : 8;
         354                 : };
         355                 :
         356                 : /* ScopeNameCompiler */
         357                 : struct ScopeNameLabels : MacroAssemblerTypedefs {
         358                 :     friend class ::ICOffsetInitializer;
         359                 :
         360          340939 :     void setInlineJumpOffset(int offset) {
         361          340939 :         inlineJumpOffset = offset;
         362          340939 :         JS_ASSERT(offset == inlineJumpOffset);
         363          340939 :     }
         364                 :
         365          340549 :     void setInlineJump(MacroAssembler &masm, Label fastPathStart, Jump inlineJump) {
         366          340549 :         int offset = masm.differenceBetween(fastPathStart, inlineJump);
         367          340549 :         setInlineJumpOffset(offset);
         368          340549 :     }
         369                 :
         370          171947 :     CodeLocationJump getInlineJump(CodeLocationLabel fastPathStart) {
         371          171947 :         return fastPathStart.jumpAtOffset(getInlineJumpOffset());
         372                 :     }
         373                 :
         374          171947 :     int getInlineJumpOffset() {
         375          171947 :         return inlineJumpOffset;
         376                 :     }
         377                 :
         378          180283 :     void setStubJumpOffset(int offset) {
         379          180283 :         stubJumpOffset = offset;
         380          180283 :         JS_ASSERT(offset == stubJumpOffset);
         381          180283 :     }
         382                 :
         383          180283 :     void setStubJump(MacroAssembler &masm, Label stubStart, Jump stubJump) {
         384          180283 :         int offset = masm.differenceBetween(stubStart, stubJump);
         385          180283 :         setStubJumpOffset(offset);
         386          180283 :     }
         387                 :
         388            8336 :     CodeLocationJump getStubJump(CodeLocationLabel lastStubStart) {
         389            8336 :         return lastStubStart.jumpAtOffset(getStubJumpOffset());
         390                 :     }
         391                 :
         392            8336 :     int getStubJumpOffset() {
         393            8336 :         return stubJumpOffset;
         394                 :     }
         395                 :
         396                 :   private:
         397                 :     /* Offset from fastPathStart to end of shape jump. */
         398                 :     int32_t inlineJumpOffset : 8;
         399                 :
         400                 :     /* Offset from lastStubStart to end of the shape jump. */
         401                 :     int32_t stubJumpOffset : 8;
         402                 : };
         403                 :
         404                 : } /* namespace ic */
         405                 : } /* namespace mjit */
         406                 : } /* namespace js */
         407                 :
         408                 : #endif /* jsjaeger_ic_labels_h__ */

Generated by: LCOV version 1.7