LCOV - app.info - js/src/jspropertycacheinlines.h

LCOV - code coverage report
| Current view: | directory - js/src - jspropertycacheinlines.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 26 | 26 | 100.0 %
| Date: | 2012-04-07 | Functions: | 2 | 2 | 100.0 %

           1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
           2                 :  * vim: set ts=8 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 Communicator client code, released
          18                 :  * March 31, 1998.
          19                 :  *
          20                 :  * The Initial Developer of the Original Code is
          21                 :  * Mozilla Corporation.
          22                 :  * Portions created by the Initial Developer are Copyright (C) 2010
          23                 :  * the Initial Developer. All Rights Reserved.
          24                 :  *
          25                 :  * Contributor(s):
          26                 :  *   Igor Bukanov <igor@mir2.org>
          27                 :  *
          28                 :  * Alternatively, the contents of this file may be used under the terms of
          29                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          30                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          31                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          32                 :  * of those above. If you wish to allow use of your version of this file only
          33                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          34                 :  * use your version of this file under the terms of the MPL, indicate your
          35                 :  * decision by deleting the provisions above and replace them with the notice
          36                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          37                 :  * the provisions above, a recipient may use your version of this file under
          38                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          39                 :  *
          40                 :  * ***** END LICENSE BLOCK ***** */
          41                 :
          42                 : #ifndef jspropertycacheinlines_h___
          43                 : #define jspropertycacheinlines_h___
          44                 :
          45                 : #include "jslock.h"
          46                 : #include "jspropertycache.h"
          47                 : #include "jsscope.h"
          48                 :
          49                 : /*
          50                 :  * This method is designed to inline the fast path in js_Interpret, so it makes
          51                 :  * "just-so" restrictions on parameters, e.g. pobj and obj should not be the
          52                 :  * same variable, since for JOF_PROP-mode opcodes, obj must not be changed
          53                 :  * because of a cache miss.
          54                 :  *
          55                 :  * On return, if name is null then obj points to the scope chain element in
          56                 :  * which the property was found, pobj is locked, and entry is valid. If name is
          57                 :  * non-null then no object is locked but entry is still set correctly for use,
          58                 :  * e.g., by PropertyCache::fill and name should be used as the id to find.
          59                 :  *
          60                 :  * We must lock pobj on a hit in order to close races with threads that might
          61                 :  * be deleting a property from its scope, or otherwise invalidating property
          62                 :  * caches (on all threads) by re-generating JSObject::shape().
          63                 :  */
          64                 : JS_ALWAYS_INLINE void
          65        79759336 : js::PropertyCache::test(JSContext *cx, jsbytecode *pc, JSObject *&obj,
          66                 :                         JSObject *&pobj, PropertyCacheEntry *&entry, PropertyName *&name)
          67                 : {
          68        79759336 :     JS_ASSERT(this == &JS_PROPERTY_CACHE(cx));
          69                 :
          70        79759336 :     const Shape *kshape = obj->lastProperty();
          71        79759336 :     entry = &table[hash(pc, kshape)];
          72                 :     PCMETER(pctestentry = entry);
          73                 :     PCMETER(tests++);
          74        79759336 :     JS_ASSERT(&obj != &pobj);
          75        79759336 :     if (entry->kpc == pc && entry->kshape == kshape) {
          76                 :         JSObject *tmp;
          77        76182951 :         pobj = obj;
          78        79350616 :         if (entry->isPrototypePropertyHit() &&
          79         3167665 :             (tmp = pobj->getProto()) != NULL) {
          80         3167665 :             pobj = tmp;
          81                 :         }
          82                 :
          83        76182951 :         if (pobj->lastProperty() == entry->pshape) {
          84                 :             PCMETER(pchits++);
          85                 :             PCMETER(entry->isOwnPropertyHit() || protopchits++);
          86        76164742 :             name = NULL;
          87        76164742 :             return;
          88                 :         }
          89                 :     }
          90         3594594 :     name = fullTest(cx, pc, &obj, &pobj, entry);
          91         3594594 :     if (name)
          92                 :         PCMETER(misses++);
          93                 : }
          94                 :
          95                 : JS_ALWAYS_INLINE bool
          96        16214533 : js::PropertyCache::testForSet(JSContext *cx, jsbytecode *pc, JSObject *obj,
          97                 :                               PropertyCacheEntry **entryp, JSObject **obj2p, PropertyName **namep)
          98                 : {
          99        16214533 :     JS_ASSERT(this == &JS_PROPERTY_CACHE(cx));
         100                 :
         101        16214533 :     const Shape *kshape = obj->lastProperty();
         102        16214533 :     PropertyCacheEntry *entry = &table[hash(pc, kshape)];
         103        16214533 :     *entryp = entry;
         104                 :     PCMETER(pctestentry = entry);
         105                 :     PCMETER(tests++);
         106                 :     PCMETER(settests++);
         107        16214533 :     if (entry->kpc == pc && entry->kshape == kshape)
         108        14771734 :         return true;
         109                 :
         110         1442799 :     PropertyName *name = fullTest(cx, pc, &obj, obj2p, entry);
         111         1442799 :     JS_ASSERT(name);
         112                 :
         113                 :     PCMETER(misses++);
         114                 :     PCMETER(setmisses++);
         115                 :
         116         1442799 :     *namep = name;
         117         1442799 :     return false;
         118                 : }
         119                 :
         120                 : #endif /* jspropertycacheinlines_h___ */

Generated by: LCOV version 1.7