fpizlo@apple.com | 6b62eaf | 2015-08-03 23:13:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "ObjectPropertyCondition.h" |
| 28 | |
| 29 | #include "JSCInlines.h" |
| 30 | #include "TrackedReferences.h" |
| 31 | |
| 32 | namespace JSC { |
| 33 | |
| 34 | void ObjectPropertyCondition::dumpInContext(PrintStream& out, DumpContext* context) const |
| 35 | { |
| 36 | if (!*this) { |
| 37 | out.print("<invalid>"); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | out.print("<", inContext(JSValue(m_object), context), ": ", inContext(m_condition, context), ">"); |
| 42 | } |
| 43 | |
| 44 | void ObjectPropertyCondition::dump(PrintStream& out) const |
| 45 | { |
| 46 | dumpInContext(out, nullptr); |
| 47 | } |
| 48 | |
| 49 | bool ObjectPropertyCondition::structureEnsuresValidityAssumingImpurePropertyWatchpoint( |
| 50 | Structure* structure) const |
| 51 | { |
| 52 | return m_condition.isStillValidAssumingImpurePropertyWatchpoint(structure); |
| 53 | } |
| 54 | |
| 55 | bool ObjectPropertyCondition::structureEnsuresValidityAssumingImpurePropertyWatchpoint() const |
| 56 | { |
| 57 | if (!*this) |
| 58 | return false; |
| 59 | |
| 60 | return structureEnsuresValidityAssumingImpurePropertyWatchpoint(m_object->structure()); |
| 61 | } |
| 62 | |
| 63 | bool ObjectPropertyCondition::validityRequiresImpurePropertyWatchpoint(Structure* structure) const |
| 64 | { |
| 65 | return m_condition.validityRequiresImpurePropertyWatchpoint(structure); |
| 66 | } |
| 67 | |
| 68 | bool ObjectPropertyCondition::validityRequiresImpurePropertyWatchpoint() const |
| 69 | { |
| 70 | if (!*this) |
| 71 | return false; |
| 72 | |
| 73 | return validityRequiresImpurePropertyWatchpoint(m_object->structure()); |
| 74 | } |
| 75 | |
| 76 | bool ObjectPropertyCondition::isStillValid(Structure* structure) const |
| 77 | { |
| 78 | return m_condition.isStillValid(structure, m_object); |
| 79 | } |
| 80 | |
| 81 | bool ObjectPropertyCondition::isStillValid() const |
| 82 | { |
| 83 | if (!*this) |
| 84 | return false; |
| 85 | |
| 86 | return isStillValid(m_object->structure()); |
| 87 | } |
| 88 | |
| 89 | bool ObjectPropertyCondition::structureEnsuresValidity(Structure* structure) const |
| 90 | { |
| 91 | return m_condition.isStillValid(structure); |
| 92 | } |
| 93 | |
| 94 | bool ObjectPropertyCondition::structureEnsuresValidity() const |
| 95 | { |
| 96 | if (!*this) |
| 97 | return false; |
| 98 | |
| 99 | return structureEnsuresValidity(m_object->structure()); |
| 100 | } |
| 101 | |
| 102 | bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint( |
| 103 | Structure* structure, PropertyCondition::WatchabilityEffort effort) const |
| 104 | { |
| 105 | return m_condition.isWatchableAssumingImpurePropertyWatchpoint(structure, m_object, effort); |
| 106 | } |
| 107 | |
| 108 | bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint( |
| 109 | PropertyCondition::WatchabilityEffort effort) const |
| 110 | { |
| 111 | if (!*this) |
| 112 | return false; |
| 113 | |
| 114 | return isWatchableAssumingImpurePropertyWatchpoint(m_object->structure(), effort); |
| 115 | } |
| 116 | |
| 117 | bool ObjectPropertyCondition::isWatchable( |
| 118 | Structure* structure, PropertyCondition::WatchabilityEffort effort) const |
| 119 | { |
| 120 | return m_condition.isWatchable(structure, m_object, effort); |
| 121 | } |
| 122 | |
| 123 | bool ObjectPropertyCondition::isWatchable(PropertyCondition::WatchabilityEffort effort) const |
| 124 | { |
| 125 | if (!*this) |
| 126 | return false; |
| 127 | |
| 128 | return isWatchable(m_object->structure(), effort); |
| 129 | } |
| 130 | |
| 131 | bool ObjectPropertyCondition::isStillLive() const |
| 132 | { |
| 133 | if (!*this) |
| 134 | return false; |
| 135 | |
| 136 | if (!Heap::isMarked(m_object)) |
| 137 | return false; |
| 138 | |
| 139 | return m_condition.isStillLive(); |
| 140 | } |
| 141 | |
| 142 | void ObjectPropertyCondition::validateReferences(const TrackedReferences& tracked) const |
| 143 | { |
| 144 | if (!*this) |
| 145 | return; |
| 146 | |
| 147 | tracked.check(m_object); |
| 148 | m_condition.validateReferences(tracked); |
| 149 | } |
| 150 | |
| 151 | ObjectPropertyCondition ObjectPropertyCondition::attemptToMakeEquivalenceWithoutBarrier() const |
| 152 | { |
| 153 | PropertyCondition result = condition().attemptToMakeEquivalenceWithoutBarrier(object()); |
| 154 | if (!result) |
| 155 | return ObjectPropertyCondition(); |
| 156 | return ObjectPropertyCondition(object(), result); |
| 157 | } |
| 158 | |
| 159 | } // namespace JSC |
| 160 | |