2 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef ResolveOperation_h
27 #define ResolveOperation_h
29 #include "PropertyOffset.h"
30 #include "WriteBarrier.h"
32 #include <wtf/Vector.h>
38 struct ResolveOperation
{
45 GetAndReturnScopedVar
,
46 GetAndReturnGlobalVar
,
47 GetAndReturnGlobalVarWatchable
,
50 ReturnGlobalObjectAsBase
,
51 GetAndReturnGlobalProperty
,
52 CheckForDynamicEntriesBeforeGlobalScope
53 } ResolveOperationType
;
55 ResolveOperationType m_operation
;
56 WriteBarrier
<Structure
> m_structure
;
58 PropertyOffset m_offset
;
59 WriteBarrier
<Unknown
>* m_registerAddress
;
61 int m_activationRegister
;
63 static ResolveOperation
getAndReturnScopedVar(PropertyOffset offset
)
66 op
.m_operation
= GetAndReturnScopedVar
;
70 static ResolveOperation
checkForDynamicEntriesBeforeGlobalScope()
73 op
.m_operation
= CheckForDynamicEntriesBeforeGlobalScope
;
77 static ResolveOperation
getAndReturnGlobalVar(WriteBarrier
<Unknown
>* registerAddress
, bool couldBeWatched
)
80 op
.m_operation
= couldBeWatched
? GetAndReturnGlobalVarWatchable
: GetAndReturnGlobalVar
;
81 op
.m_registerAddress
= registerAddress
;
84 static ResolveOperation
getAndReturnGlobalProperty()
87 op
.m_operation
= GetAndReturnGlobalProperty
;
90 static ResolveOperation
resolveFail()
93 op
.m_operation
= Fail
;
96 static ResolveOperation
skipTopScopeNode(int activationRegister
)
99 op
.m_operation
= SkipTopScopeNode
;
100 op
.m_activationRegister
= activationRegister
;
103 static ResolveOperation
skipScopes(int scopesToSkip
)
106 op
.m_operation
= SkipScopes
;
107 op
.m_scopesToSkip
= scopesToSkip
;
110 static ResolveOperation
returnGlobalObjectAsBase()
113 op
.m_operation
= ReturnGlobalObjectAsBase
;
116 static ResolveOperation
setBaseToGlobal()
119 op
.m_operation
= SetBaseToGlobal
;
122 static ResolveOperation
setBaseToUndefined()
125 op
.m_operation
= SetBaseToUndefined
;
128 static ResolveOperation
setBaseToScope()
131 op
.m_operation
= SetBaseToScope
;
134 static ResolveOperation
returnScopeAsBase()
137 op
.m_operation
= ReturnScopeAsBase
;
142 typedef Vector
<ResolveOperation
> ResolveOperations
;
144 struct PutToBaseOperation
{
145 PutToBaseOperation(bool isStrict
)
146 : m_kind(Uninitialised
)
148 , m_isStrict(isStrict
)
149 , m_predicatePointer(0)
153 enum Kind
{ Uninitialised
, Generic
, Readonly
, GlobalVariablePut
, GlobalVariablePutChecked
, GlobalPropertyPut
, VariablePut
};
156 uint8_t m_kindAsUint8
;
158 bool m_isDynamic
: 8;
161 bool* m_predicatePointer
;
162 unsigned m_scopeDepth
;
164 WriteBarrier
<Structure
> m_structure
;
166 // Used for GlobalVariablePut
167 WriteBarrier
<Unknown
>* m_registerAddress
;
169 // Used for GlobalPropertyPut and VariablePut
171 PropertyOffset m_offset
;
172 int32_t m_offsetInButterfly
;
178 #endif // ResolveOperation_h