erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
| 29 | #define V8_HYDROGEN_INSTRUCTIONS_H_ |
| 30 | |
| 31 | #include "v8.h" |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 32 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 33 | #include "allocation.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 34 | #include "code-stubs.h" |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 35 | #include "data-flow.h" |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 36 | #include "small-pointer-list.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 37 | #include "string-stream.h" |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 38 | #include "v8conversions.h" |
| 39 | #include "v8utils.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 40 | #include "zone.h" |
| 41 | |
| 42 | namespace v8 { |
| 43 | namespace internal { |
| 44 | |
| 45 | // Forward declarations. |
| 46 | class HBasicBlock; |
| 47 | class HEnvironment; |
| 48 | class HInstruction; |
| 49 | class HLoopInformation; |
| 50 | class HValue; |
| 51 | class LInstruction; |
| 52 | class LChunkBuilder; |
| 53 | |
| 54 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 55 | #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 56 | V(BitwiseBinaryOperation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 57 | V(ControlInstruction) \ |
| 58 | V(Instruction) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 59 | |
| 60 | |
| 61 | #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 62 | V(AbnormalExit) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 63 | V(AccessArgumentsAt) \ |
| 64 | V(Add) \ |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 65 | V(AllocateObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 66 | V(ApplyArguments) \ |
| 67 | V(ArgumentsElements) \ |
| 68 | V(ArgumentsLength) \ |
| 69 | V(ArgumentsObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 70 | V(ArrayLiteral) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 71 | V(Bitwise) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 72 | V(BitNot) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 73 | V(BlockEntry) \ |
| 74 | V(BoundsCheck) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 75 | V(Branch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 76 | V(CallConstantFunction) \ |
| 77 | V(CallFunction) \ |
| 78 | V(CallGlobal) \ |
| 79 | V(CallKeyed) \ |
| 80 | V(CallKnownGlobal) \ |
| 81 | V(CallNamed) \ |
| 82 | V(CallNew) \ |
| 83 | V(CallRuntime) \ |
| 84 | V(CallStub) \ |
| 85 | V(Change) \ |
| 86 | V(CheckFunction) \ |
| 87 | V(CheckInstanceType) \ |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 88 | V(CheckMaps) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 89 | V(CheckNonSmi) \ |
| 90 | V(CheckPrototypeMaps) \ |
| 91 | V(CheckSmi) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 92 | V(ClampToUint8) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 93 | V(ClassOfTestAndBranch) \ |
| 94 | V(CompareIDAndBranch) \ |
| 95 | V(CompareGeneric) \ |
| 96 | V(CompareObjectEqAndBranch) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 97 | V(CompareMap) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 98 | V(CompareConstantEqAndBranch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 99 | V(Constant) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 100 | V(Context) \ |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 101 | V(DeclareGlobals) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 102 | V(DeleteProperty) \ |
| 103 | V(Deoptimize) \ |
| 104 | V(Div) \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 105 | V(ElementsKind) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 106 | V(EnterInlined) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 107 | V(FastLiteral) \ |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 108 | V(FixedArrayBaseLength) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 109 | V(ForceRepresentation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 110 | V(FunctionLiteral) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 111 | V(GetCachedArrayIndex) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 112 | V(GlobalObject) \ |
| 113 | V(GlobalReceiver) \ |
| 114 | V(Goto) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 115 | V(HasCachedArrayIndexAndBranch) \ |
| 116 | V(HasInstanceTypeAndBranch) \ |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 117 | V(In) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 118 | V(InstanceOf) \ |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 119 | V(InstanceOfKnownGlobal) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 120 | V(InvokeFunction) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 121 | V(IsConstructCallAndBranch) \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 122 | V(IsNilAndBranch) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 123 | V(IsObjectAndBranch) \ |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 124 | V(IsStringAndBranch) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 125 | V(IsSmiAndBranch) \ |
| 126 | V(IsUndetectableAndBranch) \ |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 127 | V(StringCompareAndBranch) \ |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 128 | V(JSArrayLength) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 129 | V(LeaveInlined) \ |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 130 | V(LoadContextSlot) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 131 | V(LoadElements) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 132 | V(LoadExternalArrayPointer) \ |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 133 | V(LoadFunctionPrototype) \ |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 134 | V(LoadGlobalCell) \ |
| 135 | V(LoadGlobalGeneric) \ |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 136 | V(LoadKeyedFastDoubleElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 137 | V(LoadKeyedFastElement) \ |
| 138 | V(LoadKeyedGeneric) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 139 | V(LoadKeyedSpecializedArrayElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 140 | V(LoadNamedField) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 141 | V(LoadNamedFieldPolymorphic) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 142 | V(LoadNamedGeneric) \ |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 143 | V(MathFloorOfDiv) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 144 | V(Mod) \ |
| 145 | V(Mul) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 146 | V(ObjectLiteral) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 147 | V(OsrEntry) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 148 | V(OuterContext) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 149 | V(Parameter) \ |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 150 | V(Power) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 151 | V(PushArgument) \ |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 152 | V(Random) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 153 | V(RegExpLiteral) \ |
| 154 | V(Return) \ |
| 155 | V(Sar) \ |
| 156 | V(Shl) \ |
| 157 | V(Shr) \ |
| 158 | V(Simulate) \ |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 159 | V(SoftDeoptimize) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 160 | V(StackCheck) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 161 | V(StoreContextSlot) \ |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 162 | V(StoreGlobalCell) \ |
| 163 | V(StoreGlobalGeneric) \ |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 164 | V(StoreKeyedFastDoubleElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 165 | V(StoreKeyedFastElement) \ |
| 166 | V(StoreKeyedGeneric) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 167 | V(StoreKeyedSpecializedArrayElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 168 | V(StoreNamedField) \ |
| 169 | V(StoreNamedGeneric) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 170 | V(StringAdd) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 171 | V(StringCharCodeAt) \ |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 172 | V(StringCharFromCode) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 173 | V(StringLength) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 174 | V(Sub) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 175 | V(ThisFunction) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 176 | V(Throw) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 177 | V(ToFastProperties) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 178 | V(TransitionElementsKind) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 179 | V(Typeof) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 180 | V(TypeofIsAndBranch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 181 | V(UnaryMathOperation) \ |
| 182 | V(UnknownOSRValue) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 183 | V(UseConst) \ |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 184 | V(ValueOf) \ |
| 185 | V(ForInPrepareMap) \ |
| 186 | V(ForInCacheArray) \ |
| 187 | V(CheckMapValue) \ |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 188 | V(LoadFieldByIndex) \ |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 189 | V(DateField) \ |
| 190 | V(WrapReceiver) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 191 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 192 | #define GVN_TRACKED_FLAG_LIST(V) \ |
| 193 | V(NewSpacePromotion) |
| 194 | |
| 195 | #define GVN_UNTRACKED_FLAG_LIST(V) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 196 | V(Calls) \ |
| 197 | V(InobjectFields) \ |
| 198 | V(BackingStoreFields) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 199 | V(ElementsKind) \ |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 200 | V(ElementsPointer) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 201 | V(ArrayElements) \ |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 202 | V(DoubleArrayElements) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 203 | V(SpecializedArrayElements) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 204 | V(GlobalVars) \ |
| 205 | V(Maps) \ |
| 206 | V(ArrayLengths) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 207 | V(ContextSlots) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 208 | V(OsrEntries) |
| 209 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 210 | #define DECLARE_ABSTRACT_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 211 | virtual bool Is##type() const { return true; } \ |
| 212 | static H##type* cast(HValue* value) { \ |
| 213 | ASSERT(value->Is##type()); \ |
| 214 | return reinterpret_cast<H##type*>(value); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 215 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 216 | |
| 217 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 218 | #define DECLARE_CONCRETE_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 219 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 220 | static H##type* cast(HValue* value) { \ |
| 221 | ASSERT(value->Is##type()); \ |
| 222 | return reinterpret_cast<H##type*>(value); \ |
| 223 | } \ |
| 224 | virtual Opcode opcode() const { return HValue::k##type; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 225 | |
| 226 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 227 | class Range: public ZoneObject { |
| 228 | public: |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 229 | Range() |
| 230 | : lower_(kMinInt), |
| 231 | upper_(kMaxInt), |
| 232 | next_(NULL), |
| 233 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 234 | |
| 235 | Range(int32_t lower, int32_t upper) |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 236 | : lower_(lower), |
| 237 | upper_(upper), |
| 238 | next_(NULL), |
| 239 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 240 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 241 | int32_t upper() const { return upper_; } |
| 242 | int32_t lower() const { return lower_; } |
| 243 | Range* next() const { return next_; } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 244 | Range* CopyClearLower(Zone* zone) const { |
| 245 | return new(zone) Range(kMinInt, upper_); |
| 246 | } |
| 247 | Range* CopyClearUpper(Zone* zone) const { |
| 248 | return new(zone) Range(lower_, kMaxInt); |
| 249 | } |
| 250 | Range* Copy(Zone* zone) const { |
| 251 | Range* result = new(zone) Range(lower_, upper_); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 252 | result->set_can_be_minus_zero(CanBeMinusZero()); |
| 253 | return result; |
| 254 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 255 | int32_t Mask() const; |
| 256 | void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } |
| 257 | bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } |
| 258 | bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } |
| 259 | bool CanBeNegative() const { return lower_ < 0; } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 260 | bool Includes(int value) const { return lower_ <= value && upper_ >= value; } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 261 | bool IsMostGeneric() const { |
| 262 | return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero(); |
| 263 | } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 264 | bool IsInSmiRange() const { |
| 265 | return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 266 | } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 267 | void KeepOrder(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 268 | #ifdef DEBUG |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 269 | void Verify() const; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 270 | #endif |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 271 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 272 | void StackUpon(Range* other) { |
| 273 | Intersect(other); |
| 274 | next_ = other; |
| 275 | } |
| 276 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 277 | void Intersect(Range* other); |
| 278 | void Union(Range* other); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 279 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 280 | void AddConstant(int32_t value); |
| 281 | void Sar(int32_t value); |
| 282 | void Shl(int32_t value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 283 | bool AddAndCheckOverflow(Range* other); |
| 284 | bool SubAndCheckOverflow(Range* other); |
| 285 | bool MulAndCheckOverflow(Range* other); |
| 286 | |
| 287 | private: |
| 288 | int32_t lower_; |
| 289 | int32_t upper_; |
| 290 | Range* next_; |
| 291 | bool can_be_minus_zero_; |
| 292 | }; |
| 293 | |
| 294 | |
| 295 | class Representation { |
| 296 | public: |
| 297 | enum Kind { |
| 298 | kNone, |
| 299 | kTagged, |
| 300 | kDouble, |
| 301 | kInteger32, |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 302 | kExternal, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 303 | kNumRepresentations |
| 304 | }; |
| 305 | |
| 306 | Representation() : kind_(kNone) { } |
| 307 | |
| 308 | static Representation None() { return Representation(kNone); } |
| 309 | static Representation Tagged() { return Representation(kTagged); } |
| 310 | static Representation Integer32() { return Representation(kInteger32); } |
| 311 | static Representation Double() { return Representation(kDouble); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 312 | static Representation External() { return Representation(kExternal); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 313 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 314 | bool Equals(const Representation& other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 315 | return kind_ == other.kind_; |
| 316 | } |
| 317 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 318 | Kind kind() const { return static_cast<Kind>(kind_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 319 | bool IsNone() const { return kind_ == kNone; } |
| 320 | bool IsTagged() const { return kind_ == kTagged; } |
| 321 | bool IsInteger32() const { return kind_ == kInteger32; } |
| 322 | bool IsDouble() const { return kind_ == kDouble; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 323 | bool IsExternal() const { return kind_ == kExternal; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 324 | bool IsSpecialization() const { |
| 325 | return kind_ == kInteger32 || kind_ == kDouble; |
| 326 | } |
| 327 | const char* Mnemonic() const; |
| 328 | |
| 329 | private: |
| 330 | explicit Representation(Kind k) : kind_(k) { } |
| 331 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 332 | // Make sure kind fits in int8. |
| 333 | STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte)); |
| 334 | |
| 335 | int8_t kind_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | |
| 339 | class HType { |
| 340 | public: |
| 341 | HType() : type_(kUninitialized) { } |
| 342 | |
| 343 | static HType Tagged() { return HType(kTagged); } |
| 344 | static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } |
| 345 | static HType TaggedNumber() { return HType(kTaggedNumber); } |
| 346 | static HType Smi() { return HType(kSmi); } |
| 347 | static HType HeapNumber() { return HType(kHeapNumber); } |
| 348 | static HType String() { return HType(kString); } |
| 349 | static HType Boolean() { return HType(kBoolean); } |
| 350 | static HType NonPrimitive() { return HType(kNonPrimitive); } |
| 351 | static HType JSArray() { return HType(kJSArray); } |
| 352 | static HType JSObject() { return HType(kJSObject); } |
| 353 | static HType Uninitialized() { return HType(kUninitialized); } |
| 354 | |
| 355 | // Return the weakest (least precise) common type. |
| 356 | HType Combine(HType other) { |
| 357 | return HType(static_cast<Type>(type_ & other.type_)); |
| 358 | } |
| 359 | |
| 360 | bool Equals(const HType& other) { |
| 361 | return type_ == other.type_; |
| 362 | } |
| 363 | |
| 364 | bool IsSubtypeOf(const HType& other) { |
| 365 | return Combine(other).Equals(other); |
| 366 | } |
| 367 | |
| 368 | bool IsTagged() { |
| 369 | ASSERT(type_ != kUninitialized); |
| 370 | return ((type_ & kTagged) == kTagged); |
| 371 | } |
| 372 | |
| 373 | bool IsTaggedPrimitive() { |
| 374 | ASSERT(type_ != kUninitialized); |
| 375 | return ((type_ & kTaggedPrimitive) == kTaggedPrimitive); |
| 376 | } |
| 377 | |
| 378 | bool IsTaggedNumber() { |
| 379 | ASSERT(type_ != kUninitialized); |
| 380 | return ((type_ & kTaggedNumber) == kTaggedNumber); |
| 381 | } |
| 382 | |
| 383 | bool IsSmi() { |
| 384 | ASSERT(type_ != kUninitialized); |
| 385 | return ((type_ & kSmi) == kSmi); |
| 386 | } |
| 387 | |
| 388 | bool IsHeapNumber() { |
| 389 | ASSERT(type_ != kUninitialized); |
| 390 | return ((type_ & kHeapNumber) == kHeapNumber); |
| 391 | } |
| 392 | |
| 393 | bool IsString() { |
| 394 | ASSERT(type_ != kUninitialized); |
| 395 | return ((type_ & kString) == kString); |
| 396 | } |
| 397 | |
| 398 | bool IsBoolean() { |
| 399 | ASSERT(type_ != kUninitialized); |
| 400 | return ((type_ & kBoolean) == kBoolean); |
| 401 | } |
| 402 | |
| 403 | bool IsNonPrimitive() { |
| 404 | ASSERT(type_ != kUninitialized); |
| 405 | return ((type_ & kNonPrimitive) == kNonPrimitive); |
| 406 | } |
| 407 | |
| 408 | bool IsJSArray() { |
| 409 | ASSERT(type_ != kUninitialized); |
| 410 | return ((type_ & kJSArray) == kJSArray); |
| 411 | } |
| 412 | |
| 413 | bool IsJSObject() { |
| 414 | ASSERT(type_ != kUninitialized); |
| 415 | return ((type_ & kJSObject) == kJSObject); |
| 416 | } |
| 417 | |
| 418 | bool IsUninitialized() { |
| 419 | return type_ == kUninitialized; |
| 420 | } |
| 421 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 422 | bool IsHeapObject() { |
| 423 | ASSERT(type_ != kUninitialized); |
| 424 | return IsHeapNumber() || IsString() || IsNonPrimitive(); |
| 425 | } |
| 426 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 427 | static HType TypeFromValue(Handle<Object> value); |
| 428 | |
| 429 | const char* ToString(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 430 | |
| 431 | private: |
| 432 | enum Type { |
| 433 | kTagged = 0x1, // 0000 0000 0000 0001 |
| 434 | kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
| 435 | kTaggedNumber = 0xd, // 0000 0000 0000 1101 |
| 436 | kSmi = 0x1d, // 0000 0000 0001 1101 |
| 437 | kHeapNumber = 0x2d, // 0000 0000 0010 1101 |
| 438 | kString = 0x45, // 0000 0000 0100 0101 |
| 439 | kBoolean = 0x85, // 0000 0000 1000 0101 |
| 440 | kNonPrimitive = 0x101, // 0000 0001 0000 0001 |
| 441 | kJSObject = 0x301, // 0000 0011 0000 0001 |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 442 | kJSArray = 0x701, // 0000 0111 0000 0001 |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 443 | kUninitialized = 0x1fff // 0001 1111 1111 1111 |
| 444 | }; |
| 445 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 446 | // Make sure type fits in int16. |
| 447 | STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte))); |
| 448 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 449 | explicit HType(Type t) : type_(t) { } |
| 450 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 451 | int16_t type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 452 | }; |
| 453 | |
| 454 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 455 | class HUseListNode: public ZoneObject { |
| 456 | public: |
| 457 | HUseListNode(HValue* value, int index, HUseListNode* tail) |
| 458 | : tail_(tail), value_(value), index_(index) { |
| 459 | } |
| 460 | |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 461 | HUseListNode* tail(); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 462 | HValue* value() const { return value_; } |
| 463 | int index() const { return index_; } |
| 464 | |
| 465 | void set_tail(HUseListNode* list) { tail_ = list; } |
| 466 | |
| 467 | #ifdef DEBUG |
| 468 | void Zap() { |
| 469 | tail_ = reinterpret_cast<HUseListNode*>(1); |
| 470 | value_ = NULL; |
| 471 | index_ = -1; |
| 472 | } |
| 473 | #endif |
| 474 | |
| 475 | private: |
| 476 | HUseListNode* tail_; |
| 477 | HValue* value_; |
| 478 | int index_; |
| 479 | }; |
| 480 | |
| 481 | |
| 482 | // We reuse use list nodes behind the scenes as uses are added and deleted. |
| 483 | // This class is the safe way to iterate uses while deleting them. |
| 484 | class HUseIterator BASE_EMBEDDED { |
| 485 | public: |
| 486 | bool Done() { return current_ == NULL; } |
| 487 | void Advance(); |
| 488 | |
| 489 | HValue* value() { |
| 490 | ASSERT(!Done()); |
| 491 | return value_; |
| 492 | } |
| 493 | |
| 494 | int index() { |
| 495 | ASSERT(!Done()); |
| 496 | return index_; |
| 497 | } |
| 498 | |
| 499 | private: |
| 500 | explicit HUseIterator(HUseListNode* head); |
| 501 | |
| 502 | HUseListNode* current_; |
| 503 | HUseListNode* next_; |
| 504 | HValue* value_; |
| 505 | int index_; |
| 506 | |
| 507 | friend class HValue; |
| 508 | }; |
| 509 | |
| 510 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 511 | // There must be one corresponding kDepends flag for every kChanges flag and |
| 512 | // the order of the kChanges flags must be exactly the same as of the kDepends |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 513 | // flags. All tracked flags should appear before untracked ones. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 514 | enum GVNFlag { |
| 515 | // Declare global value numbering flags. |
| 516 | #define DECLARE_FLAG(type) kChanges##type, kDependsOn##type, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 517 | GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) |
| 518 | GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 519 | #undef DECLARE_FLAG |
| 520 | kAfterLastFlag, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 521 | kLastFlag = kAfterLastFlag - 1, |
| 522 | #define COUNT_FLAG(type) + 1 |
| 523 | kNumberOfTrackedSideEffects = 0 GVN_TRACKED_FLAG_LIST(COUNT_FLAG) |
| 524 | #undef COUNT_FLAG |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 525 | }; |
| 526 | |
| 527 | typedef EnumSet<GVNFlag> GVNFlagSet; |
| 528 | |
| 529 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 530 | class HValue: public ZoneObject { |
| 531 | public: |
| 532 | static const int kNoNumber = -1; |
| 533 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 534 | enum Flag { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 535 | kFlexibleRepresentation, |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 536 | // Participate in Global Value Numbering, i.e. elimination of |
| 537 | // unnecessary recomputations. If an instruction sets this flag, it must |
| 538 | // implement DataEquals(), which will be used to determine if other |
| 539 | // occurrences of the instruction are indeed the same. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 540 | kUseGVN, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 541 | // Track instructions that are dominating side effects. If an instruction |
| 542 | // sets this flag, it must implement SetSideEffectDominator() and should |
| 543 | // indicate which side effects to track by setting GVN flags. |
| 544 | kTrackSideEffectDominators, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 545 | kCanOverflow, |
| 546 | kBailoutOnMinusZero, |
| 547 | kCanBeDivByZero, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 548 | kDeoptimizeOnUndefined, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 549 | kIsArguments, |
| 550 | kTruncatingToInt32, |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 551 | kIsDead, |
| 552 | kLastFlag = kIsDead |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 553 | }; |
| 554 | |
| 555 | STATIC_ASSERT(kLastFlag < kBitsPerInt); |
| 556 | |
| 557 | static const int kChangesToDependsFlagsLeftShift = 1; |
| 558 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 559 | static GVNFlag ChangesFlagFromInt(int x) { |
| 560 | return static_cast<GVNFlag>(x * 2); |
| 561 | } |
| 562 | static GVNFlag DependsOnFlagFromInt(int x) { |
| 563 | return static_cast<GVNFlag>(x * 2 + 1); |
| 564 | } |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 565 | static GVNFlagSet ConvertChangesToDependsFlags(GVNFlagSet flags) { |
| 566 | return GVNFlagSet(flags.ToIntegral() << kChangesToDependsFlagsLeftShift); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 567 | } |
| 568 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 569 | static HValue* cast(HValue* value) { return value; } |
| 570 | |
| 571 | enum Opcode { |
| 572 | // Declare a unique enum value for each hydrogen instruction. |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 573 | #define DECLARE_OPCODE(type) k##type, |
| 574 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 575 | kPhi |
| 576 | #undef DECLARE_OPCODE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 577 | }; |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 578 | virtual Opcode opcode() const = 0; |
| 579 | |
| 580 | // Declare a non-virtual predicates for each concrete HInstruction or HValue. |
| 581 | #define DECLARE_PREDICATE(type) \ |
| 582 | bool Is##type() const { return opcode() == k##type; } |
| 583 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 584 | #undef DECLARE_PREDICATE |
| 585 | bool IsPhi() const { return opcode() == kPhi; } |
| 586 | |
| 587 | // Declare virtual predicates for abstract HInstruction or HValue |
| 588 | #define DECLARE_PREDICATE(type) \ |
| 589 | virtual bool Is##type() const { return false; } |
| 590 | HYDROGEN_ABSTRACT_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 591 | #undef DECLARE_PREDICATE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 592 | |
| 593 | HValue() : block_(NULL), |
| 594 | id_(kNoNumber), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 595 | type_(HType::Tagged()), |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 596 | use_list_(NULL), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 597 | range_(NULL), |
| 598 | flags_(0) {} |
| 599 | virtual ~HValue() {} |
| 600 | |
| 601 | HBasicBlock* block() const { return block_; } |
| 602 | void SetBlock(HBasicBlock* block); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 603 | int LoopWeight() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 604 | |
| 605 | int id() const { return id_; } |
| 606 | void set_id(int id) { id_ = id; } |
| 607 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 608 | HUseIterator uses() const { return HUseIterator(use_list_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 609 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 610 | virtual bool EmitAtUses() { return false; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 611 | Representation representation() const { return representation_; } |
| 612 | void ChangeRepresentation(Representation r) { |
| 613 | // Representation was already set and is allowed to be changed. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 614 | ASSERT(!r.IsNone()); |
| 615 | ASSERT(CheckFlag(kFlexibleRepresentation)); |
| 616 | RepresentationChanged(r); |
| 617 | representation_ = r; |
| 618 | } |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 619 | void AssumeRepresentation(Representation r); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 620 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 621 | virtual bool IsConvertibleToInteger() const { return true; } |
| 622 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 623 | HType type() const { return type_; } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 624 | void set_type(HType new_type) { |
| 625 | ASSERT(new_type.IsSubtypeOf(type_)); |
| 626 | type_ = new_type; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | // An operation needs to override this function iff: |
| 630 | // 1) it can produce an int32 output. |
| 631 | // 2) the true value of its output can potentially be minus zero. |
| 632 | // The implementation must set a flag so that it bails out in the case where |
| 633 | // it would otherwise output what should be a minus zero as an int32 zero. |
| 634 | // If the operation also exists in a form that takes int32 and outputs int32 |
| 635 | // then the operation should return its input value so that we can propagate |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 636 | // back. There are three operations that need to propagate back to more than |
| 637 | // one input. They are phi and binary div and mul. They always return NULL |
| 638 | // and expect the caller to take care of things. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 639 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited) { |
| 640 | visited->Add(id()); |
| 641 | return NULL; |
| 642 | } |
| 643 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 644 | bool IsDefinedAfter(HBasicBlock* other) const; |
| 645 | |
| 646 | // Operands. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 647 | virtual int OperandCount() = 0; |
| 648 | virtual HValue* OperandAt(int index) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 649 | void SetOperandAt(int index, HValue* value); |
| 650 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 651 | void DeleteAndReplaceWith(HValue* other); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 652 | void ReplaceAllUsesWith(HValue* other); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 653 | bool HasNoUses() const { return use_list_ == NULL; } |
| 654 | bool HasMultipleUses() const { |
| 655 | return use_list_ != NULL && use_list_->tail() != NULL; |
| 656 | } |
| 657 | int UseCount() const; |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 658 | |
| 659 | // Mark this HValue as dead and to be removed from other HValues' use lists. |
| 660 | void Kill(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 661 | |
| 662 | int flags() const { return flags_; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 663 | void SetFlag(Flag f) { flags_ |= (1 << f); } |
| 664 | void ClearFlag(Flag f) { flags_ &= ~(1 << f); } |
| 665 | bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } |
| 666 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 667 | // Returns true if the flag specified is set for all uses, false otherwise. |
| 668 | bool CheckUsesForFlag(Flag f); |
| 669 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 670 | GVNFlagSet gvn_flags() const { return gvn_flags_; } |
| 671 | void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } |
| 672 | void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } |
| 673 | bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } |
| 674 | void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } |
| 675 | void ClearAllSideEffects() { |
| 676 | gvn_flags_.Remove(AllSideEffectsFlagSet()); |
| 677 | } |
| 678 | bool HasSideEffects() const { |
| 679 | return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); |
| 680 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 681 | bool HasObservableSideEffects() const { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 682 | return gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 683 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 684 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 685 | GVNFlagSet DependsOnFlags() const { |
| 686 | GVNFlagSet result = gvn_flags_; |
| 687 | result.Intersect(AllDependsOnFlagSet()); |
| 688 | return result; |
| 689 | } |
| 690 | |
| 691 | GVNFlagSet SideEffectFlags() const { |
| 692 | GVNFlagSet result = gvn_flags_; |
| 693 | result.Intersect(AllSideEffectsFlagSet()); |
| 694 | return result; |
| 695 | } |
| 696 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 697 | GVNFlagSet ChangesFlags() const { |
| 698 | GVNFlagSet result = gvn_flags_; |
| 699 | result.Intersect(AllChangesFlagSet()); |
| 700 | return result; |
| 701 | } |
| 702 | |
| 703 | GVNFlagSet ObservableChangesFlags() const { |
| 704 | GVNFlagSet result = gvn_flags_; |
| 705 | result.Intersect(AllChangesFlagSet()); |
| 706 | result.Intersect(AllObservableSideEffectsFlagSet()); |
| 707 | return result; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 708 | } |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 709 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 710 | Range* range() const { return range_; } |
| 711 | bool HasRange() const { return range_ != NULL; } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 712 | void AddNewRange(Range* r, Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 713 | void RemoveLastAddedRange(); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 714 | void ComputeInitialRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 715 | |
| 716 | // Representation helpers. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 717 | virtual Representation RequiredInputRepresentation(int index) = 0; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 718 | |
| 719 | virtual Representation InferredRepresentation() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 720 | return representation(); |
| 721 | } |
| 722 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 723 | // Type feedback access. |
| 724 | virtual Representation ObservedInputRepresentation(int index) { |
| 725 | return RequiredInputRepresentation(index); |
| 726 | } |
| 727 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 728 | // This gives the instruction an opportunity to replace itself with an |
| 729 | // instruction that does the same in some better way. To replace an |
| 730 | // instruction with a new one, first add the new instruction to the graph, |
| 731 | // then return it. Return NULL to have the instruction deleted. |
| 732 | virtual HValue* Canonicalize() { return this; } |
| 733 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 734 | bool Equals(HValue* other); |
| 735 | virtual intptr_t Hashcode(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 736 | |
| 737 | // Printing support. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 738 | virtual void PrintTo(StringStream* stream) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 739 | void PrintNameTo(StringStream* stream); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 740 | void PrintTypeTo(StringStream* stream); |
| 741 | void PrintRangeTo(StringStream* stream); |
| 742 | void PrintChangesTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 743 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 744 | const char* Mnemonic() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 745 | |
| 746 | // Updated the inferred type of this instruction and returns true if |
| 747 | // it has changed. |
| 748 | bool UpdateInferredType(); |
| 749 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 750 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 751 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 752 | // This function must be overridden for instructions which have the |
| 753 | // kTrackSideEffectDominators flag set, to track instructions that are |
| 754 | // dominating side effects. |
| 755 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
| 756 | UNREACHABLE(); |
| 757 | } |
| 758 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 759 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 760 | virtual void Verify() = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 761 | #endif |
| 762 | |
| 763 | protected: |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 764 | // This function must be overridden for instructions with flag kUseGVN, to |
| 765 | // compare the non-Operand parts of the instruction. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 766 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 767 | UNREACHABLE(); |
| 768 | return false; |
| 769 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 770 | virtual void RepresentationChanged(Representation to) { } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 771 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 772 | virtual void DeleteFromGraph() = 0; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 773 | virtual void InternalSetOperandAt(int index, HValue* value) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 774 | void clear_block() { |
| 775 | ASSERT(block_ != NULL); |
| 776 | block_ = NULL; |
| 777 | } |
| 778 | |
| 779 | void set_representation(Representation r) { |
| 780 | // Representation is set-once. |
| 781 | ASSERT(representation_.IsNone() && !r.IsNone()); |
| 782 | representation_ = r; |
| 783 | } |
| 784 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 785 | static GVNFlagSet AllDependsOnFlagSet() { |
| 786 | GVNFlagSet result; |
| 787 | // Create changes mask. |
| 788 | #define ADD_FLAG(type) result.Add(kDependsOn##type); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 789 | GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
| 790 | GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 791 | #undef ADD_FLAG |
| 792 | return result; |
| 793 | } |
| 794 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 795 | static GVNFlagSet AllChangesFlagSet() { |
| 796 | GVNFlagSet result; |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 797 | // Create changes mask. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 798 | #define ADD_FLAG(type) result.Add(kChanges##type); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 799 | GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
| 800 | GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 801 | #undef ADD_FLAG |
| 802 | return result; |
| 803 | } |
| 804 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 805 | // A flag mask to mark an instruction as having arbitrary side effects. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 806 | static GVNFlagSet AllSideEffectsFlagSet() { |
| 807 | GVNFlagSet result = AllChangesFlagSet(); |
| 808 | result.Remove(kChangesOsrEntries); |
| 809 | return result; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 810 | } |
| 811 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 812 | // A flag mask of all side effects that can make observable changes in |
| 813 | // an executing program (i.e. are not safe to repeat, move or remove); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 814 | static GVNFlagSet AllObservableSideEffectsFlagSet() { |
| 815 | GVNFlagSet result = AllChangesFlagSet(); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 816 | result.Remove(kChangesNewSpacePromotion); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 817 | result.Remove(kChangesElementsKind); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 818 | result.Remove(kChangesElementsPointer); |
| 819 | result.Remove(kChangesMaps); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 820 | return result; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 821 | } |
| 822 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 823 | // Remove the matching use from the use list if present. Returns the |
| 824 | // removed list node or NULL. |
| 825 | HUseListNode* RemoveUse(HValue* value, int index); |
| 826 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 827 | void RegisterUse(int index, HValue* new_value); |
| 828 | |
| 829 | HBasicBlock* block_; |
| 830 | |
| 831 | // The id of this instruction in the hydrogen graph, assigned when first |
| 832 | // added to the graph. Reflects creation order. |
| 833 | int id_; |
| 834 | |
| 835 | Representation representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 836 | HType type_; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 837 | HUseListNode* use_list_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 838 | Range* range_; |
| 839 | int flags_; |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 840 | GVNFlagSet gvn_flags_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 841 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 842 | private: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 843 | DISALLOW_COPY_AND_ASSIGN(HValue); |
| 844 | }; |
| 845 | |
| 846 | |
| 847 | class HInstruction: public HValue { |
| 848 | public: |
| 849 | HInstruction* next() const { return next_; } |
| 850 | HInstruction* previous() const { return previous_; } |
| 851 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 852 | virtual void PrintTo(StringStream* stream); |
| 853 | virtual void PrintDataTo(StringStream* stream) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 854 | |
| 855 | bool IsLinked() const { return block() != NULL; } |
| 856 | void Unlink(); |
| 857 | void InsertBefore(HInstruction* next); |
| 858 | void InsertAfter(HInstruction* previous); |
| 859 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 860 | // The position is a write-once variable. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 861 | int position() const { return position_; } |
| 862 | bool has_position() const { return position_ != RelocInfo::kNoPosition; } |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 863 | void set_position(int position) { |
| 864 | ASSERT(!has_position()); |
| 865 | ASSERT(position != RelocInfo::kNoPosition); |
| 866 | position_ = position; |
| 867 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 868 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 869 | bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } |
| 870 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 871 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; |
| 872 | |
| 873 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 874 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 875 | #endif |
| 876 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 877 | virtual bool IsCall() { return false; } |
| 878 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 879 | DECLARE_ABSTRACT_INSTRUCTION(Instruction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 880 | |
| 881 | protected: |
| 882 | HInstruction() |
| 883 | : next_(NULL), |
| 884 | previous_(NULL), |
| 885 | position_(RelocInfo::kNoPosition) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 886 | SetGVNFlag(kDependsOnOsrEntries); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | virtual void DeleteFromGraph() { Unlink(); } |
| 890 | |
| 891 | private: |
| 892 | void InitializeAsFirst(HBasicBlock* block) { |
| 893 | ASSERT(!IsLinked()); |
| 894 | SetBlock(block); |
| 895 | } |
| 896 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 897 | void PrintMnemonicTo(StringStream* stream); |
| 898 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 899 | HInstruction* next_; |
| 900 | HInstruction* previous_; |
| 901 | int position_; |
| 902 | |
| 903 | friend class HBasicBlock; |
| 904 | }; |
| 905 | |
| 906 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 907 | template<int V> |
| 908 | class HTemplateInstruction : public HInstruction { |
| 909 | public: |
| 910 | int OperandCount() { return V; } |
| 911 | HValue* OperandAt(int i) { return inputs_[i]; } |
| 912 | |
| 913 | protected: |
| 914 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 915 | |
| 916 | private: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 917 | EmbeddedContainer<HValue*, V> inputs_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 918 | }; |
| 919 | |
| 920 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 921 | class HControlInstruction: public HInstruction { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 922 | public: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 923 | virtual HBasicBlock* SuccessorAt(int i) = 0; |
| 924 | virtual int SuccessorCount() = 0; |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 925 | virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0; |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 926 | |
| 927 | virtual void PrintDataTo(StringStream* stream); |
| 928 | |
| 929 | HBasicBlock* FirstSuccessor() { |
| 930 | return SuccessorCount() > 0 ? SuccessorAt(0) : NULL; |
| 931 | } |
| 932 | HBasicBlock* SecondSuccessor() { |
| 933 | return SuccessorCount() > 1 ? SuccessorAt(1) : NULL; |
| 934 | } |
| 935 | |
| 936 | DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction) |
| 937 | }; |
| 938 | |
| 939 | |
| 940 | class HSuccessorIterator BASE_EMBEDDED { |
| 941 | public: |
| 942 | explicit HSuccessorIterator(HControlInstruction* instr) |
| 943 | : instr_(instr), current_(0) { } |
| 944 | |
| 945 | bool Done() { return current_ >= instr_->SuccessorCount(); } |
| 946 | HBasicBlock* Current() { return instr_->SuccessorAt(current_); } |
| 947 | void Advance() { current_++; } |
| 948 | |
| 949 | private: |
| 950 | HControlInstruction* instr_; |
| 951 | int current_; |
| 952 | }; |
| 953 | |
| 954 | |
| 955 | template<int S, int V> |
| 956 | class HTemplateControlInstruction: public HControlInstruction { |
| 957 | public: |
| 958 | int SuccessorCount() { return S; } |
| 959 | HBasicBlock* SuccessorAt(int i) { return successors_[i]; } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 960 | void SetSuccessorAt(int i, HBasicBlock* block) { successors_[i] = block; } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 961 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 962 | int OperandCount() { return V; } |
| 963 | HValue* OperandAt(int i) { return inputs_[i]; } |
| 964 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 965 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 966 | protected: |
| 967 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 968 | |
| 969 | private: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 970 | EmbeddedContainer<HBasicBlock*, S> successors_; |
| 971 | EmbeddedContainer<HValue*, V> inputs_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 972 | }; |
| 973 | |
| 974 | |
| 975 | class HBlockEntry: public HTemplateInstruction<0> { |
| 976 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 977 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 978 | return Representation::None(); |
| 979 | } |
| 980 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 981 | DECLARE_CONCRETE_INSTRUCTION(BlockEntry) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 982 | }; |
| 983 | |
| 984 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 985 | // We insert soft-deoptimize when we hit code with unknown typefeedback, |
| 986 | // so that we get a chance of re-optimizing with useful typefeedback. |
| 987 | // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize. |
| 988 | class HSoftDeoptimize: public HTemplateInstruction<0> { |
| 989 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 990 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 991 | return Representation::None(); |
| 992 | } |
| 993 | |
| 994 | DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) |
| 995 | }; |
| 996 | |
| 997 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 998 | class HDeoptimize: public HControlInstruction { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 999 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1000 | HDeoptimize(int environment_length, Zone* zone) |
| 1001 | : values_(environment_length, zone) { } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1002 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1003 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1004 | return Representation::None(); |
| 1005 | } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1006 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1007 | virtual int OperandCount() { return values_.length(); } |
| 1008 | virtual HValue* OperandAt(int index) { return values_[index]; } |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 1009 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1010 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1011 | virtual int SuccessorCount() { return 0; } |
| 1012 | virtual HBasicBlock* SuccessorAt(int i) { |
| 1013 | UNREACHABLE(); |
| 1014 | return NULL; |
| 1015 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1016 | virtual void SetSuccessorAt(int i, HBasicBlock* block) { |
| 1017 | UNREACHABLE(); |
| 1018 | } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1019 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1020 | void AddEnvironmentValue(HValue* value, Zone* zone) { |
| 1021 | values_.Add(NULL, zone); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1022 | SetOperandAt(values_.length() - 1, value); |
| 1023 | } |
| 1024 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1025 | DECLARE_CONCRETE_INSTRUCTION(Deoptimize) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1026 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 1027 | enum UseEnvironment { |
| 1028 | kNoUses, |
| 1029 | kUseAll |
| 1030 | }; |
| 1031 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1032 | protected: |
| 1033 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1034 | values_[index] = value; |
| 1035 | } |
| 1036 | |
| 1037 | private: |
| 1038 | ZoneList<HValue*> values_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1039 | }; |
| 1040 | |
| 1041 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1042 | class HGoto: public HTemplateControlInstruction<1, 0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1043 | public: |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1044 | explicit HGoto(HBasicBlock* target) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1045 | SetSuccessorAt(0, target); |
| 1046 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1047 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1048 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1049 | return Representation::None(); |
| 1050 | } |
| 1051 | |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 1052 | virtual void PrintDataTo(StringStream* stream); |
| 1053 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1054 | DECLARE_CONCRETE_INSTRUCTION(Goto) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1055 | }; |
| 1056 | |
| 1057 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1058 | class HUnaryControlInstruction: public HTemplateControlInstruction<2, 1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1059 | public: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1060 | HUnaryControlInstruction(HValue* value, |
| 1061 | HBasicBlock* true_target, |
| 1062 | HBasicBlock* false_target) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1063 | SetOperandAt(0, value); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1064 | SetSuccessorAt(0, true_target); |
| 1065 | SetSuccessorAt(1, false_target); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1068 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1069 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1070 | HValue* value() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1071 | }; |
| 1072 | |
| 1073 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1074 | class HBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1075 | public: |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1076 | HBranch(HValue* value, |
| 1077 | HBasicBlock* true_target, |
| 1078 | HBasicBlock* false_target, |
| 1079 | ToBooleanStub::Types expected_input_types = ToBooleanStub::no_types()) |
| 1080 | : HUnaryControlInstruction(value, true_target, false_target), |
| 1081 | expected_input_types_(expected_input_types) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1082 | ASSERT(true_target != NULL && false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1083 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1084 | explicit HBranch(HValue* value) |
| 1085 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 1086 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1087 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1088 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1089 | return Representation::None(); |
| 1090 | } |
| 1091 | |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1092 | ToBooleanStub::Types expected_input_types() const { |
| 1093 | return expected_input_types_; |
| 1094 | } |
| 1095 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1096 | DECLARE_CONCRETE_INSTRUCTION(Branch) |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1097 | |
| 1098 | private: |
| 1099 | ToBooleanStub::Types expected_input_types_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1100 | }; |
| 1101 | |
| 1102 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1103 | class HCompareMap: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1104 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1105 | HCompareMap(HValue* value, |
| 1106 | Handle<Map> map, |
| 1107 | HBasicBlock* true_target, |
| 1108 | HBasicBlock* false_target) |
| 1109 | : HUnaryControlInstruction(value, true_target, false_target), |
| 1110 | map_(map) { |
| 1111 | ASSERT(true_target != NULL); |
| 1112 | ASSERT(false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1113 | ASSERT(!map.is_null()); |
| 1114 | } |
| 1115 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1116 | virtual void PrintDataTo(StringStream* stream); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 1117 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1118 | Handle<Map> map() const { return map_; } |
| 1119 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1120 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1121 | return Representation::Tagged(); |
| 1122 | } |
| 1123 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1124 | DECLARE_CONCRETE_INSTRUCTION(CompareMap) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1125 | |
| 1126 | private: |
| 1127 | Handle<Map> map_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1128 | }; |
| 1129 | |
| 1130 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1131 | class HReturn: public HTemplateControlInstruction<0, 1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1132 | public: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1133 | explicit HReturn(HValue* value) { |
| 1134 | SetOperandAt(0, value); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1135 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1136 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1137 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1138 | return Representation::Tagged(); |
| 1139 | } |
| 1140 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1141 | virtual void PrintDataTo(StringStream* stream); |
| 1142 | |
| 1143 | HValue* value() { return OperandAt(0); } |
| 1144 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1145 | DECLARE_CONCRETE_INSTRUCTION(Return) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1146 | }; |
| 1147 | |
| 1148 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1149 | class HAbnormalExit: public HTemplateControlInstruction<0, 0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1150 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1151 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1152 | return Representation::None(); |
| 1153 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1154 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1155 | DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1156 | }; |
| 1157 | |
| 1158 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1159 | class HUnaryOperation: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1160 | public: |
| 1161 | explicit HUnaryOperation(HValue* value) { |
| 1162 | SetOperandAt(0, value); |
| 1163 | } |
| 1164 | |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 1165 | static HUnaryOperation* cast(HValue* value) { |
| 1166 | return reinterpret_cast<HUnaryOperation*>(value); |
| 1167 | } |
| 1168 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1169 | HValue* value() { return OperandAt(0); } |
| 1170 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1171 | }; |
| 1172 | |
| 1173 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1174 | class HThrow: public HTemplateInstruction<2> { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1175 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1176 | HThrow(HValue* context, HValue* value) { |
| 1177 | SetOperandAt(0, context); |
| 1178 | SetOperandAt(1, value); |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1179 | SetAllSideEffects(); |
| 1180 | } |
| 1181 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1182 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1183 | return Representation::Tagged(); |
| 1184 | } |
| 1185 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1186 | HValue* context() { return OperandAt(0); } |
| 1187 | HValue* value() { return OperandAt(1); } |
| 1188 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1189 | DECLARE_CONCRETE_INSTRUCTION(Throw) |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1190 | }; |
| 1191 | |
| 1192 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1193 | class HUseConst: public HUnaryOperation { |
| 1194 | public: |
| 1195 | explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } |
| 1196 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1197 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1198 | return Representation::None(); |
| 1199 | } |
| 1200 | |
| 1201 | DECLARE_CONCRETE_INSTRUCTION(UseConst) |
| 1202 | }; |
| 1203 | |
| 1204 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1205 | class HForceRepresentation: public HTemplateInstruction<1> { |
| 1206 | public: |
| 1207 | HForceRepresentation(HValue* value, Representation required_representation) { |
| 1208 | SetOperandAt(0, value); |
| 1209 | set_representation(required_representation); |
| 1210 | } |
| 1211 | |
| 1212 | HValue* value() { return OperandAt(0); } |
| 1213 | |
| 1214 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1215 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1216 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1217 | return representation(); // Same as the output representation. |
| 1218 | } |
| 1219 | |
| 1220 | DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation) |
| 1221 | }; |
| 1222 | |
| 1223 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1224 | class HChange: public HUnaryOperation { |
| 1225 | public: |
| 1226 | HChange(HValue* value, |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1227 | Representation to, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1228 | bool is_truncating, |
| 1229 | bool deoptimize_on_undefined) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1230 | : HUnaryOperation(value) { |
| 1231 | ASSERT(!value->representation().IsNone() && !to.IsNone()); |
| 1232 | ASSERT(!value->representation().Equals(to)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1233 | set_representation(to); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1234 | set_type(HType::TaggedNumber()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1235 | SetFlag(kUseGVN); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1236 | if (deoptimize_on_undefined) SetFlag(kDeoptimizeOnUndefined); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1237 | if (is_truncating) SetFlag(kTruncatingToInt32); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1238 | if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
| 1241 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1242 | virtual HType CalculateInferredType(); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1243 | virtual HValue* Canonicalize(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1244 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1245 | Representation from() { return value()->representation(); } |
| 1246 | Representation to() { return representation(); } |
| 1247 | bool deoptimize_on_undefined() const { |
| 1248 | return CheckFlag(kDeoptimizeOnUndefined); |
| 1249 | } |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1250 | bool deoptimize_on_minus_zero() const { |
| 1251 | return CheckFlag(kBailoutOnMinusZero); |
| 1252 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1253 | virtual Representation RequiredInputRepresentation(int index) { |
| 1254 | return from(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1255 | } |
| 1256 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1257 | virtual Range* InferRange(Zone* zone); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 1258 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1259 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1260 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1261 | DECLARE_CONCRETE_INSTRUCTION(Change) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1262 | |
| 1263 | protected: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1264 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1265 | }; |
| 1266 | |
| 1267 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1268 | class HClampToUint8: public HUnaryOperation { |
| 1269 | public: |
| 1270 | explicit HClampToUint8(HValue* value) |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 1271 | : HUnaryOperation(value) { |
| 1272 | set_representation(Representation::Integer32()); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1273 | SetFlag(kUseGVN); |
| 1274 | } |
| 1275 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1276 | virtual Representation RequiredInputRepresentation(int index) { |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 1277 | return Representation::None(); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1278 | } |
| 1279 | |
| 1280 | DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) |
| 1281 | |
| 1282 | protected: |
| 1283 | virtual bool DataEquals(HValue* other) { return true; } |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1284 | }; |
| 1285 | |
| 1286 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1287 | class HSimulate: public HInstruction { |
| 1288 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1289 | HSimulate(int ast_id, int pop_count, Zone* zone) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1290 | : ast_id_(ast_id), |
| 1291 | pop_count_(pop_count), |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1292 | values_(2, zone), |
| 1293 | assigned_indexes_(2, zone), |
| 1294 | zone_(zone) {} |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1295 | virtual ~HSimulate() {} |
| 1296 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1297 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1298 | |
| 1299 | bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; } |
| 1300 | int ast_id() const { return ast_id_; } |
| 1301 | void set_ast_id(int id) { |
| 1302 | ASSERT(!HasAstId()); |
| 1303 | ast_id_ = id; |
| 1304 | } |
| 1305 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1306 | int pop_count() const { return pop_count_; } |
| 1307 | const ZoneList<HValue*>* values() const { return &values_; } |
| 1308 | int GetAssignedIndexAt(int index) const { |
| 1309 | ASSERT(HasAssignedIndexAt(index)); |
| 1310 | return assigned_indexes_[index]; |
| 1311 | } |
| 1312 | bool HasAssignedIndexAt(int index) const { |
| 1313 | return assigned_indexes_[index] != kNoIndex; |
| 1314 | } |
| 1315 | void AddAssignedValue(int index, HValue* value) { |
| 1316 | AddValue(index, value); |
| 1317 | } |
| 1318 | void AddPushedValue(HValue* value) { |
| 1319 | AddValue(kNoIndex, value); |
| 1320 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1321 | virtual int OperandCount() { return values_.length(); } |
| 1322 | virtual HValue* OperandAt(int index) { return values_[index]; } |
| 1323 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1324 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1325 | return Representation::None(); |
| 1326 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1327 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1328 | DECLARE_CONCRETE_INSTRUCTION(Simulate) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1329 | |
| 1330 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1331 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1332 | #endif |
| 1333 | |
| 1334 | protected: |
| 1335 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1336 | values_[index] = value; |
| 1337 | } |
| 1338 | |
| 1339 | private: |
| 1340 | static const int kNoIndex = -1; |
| 1341 | void AddValue(int index, HValue* value) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1342 | assigned_indexes_.Add(index, zone_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1343 | // Resize the list of pushed values. |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1344 | values_.Add(NULL, zone_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1345 | // Set the operand through the base method in HValue to make sure that the |
| 1346 | // use lists are correctly updated. |
| 1347 | SetOperandAt(values_.length() - 1, value); |
| 1348 | } |
| 1349 | int ast_id_; |
| 1350 | int pop_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1351 | ZoneList<HValue*> values_; |
| 1352 | ZoneList<int> assigned_indexes_; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1353 | Zone* zone_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1354 | }; |
| 1355 | |
| 1356 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1357 | class HStackCheck: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1358 | public: |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1359 | enum Type { |
| 1360 | kFunctionEntry, |
| 1361 | kBackwardsBranch |
| 1362 | }; |
| 1363 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1364 | HStackCheck(HValue* context, Type type) : type_(type) { |
| 1365 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1366 | SetGVNFlag(kChangesNewSpacePromotion); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | HValue* context() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1370 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1371 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1372 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1373 | } |
| 1374 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1375 | void Eliminate() { |
| 1376 | // The stack check eliminator might try to eliminate the same stack |
| 1377 | // check instruction multiple times. |
| 1378 | if (IsLinked()) { |
| 1379 | DeleteFromGraph(); |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | bool is_function_entry() { return type_ == kFunctionEntry; } |
| 1384 | bool is_backwards_branch() { return type_ == kBackwardsBranch; } |
| 1385 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1386 | DECLARE_CONCRETE_INSTRUCTION(StackCheck) |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1387 | |
| 1388 | private: |
| 1389 | Type type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1390 | }; |
| 1391 | |
| 1392 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1393 | class HEnterInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1394 | public: |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1395 | HEnterInlined(Handle<JSFunction> closure, |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1396 | int arguments_count, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1397 | FunctionLiteral* function, |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1398 | CallKind call_kind, |
danno@chromium.org | 8c0a43f | 2012-04-03 08:37:53 +0000 | [diff] [blame] | 1399 | bool is_construct, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1400 | Variable* arguments_var, |
| 1401 | ZoneList<HValue*>* arguments_values) |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1402 | : closure_(closure), |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1403 | arguments_count_(arguments_count), |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1404 | function_(function), |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1405 | call_kind_(call_kind), |
danno@chromium.org | 8c0a43f | 2012-04-03 08:37:53 +0000 | [diff] [blame] | 1406 | is_construct_(is_construct), |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1407 | arguments_var_(arguments_var), |
| 1408 | arguments_values_(arguments_values) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1409 | } |
| 1410 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1411 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1412 | |
| 1413 | Handle<JSFunction> closure() const { return closure_; } |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1414 | int arguments_count() const { return arguments_count_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1415 | FunctionLiteral* function() const { return function_; } |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1416 | CallKind call_kind() const { return call_kind_; } |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1417 | bool is_construct() const { return is_construct_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1418 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1419 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1420 | return Representation::None(); |
| 1421 | } |
| 1422 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1423 | Variable* arguments_var() { return arguments_var_; } |
| 1424 | ZoneList<HValue*>* arguments_values() { return arguments_values_; } |
danno@chromium.org | 8c0a43f | 2012-04-03 08:37:53 +0000 | [diff] [blame] | 1425 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1426 | DECLARE_CONCRETE_INSTRUCTION(EnterInlined) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1427 | |
| 1428 | private: |
| 1429 | Handle<JSFunction> closure_; |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1430 | int arguments_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1431 | FunctionLiteral* function_; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1432 | CallKind call_kind_; |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1433 | bool is_construct_; |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1434 | Variable* arguments_var_; |
| 1435 | ZoneList<HValue*>* arguments_values_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1436 | }; |
| 1437 | |
| 1438 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1439 | class HLeaveInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1440 | public: |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1441 | explicit HLeaveInlined(bool arguments_pushed) |
| 1442 | : arguments_pushed_(arguments_pushed) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1443 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1444 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1445 | return Representation::None(); |
| 1446 | } |
| 1447 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1448 | bool arguments_pushed() { |
| 1449 | return arguments_pushed_; |
| 1450 | } |
| 1451 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1452 | DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1453 | |
| 1454 | private: |
| 1455 | bool arguments_pushed_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1456 | }; |
| 1457 | |
| 1458 | |
| 1459 | class HPushArgument: public HUnaryOperation { |
| 1460 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1461 | explicit HPushArgument(HValue* value) : HUnaryOperation(value) { |
| 1462 | set_representation(Representation::Tagged()); |
| 1463 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1464 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1465 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1466 | return Representation::Tagged(); |
| 1467 | } |
| 1468 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1469 | HValue* argument() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1470 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1471 | DECLARE_CONCRETE_INSTRUCTION(PushArgument) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1472 | }; |
| 1473 | |
| 1474 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1475 | class HThisFunction: public HTemplateInstruction<0> { |
| 1476 | public: |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1477 | HThisFunction() { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1478 | set_representation(Representation::Tagged()); |
| 1479 | SetFlag(kUseGVN); |
| 1480 | } |
| 1481 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1482 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1483 | return Representation::None(); |
| 1484 | } |
| 1485 | |
| 1486 | DECLARE_CONCRETE_INSTRUCTION(ThisFunction) |
| 1487 | |
| 1488 | protected: |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1489 | virtual bool DataEquals(HValue* other) { return true; } |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1490 | }; |
| 1491 | |
| 1492 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1493 | class HContext: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1494 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1495 | HContext() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1496 | set_representation(Representation::Tagged()); |
| 1497 | SetFlag(kUseGVN); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1498 | } |
| 1499 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1500 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1501 | return Representation::None(); |
| 1502 | } |
| 1503 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1504 | DECLARE_CONCRETE_INSTRUCTION(Context) |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1505 | |
| 1506 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1507 | virtual bool DataEquals(HValue* other) { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1508 | }; |
| 1509 | |
| 1510 | |
| 1511 | class HOuterContext: public HUnaryOperation { |
| 1512 | public: |
| 1513 | explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { |
| 1514 | set_representation(Representation::Tagged()); |
| 1515 | SetFlag(kUseGVN); |
| 1516 | } |
| 1517 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1518 | DECLARE_CONCRETE_INSTRUCTION(OuterContext); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1519 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1520 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1521 | return Representation::Tagged(); |
| 1522 | } |
| 1523 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1524 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1525 | virtual bool DataEquals(HValue* other) { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1526 | }; |
| 1527 | |
| 1528 | |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 1529 | class HDeclareGlobals: public HUnaryOperation { |
| 1530 | public: |
| 1531 | HDeclareGlobals(HValue* context, |
| 1532 | Handle<FixedArray> pairs, |
| 1533 | int flags) |
| 1534 | : HUnaryOperation(context), |
| 1535 | pairs_(pairs), |
| 1536 | flags_(flags) { |
| 1537 | set_representation(Representation::Tagged()); |
| 1538 | SetAllSideEffects(); |
| 1539 | } |
| 1540 | |
| 1541 | HValue* context() { return OperandAt(0); } |
| 1542 | Handle<FixedArray> pairs() const { return pairs_; } |
| 1543 | int flags() const { return flags_; } |
| 1544 | |
| 1545 | DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals) |
| 1546 | |
| 1547 | virtual Representation RequiredInputRepresentation(int index) { |
| 1548 | return Representation::Tagged(); |
| 1549 | } |
| 1550 | private: |
| 1551 | Handle<FixedArray> pairs_; |
| 1552 | int flags_; |
| 1553 | }; |
| 1554 | |
| 1555 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1556 | class HGlobalObject: public HUnaryOperation { |
| 1557 | public: |
| 1558 | explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { |
| 1559 | set_representation(Representation::Tagged()); |
| 1560 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1563 | DECLARE_CONCRETE_INSTRUCTION(GlobalObject) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1564 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1565 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1566 | return Representation::Tagged(); |
| 1567 | } |
| 1568 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1569 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1570 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1571 | }; |
| 1572 | |
| 1573 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1574 | class HGlobalReceiver: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1575 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1576 | explicit HGlobalReceiver(HValue* global_object) |
| 1577 | : HUnaryOperation(global_object) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1578 | set_representation(Representation::Tagged()); |
| 1579 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1580 | } |
| 1581 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1582 | DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1583 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1584 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1585 | return Representation::Tagged(); |
| 1586 | } |
| 1587 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1588 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1589 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1590 | }; |
| 1591 | |
| 1592 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1593 | template <int V> |
| 1594 | class HCall: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1595 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1596 | // The argument count includes the receiver. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1597 | explicit HCall<V>(int argument_count) : argument_count_(argument_count) { |
| 1598 | this->set_representation(Representation::Tagged()); |
| 1599 | this->SetAllSideEffects(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1600 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1601 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1602 | virtual HType CalculateInferredType() { return HType::Tagged(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1603 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1604 | virtual int argument_count() const { return argument_count_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1605 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1606 | virtual bool IsCall() { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1607 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1608 | private: |
| 1609 | int argument_count_; |
| 1610 | }; |
| 1611 | |
| 1612 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1613 | class HUnaryCall: public HCall<1> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1614 | public: |
| 1615 | HUnaryCall(HValue* value, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1616 | : HCall<1>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1617 | SetOperandAt(0, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1618 | } |
| 1619 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1620 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1621 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1622 | } |
| 1623 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1624 | virtual void PrintDataTo(StringStream* stream); |
| 1625 | |
| 1626 | HValue* value() { return OperandAt(0); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1627 | }; |
| 1628 | |
| 1629 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1630 | class HBinaryCall: public HCall<2> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1631 | public: |
| 1632 | HBinaryCall(HValue* first, HValue* second, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1633 | : HCall<2>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1634 | SetOperandAt(0, first); |
| 1635 | SetOperandAt(1, second); |
| 1636 | } |
| 1637 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1638 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1639 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1640 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1641 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1642 | } |
| 1643 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1644 | HValue* first() { return OperandAt(0); } |
| 1645 | HValue* second() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1646 | }; |
| 1647 | |
| 1648 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1649 | class HInvokeFunction: public HBinaryCall { |
| 1650 | public: |
| 1651 | HInvokeFunction(HValue* context, HValue* function, int argument_count) |
| 1652 | : HBinaryCall(context, function, argument_count) { |
| 1653 | } |
| 1654 | |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1655 | HInvokeFunction(HValue* context, |
| 1656 | HValue* function, |
| 1657 | Handle<JSFunction> known_function, |
| 1658 | int argument_count) |
| 1659 | : HBinaryCall(context, function, argument_count), |
| 1660 | known_function_(known_function) { |
| 1661 | } |
| 1662 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1663 | virtual Representation RequiredInputRepresentation(int index) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1664 | return Representation::Tagged(); |
| 1665 | } |
| 1666 | |
| 1667 | HValue* context() { return first(); } |
| 1668 | HValue* function() { return second(); } |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1669 | Handle<JSFunction> known_function() { return known_function_; } |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1670 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1671 | DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1672 | |
| 1673 | private: |
| 1674 | Handle<JSFunction> known_function_; |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1675 | }; |
| 1676 | |
| 1677 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1678 | class HCallConstantFunction: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1679 | public: |
| 1680 | HCallConstantFunction(Handle<JSFunction> function, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1681 | : HCall<0>(argument_count), function_(function) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1682 | |
| 1683 | Handle<JSFunction> function() const { return function_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1684 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1685 | bool IsApplyFunction() const { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1686 | return function_->code() == |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1687 | Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1688 | } |
| 1689 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1690 | virtual void PrintDataTo(StringStream* stream); |
| 1691 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1692 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1693 | return Representation::None(); |
| 1694 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1695 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1696 | DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1697 | |
| 1698 | private: |
| 1699 | Handle<JSFunction> function_; |
| 1700 | }; |
| 1701 | |
| 1702 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1703 | class HCallKeyed: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1704 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1705 | HCallKeyed(HValue* context, HValue* key, int argument_count) |
| 1706 | : HBinaryCall(context, key, argument_count) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1707 | } |
| 1708 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1709 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1710 | return Representation::Tagged(); |
| 1711 | } |
| 1712 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1713 | HValue* context() { return first(); } |
| 1714 | HValue* key() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1715 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1716 | DECLARE_CONCRETE_INSTRUCTION(CallKeyed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1717 | }; |
| 1718 | |
| 1719 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1720 | class HCallNamed: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1721 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1722 | HCallNamed(HValue* context, Handle<String> name, int argument_count) |
| 1723 | : HUnaryCall(context, argument_count), name_(name) { |
| 1724 | } |
| 1725 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1726 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1727 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1728 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1729 | Handle<String> name() const { return name_; } |
| 1730 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1731 | DECLARE_CONCRETE_INSTRUCTION(CallNamed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1732 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1733 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1734 | return Representation::Tagged(); |
| 1735 | } |
| 1736 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1737 | private: |
| 1738 | Handle<String> name_; |
| 1739 | }; |
| 1740 | |
| 1741 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1742 | class HCallFunction: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1743 | public: |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1744 | HCallFunction(HValue* context, HValue* function, int argument_count) |
| 1745 | : HBinaryCall(context, function, argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1748 | HValue* context() { return first(); } |
| 1749 | HValue* function() { return second(); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1750 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1751 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1752 | return Representation::Tagged(); |
| 1753 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1754 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1755 | DECLARE_CONCRETE_INSTRUCTION(CallFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1756 | }; |
| 1757 | |
| 1758 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1759 | class HCallGlobal: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1760 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1761 | HCallGlobal(HValue* context, Handle<String> name, int argument_count) |
| 1762 | : HUnaryCall(context, argument_count), name_(name) { |
| 1763 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1764 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1765 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1766 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1767 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1768 | Handle<String> name() const { return name_; } |
| 1769 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1770 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1771 | return Representation::Tagged(); |
| 1772 | } |
| 1773 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1774 | DECLARE_CONCRETE_INSTRUCTION(CallGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1775 | |
| 1776 | private: |
| 1777 | Handle<String> name_; |
| 1778 | }; |
| 1779 | |
| 1780 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1781 | class HCallKnownGlobal: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1782 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1783 | HCallKnownGlobal(Handle<JSFunction> target, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1784 | : HCall<0>(argument_count), target_(target) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1785 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1786 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1787 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1788 | Handle<JSFunction> target() const { return target_; } |
| 1789 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1790 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1791 | return Representation::None(); |
| 1792 | } |
| 1793 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1794 | DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1795 | |
| 1796 | private: |
| 1797 | Handle<JSFunction> target_; |
| 1798 | }; |
| 1799 | |
| 1800 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1801 | class HCallNew: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1802 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1803 | HCallNew(HValue* context, HValue* constructor, int argument_count) |
| 1804 | : HBinaryCall(context, constructor, argument_count) { |
| 1805 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1806 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1807 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1808 | return Representation::Tagged(); |
| 1809 | } |
| 1810 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1811 | HValue* context() { return first(); } |
| 1812 | HValue* constructor() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1813 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1814 | DECLARE_CONCRETE_INSTRUCTION(CallNew) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1815 | }; |
| 1816 | |
| 1817 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1818 | class HCallRuntime: public HCall<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1819 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1820 | HCallRuntime(HValue* context, |
| 1821 | Handle<String> name, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1822 | const Runtime::Function* c_function, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1823 | int argument_count) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1824 | : HCall<1>(argument_count), c_function_(c_function), name_(name) { |
| 1825 | SetOperandAt(0, context); |
| 1826 | } |
| 1827 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1828 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1829 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1830 | HValue* context() { return OperandAt(0); } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1831 | const Runtime::Function* function() const { return c_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1832 | Handle<String> name() const { return name_; } |
| 1833 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1834 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1835 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1836 | } |
| 1837 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1838 | DECLARE_CONCRETE_INSTRUCTION(CallRuntime) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1839 | |
| 1840 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1841 | const Runtime::Function* c_function_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1842 | Handle<String> name_; |
| 1843 | }; |
| 1844 | |
| 1845 | |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 1846 | class HJSArrayLength: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1847 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1848 | HJSArrayLength(HValue* value, HValue* typecheck, |
| 1849 | HType type = HType::Tagged()) { |
| 1850 | set_type(type); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1851 | // The length of an array is stored as a tagged value in the array |
| 1852 | // object. It is guaranteed to be 32 bit integer, but it can be |
| 1853 | // represented as either a smi or heap number. |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 1854 | SetOperandAt(0, value); |
| 1855 | SetOperandAt(1, typecheck); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1856 | set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1857 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1858 | SetGVNFlag(kDependsOnArrayLengths); |
| 1859 | SetGVNFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1860 | } |
| 1861 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1862 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1863 | return Representation::Tagged(); |
| 1864 | } |
| 1865 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1866 | virtual void PrintDataTo(StringStream* stream); |
| 1867 | |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 1868 | HValue* value() { return OperandAt(0); } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1869 | HValue* typecheck() { return OperandAt(1); } |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 1870 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1871 | DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1872 | |
| 1873 | protected: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1874 | virtual bool DataEquals(HValue* other_raw) { return true; } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1875 | }; |
| 1876 | |
| 1877 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 1878 | class HFixedArrayBaseLength: public HUnaryOperation { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1879 | public: |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 1880 | explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1881 | set_representation(Representation::Tagged()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1882 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1883 | SetGVNFlag(kDependsOnArrayLengths); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1884 | } |
| 1885 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1886 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1887 | return Representation::Tagged(); |
| 1888 | } |
| 1889 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 1890 | DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1891 | |
| 1892 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1893 | virtual bool DataEquals(HValue* other) { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1894 | }; |
| 1895 | |
| 1896 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1897 | class HElementsKind: public HUnaryOperation { |
| 1898 | public: |
| 1899 | explicit HElementsKind(HValue* value) : HUnaryOperation(value) { |
| 1900 | set_representation(Representation::Integer32()); |
| 1901 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1902 | SetGVNFlag(kDependsOnElementsKind); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1903 | } |
| 1904 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1905 | virtual Representation RequiredInputRepresentation(int index) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1906 | return Representation::Tagged(); |
| 1907 | } |
| 1908 | |
| 1909 | DECLARE_CONCRETE_INSTRUCTION(ElementsKind) |
| 1910 | |
| 1911 | protected: |
| 1912 | virtual bool DataEquals(HValue* other) { return true; } |
| 1913 | }; |
| 1914 | |
| 1915 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1916 | class HBitNot: public HUnaryOperation { |
| 1917 | public: |
| 1918 | explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
| 1919 | set_representation(Representation::Integer32()); |
| 1920 | SetFlag(kUseGVN); |
| 1921 | SetFlag(kTruncatingToInt32); |
| 1922 | } |
| 1923 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1924 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1925 | return Representation::Integer32(); |
| 1926 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1927 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1928 | |
mstarzinger@chromium.org | 88d326b | 2012-04-23 12:57:22 +0000 | [diff] [blame] | 1929 | virtual HValue* Canonicalize(); |
| 1930 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1931 | DECLARE_CONCRETE_INSTRUCTION(BitNot) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1932 | |
| 1933 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1934 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1935 | }; |
| 1936 | |
| 1937 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1938 | class HUnaryMathOperation: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1939 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1940 | HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
| 1941 | : op_(op) { |
| 1942 | SetOperandAt(0, context); |
| 1943 | SetOperandAt(1, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1944 | switch (op) { |
| 1945 | case kMathFloor: |
| 1946 | case kMathRound: |
| 1947 | case kMathCeil: |
| 1948 | set_representation(Representation::Integer32()); |
| 1949 | break; |
| 1950 | case kMathAbs: |
| 1951 | set_representation(Representation::Tagged()); |
| 1952 | SetFlag(kFlexibleRepresentation); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1953 | SetGVNFlag(kChangesNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1954 | break; |
| 1955 | case kMathSqrt: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1956 | case kMathPowHalf: |
| 1957 | case kMathLog: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 1958 | case kMathSin: |
| 1959 | case kMathCos: |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 1960 | case kMathTan: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1961 | set_representation(Representation::Double()); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1962 | SetGVNFlag(kChangesNewSpacePromotion); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1963 | break; |
| 1964 | default: |
| 1965 | UNREACHABLE(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1966 | } |
| 1967 | SetFlag(kUseGVN); |
| 1968 | } |
| 1969 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1970 | HValue* context() { return OperandAt(0); } |
| 1971 | HValue* value() { return OperandAt(1); } |
| 1972 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1973 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1974 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1975 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1976 | |
| 1977 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1978 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1979 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1980 | if (index == 0) { |
| 1981 | return Representation::Tagged(); |
| 1982 | } else { |
| 1983 | switch (op_) { |
| 1984 | case kMathFloor: |
| 1985 | case kMathRound: |
| 1986 | case kMathCeil: |
| 1987 | case kMathSqrt: |
| 1988 | case kMathPowHalf: |
| 1989 | case kMathLog: |
| 1990 | case kMathSin: |
| 1991 | case kMathCos: |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 1992 | case kMathTan: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1993 | return Representation::Double(); |
| 1994 | case kMathAbs: |
| 1995 | return representation(); |
| 1996 | default: |
| 1997 | UNREACHABLE(); |
| 1998 | return Representation::None(); |
| 1999 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2000 | } |
| 2001 | } |
| 2002 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 2003 | virtual HValue* Canonicalize(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2004 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2005 | BuiltinFunctionId op() const { return op_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2006 | const char* OpName() const; |
| 2007 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2008 | DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2009 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2010 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2011 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2012 | HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
| 2013 | return op_ == b->op(); |
| 2014 | } |
| 2015 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2016 | private: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2017 | BuiltinFunctionId op_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2018 | }; |
| 2019 | |
| 2020 | |
| 2021 | class HLoadElements: public HUnaryOperation { |
| 2022 | public: |
| 2023 | explicit HLoadElements(HValue* value) : HUnaryOperation(value) { |
| 2024 | set_representation(Representation::Tagged()); |
| 2025 | SetFlag(kUseGVN); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 2026 | SetGVNFlag(kDependsOnElementsPointer); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2027 | } |
| 2028 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2029 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2030 | return Representation::Tagged(); |
| 2031 | } |
| 2032 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2033 | DECLARE_CONCRETE_INSTRUCTION(LoadElements) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2034 | |
| 2035 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2036 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2037 | }; |
| 2038 | |
| 2039 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2040 | class HLoadExternalArrayPointer: public HUnaryOperation { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2041 | public: |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2042 | explicit HLoadExternalArrayPointer(HValue* value) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2043 | : HUnaryOperation(value) { |
| 2044 | set_representation(Representation::External()); |
| 2045 | // The result of this instruction is idempotent as long as its inputs don't |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2046 | // change. The external array of a specialized array elements object cannot |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2047 | // change once set, so it's no necessary to introduce any additional |
| 2048 | // dependencies on top of the inputs. |
| 2049 | SetFlag(kUseGVN); |
| 2050 | } |
| 2051 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2052 | virtual Representation RequiredInputRepresentation(int index) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2053 | return Representation::Tagged(); |
| 2054 | } |
| 2055 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2056 | DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2057 | |
| 2058 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2059 | virtual bool DataEquals(HValue* other) { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2060 | }; |
| 2061 | |
| 2062 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2063 | class HCheckMaps: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2064 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2065 | HCheckMaps(HValue* value, Handle<Map> map, Zone* zone, |
| 2066 | HValue* typecheck = NULL) { |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2067 | SetOperandAt(0, value); |
| 2068 | // If callers don't depend on a typecheck, they can pass in NULL. In that |
| 2069 | // case we use a copy of the |value| argument as a dummy value. |
| 2070 | SetOperandAt(1, typecheck != NULL ? typecheck : value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2071 | set_representation(Representation::Tagged()); |
| 2072 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2073 | SetGVNFlag(kDependsOnMaps); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2074 | SetGVNFlag(kDependsOnElementsKind); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2075 | map_set()->Add(map, zone); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2076 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2077 | HCheckMaps(HValue* value, SmallMapList* maps, Zone* zone) { |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2078 | SetOperandAt(0, value); |
| 2079 | SetOperandAt(1, value); |
| 2080 | set_representation(Representation::Tagged()); |
| 2081 | SetFlag(kUseGVN); |
| 2082 | SetGVNFlag(kDependsOnMaps); |
| 2083 | SetGVNFlag(kDependsOnElementsKind); |
| 2084 | for (int i = 0; i < maps->length(); i++) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2085 | map_set()->Add(maps->at(i), zone); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 2086 | } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2087 | map_set()->Sort(); |
| 2088 | } |
| 2089 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2090 | static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map, |
| 2091 | Zone* zone) { |
| 2092 | HCheckMaps* check_map = new(zone) HCheckMaps(object, map, zone); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2093 | SmallMapList* map_set = check_map->map_set(); |
| 2094 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2095 | // Since transitioned elements maps of the initial map don't fail the map |
| 2096 | // check, the CheckMaps instruction doesn't need to depend on ElementsKinds. |
| 2097 | check_map->ClearGVNFlag(kDependsOnElementsKind); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2098 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2099 | ElementsKind kind = map->elements_kind(); |
| 2100 | bool packed = IsFastPackedElementsKind(kind); |
| 2101 | while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { |
| 2102 | kind = GetNextMoreGeneralFastElementsKind(kind, packed); |
| 2103 | Map* transitioned_map = |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2104 | map->LookupElementsTransitionMap(kind); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2105 | if (transitioned_map) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2106 | map_set->Add(Handle<Map>(transitioned_map), zone); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2107 | } |
| 2108 | }; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2109 | map_set->Sort(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2110 | return check_map; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2111 | } |
| 2112 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2113 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2114 | return Representation::Tagged(); |
| 2115 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2116 | virtual void PrintDataTo(StringStream* stream); |
| 2117 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2118 | |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2119 | HValue* value() { return OperandAt(0); } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2120 | SmallMapList* map_set() { return &map_set_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2121 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2122 | DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2123 | |
| 2124 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2125 | virtual bool DataEquals(HValue* other) { |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2126 | HCheckMaps* b = HCheckMaps::cast(other); |
| 2127 | // Relies on the fact that map_set has been sorted before. |
| 2128 | if (map_set()->length() != b->map_set()->length()) return false; |
| 2129 | for (int i = 0; i < map_set()->length(); i++) { |
| 2130 | if (!map_set()->at(i).is_identical_to(b->map_set()->at(i))) return false; |
| 2131 | } |
| 2132 | return true; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2133 | } |
| 2134 | |
| 2135 | private: |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2136 | SmallMapList map_set_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2137 | }; |
| 2138 | |
| 2139 | |
| 2140 | class HCheckFunction: public HUnaryOperation { |
| 2141 | public: |
| 2142 | HCheckFunction(HValue* value, Handle<JSFunction> function) |
| 2143 | : HUnaryOperation(value), target_(function) { |
| 2144 | set_representation(Representation::Tagged()); |
| 2145 | SetFlag(kUseGVN); |
| 2146 | } |
| 2147 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2148 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2149 | return Representation::Tagged(); |
| 2150 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2151 | virtual void PrintDataTo(StringStream* stream); |
| 2152 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2153 | |
| 2154 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2155 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2156 | #endif |
| 2157 | |
| 2158 | Handle<JSFunction> target() const { return target_; } |
| 2159 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2160 | DECLARE_CONCRETE_INSTRUCTION(CheckFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2161 | |
| 2162 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2163 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2164 | HCheckFunction* b = HCheckFunction::cast(other); |
| 2165 | return target_.is_identical_to(b->target()); |
| 2166 | } |
| 2167 | |
| 2168 | private: |
| 2169 | Handle<JSFunction> target_; |
| 2170 | }; |
| 2171 | |
| 2172 | |
| 2173 | class HCheckInstanceType: public HUnaryOperation { |
| 2174 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2175 | static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { |
| 2176 | return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2177 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2178 | static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { |
| 2179 | return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2180 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2181 | static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) { |
| 2182 | return new(zone) HCheckInstanceType(value, IS_STRING); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2183 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2184 | static HCheckInstanceType* NewIsSymbol(HValue* value, Zone* zone) { |
| 2185 | return new(zone) HCheckInstanceType(value, IS_SYMBOL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2186 | } |
| 2187 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2188 | virtual void PrintDataTo(StringStream* stream); |
| 2189 | |
| 2190 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2191 | return Representation::Tagged(); |
| 2192 | } |
| 2193 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2194 | virtual HValue* Canonicalize(); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2195 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2196 | bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; } |
| 2197 | void GetCheckInterval(InstanceType* first, InstanceType* last); |
| 2198 | void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2199 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2200 | DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2201 | |
| 2202 | protected: |
| 2203 | // TODO(ager): It could be nice to allow the ommision of instance |
| 2204 | // type checks if we have already performed an instance type check |
| 2205 | // with a larger range. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2206 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2207 | HCheckInstanceType* b = HCheckInstanceType::cast(other); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2208 | return check_ == b->check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2209 | } |
| 2210 | |
| 2211 | private: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2212 | enum Check { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2213 | IS_SPEC_OBJECT, |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2214 | IS_JS_ARRAY, |
| 2215 | IS_STRING, |
| 2216 | IS_SYMBOL, |
| 2217 | LAST_INTERVAL_CHECK = IS_JS_ARRAY |
| 2218 | }; |
| 2219 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2220 | const char* GetCheckName(); |
| 2221 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2222 | HCheckInstanceType(HValue* value, Check check) |
| 2223 | : HUnaryOperation(value), check_(check) { |
| 2224 | set_representation(Representation::Tagged()); |
| 2225 | SetFlag(kUseGVN); |
| 2226 | } |
| 2227 | |
| 2228 | const Check check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2229 | }; |
| 2230 | |
| 2231 | |
| 2232 | class HCheckNonSmi: public HUnaryOperation { |
| 2233 | public: |
| 2234 | explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { |
| 2235 | set_representation(Representation::Tagged()); |
| 2236 | SetFlag(kUseGVN); |
| 2237 | } |
| 2238 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2239 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2240 | return Representation::Tagged(); |
| 2241 | } |
| 2242 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2243 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2244 | |
| 2245 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2246 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2247 | #endif |
| 2248 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2249 | virtual HValue* Canonicalize() { |
| 2250 | HType value_type = value()->type(); |
| 2251 | if (!value_type.IsUninitialized() && |
| 2252 | (value_type.IsHeapNumber() || |
| 2253 | value_type.IsString() || |
| 2254 | value_type.IsBoolean() || |
| 2255 | value_type.IsNonPrimitive())) { |
| 2256 | return NULL; |
| 2257 | } |
| 2258 | return this; |
| 2259 | } |
| 2260 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2261 | DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2262 | |
| 2263 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2264 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2265 | }; |
| 2266 | |
| 2267 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2268 | class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2269 | public: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2270 | HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder) |
| 2271 | : prototype_(prototype), holder_(holder) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2272 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2273 | SetGVNFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2274 | } |
| 2275 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2276 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2277 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2278 | #endif |
| 2279 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2280 | Handle<JSObject> prototype() const { return prototype_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2281 | Handle<JSObject> holder() const { return holder_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2282 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2283 | DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2284 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2285 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2286 | return Representation::None(); |
| 2287 | } |
| 2288 | |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 2289 | virtual void PrintDataTo(StringStream* stream); |
| 2290 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2291 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2292 | ASSERT(!HEAP->IsAllocationAllowed()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2293 | intptr_t hash = reinterpret_cast<intptr_t>(*prototype()); |
| 2294 | hash = 17 * hash + reinterpret_cast<intptr_t>(*holder()); |
| 2295 | return hash; |
| 2296 | } |
| 2297 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2298 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2299 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2300 | HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2301 | return prototype_.is_identical_to(b->prototype()) && |
| 2302 | holder_.is_identical_to(b->holder()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2306 | Handle<JSObject> prototype_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2307 | Handle<JSObject> holder_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2308 | }; |
| 2309 | |
| 2310 | |
| 2311 | class HCheckSmi: public HUnaryOperation { |
| 2312 | public: |
| 2313 | explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { |
| 2314 | set_representation(Representation::Tagged()); |
| 2315 | SetFlag(kUseGVN); |
| 2316 | } |
| 2317 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2318 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2319 | return Representation::Tagged(); |
| 2320 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2321 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2322 | |
| 2323 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2324 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2325 | #endif |
| 2326 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2327 | DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2328 | |
| 2329 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2330 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2331 | }; |
| 2332 | |
| 2333 | |
| 2334 | class HPhi: public HValue { |
| 2335 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2336 | HPhi(int merged_index, Zone* zone) |
| 2337 | : inputs_(2, zone), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2338 | merged_index_(merged_index), |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2339 | phi_id_(-1), |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2340 | is_live_(false), |
| 2341 | is_convertible_to_integer_(true) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2342 | for (int i = 0; i < Representation::kNumRepresentations; i++) { |
| 2343 | non_phi_uses_[i] = 0; |
| 2344 | indirect_uses_[i] = 0; |
| 2345 | } |
| 2346 | ASSERT(merged_index >= 0); |
| 2347 | set_representation(Representation::Tagged()); |
| 2348 | SetFlag(kFlexibleRepresentation); |
| 2349 | } |
| 2350 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 2351 | virtual Representation InferredRepresentation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2352 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2353 | virtual Range* InferRange(Zone* zone); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2354 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2355 | return representation(); |
| 2356 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2357 | virtual HType CalculateInferredType(); |
| 2358 | virtual int OperandCount() { return inputs_.length(); } |
| 2359 | virtual HValue* OperandAt(int index) { return inputs_[index]; } |
| 2360 | HValue* GetRedundantReplacement(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2361 | void AddInput(HValue* value); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2362 | bool HasRealUses(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2363 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2364 | bool IsReceiver() { return merged_index_ == 0; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2365 | |
| 2366 | int merged_index() const { return merged_index_; } |
| 2367 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2368 | virtual void PrintTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2369 | |
| 2370 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2371 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2372 | #endif |
| 2373 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2374 | void InitRealUses(int id); |
| 2375 | void AddNonPhiUsesFrom(HPhi* other); |
| 2376 | void AddIndirectUsesTo(int* use_count); |
| 2377 | |
| 2378 | int tagged_non_phi_uses() const { |
| 2379 | return non_phi_uses_[Representation::kTagged]; |
| 2380 | } |
| 2381 | int int32_non_phi_uses() const { |
| 2382 | return non_phi_uses_[Representation::kInteger32]; |
| 2383 | } |
| 2384 | int double_non_phi_uses() const { |
| 2385 | return non_phi_uses_[Representation::kDouble]; |
| 2386 | } |
| 2387 | int tagged_indirect_uses() const { |
| 2388 | return indirect_uses_[Representation::kTagged]; |
| 2389 | } |
| 2390 | int int32_indirect_uses() const { |
| 2391 | return indirect_uses_[Representation::kInteger32]; |
| 2392 | } |
| 2393 | int double_indirect_uses() const { |
| 2394 | return indirect_uses_[Representation::kDouble]; |
| 2395 | } |
| 2396 | int phi_id() { return phi_id_; } |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2397 | bool is_live() { return is_live_; } |
| 2398 | void set_is_live(bool b) { is_live_ = b; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2399 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2400 | static HPhi* cast(HValue* value) { |
| 2401 | ASSERT(value->IsPhi()); |
| 2402 | return reinterpret_cast<HPhi*>(value); |
| 2403 | } |
| 2404 | virtual Opcode opcode() const { return HValue::kPhi; } |
| 2405 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2406 | virtual bool IsConvertibleToInteger() const { |
| 2407 | return is_convertible_to_integer_; |
| 2408 | } |
| 2409 | |
| 2410 | void set_is_convertible_to_integer(bool b) { |
| 2411 | is_convertible_to_integer_ = b; |
| 2412 | } |
| 2413 | |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 2414 | bool AllOperandsConvertibleToInteger() { |
| 2415 | for (int i = 0; i < OperandCount(); ++i) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2416 | if (!OperandAt(i)->IsConvertibleToInteger()) { |
| 2417 | return false; |
| 2418 | } |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 2419 | } |
| 2420 | return true; |
| 2421 | } |
| 2422 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2423 | void ResetInteger32Uses(); |
| 2424 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2425 | protected: |
| 2426 | virtual void DeleteFromGraph(); |
| 2427 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 2428 | inputs_[index] = value; |
| 2429 | } |
| 2430 | |
| 2431 | private: |
| 2432 | ZoneList<HValue*> inputs_; |
| 2433 | int merged_index_; |
| 2434 | |
| 2435 | int non_phi_uses_[Representation::kNumRepresentations]; |
| 2436 | int indirect_uses_[Representation::kNumRepresentations]; |
| 2437 | int phi_id_; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2438 | bool is_live_; |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2439 | bool is_convertible_to_integer_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2440 | }; |
| 2441 | |
| 2442 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2443 | class HArgumentsObject: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2444 | public: |
| 2445 | HArgumentsObject() { |
| 2446 | set_representation(Representation::Tagged()); |
| 2447 | SetFlag(kIsArguments); |
| 2448 | } |
| 2449 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2450 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2451 | return Representation::None(); |
| 2452 | } |
| 2453 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2454 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2455 | }; |
| 2456 | |
| 2457 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2458 | class HConstant: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2459 | public: |
| 2460 | HConstant(Handle<Object> handle, Representation r); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2461 | HConstant(int32_t value, Representation r); |
| 2462 | HConstant(double value, Representation r); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2463 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2464 | Handle<Object> handle() { |
| 2465 | if (handle_.is_null()) { |
| 2466 | handle_ = FACTORY->NewNumber(double_value_, TENURED); |
| 2467 | } |
| 2468 | ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| 2469 | return handle_; |
| 2470 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2471 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2472 | bool InOldSpace() const { return !HEAP->InNewSpace(*handle_); } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2473 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2474 | bool ImmortalImmovable() const { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2475 | if (has_int32_value_) { |
| 2476 | return false; |
| 2477 | } |
| 2478 | if (has_double_value_) { |
| 2479 | if (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) || |
| 2480 | isnan(double_value_)) { |
| 2481 | return true; |
| 2482 | } |
| 2483 | return false; |
| 2484 | } |
| 2485 | |
| 2486 | ASSERT(!handle_.is_null()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2487 | Heap* heap = HEAP; |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2488 | // We should have handled minus_zero_value and nan_value in the |
| 2489 | // has_double_value_ clause above. |
| 2490 | ASSERT(*handle_ != heap->minus_zero_value()); |
| 2491 | ASSERT(*handle_ != heap->nan_value()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2492 | if (*handle_ == heap->undefined_value()) return true; |
| 2493 | if (*handle_ == heap->null_value()) return true; |
| 2494 | if (*handle_ == heap->true_value()) return true; |
| 2495 | if (*handle_ == heap->false_value()) return true; |
| 2496 | if (*handle_ == heap->the_hole_value()) return true; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2497 | if (*handle_ == heap->empty_string()) return true; |
| 2498 | return false; |
| 2499 | } |
| 2500 | |
| 2501 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2502 | return Representation::None(); |
| 2503 | } |
| 2504 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2505 | virtual bool IsConvertibleToInteger() const { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2506 | return has_int32_value_; |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2507 | } |
| 2508 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2509 | virtual bool EmitAtUses() { return !representation().IsDouble(); } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2510 | virtual HValue* Canonicalize(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2511 | virtual void PrintDataTo(StringStream* stream); |
| 2512 | virtual HType CalculateInferredType(); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2513 | bool IsInteger() { return handle()->IsSmi(); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2514 | HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
| 2515 | HConstant* CopyToTruncatedInt32(Zone* zone) const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2516 | bool HasInteger32Value() const { return has_int32_value_; } |
| 2517 | int32_t Integer32Value() const { |
| 2518 | ASSERT(HasInteger32Value()); |
| 2519 | return int32_value_; |
| 2520 | } |
| 2521 | bool HasDoubleValue() const { return has_double_value_; } |
| 2522 | double DoubleValue() const { |
| 2523 | ASSERT(HasDoubleValue()); |
| 2524 | return double_value_; |
| 2525 | } |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2526 | bool HasNumberValue() const { return has_double_value_; } |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 2527 | int32_t NumberValueAsInteger32() const { |
| 2528 | ASSERT(HasNumberValue()); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2529 | // Irrespective of whether a numeric HConstant can be safely |
| 2530 | // represented as an int32, we store the (in some cases lossy) |
| 2531 | // representation of the number in int32_value_. |
| 2532 | return int32_value_; |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 2533 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2534 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2535 | bool ToBoolean(); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 2536 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2537 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2538 | ASSERT(!HEAP->allow_allocation(false)); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2539 | intptr_t hash; |
| 2540 | |
| 2541 | if (has_int32_value_) { |
| 2542 | hash = static_cast<intptr_t>(int32_value_); |
| 2543 | } else if (has_double_value_) { |
| 2544 | hash = static_cast<intptr_t>(BitCast<int64_t>(double_value_)); |
| 2545 | } else { |
| 2546 | ASSERT(!handle_.is_null()); |
| 2547 | hash = reinterpret_cast<intptr_t>(*handle_); |
| 2548 | } |
| 2549 | |
| 2550 | return hash; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2551 | } |
| 2552 | |
| 2553 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2554 | virtual void Verify() { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2555 | #endif |
| 2556 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2557 | DECLARE_CONCRETE_INSTRUCTION(Constant) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2558 | |
| 2559 | protected: |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2560 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2561 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2562 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2563 | HConstant* other_constant = HConstant::cast(other); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2564 | if (has_int32_value_) { |
| 2565 | return other_constant->has_int32_value_ && |
| 2566 | int32_value_ == other_constant->int32_value_; |
| 2567 | } else if (has_double_value_) { |
| 2568 | return other_constant->has_double_value_ && |
| 2569 | BitCast<int64_t>(double_value_) == |
| 2570 | BitCast<int64_t>(other_constant->double_value_); |
| 2571 | } else { |
| 2572 | ASSERT(!handle_.is_null()); |
| 2573 | return !other_constant->handle_.is_null() && |
| 2574 | *handle_ == *other_constant->handle_; |
| 2575 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2576 | } |
| 2577 | |
| 2578 | private: |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2579 | // If this is a numerical constant, handle_ either points to to the |
| 2580 | // HeapObject the constant originated from or is null. If the |
| 2581 | // constant is non-numeric, handle_ always points to a valid |
| 2582 | // constant HeapObject. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2583 | Handle<Object> handle_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2584 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 2585 | // We store the HConstant in the most specific form safely possible. |
| 2586 | // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 2587 | // int32_value_ and double_value_ hold valid, safe representations |
| 2588 | // of the constant. has_int32_value_ implies has_double_value_ but |
| 2589 | // not the converse. |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2590 | bool has_int32_value_ : 1; |
| 2591 | bool has_double_value_ : 1; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2592 | int32_t int32_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2593 | double double_value_; |
| 2594 | }; |
| 2595 | |
| 2596 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2597 | class HBinaryOperation: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2598 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2599 | HBinaryOperation(HValue* context, HValue* left, HValue* right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2600 | ASSERT(left != NULL && right != NULL); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2601 | SetOperandAt(0, context); |
| 2602 | SetOperandAt(1, left); |
| 2603 | SetOperandAt(2, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2604 | } |
| 2605 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2606 | HValue* context() { return OperandAt(0); } |
| 2607 | HValue* left() { return OperandAt(1); } |
| 2608 | HValue* right() { return OperandAt(2); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2609 | |
| 2610 | // TODO(kasperl): Move these helpers to the IA-32 Lithium |
| 2611 | // instruction sequence builder. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2612 | HValue* LeastConstantOperand() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2613 | if (IsCommutative() && left()->IsConstant()) return right(); |
| 2614 | return left(); |
| 2615 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2616 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2617 | HValue* MostConstantOperand() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2618 | if (IsCommutative() && left()->IsConstant()) return left(); |
| 2619 | return right(); |
| 2620 | } |
| 2621 | |
| 2622 | virtual bool IsCommutative() const { return false; } |
| 2623 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2624 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2625 | }; |
| 2626 | |
| 2627 | |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 2628 | class HWrapReceiver: public HTemplateInstruction<2> { |
| 2629 | public: |
| 2630 | HWrapReceiver(HValue* receiver, HValue* function) { |
| 2631 | set_representation(Representation::Tagged()); |
| 2632 | SetOperandAt(0, receiver); |
| 2633 | SetOperandAt(1, function); |
| 2634 | } |
| 2635 | |
| 2636 | virtual Representation RequiredInputRepresentation(int index) { |
| 2637 | return Representation::Tagged(); |
| 2638 | } |
| 2639 | |
| 2640 | HValue* receiver() { return OperandAt(0); } |
| 2641 | HValue* function() { return OperandAt(1); } |
| 2642 | |
| 2643 | virtual HValue* Canonicalize(); |
| 2644 | |
| 2645 | DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) |
| 2646 | }; |
| 2647 | |
| 2648 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2649 | class HApplyArguments: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2650 | public: |
| 2651 | HApplyArguments(HValue* function, |
| 2652 | HValue* receiver, |
| 2653 | HValue* length, |
| 2654 | HValue* elements) { |
| 2655 | set_representation(Representation::Tagged()); |
| 2656 | SetOperandAt(0, function); |
| 2657 | SetOperandAt(1, receiver); |
| 2658 | SetOperandAt(2, length); |
| 2659 | SetOperandAt(3, elements); |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 2660 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2661 | } |
| 2662 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2663 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2664 | // The length is untagged, all other inputs are tagged. |
| 2665 | return (index == 2) |
| 2666 | ? Representation::Integer32() |
| 2667 | : Representation::Tagged(); |
| 2668 | } |
| 2669 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2670 | HValue* function() { return OperandAt(0); } |
| 2671 | HValue* receiver() { return OperandAt(1); } |
| 2672 | HValue* length() { return OperandAt(2); } |
| 2673 | HValue* elements() { return OperandAt(3); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2674 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2675 | DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2676 | }; |
| 2677 | |
| 2678 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2679 | class HArgumentsElements: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2680 | public: |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2681 | explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2682 | // The value produced by this instruction is a pointer into the stack |
| 2683 | // that looks as if it was a smi because of alignment. |
| 2684 | set_representation(Representation::Tagged()); |
| 2685 | SetFlag(kUseGVN); |
| 2686 | } |
| 2687 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2688 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2689 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2690 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2691 | return Representation::None(); |
| 2692 | } |
| 2693 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2694 | bool from_inlined() const { return from_inlined_; } |
| 2695 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2696 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2697 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 2698 | |
| 2699 | bool from_inlined_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2700 | }; |
| 2701 | |
| 2702 | |
| 2703 | class HArgumentsLength: public HUnaryOperation { |
| 2704 | public: |
| 2705 | explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { |
| 2706 | set_representation(Representation::Integer32()); |
| 2707 | SetFlag(kUseGVN); |
| 2708 | } |
| 2709 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2710 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2711 | return Representation::Tagged(); |
| 2712 | } |
| 2713 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2714 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2715 | |
| 2716 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2717 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2718 | }; |
| 2719 | |
| 2720 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2721 | class HAccessArgumentsAt: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2722 | public: |
| 2723 | HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { |
| 2724 | set_representation(Representation::Tagged()); |
| 2725 | SetFlag(kUseGVN); |
| 2726 | SetOperandAt(0, arguments); |
| 2727 | SetOperandAt(1, length); |
| 2728 | SetOperandAt(2, index); |
| 2729 | } |
| 2730 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2731 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2732 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2733 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2734 | // The arguments elements is considered tagged. |
| 2735 | return index == 0 |
| 2736 | ? Representation::Tagged() |
| 2737 | : Representation::Integer32(); |
| 2738 | } |
| 2739 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2740 | HValue* arguments() { return OperandAt(0); } |
| 2741 | HValue* length() { return OperandAt(1); } |
| 2742 | HValue* index() { return OperandAt(2); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2743 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2744 | DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2745 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2746 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2747 | }; |
| 2748 | |
| 2749 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2750 | class HBoundsCheck: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2751 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2752 | HBoundsCheck(HValue* index, HValue* length) { |
| 2753 | SetOperandAt(0, index); |
| 2754 | SetOperandAt(1, length); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 2755 | set_representation(Representation::Integer32()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2756 | SetFlag(kUseGVN); |
| 2757 | } |
| 2758 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2759 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2760 | return Representation::Integer32(); |
| 2761 | } |
| 2762 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 2763 | virtual void PrintDataTo(StringStream* stream); |
| 2764 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2765 | HValue* index() { return OperandAt(0); } |
| 2766 | HValue* length() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2767 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2768 | DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2769 | |
| 2770 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2771 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2772 | }; |
| 2773 | |
| 2774 | |
| 2775 | class HBitwiseBinaryOperation: public HBinaryOperation { |
| 2776 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2777 | HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 2778 | : HBinaryOperation(context, left, right) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2779 | set_representation(Representation::Tagged()); |
| 2780 | SetFlag(kFlexibleRepresentation); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2781 | SetAllSideEffects(); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2782 | observed_input_representation_[0] = Representation::Tagged(); |
| 2783 | observed_input_representation_[1] = Representation::None(); |
| 2784 | observed_input_representation_[2] = Representation::None(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2785 | } |
| 2786 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2787 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2788 | return index == 0 |
| 2789 | ? Representation::Tagged() |
| 2790 | : representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2791 | } |
| 2792 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2793 | virtual void RepresentationChanged(Representation to) { |
| 2794 | if (!to.IsTagged()) { |
| 2795 | ASSERT(to.IsInteger32()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2796 | ClearAllSideEffects(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2797 | SetFlag(kTruncatingToInt32); |
| 2798 | SetFlag(kUseGVN); |
| 2799 | } |
| 2800 | } |
| 2801 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2802 | virtual HType CalculateInferredType(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2803 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2804 | virtual Representation ObservedInputRepresentation(int index) { |
| 2805 | return observed_input_representation_[index]; |
| 2806 | } |
| 2807 | |
| 2808 | void InitializeObservedInputRepresentation(Representation r) { |
| 2809 | observed_input_representation_[1] = r; |
| 2810 | observed_input_representation_[2] = r; |
| 2811 | } |
| 2812 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2813 | DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2814 | |
| 2815 | private: |
| 2816 | Representation observed_input_representation_[3]; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2817 | }; |
| 2818 | |
| 2819 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 2820 | class HMathFloorOfDiv: public HBinaryOperation { |
| 2821 | public: |
| 2822 | HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) |
| 2823 | : HBinaryOperation(context, left, right) { |
| 2824 | set_representation(Representation::Integer32()); |
| 2825 | SetFlag(kUseGVN); |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 2826 | SetFlag(kCanOverflow); |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 2827 | } |
| 2828 | |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 2829 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2830 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 2831 | virtual Representation RequiredInputRepresentation(int index) { |
| 2832 | return Representation::Integer32(); |
| 2833 | } |
| 2834 | |
| 2835 | DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) |
| 2836 | |
| 2837 | protected: |
| 2838 | virtual bool DataEquals(HValue* other) { return true; } |
| 2839 | }; |
| 2840 | |
| 2841 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2842 | class HArithmeticBinaryOperation: public HBinaryOperation { |
| 2843 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2844 | HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 2845 | : HBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2846 | set_representation(Representation::Tagged()); |
| 2847 | SetFlag(kFlexibleRepresentation); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2848 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2849 | } |
| 2850 | |
| 2851 | virtual void RepresentationChanged(Representation to) { |
| 2852 | if (!to.IsTagged()) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2853 | ClearAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2854 | SetFlag(kUseGVN); |
| 2855 | } |
| 2856 | } |
| 2857 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2858 | virtual HType CalculateInferredType(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2859 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2860 | return index == 0 |
| 2861 | ? Representation::Tagged() |
| 2862 | : representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2863 | } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2864 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2865 | virtual Representation InferredRepresentation() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2866 | if (left()->representation().Equals(right()->representation())) { |
| 2867 | return left()->representation(); |
| 2868 | } |
| 2869 | return HValue::InferredRepresentation(); |
| 2870 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2871 | }; |
| 2872 | |
| 2873 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2874 | class HCompareGeneric: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2875 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2876 | HCompareGeneric(HValue* context, |
| 2877 | HValue* left, |
| 2878 | HValue* right, |
| 2879 | Token::Value token) |
| 2880 | : HBinaryOperation(context, left, right), token_(token) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2881 | ASSERT(Token::IsCompareOp(token)); |
| 2882 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2883 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2884 | } |
| 2885 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2886 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2887 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2888 | } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2889 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2890 | Representation GetInputRepresentation() const { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2891 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2892 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2893 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2894 | Token::Value token() const { return token_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2895 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2896 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2897 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2898 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2899 | DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) |
| 2900 | |
| 2901 | private: |
| 2902 | Token::Value token_; |
| 2903 | }; |
| 2904 | |
| 2905 | |
| 2906 | class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> { |
| 2907 | public: |
| 2908 | HCompareIDAndBranch(HValue* left, HValue* right, Token::Value token) |
| 2909 | : token_(token) { |
| 2910 | ASSERT(Token::IsCompareOp(token)); |
| 2911 | SetOperandAt(0, left); |
| 2912 | SetOperandAt(1, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2913 | } |
| 2914 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2915 | HValue* left() { return OperandAt(0); } |
| 2916 | HValue* right() { return OperandAt(1); } |
| 2917 | Token::Value token() const { return token_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2918 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2919 | void SetInputRepresentation(Representation r); |
| 2920 | Representation GetInputRepresentation() const { |
| 2921 | return input_representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2922 | } |
| 2923 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2924 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2925 | return input_representation_; |
| 2926 | } |
| 2927 | virtual void PrintDataTo(StringStream* stream); |
| 2928 | |
| 2929 | DECLARE_CONCRETE_INSTRUCTION(CompareIDAndBranch) |
| 2930 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2931 | private: |
| 2932 | Representation input_representation_; |
| 2933 | Token::Value token_; |
| 2934 | }; |
| 2935 | |
| 2936 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2937 | class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2938 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2939 | HCompareObjectEqAndBranch(HValue* left, HValue* right) { |
| 2940 | SetOperandAt(0, left); |
| 2941 | SetOperandAt(1, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2942 | } |
| 2943 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2944 | HValue* left() { return OperandAt(0); } |
| 2945 | HValue* right() { return OperandAt(1); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2946 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2947 | virtual void PrintDataTo(StringStream* stream); |
| 2948 | |
| 2949 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2950 | return Representation::Tagged(); |
| 2951 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2952 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2953 | DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2954 | }; |
| 2955 | |
| 2956 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2957 | class HCompareConstantEqAndBranch: public HUnaryControlInstruction { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2958 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2959 | HCompareConstantEqAndBranch(HValue* left, int right, Token::Value op) |
| 2960 | : HUnaryControlInstruction(left, NULL, NULL), op_(op), right_(right) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2961 | ASSERT(op == Token::EQ_STRICT); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2962 | } |
| 2963 | |
| 2964 | Token::Value op() const { return op_; } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2965 | HValue* left() { return value(); } |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2966 | int right() const { return right_; } |
| 2967 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2968 | virtual Representation RequiredInputRepresentation(int index) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2969 | return Representation::Integer32(); |
| 2970 | } |
| 2971 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2972 | DECLARE_CONCRETE_INSTRUCTION(CompareConstantEqAndBranch); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2973 | |
| 2974 | private: |
| 2975 | const Token::Value op_; |
| 2976 | const int right_; |
| 2977 | }; |
| 2978 | |
| 2979 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2980 | class HIsNilAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2981 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2982 | HIsNilAndBranch(HValue* value, EqualityKind kind, NilValue nil) |
| 2983 | : HUnaryControlInstruction(value, NULL, NULL), kind_(kind), nil_(nil) { } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2984 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2985 | EqualityKind kind() const { return kind_; } |
| 2986 | NilValue nil() const { return nil_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2987 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2988 | virtual void PrintDataTo(StringStream* stream); |
| 2989 | |
| 2990 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2991 | return Representation::Tagged(); |
| 2992 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2993 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2994 | DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch) |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2995 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2996 | private: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2997 | EqualityKind kind_; |
| 2998 | NilValue nil_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2999 | }; |
| 3000 | |
| 3001 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3002 | class HIsObjectAndBranch: public HUnaryControlInstruction { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3003 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3004 | explicit HIsObjectAndBranch(HValue* value) |
| 3005 | : HUnaryControlInstruction(value, NULL, NULL) { } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3006 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3007 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3008 | return Representation::Tagged(); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 3009 | } |
| 3010 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3011 | DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) |
| 3012 | }; |
| 3013 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3014 | class HIsStringAndBranch: public HUnaryControlInstruction { |
| 3015 | public: |
| 3016 | explicit HIsStringAndBranch(HValue* value) |
| 3017 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3018 | |
| 3019 | virtual Representation RequiredInputRepresentation(int index) { |
| 3020 | return Representation::Tagged(); |
| 3021 | } |
| 3022 | |
| 3023 | DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch) |
| 3024 | }; |
| 3025 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3026 | |
| 3027 | class HIsSmiAndBranch: public HUnaryControlInstruction { |
| 3028 | public: |
| 3029 | explicit HIsSmiAndBranch(HValue* value) |
| 3030 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3031 | |
| 3032 | DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) |
| 3033 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3034 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3035 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3036 | } |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 3037 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3038 | protected: |
| 3039 | virtual bool DataEquals(HValue* other) { return true; } |
| 3040 | }; |
| 3041 | |
| 3042 | |
| 3043 | class HIsUndetectableAndBranch: public HUnaryControlInstruction { |
| 3044 | public: |
| 3045 | explicit HIsUndetectableAndBranch(HValue* value) |
| 3046 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3047 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3048 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3049 | return Representation::Tagged(); |
| 3050 | } |
| 3051 | |
| 3052 | DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) |
| 3053 | }; |
| 3054 | |
| 3055 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3056 | class HStringCompareAndBranch: public HTemplateControlInstruction<2, 3> { |
| 3057 | public: |
| 3058 | HStringCompareAndBranch(HValue* context, |
| 3059 | HValue* left, |
| 3060 | HValue* right, |
| 3061 | Token::Value token) |
| 3062 | : token_(token) { |
| 3063 | ASSERT(Token::IsCompareOp(token)); |
| 3064 | SetOperandAt(0, context); |
| 3065 | SetOperandAt(1, left); |
| 3066 | SetOperandAt(2, right); |
| 3067 | set_representation(Representation::Tagged()); |
| 3068 | } |
| 3069 | |
| 3070 | HValue* context() { return OperandAt(0); } |
| 3071 | HValue* left() { return OperandAt(1); } |
| 3072 | HValue* right() { return OperandAt(2); } |
| 3073 | Token::Value token() const { return token_; } |
| 3074 | |
| 3075 | virtual void PrintDataTo(StringStream* stream); |
| 3076 | |
| 3077 | virtual Representation RequiredInputRepresentation(int index) { |
| 3078 | return Representation::Tagged(); |
| 3079 | } |
| 3080 | |
| 3081 | Representation GetInputRepresentation() const { |
| 3082 | return Representation::Tagged(); |
| 3083 | } |
| 3084 | |
| 3085 | DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch) |
| 3086 | |
| 3087 | private: |
| 3088 | Token::Value token_; |
| 3089 | }; |
| 3090 | |
| 3091 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3092 | class HIsConstructCallAndBranch: public HTemplateControlInstruction<2, 0> { |
| 3093 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3094 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3095 | return Representation::None(); |
| 3096 | } |
| 3097 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3098 | DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch) |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 3099 | }; |
| 3100 | |
| 3101 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3102 | class HHasInstanceTypeAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3103 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3104 | HHasInstanceTypeAndBranch(HValue* value, InstanceType type) |
| 3105 | : HUnaryControlInstruction(value, NULL, NULL), from_(type), to_(type) { } |
| 3106 | HHasInstanceTypeAndBranch(HValue* value, InstanceType from, InstanceType to) |
| 3107 | : HUnaryControlInstruction(value, NULL, NULL), from_(from), to_(to) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3108 | ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. |
| 3109 | } |
| 3110 | |
| 3111 | InstanceType from() { return from_; } |
| 3112 | InstanceType to() { return to_; } |
| 3113 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3114 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3115 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3116 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3117 | return Representation::Tagged(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3118 | } |
| 3119 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3120 | DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch) |
| 3121 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3122 | private: |
| 3123 | InstanceType from_; |
| 3124 | InstanceType to_; // Inclusive range, not all combinations work. |
| 3125 | }; |
| 3126 | |
| 3127 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3128 | class HHasCachedArrayIndexAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3129 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3130 | explicit HHasCachedArrayIndexAndBranch(HValue* value) |
| 3131 | : HUnaryControlInstruction(value, NULL, NULL) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3132 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3133 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3134 | return Representation::Tagged(); |
| 3135 | } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3136 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3137 | DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3138 | }; |
| 3139 | |
| 3140 | |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 3141 | class HGetCachedArrayIndex: public HUnaryOperation { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 3142 | public: |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 3143 | explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) { |
| 3144 | set_representation(Representation::Tagged()); |
| 3145 | SetFlag(kUseGVN); |
| 3146 | } |
| 3147 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3148 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 3149 | return Representation::Tagged(); |
| 3150 | } |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 3151 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3152 | DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex) |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 3153 | |
| 3154 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3155 | virtual bool DataEquals(HValue* other) { return true; } |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 3156 | }; |
| 3157 | |
| 3158 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3159 | class HClassOfTestAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3160 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3161 | HClassOfTestAndBranch(HValue* value, Handle<String> class_name) |
| 3162 | : HUnaryControlInstruction(value, NULL, NULL), |
| 3163 | class_name_(class_name) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3164 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3165 | DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch) |
| 3166 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3167 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3168 | return Representation::Tagged(); |
| 3169 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3170 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3171 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3172 | |
| 3173 | Handle<String> class_name() const { return class_name_; } |
| 3174 | |
| 3175 | private: |
| 3176 | Handle<String> class_name_; |
| 3177 | }; |
| 3178 | |
| 3179 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3180 | class HTypeofIsAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3181 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3182 | HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) |
| 3183 | : HUnaryControlInstruction(value, NULL, NULL), |
| 3184 | type_literal_(type_literal) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3185 | |
| 3186 | Handle<String> type_literal() { return type_literal_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3187 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3188 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3189 | DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3190 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3191 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3192 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3193 | } |
| 3194 | |
| 3195 | private: |
| 3196 | Handle<String> type_literal_; |
| 3197 | }; |
| 3198 | |
| 3199 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3200 | class HInstanceOf: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3201 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3202 | HInstanceOf(HValue* context, HValue* left, HValue* right) |
| 3203 | : HBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3204 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3205 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3206 | } |
| 3207 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3208 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3209 | return Representation::Tagged(); |
| 3210 | } |
| 3211 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 3212 | virtual HType CalculateInferredType(); |
| 3213 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3214 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3215 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3216 | DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3217 | }; |
| 3218 | |
| 3219 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3220 | class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3221 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3222 | HInstanceOfKnownGlobal(HValue* context, |
| 3223 | HValue* left, |
| 3224 | Handle<JSFunction> right) |
| 3225 | : function_(right) { |
| 3226 | SetOperandAt(0, context); |
| 3227 | SetOperandAt(1, left); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3228 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3229 | SetAllSideEffects(); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3230 | } |
| 3231 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3232 | HValue* context() { return OperandAt(0); } |
| 3233 | HValue* left() { return OperandAt(1); } |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3234 | Handle<JSFunction> function() { return function_; } |
| 3235 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3236 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3237 | return Representation::Tagged(); |
| 3238 | } |
| 3239 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 3240 | virtual HType CalculateInferredType(); |
| 3241 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3242 | DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 3243 | |
| 3244 | private: |
| 3245 | Handle<JSFunction> function_; |
| 3246 | }; |
| 3247 | |
| 3248 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3249 | class HPower: public HTemplateInstruction<2> { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3250 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3251 | HPower(HValue* left, HValue* right) { |
| 3252 | SetOperandAt(0, left); |
| 3253 | SetOperandAt(1, right); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3254 | set_representation(Representation::Double()); |
| 3255 | SetFlag(kUseGVN); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 3256 | SetGVNFlag(kChangesNewSpacePromotion); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3257 | } |
| 3258 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3259 | HValue* left() { return OperandAt(0); } |
| 3260 | HValue* right() { return OperandAt(1); } |
| 3261 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3262 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3263 | return index == 0 |
| 3264 | ? Representation::Double() |
| 3265 | : Representation::None(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3266 | } |
| 3267 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3268 | DECLARE_CONCRETE_INSTRUCTION(Power) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3269 | |
| 3270 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3271 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3272 | }; |
| 3273 | |
| 3274 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 3275 | class HRandom: public HTemplateInstruction<1> { |
| 3276 | public: |
| 3277 | explicit HRandom(HValue* global_object) { |
| 3278 | SetOperandAt(0, global_object); |
| 3279 | set_representation(Representation::Double()); |
| 3280 | } |
| 3281 | |
| 3282 | HValue* global_object() { return OperandAt(0); } |
| 3283 | |
| 3284 | virtual Representation RequiredInputRepresentation(int index) { |
| 3285 | return Representation::Tagged(); |
| 3286 | } |
| 3287 | |
| 3288 | DECLARE_CONCRETE_INSTRUCTION(Random) |
| 3289 | }; |
| 3290 | |
| 3291 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3292 | class HAdd: public HArithmeticBinaryOperation { |
| 3293 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3294 | HAdd(HValue* context, HValue* left, HValue* right) |
| 3295 | : HArithmeticBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3296 | SetFlag(kCanOverflow); |
| 3297 | } |
| 3298 | |
| 3299 | // Add is only commutative if two integer values are added and not if two |
| 3300 | // tagged values are added (because it might be a String concatenation). |
| 3301 | virtual bool IsCommutative() const { |
| 3302 | return !representation().IsTagged(); |
| 3303 | } |
| 3304 | |
| 3305 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3306 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3307 | static HInstruction* NewHAdd(Zone* zone, |
| 3308 | HValue* context, |
| 3309 | HValue* left, |
| 3310 | HValue* right); |
| 3311 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3312 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3313 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3314 | virtual HValue* Canonicalize(); |
| 3315 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3316 | DECLARE_CONCRETE_INSTRUCTION(Add) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3317 | |
| 3318 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3319 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3320 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3321 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3322 | }; |
| 3323 | |
| 3324 | |
| 3325 | class HSub: public HArithmeticBinaryOperation { |
| 3326 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3327 | HSub(HValue* context, HValue* left, HValue* right) |
| 3328 | : HArithmeticBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3329 | SetFlag(kCanOverflow); |
| 3330 | } |
| 3331 | |
| 3332 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3333 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3334 | virtual HValue* Canonicalize(); |
| 3335 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3336 | static HInstruction* NewHSub(Zone* zone, |
| 3337 | HValue* context, |
| 3338 | HValue* left, |
| 3339 | HValue* right); |
| 3340 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3341 | DECLARE_CONCRETE_INSTRUCTION(Sub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3342 | |
| 3343 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3344 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3345 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3346 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3347 | }; |
| 3348 | |
| 3349 | |
| 3350 | class HMul: public HArithmeticBinaryOperation { |
| 3351 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3352 | HMul(HValue* context, HValue* left, HValue* right) |
| 3353 | : HArithmeticBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3354 | SetFlag(kCanOverflow); |
| 3355 | } |
| 3356 | |
| 3357 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3358 | |
| 3359 | // Only commutative if it is certain that not two objects are multiplicated. |
| 3360 | virtual bool IsCommutative() const { |
| 3361 | return !representation().IsTagged(); |
| 3362 | } |
| 3363 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3364 | static HInstruction* NewHMul(Zone* zone, |
| 3365 | HValue* context, |
| 3366 | HValue* left, |
| 3367 | HValue* right); |
| 3368 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3369 | DECLARE_CONCRETE_INSTRUCTION(Mul) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3370 | |
| 3371 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3372 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3373 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3374 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3375 | }; |
| 3376 | |
| 3377 | |
| 3378 | class HMod: public HArithmeticBinaryOperation { |
| 3379 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3380 | HMod(HValue* context, HValue* left, HValue* right) |
| 3381 | : HArithmeticBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3382 | SetFlag(kCanBeDivByZero); |
| 3383 | } |
| 3384 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 3385 | bool HasPowerOf2Divisor() { |
| 3386 | if (right()->IsConstant() && |
| 3387 | HConstant::cast(right())->HasInteger32Value()) { |
| 3388 | int32_t value = HConstant::cast(right())->Integer32Value(); |
| 3389 | return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
| 3390 | } |
| 3391 | |
| 3392 | return false; |
| 3393 | } |
| 3394 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3395 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3396 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3397 | static HInstruction* NewHMod(Zone* zone, |
| 3398 | HValue* context, |
| 3399 | HValue* left, |
| 3400 | HValue* right); |
| 3401 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3402 | DECLARE_CONCRETE_INSTRUCTION(Mod) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3403 | |
| 3404 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3405 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3406 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3407 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3408 | }; |
| 3409 | |
| 3410 | |
| 3411 | class HDiv: public HArithmeticBinaryOperation { |
| 3412 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3413 | HDiv(HValue* context, HValue* left, HValue* right) |
| 3414 | : HArithmeticBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3415 | SetFlag(kCanBeDivByZero); |
| 3416 | SetFlag(kCanOverflow); |
| 3417 | } |
| 3418 | |
| 3419 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3420 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3421 | static HInstruction* NewHDiv(Zone* zone, |
| 3422 | HValue* context, |
| 3423 | HValue* left, |
| 3424 | HValue* right); |
| 3425 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3426 | DECLARE_CONCRETE_INSTRUCTION(Div) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3427 | |
| 3428 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3429 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3430 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3431 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3432 | }; |
| 3433 | |
| 3434 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3435 | class HBitwise: public HBitwiseBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3436 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3437 | HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
| 3438 | : HBitwiseBinaryOperation(context, left, right), op_(op) { |
| 3439 | ASSERT(op == Token::BIT_AND || |
| 3440 | op == Token::BIT_OR || |
| 3441 | op == Token::BIT_XOR); |
| 3442 | } |
| 3443 | |
| 3444 | Token::Value op() const { return op_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3445 | |
| 3446 | virtual bool IsCommutative() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3447 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 3448 | virtual HValue* Canonicalize(); |
| 3449 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3450 | static HInstruction* NewHBitwise(Zone* zone, |
| 3451 | Token::Value op, |
| 3452 | HValue* context, |
| 3453 | HValue* left, |
| 3454 | HValue* right); |
| 3455 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 3456 | virtual void PrintDataTo(StringStream* stream); |
| 3457 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3458 | DECLARE_CONCRETE_INSTRUCTION(Bitwise) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3459 | |
| 3460 | protected: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3461 | virtual bool DataEquals(HValue* other) { |
| 3462 | return op() == HBitwise::cast(other)->op(); |
| 3463 | } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3464 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3465 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3466 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3467 | private: |
| 3468 | Token::Value op_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3469 | }; |
| 3470 | |
| 3471 | |
| 3472 | class HShl: public HBitwiseBinaryOperation { |
| 3473 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3474 | HShl(HValue* context, HValue* left, HValue* right) |
| 3475 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3476 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3477 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3478 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3479 | static HInstruction* NewHShl(Zone* zone, |
| 3480 | HValue* context, |
| 3481 | HValue* left, |
| 3482 | HValue* right); |
| 3483 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3484 | DECLARE_CONCRETE_INSTRUCTION(Shl) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3485 | |
| 3486 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3487 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3488 | }; |
| 3489 | |
| 3490 | |
| 3491 | class HShr: public HBitwiseBinaryOperation { |
| 3492 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3493 | HShr(HValue* context, HValue* left, HValue* right) |
| 3494 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3495 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3496 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3497 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3498 | static HInstruction* NewHShr(Zone* zone, |
| 3499 | HValue* context, |
| 3500 | HValue* left, |
| 3501 | HValue* right); |
| 3502 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3503 | DECLARE_CONCRETE_INSTRUCTION(Shr) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3504 | |
| 3505 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3506 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3507 | }; |
| 3508 | |
| 3509 | |
| 3510 | class HSar: public HBitwiseBinaryOperation { |
| 3511 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3512 | HSar(HValue* context, HValue* left, HValue* right) |
| 3513 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3514 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3515 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3516 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3517 | static HInstruction* NewHSar(Zone* zone, |
| 3518 | HValue* context, |
| 3519 | HValue* left, |
| 3520 | HValue* right); |
| 3521 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3522 | DECLARE_CONCRETE_INSTRUCTION(Sar) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3523 | |
| 3524 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3525 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3526 | }; |
| 3527 | |
| 3528 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3529 | class HOsrEntry: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3530 | public: |
| 3531 | explicit HOsrEntry(int ast_id) : ast_id_(ast_id) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3532 | SetGVNFlag(kChangesOsrEntries); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3533 | } |
| 3534 | |
| 3535 | int ast_id() const { return ast_id_; } |
| 3536 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3537 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3538 | return Representation::None(); |
| 3539 | } |
| 3540 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3541 | DECLARE_CONCRETE_INSTRUCTION(OsrEntry) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3542 | |
| 3543 | private: |
| 3544 | int ast_id_; |
| 3545 | }; |
| 3546 | |
| 3547 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3548 | class HParameter: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3549 | public: |
| 3550 | explicit HParameter(unsigned index) : index_(index) { |
| 3551 | set_representation(Representation::Tagged()); |
| 3552 | } |
| 3553 | |
| 3554 | unsigned index() const { return index_; } |
| 3555 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3556 | virtual void PrintDataTo(StringStream* stream); |
| 3557 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3558 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3559 | return Representation::None(); |
| 3560 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3561 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3562 | DECLARE_CONCRETE_INSTRUCTION(Parameter) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3563 | |
| 3564 | private: |
| 3565 | unsigned index_; |
| 3566 | }; |
| 3567 | |
| 3568 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3569 | class HCallStub: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3570 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3571 | HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) |
| 3572 | : HUnaryCall(context, argument_count), |
| 3573 | major_key_(major_key), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3574 | transcendental_type_(TranscendentalCache::kNumberOfCaches) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3575 | } |
| 3576 | |
| 3577 | CodeStub::Major major_key() { return major_key_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3578 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3579 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3580 | |
| 3581 | void set_transcendental_type(TranscendentalCache::Type transcendental_type) { |
| 3582 | transcendental_type_ = transcendental_type; |
| 3583 | } |
| 3584 | TranscendentalCache::Type transcendental_type() { |
| 3585 | return transcendental_type_; |
| 3586 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3587 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3588 | virtual void PrintDataTo(StringStream* stream); |
| 3589 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3590 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3591 | return Representation::Tagged(); |
| 3592 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3593 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3594 | DECLARE_CONCRETE_INSTRUCTION(CallStub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3595 | |
| 3596 | private: |
| 3597 | CodeStub::Major major_key_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3598 | TranscendentalCache::Type transcendental_type_; |
| 3599 | }; |
| 3600 | |
| 3601 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3602 | class HUnknownOSRValue: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3603 | public: |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 3604 | HUnknownOSRValue() |
| 3605 | : incoming_value_(NULL) { |
| 3606 | set_representation(Representation::Tagged()); |
| 3607 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3608 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3609 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3610 | return Representation::None(); |
| 3611 | } |
| 3612 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 3613 | void set_incoming_value(HPhi* value) { |
| 3614 | incoming_value_ = value; |
| 3615 | } |
| 3616 | |
| 3617 | HPhi* incoming_value() { |
| 3618 | return incoming_value_; |
| 3619 | } |
| 3620 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3621 | DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 3622 | |
| 3623 | private: |
| 3624 | HPhi* incoming_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3625 | }; |
| 3626 | |
| 3627 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3628 | class HLoadGlobalCell: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3629 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3630 | HLoadGlobalCell(Handle<JSGlobalPropertyCell> cell, PropertyDetails details) |
| 3631 | : cell_(cell), details_(details) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3632 | set_representation(Representation::Tagged()); |
| 3633 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3634 | SetGVNFlag(kDependsOnGlobalVars); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3635 | } |
| 3636 | |
| 3637 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3638 | bool RequiresHoleCheck(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3639 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3640 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3641 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3642 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3643 | ASSERT(!HEAP->allow_allocation(false)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3644 | return reinterpret_cast<intptr_t>(*cell_); |
| 3645 | } |
| 3646 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3647 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3648 | return Representation::None(); |
| 3649 | } |
| 3650 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3651 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3652 | |
| 3653 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3654 | virtual bool DataEquals(HValue* other) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3655 | HLoadGlobalCell* b = HLoadGlobalCell::cast(other); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3656 | return cell_.is_identical_to(b->cell()); |
| 3657 | } |
| 3658 | |
| 3659 | private: |
| 3660 | Handle<JSGlobalPropertyCell> cell_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3661 | PropertyDetails details_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3662 | }; |
| 3663 | |
| 3664 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3665 | class HLoadGlobalGeneric: public HTemplateInstruction<2> { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3666 | public: |
| 3667 | HLoadGlobalGeneric(HValue* context, |
| 3668 | HValue* global_object, |
| 3669 | Handle<Object> name, |
| 3670 | bool for_typeof) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3671 | : name_(name), |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3672 | for_typeof_(for_typeof) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3673 | SetOperandAt(0, context); |
| 3674 | SetOperandAt(1, global_object); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3675 | set_representation(Representation::Tagged()); |
| 3676 | SetAllSideEffects(); |
| 3677 | } |
| 3678 | |
| 3679 | HValue* context() { return OperandAt(0); } |
| 3680 | HValue* global_object() { return OperandAt(1); } |
| 3681 | Handle<Object> name() const { return name_; } |
| 3682 | bool for_typeof() const { return for_typeof_; } |
| 3683 | |
| 3684 | virtual void PrintDataTo(StringStream* stream); |
| 3685 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3686 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3687 | return Representation::Tagged(); |
| 3688 | } |
| 3689 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3690 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3691 | |
| 3692 | private: |
| 3693 | Handle<Object> name_; |
| 3694 | bool for_typeof_; |
| 3695 | }; |
| 3696 | |
| 3697 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 3698 | inline bool StoringValueNeedsWriteBarrier(HValue* value) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3699 | return !value->type().IsBoolean() |
| 3700 | && !value->type().IsSmi() |
| 3701 | && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); |
| 3702 | } |
| 3703 | |
| 3704 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 3705 | inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
| 3706 | HValue* new_space_dominator) { |
| 3707 | return !object->IsAllocateObject() || (object != new_space_dominator); |
| 3708 | } |
| 3709 | |
| 3710 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3711 | class HStoreGlobalCell: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3712 | public: |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3713 | HStoreGlobalCell(HValue* value, |
| 3714 | Handle<JSGlobalPropertyCell> cell, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3715 | PropertyDetails details) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3716 | : HUnaryOperation(value), |
| 3717 | cell_(cell), |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3718 | details_(details) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3719 | SetGVNFlag(kChangesGlobalVars); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3720 | } |
| 3721 | |
| 3722 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3723 | bool RequiresHoleCheck() { |
| 3724 | return !details_.IsDontDelete() || details_.IsReadOnly(); |
| 3725 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3726 | bool NeedsWriteBarrier() { |
| 3727 | return StoringValueNeedsWriteBarrier(value()); |
| 3728 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3729 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3730 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3731 | return Representation::Tagged(); |
| 3732 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3733 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3734 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3735 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3736 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3737 | private: |
| 3738 | Handle<JSGlobalPropertyCell> cell_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3739 | PropertyDetails details_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3740 | }; |
| 3741 | |
| 3742 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3743 | class HStoreGlobalGeneric: public HTemplateInstruction<3> { |
| 3744 | public: |
| 3745 | HStoreGlobalGeneric(HValue* context, |
| 3746 | HValue* global_object, |
| 3747 | Handle<Object> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3748 | HValue* value, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 3749 | StrictModeFlag strict_mode_flag) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3750 | : name_(name), |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 3751 | strict_mode_flag_(strict_mode_flag) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3752 | SetOperandAt(0, context); |
| 3753 | SetOperandAt(1, global_object); |
| 3754 | SetOperandAt(2, value); |
| 3755 | set_representation(Representation::Tagged()); |
| 3756 | SetAllSideEffects(); |
| 3757 | } |
| 3758 | |
| 3759 | HValue* context() { return OperandAt(0); } |
| 3760 | HValue* global_object() { return OperandAt(1); } |
| 3761 | Handle<Object> name() const { return name_; } |
| 3762 | HValue* value() { return OperandAt(2); } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 3763 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3764 | |
| 3765 | virtual void PrintDataTo(StringStream* stream); |
| 3766 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3767 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3768 | return Representation::Tagged(); |
| 3769 | } |
| 3770 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3771 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3772 | |
| 3773 | private: |
| 3774 | Handle<Object> name_; |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 3775 | StrictModeFlag strict_mode_flag_; |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3776 | }; |
| 3777 | |
| 3778 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3779 | class HLoadContextSlot: public HUnaryOperation { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3780 | public: |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3781 | enum Mode { |
| 3782 | // Perform a normal load of the context slot without checking its value. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3783 | kNoCheck, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3784 | // Load and check the value of the context slot. Deoptimize if it's the |
| 3785 | // hole value. This is used for checking for loading of uninitialized |
| 3786 | // harmony bindings where we deoptimize into full-codegen generated code |
| 3787 | // which will subsequently throw a reference error. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3788 | kCheckDeoptimize, |
| 3789 | // Load and check the value of the context slot. Return undefined if it's |
| 3790 | // the hole value. This is used for non-harmony const assignments |
| 3791 | kCheckReturnUndefined |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3792 | }; |
| 3793 | |
| 3794 | HLoadContextSlot(HValue* context, Variable* var) |
| 3795 | : HUnaryOperation(context), slot_index_(var->index()) { |
| 3796 | ASSERT(var->IsContextSlot()); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3797 | switch (var->mode()) { |
| 3798 | case LET: |
| 3799 | case CONST_HARMONY: |
| 3800 | mode_ = kCheckDeoptimize; |
| 3801 | break; |
| 3802 | case CONST: |
| 3803 | mode_ = kCheckReturnUndefined; |
| 3804 | break; |
| 3805 | default: |
| 3806 | mode_ = kNoCheck; |
| 3807 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3808 | set_representation(Representation::Tagged()); |
| 3809 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3810 | SetGVNFlag(kDependsOnContextSlots); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3811 | } |
| 3812 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3813 | int slot_index() const { return slot_index_; } |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3814 | Mode mode() const { return mode_; } |
| 3815 | |
| 3816 | bool DeoptimizesOnHole() { |
| 3817 | return mode_ == kCheckDeoptimize; |
| 3818 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3819 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3820 | bool RequiresHoleCheck() { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3821 | return mode_ != kNoCheck; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3822 | } |
| 3823 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3824 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3825 | return Representation::Tagged(); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3826 | } |
| 3827 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3828 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3829 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3830 | DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3831 | |
| 3832 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3833 | virtual bool DataEquals(HValue* other) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3834 | HLoadContextSlot* b = HLoadContextSlot::cast(other); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3835 | return (slot_index() == b->slot_index()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | private: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3839 | int slot_index_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3840 | Mode mode_; |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3841 | }; |
| 3842 | |
| 3843 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3844 | class HStoreContextSlot: public HTemplateInstruction<2> { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3845 | public: |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3846 | enum Mode { |
| 3847 | // Perform a normal store to the context slot without checking its previous |
| 3848 | // value. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3849 | kNoCheck, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3850 | // Check the previous value of the context slot and deoptimize if it's the |
| 3851 | // hole value. This is used for checking for assignments to uninitialized |
| 3852 | // harmony bindings where we deoptimize into full-codegen generated code |
| 3853 | // which will subsequently throw a reference error. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3854 | kCheckDeoptimize, |
| 3855 | // Check the previous value and ignore assignment if it isn't a hole value |
| 3856 | kCheckIgnoreAssignment |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3857 | }; |
| 3858 | |
| 3859 | HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) |
| 3860 | : slot_index_(slot_index), mode_(mode) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3861 | SetOperandAt(0, context); |
| 3862 | SetOperandAt(1, value); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3863 | SetGVNFlag(kChangesContextSlots); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3864 | } |
| 3865 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3866 | HValue* context() { return OperandAt(0); } |
| 3867 | HValue* value() { return OperandAt(1); } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3868 | int slot_index() const { return slot_index_; } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3869 | Mode mode() const { return mode_; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3870 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3871 | bool NeedsWriteBarrier() { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3872 | return StoringValueNeedsWriteBarrier(value()); |
| 3873 | } |
| 3874 | |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3875 | bool DeoptimizesOnHole() { |
| 3876 | return mode_ == kCheckDeoptimize; |
| 3877 | } |
| 3878 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3879 | bool RequiresHoleCheck() { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 3880 | return mode_ != kNoCheck; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3881 | } |
| 3882 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3883 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3884 | return Representation::Tagged(); |
| 3885 | } |
| 3886 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3887 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3888 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3889 | DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3890 | |
| 3891 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3892 | int slot_index_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 3893 | Mode mode_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3894 | }; |
| 3895 | |
| 3896 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3897 | class HLoadNamedField: public HUnaryOperation { |
| 3898 | public: |
| 3899 | HLoadNamedField(HValue* object, bool is_in_object, int offset) |
| 3900 | : HUnaryOperation(object), |
| 3901 | is_in_object_(is_in_object), |
| 3902 | offset_(offset) { |
| 3903 | set_representation(Representation::Tagged()); |
| 3904 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3905 | SetGVNFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3906 | if (is_in_object) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3907 | SetGVNFlag(kDependsOnInobjectFields); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3908 | } else { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 3909 | SetGVNFlag(kDependsOnBackingStoreFields); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3910 | } |
| 3911 | } |
| 3912 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3913 | HValue* object() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3914 | bool is_in_object() const { return is_in_object_; } |
| 3915 | int offset() const { return offset_; } |
| 3916 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3917 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3918 | return Representation::Tagged(); |
| 3919 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3920 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3921 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3922 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3923 | |
| 3924 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3925 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3926 | HLoadNamedField* b = HLoadNamedField::cast(other); |
| 3927 | return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; |
| 3928 | } |
| 3929 | |
| 3930 | private: |
| 3931 | bool is_in_object_; |
| 3932 | int offset_; |
| 3933 | }; |
| 3934 | |
| 3935 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3936 | class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3937 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3938 | HLoadNamedFieldPolymorphic(HValue* context, |
| 3939 | HValue* object, |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 3940 | SmallMapList* types, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3941 | Handle<String> name, |
| 3942 | Zone* zone); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3943 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3944 | HValue* context() { return OperandAt(0); } |
| 3945 | HValue* object() { return OperandAt(1); } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 3946 | SmallMapList* types() { return &types_; } |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3947 | Handle<String> name() { return name_; } |
| 3948 | bool need_generic() { return need_generic_; } |
| 3949 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3950 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3951 | return Representation::Tagged(); |
| 3952 | } |
| 3953 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 3954 | virtual void PrintDataTo(StringStream* stream); |
| 3955 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3956 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic) |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3957 | |
| 3958 | static const int kMaxLoadPolymorphism = 4; |
| 3959 | |
| 3960 | protected: |
| 3961 | virtual bool DataEquals(HValue* value); |
| 3962 | |
| 3963 | private: |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 3964 | SmallMapList types_; |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3965 | Handle<String> name_; |
| 3966 | bool need_generic_; |
| 3967 | }; |
| 3968 | |
| 3969 | |
| 3970 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3971 | class HLoadNamedGeneric: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3972 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3973 | HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3974 | : name_(name) { |
| 3975 | SetOperandAt(0, context); |
| 3976 | SetOperandAt(1, object); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3977 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3978 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3979 | } |
| 3980 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3981 | HValue* context() { return OperandAt(0); } |
| 3982 | HValue* object() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3983 | Handle<Object> name() const { return name_; } |
| 3984 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3985 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3986 | return Representation::Tagged(); |
| 3987 | } |
| 3988 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 3989 | virtual void PrintDataTo(StringStream* stream); |
| 3990 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3991 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3992 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3993 | private: |
| 3994 | Handle<Object> name_; |
| 3995 | }; |
| 3996 | |
| 3997 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3998 | class HLoadFunctionPrototype: public HUnaryOperation { |
| 3999 | public: |
| 4000 | explicit HLoadFunctionPrototype(HValue* function) |
| 4001 | : HUnaryOperation(function) { |
| 4002 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4003 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4004 | SetGVNFlag(kDependsOnCalls); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4005 | } |
| 4006 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4007 | HValue* function() { return OperandAt(0); } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4008 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4009 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4010 | return Representation::Tagged(); |
| 4011 | } |
| 4012 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4013 | DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype) |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4014 | |
| 4015 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4016 | virtual bool DataEquals(HValue* other) { return true; } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4017 | }; |
| 4018 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4019 | class ArrayInstructionInterface { |
| 4020 | public: |
| 4021 | virtual HValue* GetKey() = 0; |
| 4022 | virtual void SetKey(HValue* key) = 0; |
| 4023 | virtual void SetIndexOffset(uint32_t index_offset) = 0; |
| 4024 | virtual bool IsDehoisted() = 0; |
| 4025 | virtual void SetDehoisted(bool is_dehoisted) = 0; |
| 4026 | virtual ~ArrayInstructionInterface() { }; |
| 4027 | }; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 4028 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4029 | class HLoadKeyedFastElement |
| 4030 | : public HTemplateInstruction<2>, public ArrayInstructionInterface { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4031 | public: |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 4032 | HLoadKeyedFastElement(HValue* obj, |
| 4033 | HValue* key, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4034 | ElementsKind elements_kind = FAST_ELEMENTS) |
| 4035 | : bit_field_(0) { |
| 4036 | ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); |
| 4037 | bit_field_ = ElementsKindField::encode(elements_kind); |
| 4038 | if (IsFastSmiElementsKind(elements_kind) && |
| 4039 | IsFastPackedElementsKind(elements_kind)) { |
| 4040 | set_type(HType::Smi()); |
| 4041 | } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4042 | SetOperandAt(0, obj); |
| 4043 | SetOperandAt(1, key); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4044 | set_representation(Representation::Tagged()); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4045 | SetGVNFlag(kDependsOnArrayElements); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4046 | SetFlag(kUseGVN); |
| 4047 | } |
| 4048 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4049 | HValue* object() { return OperandAt(0); } |
| 4050 | HValue* key() { return OperandAt(1); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4051 | uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| 4052 | void SetIndexOffset(uint32_t index_offset) { |
| 4053 | bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 4054 | } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4055 | HValue* GetKey() { return key(); } |
| 4056 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4057 | bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| 4058 | void SetDehoisted(bool is_dehoisted) { |
| 4059 | bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 4060 | } |
| 4061 | ElementsKind elements_kind() const { |
| 4062 | return ElementsKindField::decode(bit_field_); |
| 4063 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4064 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4065 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4066 | // The key is supposed to be Integer32. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4067 | return index == 0 |
| 4068 | ? Representation::Tagged() |
| 4069 | : Representation::Integer32(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4070 | } |
| 4071 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4072 | virtual void PrintDataTo(StringStream* stream); |
| 4073 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4074 | bool RequiresHoleCheck(); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 4075 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4076 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4077 | |
| 4078 | protected: |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 4079 | virtual bool DataEquals(HValue* other) { |
| 4080 | if (!other->IsLoadKeyedFastElement()) return false; |
| 4081 | HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4082 | if (IsDehoisted() && index_offset() != other_load->index_offset()) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4083 | return false; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4084 | return elements_kind() == other_load->elements_kind(); |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | private: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4088 | class ElementsKindField: public BitField<ElementsKind, 0, 4> {}; |
| 4089 | class IndexOffsetField: public BitField<uint32_t, 4, 27> {}; |
| 4090 | class IsDehoistedField: public BitField<bool, 31, 1> {}; |
| 4091 | uint32_t bit_field_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4092 | }; |
| 4093 | |
| 4094 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4095 | enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; |
| 4096 | |
| 4097 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4098 | class HLoadKeyedFastDoubleElement |
| 4099 | : public HTemplateInstruction<2>, public ArrayInstructionInterface { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4100 | public: |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4101 | HLoadKeyedFastDoubleElement( |
| 4102 | HValue* elements, |
| 4103 | HValue* key, |
| 4104 | HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4105 | : index_offset_(0), |
| 4106 | is_dehoisted_(false), |
| 4107 | hole_check_mode_(hole_check_mode) { |
| 4108 | SetOperandAt(0, elements); |
| 4109 | SetOperandAt(1, key); |
| 4110 | set_representation(Representation::Double()); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4111 | SetGVNFlag(kDependsOnDoubleArrayElements); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4112 | SetFlag(kUseGVN); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4113 | } |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4114 | |
| 4115 | HValue* elements() { return OperandAt(0); } |
| 4116 | HValue* key() { return OperandAt(1); } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4117 | uint32_t index_offset() { return index_offset_; } |
| 4118 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 4119 | HValue* GetKey() { return key(); } |
| 4120 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4121 | bool IsDehoisted() { return is_dehoisted_; } |
| 4122 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4123 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4124 | virtual Representation RequiredInputRepresentation(int index) { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4125 | // The key is supposed to be Integer32. |
| 4126 | return index == 0 |
| 4127 | ? Representation::Tagged() |
| 4128 | : Representation::Integer32(); |
| 4129 | } |
| 4130 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4131 | bool RequiresHoleCheck() { |
| 4132 | return hole_check_mode_ == PERFORM_HOLE_CHECK; |
| 4133 | } |
| 4134 | |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4135 | virtual void PrintDataTo(StringStream* stream); |
| 4136 | |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4137 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement) |
| 4138 | |
| 4139 | protected: |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4140 | virtual bool DataEquals(HValue* other) { |
| 4141 | if (!other->IsLoadKeyedFastDoubleElement()) return false; |
| 4142 | HLoadKeyedFastDoubleElement* other_load = |
| 4143 | HLoadKeyedFastDoubleElement::cast(other); |
| 4144 | return hole_check_mode_ == other_load->hole_check_mode_; |
| 4145 | } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4146 | |
| 4147 | private: |
| 4148 | uint32_t index_offset_; |
| 4149 | bool is_dehoisted_; |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4150 | HoleCheckMode hole_check_mode_; |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4151 | }; |
| 4152 | |
| 4153 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4154 | class HLoadKeyedSpecializedArrayElement |
| 4155 | : public HTemplateInstruction<2>, public ArrayInstructionInterface { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4156 | public: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4157 | HLoadKeyedSpecializedArrayElement(HValue* external_elements, |
| 4158 | HValue* key, |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4159 | ElementsKind elements_kind) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4160 | : elements_kind_(elements_kind), |
| 4161 | index_offset_(0), |
| 4162 | is_dehoisted_(false) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4163 | SetOperandAt(0, external_elements); |
| 4164 | SetOperandAt(1, key); |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4165 | if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
| 4166 | elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4167 | set_representation(Representation::Double()); |
| 4168 | } else { |
| 4169 | set_representation(Representation::Integer32()); |
| 4170 | } |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4171 | SetGVNFlag(kDependsOnSpecializedArrayElements); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4172 | // Native code could change the specialized array. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4173 | SetGVNFlag(kDependsOnCalls); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4174 | SetFlag(kUseGVN); |
| 4175 | } |
| 4176 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4177 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4178 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4179 | virtual Representation RequiredInputRepresentation(int index) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4180 | // The key is supposed to be Integer32, but the base pointer |
| 4181 | // for the element load is a naked pointer. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4182 | return index == 0 |
| 4183 | ? Representation::External() |
| 4184 | : Representation::Integer32(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4185 | } |
| 4186 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4187 | HValue* external_pointer() { return OperandAt(0); } |
| 4188 | HValue* key() { return OperandAt(1); } |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4189 | ElementsKind elements_kind() const { return elements_kind_; } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4190 | uint32_t index_offset() { return index_offset_; } |
| 4191 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 4192 | HValue* GetKey() { return key(); } |
| 4193 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4194 | bool IsDehoisted() { return is_dehoisted_; } |
| 4195 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4196 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4197 | virtual Range* InferRange(Zone* zone); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 4198 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4199 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4200 | |
| 4201 | protected: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4202 | virtual bool DataEquals(HValue* other) { |
| 4203 | if (!other->IsLoadKeyedSpecializedArrayElement()) return false; |
| 4204 | HLoadKeyedSpecializedArrayElement* cast_other = |
| 4205 | HLoadKeyedSpecializedArrayElement::cast(other); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4206 | return elements_kind_ == cast_other->elements_kind(); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4207 | } |
| 4208 | |
| 4209 | private: |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4210 | ElementsKind elements_kind_; |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4211 | uint32_t index_offset_; |
| 4212 | bool is_dehoisted_; |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4213 | }; |
| 4214 | |
| 4215 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4216 | class HLoadKeyedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4217 | public: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 4218 | HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4219 | set_representation(Representation::Tagged()); |
| 4220 | SetOperandAt(0, obj); |
| 4221 | SetOperandAt(1, key); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4222 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4223 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4224 | } |
| 4225 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4226 | HValue* object() { return OperandAt(0); } |
| 4227 | HValue* key() { return OperandAt(1); } |
| 4228 | HValue* context() { return OperandAt(2); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4229 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4230 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4231 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4232 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4233 | return Representation::Tagged(); |
| 4234 | } |
| 4235 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 4236 | virtual HValue* Canonicalize(); |
| 4237 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4238 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4239 | }; |
| 4240 | |
| 4241 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4242 | class HStoreNamedField: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4243 | public: |
| 4244 | HStoreNamedField(HValue* obj, |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4245 | Handle<String> name, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4246 | HValue* val, |
| 4247 | bool in_object, |
| 4248 | int offset) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4249 | : name_(name), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4250 | is_in_object_(in_object), |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4251 | offset_(offset), |
| 4252 | new_space_dominator_(NULL) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4253 | SetOperandAt(0, obj); |
| 4254 | SetOperandAt(1, val); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4255 | SetFlag(kTrackSideEffectDominators); |
| 4256 | SetGVNFlag(kDependsOnNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4257 | if (is_in_object_) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4258 | SetGVNFlag(kChangesInobjectFields); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4259 | } else { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4260 | SetGVNFlag(kChangesBackingStoreFields); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4261 | } |
| 4262 | } |
| 4263 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4264 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4265 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4266 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 4267 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4268 | } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4269 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
| 4270 | ASSERT(side_effect == kChangesNewSpacePromotion); |
| 4271 | new_space_dominator_ = dominator; |
| 4272 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4273 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4274 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4275 | HValue* object() { return OperandAt(0); } |
| 4276 | HValue* value() { return OperandAt(1); } |
| 4277 | |
| 4278 | Handle<String> name() const { return name_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4279 | bool is_in_object() const { return is_in_object_; } |
| 4280 | int offset() const { return offset_; } |
| 4281 | Handle<Map> transition() const { return transition_; } |
| 4282 | void set_transition(Handle<Map> map) { transition_ = map; } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4283 | HValue* new_space_dominator() const { return new_space_dominator_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4284 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4285 | bool NeedsWriteBarrier() { |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4286 | return StoringValueNeedsWriteBarrier(value()) && |
| 4287 | ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 4288 | } |
| 4289 | |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 4290 | bool NeedsWriteBarrierForMap() { |
| 4291 | return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
| 4292 | } |
| 4293 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4294 | private: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4295 | Handle<String> name_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4296 | bool is_in_object_; |
| 4297 | int offset_; |
| 4298 | Handle<Map> transition_; |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4299 | HValue* new_space_dominator_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4300 | }; |
| 4301 | |
| 4302 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4303 | class HStoreNamedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4304 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4305 | HStoreNamedGeneric(HValue* context, |
| 4306 | HValue* object, |
| 4307 | Handle<String> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 4308 | HValue* value, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4309 | StrictModeFlag strict_mode_flag) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 4310 | : name_(name), |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4311 | strict_mode_flag_(strict_mode_flag) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4312 | SetOperandAt(0, object); |
| 4313 | SetOperandAt(1, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4314 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4315 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4316 | } |
| 4317 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4318 | HValue* object() { return OperandAt(0); } |
| 4319 | HValue* value() { return OperandAt(1); } |
| 4320 | HValue* context() { return OperandAt(2); } |
| 4321 | Handle<String> name() { return name_; } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4322 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4323 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4324 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4325 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4326 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4327 | return Representation::Tagged(); |
| 4328 | } |
| 4329 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4330 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4331 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4332 | private: |
| 4333 | Handle<String> name_; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4334 | StrictModeFlag strict_mode_flag_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4335 | }; |
| 4336 | |
| 4337 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4338 | class HStoreKeyedFastElement |
| 4339 | : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4340 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4341 | HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val, |
| 4342 | ElementsKind elements_kind = FAST_ELEMENTS) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4343 | : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4344 | SetOperandAt(0, obj); |
| 4345 | SetOperandAt(1, key); |
| 4346 | SetOperandAt(2, val); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4347 | SetGVNFlag(kChangesArrayElements); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4348 | } |
| 4349 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4350 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4351 | // The key is supposed to be Integer32. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4352 | return index == 1 |
| 4353 | ? Representation::Integer32() |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4354 | : Representation::Tagged(); |
| 4355 | } |
| 4356 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4357 | HValue* object() { return OperandAt(0); } |
| 4358 | HValue* key() { return OperandAt(1); } |
| 4359 | HValue* value() { return OperandAt(2); } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4360 | bool value_is_smi() { |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4361 | return IsFastSmiElementsKind(elements_kind_); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4362 | } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4363 | uint32_t index_offset() { return index_offset_; } |
| 4364 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 4365 | HValue* GetKey() { return key(); } |
| 4366 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4367 | bool IsDehoisted() { return is_dehoisted_; } |
| 4368 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4369 | |
| 4370 | bool NeedsWriteBarrier() { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4371 | if (value_is_smi()) { |
| 4372 | return false; |
| 4373 | } else { |
| 4374 | return StoringValueNeedsWriteBarrier(value()); |
| 4375 | } |
| 4376 | } |
| 4377 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4378 | virtual void PrintDataTo(StringStream* stream); |
| 4379 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4380 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4381 | |
| 4382 | private: |
| 4383 | ElementsKind elements_kind_; |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4384 | uint32_t index_offset_; |
| 4385 | bool is_dehoisted_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4386 | }; |
| 4387 | |
| 4388 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4389 | class HStoreKeyedFastDoubleElement |
| 4390 | : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4391 | public: |
| 4392 | HStoreKeyedFastDoubleElement(HValue* elements, |
| 4393 | HValue* key, |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4394 | HValue* val) |
| 4395 | : index_offset_(0), is_dehoisted_(false) { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4396 | SetOperandAt(0, elements); |
| 4397 | SetOperandAt(1, key); |
| 4398 | SetOperandAt(2, val); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4399 | SetGVNFlag(kChangesDoubleArrayElements); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4400 | } |
| 4401 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4402 | virtual Representation RequiredInputRepresentation(int index) { |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4403 | if (index == 1) { |
| 4404 | return Representation::Integer32(); |
| 4405 | } else if (index == 2) { |
| 4406 | return Representation::Double(); |
| 4407 | } else { |
| 4408 | return Representation::Tagged(); |
| 4409 | } |
| 4410 | } |
| 4411 | |
| 4412 | HValue* elements() { return OperandAt(0); } |
| 4413 | HValue* key() { return OperandAt(1); } |
| 4414 | HValue* value() { return OperandAt(2); } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4415 | uint32_t index_offset() { return index_offset_; } |
| 4416 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 4417 | HValue* GetKey() { return key(); } |
| 4418 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4419 | bool IsDehoisted() { return is_dehoisted_; } |
| 4420 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4421 | |
| 4422 | bool NeedsWriteBarrier() { |
| 4423 | return StoringValueNeedsWriteBarrier(value()); |
| 4424 | } |
| 4425 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4426 | bool NeedsCanonicalization(); |
| 4427 | |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4428 | virtual void PrintDataTo(StringStream* stream); |
| 4429 | |
| 4430 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4431 | |
| 4432 | private: |
| 4433 | uint32_t index_offset_; |
| 4434 | bool is_dehoisted_; |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 4435 | }; |
| 4436 | |
| 4437 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4438 | class HStoreKeyedSpecializedArrayElement |
| 4439 | : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4440 | public: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4441 | HStoreKeyedSpecializedArrayElement(HValue* external_elements, |
| 4442 | HValue* key, |
| 4443 | HValue* val, |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4444 | ElementsKind elements_kind) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4445 | : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4446 | SetGVNFlag(kChangesSpecializedArrayElements); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4447 | SetOperandAt(0, external_elements); |
| 4448 | SetOperandAt(1, key); |
| 4449 | SetOperandAt(2, val); |
| 4450 | } |
| 4451 | |
| 4452 | virtual void PrintDataTo(StringStream* stream); |
| 4453 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4454 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4455 | if (index == 0) { |
| 4456 | return Representation::External(); |
| 4457 | } else { |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4458 | bool float_or_double_elements = |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4459 | elements_kind() == EXTERNAL_FLOAT_ELEMENTS || |
| 4460 | elements_kind() == EXTERNAL_DOUBLE_ELEMENTS; |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4461 | if (index == 2 && float_or_double_elements) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4462 | return Representation::Double(); |
| 4463 | } else { |
| 4464 | return Representation::Integer32(); |
| 4465 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4466 | } |
| 4467 | } |
| 4468 | |
| 4469 | HValue* external_pointer() { return OperandAt(0); } |
| 4470 | HValue* key() { return OperandAt(1); } |
| 4471 | HValue* value() { return OperandAt(2); } |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4472 | ElementsKind elements_kind() const { return elements_kind_; } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4473 | uint32_t index_offset() { return index_offset_; } |
| 4474 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 4475 | HValue* GetKey() { return key(); } |
| 4476 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 4477 | bool IsDehoisted() { return is_dehoisted_; } |
| 4478 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4479 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4480 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement) |
| 4481 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4482 | private: |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 4483 | ElementsKind elements_kind_; |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 4484 | uint32_t index_offset_; |
| 4485 | bool is_dehoisted_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4486 | }; |
| 4487 | |
| 4488 | |
| 4489 | class HStoreKeyedGeneric: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4490 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4491 | HStoreKeyedGeneric(HValue* context, |
| 4492 | HValue* object, |
| 4493 | HValue* key, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 4494 | HValue* value, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4495 | StrictModeFlag strict_mode_flag) |
| 4496 | : strict_mode_flag_(strict_mode_flag) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4497 | SetOperandAt(0, object); |
| 4498 | SetOperandAt(1, key); |
| 4499 | SetOperandAt(2, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4500 | SetOperandAt(3, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4501 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4502 | } |
| 4503 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4504 | HValue* object() { return OperandAt(0); } |
| 4505 | HValue* key() { return OperandAt(1); } |
| 4506 | HValue* value() { return OperandAt(2); } |
| 4507 | HValue* context() { return OperandAt(3); } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4508 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4509 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4510 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4511 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4512 | } |
| 4513 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4514 | virtual void PrintDataTo(StringStream* stream); |
| 4515 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4516 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 4517 | |
| 4518 | private: |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4519 | StrictModeFlag strict_mode_flag_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4520 | }; |
| 4521 | |
| 4522 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4523 | class HTransitionElementsKind: public HTemplateInstruction<1> { |
| 4524 | public: |
| 4525 | HTransitionElementsKind(HValue* object, |
| 4526 | Handle<Map> original_map, |
| 4527 | Handle<Map> transitioned_map) |
| 4528 | : original_map_(original_map), |
| 4529 | transitioned_map_(transitioned_map) { |
| 4530 | SetOperandAt(0, object); |
| 4531 | SetFlag(kUseGVN); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4532 | // Don't set GVN DependOn flags here. That would defeat GVN's detection of |
| 4533 | // congruent HTransitionElementsKind instructions. Instruction hoisting |
| 4534 | // handles HTransitionElementsKind instruction specially, explicitly adding |
| 4535 | // DependsOn flags during its dependency calculations. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4536 | SetGVNFlag(kChangesElementsKind); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4537 | if (original_map->has_fast_double_elements()) { |
| 4538 | SetGVNFlag(kChangesElementsPointer); |
| 4539 | SetGVNFlag(kChangesNewSpacePromotion); |
| 4540 | } |
| 4541 | if (transitioned_map->has_fast_double_elements()) { |
| 4542 | SetGVNFlag(kChangesElementsPointer); |
| 4543 | SetGVNFlag(kChangesNewSpacePromotion); |
| 4544 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4545 | set_representation(Representation::Tagged()); |
| 4546 | } |
| 4547 | |
| 4548 | virtual Representation RequiredInputRepresentation(int index) { |
| 4549 | return Representation::Tagged(); |
| 4550 | } |
| 4551 | |
| 4552 | HValue* object() { return OperandAt(0); } |
| 4553 | Handle<Map> original_map() { return original_map_; } |
| 4554 | Handle<Map> transitioned_map() { return transitioned_map_; } |
| 4555 | |
| 4556 | virtual void PrintDataTo(StringStream* stream); |
| 4557 | |
| 4558 | DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) |
| 4559 | |
| 4560 | protected: |
| 4561 | virtual bool DataEquals(HValue* other) { |
| 4562 | HTransitionElementsKind* instr = HTransitionElementsKind::cast(other); |
| 4563 | return original_map_.is_identical_to(instr->original_map()) && |
| 4564 | transitioned_map_.is_identical_to(instr->transitioned_map()); |
| 4565 | } |
| 4566 | |
| 4567 | private: |
| 4568 | Handle<Map> original_map_; |
| 4569 | Handle<Map> transitioned_map_; |
| 4570 | }; |
| 4571 | |
| 4572 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 4573 | class HStringAdd: public HBinaryOperation { |
| 4574 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4575 | HStringAdd(HValue* context, HValue* left, HValue* right) |
| 4576 | : HBinaryOperation(context, left, right) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 4577 | set_representation(Representation::Tagged()); |
| 4578 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4579 | SetGVNFlag(kDependsOnMaps); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 4580 | } |
| 4581 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4582 | virtual Representation RequiredInputRepresentation(int index) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 4583 | return Representation::Tagged(); |
| 4584 | } |
| 4585 | |
| 4586 | virtual HType CalculateInferredType() { |
| 4587 | return HType::String(); |
| 4588 | } |
| 4589 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4590 | DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 4591 | |
| 4592 | protected: |
| 4593 | virtual bool DataEquals(HValue* other) { return true; } |
| 4594 | }; |
| 4595 | |
| 4596 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4597 | class HStringCharCodeAt: public HTemplateInstruction<3> { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4598 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4599 | HStringCharCodeAt(HValue* context, HValue* string, HValue* index) { |
| 4600 | SetOperandAt(0, context); |
| 4601 | SetOperandAt(1, string); |
| 4602 | SetOperandAt(2, index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4603 | set_representation(Representation::Integer32()); |
| 4604 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4605 | SetGVNFlag(kDependsOnMaps); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4606 | SetGVNFlag(kChangesNewSpacePromotion); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4607 | } |
| 4608 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4609 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4610 | // The index is supposed to be Integer32. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4611 | return index == 2 |
| 4612 | ? Representation::Integer32() |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4613 | : Representation::Tagged(); |
| 4614 | } |
| 4615 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4616 | HValue* context() { return OperandAt(0); } |
| 4617 | HValue* string() { return OperandAt(1); } |
| 4618 | HValue* index() { return OperandAt(2); } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4619 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4620 | DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4621 | |
| 4622 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4623 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4624 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4625 | virtual Range* InferRange(Zone* zone) { |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 4626 | return new(zone) Range(0, String::kMaxUtf16CodeUnit); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4627 | } |
| 4628 | }; |
| 4629 | |
| 4630 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4631 | class HStringCharFromCode: public HTemplateInstruction<2> { |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4632 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4633 | HStringCharFromCode(HValue* context, HValue* char_code) { |
| 4634 | SetOperandAt(0, context); |
| 4635 | SetOperandAt(1, char_code); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4636 | set_representation(Representation::Tagged()); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4637 | SetFlag(kUseGVN); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4638 | SetGVNFlag(kChangesNewSpacePromotion); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4639 | } |
| 4640 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4641 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4642 | return index == 0 |
| 4643 | ? Representation::Tagged() |
| 4644 | : Representation::Integer32(); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4645 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4646 | virtual HType CalculateInferredType(); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4647 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4648 | HValue* context() { return OperandAt(0); } |
| 4649 | HValue* value() { return OperandAt(1); } |
| 4650 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4651 | virtual bool DataEquals(HValue* other) { return true; } |
| 4652 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4653 | DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4654 | }; |
| 4655 | |
| 4656 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4657 | class HStringLength: public HUnaryOperation { |
| 4658 | public: |
| 4659 | explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
| 4660 | set_representation(Representation::Tagged()); |
| 4661 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4662 | SetGVNFlag(kDependsOnMaps); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4663 | } |
| 4664 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4665 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4666 | return Representation::Tagged(); |
| 4667 | } |
| 4668 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4669 | virtual HType CalculateInferredType() { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4670 | STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
| 4671 | return HType::Smi(); |
| 4672 | } |
| 4673 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4674 | DECLARE_CONCRETE_INSTRUCTION(StringLength) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4675 | |
| 4676 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4677 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4678 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4679 | virtual Range* InferRange(Zone* zone) { |
| 4680 | return new(zone) Range(0, String::kMaxLength); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 4681 | } |
| 4682 | }; |
| 4683 | |
| 4684 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 4685 | class HAllocateObject: public HTemplateInstruction<1> { |
| 4686 | public: |
| 4687 | HAllocateObject(HValue* context, Handle<JSFunction> constructor) |
| 4688 | : constructor_(constructor) { |
| 4689 | SetOperandAt(0, context); |
| 4690 | set_representation(Representation::Tagged()); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 4691 | SetGVNFlag(kChangesNewSpacePromotion); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 4692 | } |
| 4693 | |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 4694 | // Maximum instance size for which allocations will be inlined. |
| 4695 | static const int kMaxSize = 64 * kPointerSize; |
| 4696 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 4697 | HValue* context() { return OperandAt(0); } |
| 4698 | Handle<JSFunction> constructor() { return constructor_; } |
| 4699 | |
| 4700 | virtual Representation RequiredInputRepresentation(int index) { |
| 4701 | return Representation::Tagged(); |
| 4702 | } |
| 4703 | virtual HType CalculateInferredType(); |
| 4704 | |
| 4705 | DECLARE_CONCRETE_INSTRUCTION(AllocateObject) |
| 4706 | |
| 4707 | private: |
| 4708 | Handle<JSFunction> constructor_; |
| 4709 | }; |
| 4710 | |
| 4711 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4712 | template <int V> |
| 4713 | class HMaterializedLiteral: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4714 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4715 | HMaterializedLiteral<V>(int index, int depth) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4716 | : literal_index_(index), depth_(depth) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4717 | this->set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4718 | } |
| 4719 | |
| 4720 | int literal_index() const { return literal_index_; } |
| 4721 | int depth() const { return depth_; } |
| 4722 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4723 | private: |
| 4724 | int literal_index_; |
| 4725 | int depth_; |
| 4726 | }; |
| 4727 | |
| 4728 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4729 | class HFastLiteral: public HMaterializedLiteral<1> { |
| 4730 | public: |
| 4731 | HFastLiteral(HValue* context, |
| 4732 | Handle<JSObject> boilerplate, |
| 4733 | int total_size, |
| 4734 | int literal_index, |
| 4735 | int depth) |
| 4736 | : HMaterializedLiteral<1>(literal_index, depth), |
| 4737 | boilerplate_(boilerplate), |
| 4738 | total_size_(total_size) { |
| 4739 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4740 | SetGVNFlag(kChangesNewSpacePromotion); |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4741 | } |
| 4742 | |
| 4743 | // Maximum depth and total number of elements and properties for literal |
| 4744 | // graphs to be considered for fast deep-copying. |
| 4745 | static const int kMaxLiteralDepth = 3; |
| 4746 | static const int kMaxLiteralProperties = 8; |
| 4747 | |
| 4748 | HValue* context() { return OperandAt(0); } |
| 4749 | Handle<JSObject> boilerplate() const { return boilerplate_; } |
| 4750 | int total_size() const { return total_size_; } |
| 4751 | |
| 4752 | virtual Representation RequiredInputRepresentation(int index) { |
| 4753 | return Representation::Tagged(); |
| 4754 | } |
| 4755 | virtual HType CalculateInferredType(); |
| 4756 | |
| 4757 | DECLARE_CONCRETE_INSTRUCTION(FastLiteral) |
| 4758 | |
| 4759 | private: |
| 4760 | Handle<JSObject> boilerplate_; |
| 4761 | int total_size_; |
| 4762 | }; |
| 4763 | |
| 4764 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4765 | class HArrayLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4766 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4767 | HArrayLiteral(HValue* context, |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 4768 | Handle<HeapObject> boilerplate_object, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4769 | int length, |
| 4770 | int literal_index, |
| 4771 | int depth) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4772 | : HMaterializedLiteral<1>(literal_index, depth), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4773 | length_(length), |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 4774 | boilerplate_object_(boilerplate_object) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4775 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4776 | SetGVNFlag(kChangesNewSpacePromotion); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4777 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4778 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4779 | HValue* context() { return OperandAt(0); } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 4780 | ElementsKind boilerplate_elements_kind() const { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 4781 | if (!boilerplate_object_->IsJSObject()) { |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 4782 | return TERMINAL_FAST_ELEMENTS_KIND; |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 4783 | } |
| 4784 | return Handle<JSObject>::cast(boilerplate_object_)->GetElementsKind(); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 4785 | } |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 4786 | Handle<HeapObject> boilerplate_object() const { return boilerplate_object_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4787 | int length() const { return length_; } |
| 4788 | |
| 4789 | bool IsCopyOnWrite() const; |
| 4790 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4791 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4792 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4793 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4794 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4795 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4796 | DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4797 | |
| 4798 | private: |
| 4799 | int length_; |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 4800 | Handle<HeapObject> boilerplate_object_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4801 | }; |
| 4802 | |
| 4803 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4804 | class HObjectLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4805 | public: |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4806 | HObjectLiteral(HValue* context, |
| 4807 | Handle<FixedArray> constant_properties, |
| 4808 | bool fast_elements, |
| 4809 | int literal_index, |
| 4810 | int depth, |
| 4811 | bool has_function) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4812 | : HMaterializedLiteral<1>(literal_index, depth), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4813 | constant_properties_(constant_properties), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4814 | fast_elements_(fast_elements), |
| 4815 | has_function_(has_function) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4816 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4817 | SetGVNFlag(kChangesNewSpacePromotion); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4818 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4819 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4820 | HValue* context() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4821 | Handle<FixedArray> constant_properties() const { |
| 4822 | return constant_properties_; |
| 4823 | } |
| 4824 | bool fast_elements() const { return fast_elements_; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4825 | bool has_function() const { return has_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4826 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4827 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4828 | return Representation::Tagged(); |
| 4829 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4830 | virtual HType CalculateInferredType(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4831 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4832 | DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4833 | |
| 4834 | private: |
| 4835 | Handle<FixedArray> constant_properties_; |
| 4836 | bool fast_elements_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4837 | bool has_function_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4838 | }; |
| 4839 | |
| 4840 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4841 | class HRegExpLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4842 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4843 | HRegExpLiteral(HValue* context, |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 4844 | Handle<FixedArray> literals, |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4845 | Handle<String> pattern, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4846 | Handle<String> flags, |
| 4847 | int literal_index) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4848 | : HMaterializedLiteral<1>(literal_index, 0), |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 4849 | literals_(literals), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4850 | pattern_(pattern), |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4851 | flags_(flags) { |
| 4852 | SetOperandAt(0, context); |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 4853 | SetAllSideEffects(); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4854 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4855 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4856 | HValue* context() { return OperandAt(0); } |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 4857 | Handle<FixedArray> literals() { return literals_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4858 | Handle<String> pattern() { return pattern_; } |
| 4859 | Handle<String> flags() { return flags_; } |
| 4860 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4861 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4862 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4863 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4864 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4865 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4866 | DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4867 | |
| 4868 | private: |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 4869 | Handle<FixedArray> literals_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4870 | Handle<String> pattern_; |
| 4871 | Handle<String> flags_; |
| 4872 | }; |
| 4873 | |
| 4874 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4875 | class HFunctionLiteral: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4876 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4877 | HFunctionLiteral(HValue* context, |
| 4878 | Handle<SharedFunctionInfo> shared, |
| 4879 | bool pretenure) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4880 | : shared_info_(shared), pretenure_(pretenure) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4881 | SetOperandAt(0, context); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4882 | set_representation(Representation::Tagged()); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 4883 | SetGVNFlag(kChangesNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4884 | } |
| 4885 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4886 | HValue* context() { return OperandAt(0); } |
| 4887 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4888 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4889 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4890 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4891 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4892 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4893 | DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4894 | |
| 4895 | Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 4896 | bool pretenure() const { return pretenure_; } |
| 4897 | |
| 4898 | private: |
| 4899 | Handle<SharedFunctionInfo> shared_info_; |
| 4900 | bool pretenure_; |
| 4901 | }; |
| 4902 | |
| 4903 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4904 | class HTypeof: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4905 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4906 | explicit HTypeof(HValue* context, HValue* value) { |
| 4907 | SetOperandAt(0, context); |
| 4908 | SetOperandAt(1, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4909 | set_representation(Representation::Tagged()); |
| 4910 | } |
| 4911 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4912 | HValue* context() { return OperandAt(0); } |
| 4913 | HValue* value() { return OperandAt(1); } |
| 4914 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4915 | virtual HValue* Canonicalize(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4916 | virtual void PrintDataTo(StringStream* stream); |
| 4917 | |
| 4918 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 4919 | return Representation::Tagged(); |
| 4920 | } |
| 4921 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4922 | DECLARE_CONCRETE_INSTRUCTION(Typeof) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4923 | }; |
| 4924 | |
| 4925 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4926 | class HToFastProperties: public HUnaryOperation { |
| 4927 | public: |
| 4928 | explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { |
| 4929 | // This instruction is not marked as having side effects, but |
| 4930 | // changes the map of the input operand. Use it only when creating |
| 4931 | // object literals. |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 4932 | ASSERT(value->IsObjectLiteral() || value->IsFastLiteral()); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4933 | set_representation(Representation::Tagged()); |
| 4934 | } |
| 4935 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4936 | virtual Representation RequiredInputRepresentation(int index) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4937 | return Representation::Tagged(); |
| 4938 | } |
| 4939 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4940 | DECLARE_CONCRETE_INSTRUCTION(ToFastProperties) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4941 | }; |
| 4942 | |
| 4943 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4944 | class HValueOf: public HUnaryOperation { |
| 4945 | public: |
| 4946 | explicit HValueOf(HValue* value) : HUnaryOperation(value) { |
| 4947 | set_representation(Representation::Tagged()); |
| 4948 | } |
| 4949 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4950 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4951 | return Representation::Tagged(); |
| 4952 | } |
| 4953 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4954 | DECLARE_CONCRETE_INSTRUCTION(ValueOf) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4955 | }; |
| 4956 | |
| 4957 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 4958 | class HDateField: public HUnaryOperation { |
| 4959 | public: |
| 4960 | HDateField(HValue* date, Smi* index) |
| 4961 | : HUnaryOperation(date), index_(index) { |
| 4962 | set_representation(Representation::Tagged()); |
| 4963 | } |
| 4964 | |
| 4965 | Smi* index() const { return index_; } |
| 4966 | |
| 4967 | virtual Representation RequiredInputRepresentation(int index) { |
| 4968 | return Representation::Tagged(); |
| 4969 | } |
| 4970 | |
| 4971 | DECLARE_CONCRETE_INSTRUCTION(DateField) |
| 4972 | |
| 4973 | private: |
| 4974 | Smi* index_; |
| 4975 | }; |
| 4976 | |
| 4977 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4978 | class HDeleteProperty: public HBinaryOperation { |
| 4979 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4980 | HDeleteProperty(HValue* context, HValue* obj, HValue* key) |
| 4981 | : HBinaryOperation(context, obj, key) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4982 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4983 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4984 | } |
| 4985 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4986 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4987 | return Representation::Tagged(); |
| 4988 | } |
| 4989 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4990 | virtual HType CalculateInferredType(); |
| 4991 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4992 | DECLARE_CONCRETE_INSTRUCTION(DeleteProperty) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4993 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4994 | HValue* object() { return left(); } |
| 4995 | HValue* key() { return right(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4996 | }; |
| 4997 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 4998 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4999 | class HIn: public HTemplateInstruction<3> { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 5000 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5001 | HIn(HValue* context, HValue* key, HValue* object) { |
| 5002 | SetOperandAt(0, context); |
| 5003 | SetOperandAt(1, key); |
| 5004 | SetOperandAt(2, object); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 5005 | set_representation(Representation::Tagged()); |
| 5006 | SetAllSideEffects(); |
| 5007 | } |
| 5008 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5009 | HValue* context() { return OperandAt(0); } |
| 5010 | HValue* key() { return OperandAt(1); } |
| 5011 | HValue* object() { return OperandAt(2); } |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 5012 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5013 | virtual Representation RequiredInputRepresentation(int index) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 5014 | return Representation::Tagged(); |
| 5015 | } |
| 5016 | |
| 5017 | virtual HType CalculateInferredType() { |
| 5018 | return HType::Boolean(); |
| 5019 | } |
| 5020 | |
| 5021 | virtual void PrintDataTo(StringStream* stream); |
| 5022 | |
| 5023 | DECLARE_CONCRETE_INSTRUCTION(In) |
| 5024 | }; |
| 5025 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 5026 | |
| 5027 | class HCheckMapValue: public HTemplateInstruction<2> { |
| 5028 | public: |
| 5029 | HCheckMapValue(HValue* value, |
| 5030 | HValue* map) { |
| 5031 | SetOperandAt(0, value); |
| 5032 | SetOperandAt(1, map); |
| 5033 | set_representation(Representation::Tagged()); |
| 5034 | SetFlag(kUseGVN); |
| 5035 | SetGVNFlag(kDependsOnMaps); |
| 5036 | SetGVNFlag(kDependsOnElementsKind); |
| 5037 | } |
| 5038 | |
| 5039 | virtual Representation RequiredInputRepresentation(int index) { |
| 5040 | return Representation::Tagged(); |
| 5041 | } |
| 5042 | |
| 5043 | virtual void PrintDataTo(StringStream* stream); |
| 5044 | |
| 5045 | virtual HType CalculateInferredType() { |
| 5046 | return HType::Tagged(); |
| 5047 | } |
| 5048 | |
| 5049 | HValue* value() { return OperandAt(0); } |
| 5050 | HValue* map() { return OperandAt(1); } |
| 5051 | |
| 5052 | DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) |
| 5053 | |
| 5054 | protected: |
| 5055 | virtual bool DataEquals(HValue* other) { |
| 5056 | return true; |
| 5057 | } |
| 5058 | }; |
| 5059 | |
| 5060 | |
| 5061 | class HForInPrepareMap : public HTemplateInstruction<2> { |
| 5062 | public: |
| 5063 | HForInPrepareMap(HValue* context, |
| 5064 | HValue* object) { |
| 5065 | SetOperandAt(0, context); |
| 5066 | SetOperandAt(1, object); |
| 5067 | set_representation(Representation::Tagged()); |
| 5068 | SetAllSideEffects(); |
| 5069 | } |
| 5070 | |
| 5071 | virtual Representation RequiredInputRepresentation(int index) { |
| 5072 | return Representation::Tagged(); |
| 5073 | } |
| 5074 | |
| 5075 | HValue* context() { return OperandAt(0); } |
| 5076 | HValue* enumerable() { return OperandAt(1); } |
| 5077 | |
| 5078 | virtual void PrintDataTo(StringStream* stream); |
| 5079 | |
| 5080 | virtual HType CalculateInferredType() { |
| 5081 | return HType::Tagged(); |
| 5082 | } |
| 5083 | |
| 5084 | DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap); |
| 5085 | }; |
| 5086 | |
| 5087 | |
| 5088 | class HForInCacheArray : public HTemplateInstruction<2> { |
| 5089 | public: |
| 5090 | HForInCacheArray(HValue* enumerable, |
| 5091 | HValue* keys, |
| 5092 | int idx) : idx_(idx) { |
| 5093 | SetOperandAt(0, enumerable); |
| 5094 | SetOperandAt(1, keys); |
| 5095 | set_representation(Representation::Tagged()); |
| 5096 | } |
| 5097 | |
| 5098 | virtual Representation RequiredInputRepresentation(int index) { |
| 5099 | return Representation::Tagged(); |
| 5100 | } |
| 5101 | |
| 5102 | HValue* enumerable() { return OperandAt(0); } |
| 5103 | HValue* map() { return OperandAt(1); } |
| 5104 | int idx() { return idx_; } |
| 5105 | |
| 5106 | HForInCacheArray* index_cache() { |
| 5107 | return index_cache_; |
| 5108 | } |
| 5109 | |
| 5110 | void set_index_cache(HForInCacheArray* index_cache) { |
| 5111 | index_cache_ = index_cache; |
| 5112 | } |
| 5113 | |
| 5114 | virtual void PrintDataTo(StringStream* stream); |
| 5115 | |
| 5116 | virtual HType CalculateInferredType() { |
| 5117 | return HType::Tagged(); |
| 5118 | } |
| 5119 | |
| 5120 | DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray); |
| 5121 | |
| 5122 | private: |
| 5123 | int idx_; |
| 5124 | HForInCacheArray* index_cache_; |
| 5125 | }; |
| 5126 | |
| 5127 | |
| 5128 | class HLoadFieldByIndex : public HTemplateInstruction<2> { |
| 5129 | public: |
| 5130 | HLoadFieldByIndex(HValue* object, |
| 5131 | HValue* index) { |
| 5132 | SetOperandAt(0, object); |
| 5133 | SetOperandAt(1, index); |
| 5134 | set_representation(Representation::Tagged()); |
| 5135 | } |
| 5136 | |
| 5137 | virtual Representation RequiredInputRepresentation(int index) { |
| 5138 | return Representation::Tagged(); |
| 5139 | } |
| 5140 | |
| 5141 | HValue* object() { return OperandAt(0); } |
| 5142 | HValue* index() { return OperandAt(1); } |
| 5143 | |
| 5144 | virtual void PrintDataTo(StringStream* stream); |
| 5145 | |
| 5146 | virtual HType CalculateInferredType() { |
| 5147 | return HType::Tagged(); |
| 5148 | } |
| 5149 | |
| 5150 | DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); |
| 5151 | }; |
| 5152 | |
| 5153 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5154 | #undef DECLARE_INSTRUCTION |
| 5155 | #undef DECLARE_CONCRETE_INSTRUCTION |
| 5156 | |
| 5157 | } } // namespace v8::internal |
| 5158 | |
| 5159 | #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |