Changeset 175172 in webkit


Ignore:
Timestamp:
Oct 24, 2014 12:16:29 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Simplified IndexingType's hasAnyArrayStorage().
<https://webkit.org/b/138051>

Reviewed by Michael Saboff.

IndexingType's hasAnyArrayStorage() currently does subtraction of ArrayStorageShape
with the purpose of making non-ArrayStorage types underflow (with that subtraction)
and have a result that exceeds SlowPutArrayStorageShape. What it is doing is
basically checking for a shape value that is greater equal to ArrayStorageShape.
We can just simplify the code as such.

Also added a comment to describe the structure of the bits in IndexingType.

  • runtime/IndexingType.h:

(JSC::hasAnyArrayStorage):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r175151 r175172  
     12014-10-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Simplified IndexingType's hasAnyArrayStorage().
     4        <https://webkit.org/b/138051>
     5
     6        Reviewed by Michael Saboff.
     7
     8        IndexingType's hasAnyArrayStorage() currently does subtraction of ArrayStorageShape
     9        with the purpose of making non-ArrayStorage types underflow (with that subtraction)
     10        and have a result that exceeds SlowPutArrayStorageShape.  What it is doing is
     11        basically checking for a shape value that is greater equal to ArrayStorageShape.
     12        We can just simplify the code as such.
     13
     14        Also added a comment to describe the structure of the bits in IndexingType.
     15
     16        * runtime/IndexingType.h:
     17        (JSC::hasAnyArrayStorage):
     18
    1192014-10-23  Joseph Pecoraro  <pecoraro@apple.com>
    220
  • trunk/Source/JavaScriptCore/runtime/IndexingType.h

    r166292 r175172  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131
    3232namespace JSC {
     33
     34/*
     35    Structure of the IndexingType
     36    =============================
     37    Conceptually, the IndexingType looks like this:
     38
     39    struct IndexingType {
     40        uint8_t isArray:1;                    // bit 0
     41        uint8_t shape:4;                      // bit 1 - 4
     42        uint8_t mayHaveIndexedAccessors:1;    // bit 5
     43    };
     44
     45    The shape values (e.g. Int32Shape, ContiguousShape, etc) are an enumeration of
     46    various shapes (though not necessarily sequential in terms of their values).
     47    Hence, shape values are not bitwise exclusive with respect to each other.
     48*/
    3349
    3450typedef uint8_t IndexingType;
     
    129145static inline bool hasAnyArrayStorage(IndexingType indexingType)
    130146{
    131     return static_cast<uint8_t>((indexingType & IndexingShapeMask) - ArrayStorageShape) <= static_cast<uint8_t>(SlowPutArrayStorageShape - ArrayStorageShape);
     147    return static_cast<uint8_t>(indexingType & IndexingShapeMask) >= ArrayStorageShape;
    132148}
    133149
Note: See TracChangeset for help on using the changeset viewer.