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; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 48 | class HInferRepresentation; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 49 | class HInstruction; |
| 50 | class HLoopInformation; |
| 51 | class HValue; |
| 52 | class LInstruction; |
| 53 | class LChunkBuilder; |
| 54 | |
| 55 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 56 | #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 57 | V(BinaryOperation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 58 | V(BitwiseBinaryOperation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 59 | V(ControlInstruction) \ |
| 60 | V(Instruction) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 61 | |
| 62 | |
| 63 | #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 64 | V(AbnormalExit) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 65 | V(AccessArgumentsAt) \ |
| 66 | V(Add) \ |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 67 | V(Allocate) \ |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 68 | V(AllocateObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 69 | V(ApplyArguments) \ |
| 70 | V(ArgumentsElements) \ |
| 71 | V(ArgumentsLength) \ |
| 72 | V(ArgumentsObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 73 | V(ArrayLiteral) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 74 | V(Bitwise) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 75 | V(BitNot) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 76 | V(BlockEntry) \ |
| 77 | V(BoundsCheck) \ |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 78 | V(BoundsCheckBaseIndexInformation) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 79 | V(Branch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 80 | V(CallConstantFunction) \ |
| 81 | V(CallFunction) \ |
| 82 | V(CallGlobal) \ |
| 83 | V(CallKeyed) \ |
| 84 | V(CallKnownGlobal) \ |
| 85 | V(CallNamed) \ |
| 86 | V(CallNew) \ |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 87 | V(CallNewArray) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 88 | V(CallRuntime) \ |
| 89 | V(CallStub) \ |
| 90 | V(Change) \ |
| 91 | V(CheckFunction) \ |
| 92 | V(CheckInstanceType) \ |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 93 | V(CheckMaps) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 94 | V(CheckNonSmi) \ |
| 95 | V(CheckPrototypeMaps) \ |
| 96 | V(CheckSmi) \ |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 97 | V(CheckSmiOrInt32) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 98 | V(ClampToUint8) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 99 | V(ClassOfTestAndBranch) \ |
| 100 | V(CompareIDAndBranch) \ |
| 101 | V(CompareGeneric) \ |
| 102 | V(CompareObjectEqAndBranch) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 103 | V(CompareMap) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 104 | V(CompareConstantEqAndBranch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 105 | V(Constant) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 106 | V(Context) \ |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 107 | V(DeclareGlobals) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 108 | V(DeleteProperty) \ |
| 109 | V(Deoptimize) \ |
| 110 | V(Div) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 111 | V(DummyUse) \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 112 | V(ElementsKind) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 113 | V(EnterInlined) \ |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 114 | V(FixedArrayBaseLength) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 115 | V(ForceRepresentation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 116 | V(FunctionLiteral) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 117 | V(GetCachedArrayIndex) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 118 | V(GlobalObject) \ |
| 119 | V(GlobalReceiver) \ |
| 120 | V(Goto) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 121 | V(HasCachedArrayIndexAndBranch) \ |
| 122 | V(HasInstanceTypeAndBranch) \ |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 123 | V(InductionVariableAnnotation) \ |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 124 | V(In) \ |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 125 | V(InnerAllocatedObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 126 | V(InstanceOf) \ |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 127 | V(InstanceOfKnownGlobal) \ |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 128 | V(InstanceSize) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 129 | V(InvokeFunction) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 130 | V(IsConstructCallAndBranch) \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 131 | V(IsNilAndBranch) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 132 | V(IsObjectAndBranch) \ |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 133 | V(IsStringAndBranch) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 134 | V(IsSmiAndBranch) \ |
| 135 | V(IsUndetectableAndBranch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 136 | V(LeaveInlined) \ |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 137 | V(LoadContextSlot) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 138 | V(LoadExternalArrayPointer) \ |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 139 | V(LoadFunctionPrototype) \ |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 140 | V(LoadGlobalCell) \ |
| 141 | V(LoadGlobalGeneric) \ |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 142 | V(LoadKeyed) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 143 | V(LoadKeyedGeneric) \ |
| 144 | V(LoadNamedField) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 145 | V(LoadNamedFieldPolymorphic) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 146 | V(LoadNamedGeneric) \ |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 147 | V(MapEnumLength) \ |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 148 | V(MathFloorOfDiv) \ |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 149 | V(MathMinMax) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 150 | V(Mod) \ |
| 151 | V(Mul) \ |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 152 | V(NumericConstraint) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 153 | V(ObjectLiteral) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 154 | V(OsrEntry) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 155 | V(OuterContext) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 156 | V(Parameter) \ |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 157 | V(Power) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 158 | V(PushArgument) \ |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 159 | V(Random) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 160 | V(RegExpLiteral) \ |
| 161 | V(Return) \ |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 162 | V(Ror) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 163 | V(Sar) \ |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 164 | V(SeqStringSetChar) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 165 | V(Shl) \ |
| 166 | V(Shr) \ |
| 167 | V(Simulate) \ |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 168 | V(SoftDeoptimize) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 169 | V(StackCheck) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 170 | V(StoreContextSlot) \ |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 171 | V(StoreGlobalCell) \ |
| 172 | V(StoreGlobalGeneric) \ |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 173 | V(StoreKeyed) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 174 | V(StoreKeyedGeneric) \ |
| 175 | V(StoreNamedField) \ |
| 176 | V(StoreNamedGeneric) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 177 | V(StringAdd) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 178 | V(StringCharCodeAt) \ |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 179 | V(StringCharFromCode) \ |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 180 | V(StringCompareAndBranch) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 181 | V(StringLength) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 182 | V(Sub) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 183 | V(ThisFunction) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 184 | V(Throw) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 185 | V(ToFastProperties) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 186 | V(TransitionElementsKind) \ |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 187 | V(TrapAllocationMemento) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 188 | V(Typeof) \ |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 189 | V(TypeofIsAndBranch) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 190 | V(UnaryMathOperation) \ |
| 191 | V(UnknownOSRValue) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 192 | V(UseConst) \ |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 193 | V(ValueOf) \ |
| 194 | V(ForInPrepareMap) \ |
| 195 | V(ForInCacheArray) \ |
| 196 | V(CheckMapValue) \ |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 197 | V(LoadFieldByIndex) \ |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 198 | V(DateField) \ |
| 199 | V(WrapReceiver) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 200 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 201 | #define GVN_TRACKED_FLAG_LIST(V) \ |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 202 | V(Maps) \ |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 203 | V(NewSpacePromotion) |
| 204 | |
| 205 | #define GVN_UNTRACKED_FLAG_LIST(V) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 206 | V(Calls) \ |
| 207 | V(InobjectFields) \ |
| 208 | V(BackingStoreFields) \ |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 209 | V(DoubleFields) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 210 | V(ElementsKind) \ |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 211 | V(ElementsPointer) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 212 | V(ArrayElements) \ |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 213 | V(DoubleArrayElements) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 214 | V(SpecializedArrayElements) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 215 | V(GlobalVars) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 216 | V(ArrayLengths) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 217 | V(ContextSlots) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 218 | V(OsrEntries) |
| 219 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 220 | #define DECLARE_ABSTRACT_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | virtual bool Is##type() const { return true; } \ |
| 222 | static H##type* cast(HValue* value) { \ |
| 223 | ASSERT(value->Is##type()); \ |
| 224 | return reinterpret_cast<H##type*>(value); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 225 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 226 | |
| 227 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 228 | #define DECLARE_CONCRETE_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 229 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 230 | static H##type* cast(HValue* value) { \ |
| 231 | ASSERT(value->Is##type()); \ |
| 232 | return reinterpret_cast<H##type*>(value); \ |
| 233 | } \ |
| 234 | virtual Opcode opcode() const { return HValue::k##type; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 235 | |
| 236 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 237 | class Range: public ZoneObject { |
| 238 | public: |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 239 | Range() |
| 240 | : lower_(kMinInt), |
| 241 | upper_(kMaxInt), |
| 242 | next_(NULL), |
| 243 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 244 | |
| 245 | Range(int32_t lower, int32_t upper) |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 246 | : lower_(lower), |
| 247 | upper_(upper), |
| 248 | next_(NULL), |
| 249 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 250 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 251 | int32_t upper() const { return upper_; } |
| 252 | int32_t lower() const { return lower_; } |
| 253 | Range* next() const { return next_; } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 254 | Range* CopyClearLower(Zone* zone) const { |
| 255 | return new(zone) Range(kMinInt, upper_); |
| 256 | } |
| 257 | Range* CopyClearUpper(Zone* zone) const { |
| 258 | return new(zone) Range(lower_, kMaxInt); |
| 259 | } |
| 260 | Range* Copy(Zone* zone) const { |
| 261 | Range* result = new(zone) Range(lower_, upper_); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 262 | result->set_can_be_minus_zero(CanBeMinusZero()); |
| 263 | return result; |
| 264 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 265 | int32_t Mask() const; |
| 266 | void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } |
| 267 | bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } |
| 268 | bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } |
| 269 | bool CanBeNegative() const { return lower_ < 0; } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 270 | bool Includes(int value) const { return lower_ <= value && upper_ >= value; } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 271 | bool IsMostGeneric() const { |
| 272 | return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero(); |
| 273 | } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 274 | bool IsInSmiRange() const { |
| 275 | return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 276 | } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 277 | void KeepOrder(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 278 | #ifdef DEBUG |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 279 | void Verify() const; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 280 | #endif |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 281 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 282 | void StackUpon(Range* other) { |
| 283 | Intersect(other); |
| 284 | next_ = other; |
| 285 | } |
| 286 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 287 | void Intersect(Range* other); |
| 288 | void Union(Range* other); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 289 | void CombinedMax(Range* other); |
| 290 | void CombinedMin(Range* other); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 291 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 292 | void AddConstant(int32_t value); |
| 293 | void Sar(int32_t value); |
| 294 | void Shl(int32_t value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 295 | bool AddAndCheckOverflow(Range* other); |
| 296 | bool SubAndCheckOverflow(Range* other); |
| 297 | bool MulAndCheckOverflow(Range* other); |
| 298 | |
| 299 | private: |
| 300 | int32_t lower_; |
| 301 | int32_t upper_; |
| 302 | Range* next_; |
| 303 | bool can_be_minus_zero_; |
| 304 | }; |
| 305 | |
| 306 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 307 | class UniqueValueId { |
| 308 | public: |
| 309 | UniqueValueId() : raw_address_(NULL) { } |
| 310 | |
| 311 | explicit UniqueValueId(Object* object) { |
| 312 | raw_address_ = reinterpret_cast<Address>(object); |
| 313 | ASSERT(IsInitialized()); |
| 314 | } |
| 315 | |
| 316 | explicit UniqueValueId(Handle<Object> handle) { |
| 317 | static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1); |
| 318 | if (handle.is_null()) { |
| 319 | raw_address_ = kEmptyHandleSentinel; |
| 320 | } else { |
| 321 | raw_address_ = reinterpret_cast<Address>(*handle); |
| 322 | ASSERT_NE(kEmptyHandleSentinel, raw_address_); |
| 323 | } |
| 324 | ASSERT(IsInitialized()); |
| 325 | } |
| 326 | |
| 327 | bool IsInitialized() const { return raw_address_ != NULL; } |
| 328 | |
| 329 | bool operator==(const UniqueValueId& other) const { |
| 330 | ASSERT(IsInitialized() && other.IsInitialized()); |
| 331 | return raw_address_ == other.raw_address_; |
| 332 | } |
| 333 | |
| 334 | bool operator!=(const UniqueValueId& other) const { |
| 335 | ASSERT(IsInitialized() && other.IsInitialized()); |
| 336 | return raw_address_ != other.raw_address_; |
| 337 | } |
| 338 | |
| 339 | intptr_t Hashcode() const { |
| 340 | ASSERT(IsInitialized()); |
| 341 | return reinterpret_cast<intptr_t>(raw_address_); |
| 342 | } |
| 343 | |
| 344 | private: |
| 345 | Address raw_address_; |
| 346 | }; |
| 347 | |
| 348 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 349 | class HType { |
| 350 | public: |
| 351 | HType() : type_(kUninitialized) { } |
| 352 | |
| 353 | static HType Tagged() { return HType(kTagged); } |
| 354 | static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } |
| 355 | static HType TaggedNumber() { return HType(kTaggedNumber); } |
| 356 | static HType Smi() { return HType(kSmi); } |
| 357 | static HType HeapNumber() { return HType(kHeapNumber); } |
| 358 | static HType String() { return HType(kString); } |
| 359 | static HType Boolean() { return HType(kBoolean); } |
| 360 | static HType NonPrimitive() { return HType(kNonPrimitive); } |
| 361 | static HType JSArray() { return HType(kJSArray); } |
| 362 | static HType JSObject() { return HType(kJSObject); } |
| 363 | static HType Uninitialized() { return HType(kUninitialized); } |
| 364 | |
| 365 | // Return the weakest (least precise) common type. |
| 366 | HType Combine(HType other) { |
| 367 | return HType(static_cast<Type>(type_ & other.type_)); |
| 368 | } |
| 369 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 370 | bool Equals(const HType& other) const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 371 | return type_ == other.type_; |
| 372 | } |
| 373 | |
| 374 | bool IsSubtypeOf(const HType& other) { |
| 375 | return Combine(other).Equals(other); |
| 376 | } |
| 377 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 378 | bool IsTagged() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 379 | ASSERT(type_ != kUninitialized); |
| 380 | return ((type_ & kTagged) == kTagged); |
| 381 | } |
| 382 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 383 | bool IsTaggedPrimitive() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 384 | ASSERT(type_ != kUninitialized); |
| 385 | return ((type_ & kTaggedPrimitive) == kTaggedPrimitive); |
| 386 | } |
| 387 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 388 | bool IsTaggedNumber() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 389 | ASSERT(type_ != kUninitialized); |
| 390 | return ((type_ & kTaggedNumber) == kTaggedNumber); |
| 391 | } |
| 392 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 393 | bool IsSmi() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 394 | ASSERT(type_ != kUninitialized); |
| 395 | return ((type_ & kSmi) == kSmi); |
| 396 | } |
| 397 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 398 | bool IsHeapNumber() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 399 | ASSERT(type_ != kUninitialized); |
| 400 | return ((type_ & kHeapNumber) == kHeapNumber); |
| 401 | } |
| 402 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 403 | bool IsString() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 404 | ASSERT(type_ != kUninitialized); |
| 405 | return ((type_ & kString) == kString); |
| 406 | } |
| 407 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 408 | bool IsBoolean() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 409 | ASSERT(type_ != kUninitialized); |
| 410 | return ((type_ & kBoolean) == kBoolean); |
| 411 | } |
| 412 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 413 | bool IsNonPrimitive() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 414 | ASSERT(type_ != kUninitialized); |
| 415 | return ((type_ & kNonPrimitive) == kNonPrimitive); |
| 416 | } |
| 417 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 418 | bool IsJSArray() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 419 | ASSERT(type_ != kUninitialized); |
| 420 | return ((type_ & kJSArray) == kJSArray); |
| 421 | } |
| 422 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 423 | bool IsJSObject() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 424 | ASSERT(type_ != kUninitialized); |
| 425 | return ((type_ & kJSObject) == kJSObject); |
| 426 | } |
| 427 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 428 | bool IsUninitialized() const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 429 | return type_ == kUninitialized; |
| 430 | } |
| 431 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 432 | bool IsHeapObject() const { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 433 | ASSERT(type_ != kUninitialized); |
| 434 | return IsHeapNumber() || IsString() || IsNonPrimitive(); |
| 435 | } |
| 436 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 437 | static HType TypeFromValue(Handle<Object> value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 438 | |
| 439 | const char* ToString(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 440 | |
| 441 | private: |
| 442 | enum Type { |
| 443 | kTagged = 0x1, // 0000 0000 0000 0001 |
| 444 | kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
| 445 | kTaggedNumber = 0xd, // 0000 0000 0000 1101 |
| 446 | kSmi = 0x1d, // 0000 0000 0001 1101 |
| 447 | kHeapNumber = 0x2d, // 0000 0000 0010 1101 |
| 448 | kString = 0x45, // 0000 0000 0100 0101 |
| 449 | kBoolean = 0x85, // 0000 0000 1000 0101 |
| 450 | kNonPrimitive = 0x101, // 0000 0001 0000 0001 |
| 451 | kJSObject = 0x301, // 0000 0011 0000 0001 |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 452 | kJSArray = 0x701, // 0000 0111 0000 0001 |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 453 | kUninitialized = 0x1fff // 0001 1111 1111 1111 |
| 454 | }; |
| 455 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 456 | // Make sure type fits in int16. |
| 457 | STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte))); |
| 458 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 459 | explicit HType(Type t) : type_(t) { } |
| 460 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 461 | int16_t type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 462 | }; |
| 463 | |
| 464 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 465 | class HUseListNode: public ZoneObject { |
| 466 | public: |
| 467 | HUseListNode(HValue* value, int index, HUseListNode* tail) |
| 468 | : tail_(tail), value_(value), index_(index) { |
| 469 | } |
| 470 | |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 471 | HUseListNode* tail(); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 472 | HValue* value() const { return value_; } |
| 473 | int index() const { return index_; } |
| 474 | |
| 475 | void set_tail(HUseListNode* list) { tail_ = list; } |
| 476 | |
| 477 | #ifdef DEBUG |
| 478 | void Zap() { |
| 479 | tail_ = reinterpret_cast<HUseListNode*>(1); |
| 480 | value_ = NULL; |
| 481 | index_ = -1; |
| 482 | } |
| 483 | #endif |
| 484 | |
| 485 | private: |
| 486 | HUseListNode* tail_; |
| 487 | HValue* value_; |
| 488 | int index_; |
| 489 | }; |
| 490 | |
| 491 | |
| 492 | // We reuse use list nodes behind the scenes as uses are added and deleted. |
| 493 | // This class is the safe way to iterate uses while deleting them. |
| 494 | class HUseIterator BASE_EMBEDDED { |
| 495 | public: |
| 496 | bool Done() { return current_ == NULL; } |
| 497 | void Advance(); |
| 498 | |
| 499 | HValue* value() { |
| 500 | ASSERT(!Done()); |
| 501 | return value_; |
| 502 | } |
| 503 | |
| 504 | int index() { |
| 505 | ASSERT(!Done()); |
| 506 | return index_; |
| 507 | } |
| 508 | |
| 509 | private: |
| 510 | explicit HUseIterator(HUseListNode* head); |
| 511 | |
| 512 | HUseListNode* current_; |
| 513 | HUseListNode* next_; |
| 514 | HValue* value_; |
| 515 | int index_; |
| 516 | |
| 517 | friend class HValue; |
| 518 | }; |
| 519 | |
| 520 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 521 | // There must be one corresponding kDepends flag for every kChanges flag and |
| 522 | // 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] | 523 | // flags. All tracked flags should appear before untracked ones. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 524 | enum GVNFlag { |
| 525 | // Declare global value numbering flags. |
| 526 | #define DECLARE_FLAG(type) kChanges##type, kDependsOn##type, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 527 | GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) |
| 528 | GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 529 | #undef DECLARE_FLAG |
| 530 | kAfterLastFlag, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 531 | kLastFlag = kAfterLastFlag - 1, |
| 532 | #define COUNT_FLAG(type) + 1 |
| 533 | kNumberOfTrackedSideEffects = 0 GVN_TRACKED_FLAG_LIST(COUNT_FLAG) |
| 534 | #undef COUNT_FLAG |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 535 | }; |
| 536 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 537 | |
| 538 | class NumericRelation { |
| 539 | public: |
| 540 | enum Kind { NONE, EQ, GT, GE, LT, LE, NE }; |
| 541 | static const char* MnemonicFromKind(Kind kind) { |
| 542 | switch (kind) { |
| 543 | case NONE: return "NONE"; |
| 544 | case EQ: return "EQ"; |
| 545 | case GT: return "GT"; |
| 546 | case GE: return "GE"; |
| 547 | case LT: return "LT"; |
| 548 | case LE: return "LE"; |
| 549 | case NE: return "NE"; |
| 550 | } |
| 551 | UNREACHABLE(); |
| 552 | return NULL; |
| 553 | } |
| 554 | const char* Mnemonic() const { return MnemonicFromKind(kind_); } |
| 555 | |
| 556 | static NumericRelation None() { return NumericRelation(NONE); } |
| 557 | static NumericRelation Eq() { return NumericRelation(EQ); } |
| 558 | static NumericRelation Gt() { return NumericRelation(GT); } |
| 559 | static NumericRelation Ge() { return NumericRelation(GE); } |
| 560 | static NumericRelation Lt() { return NumericRelation(LT); } |
| 561 | static NumericRelation Le() { return NumericRelation(LE); } |
| 562 | static NumericRelation Ne() { return NumericRelation(NE); } |
| 563 | |
| 564 | bool IsNone() { return kind_ == NONE; } |
| 565 | |
| 566 | static NumericRelation FromToken(Token::Value token) { |
| 567 | switch (token) { |
| 568 | case Token::EQ: return Eq(); |
| 569 | case Token::EQ_STRICT: return Eq(); |
| 570 | case Token::LT: return Lt(); |
| 571 | case Token::GT: return Gt(); |
| 572 | case Token::LTE: return Le(); |
| 573 | case Token::GTE: return Ge(); |
| 574 | case Token::NE: return Ne(); |
| 575 | case Token::NE_STRICT: return Ne(); |
| 576 | default: return None(); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | // The semantics of "Reversed" is that if "x rel y" is true then also |
| 581 | // "y rel.Reversed() x" is true, and that rel.Reversed().Reversed() == rel. |
| 582 | NumericRelation Reversed() { |
| 583 | switch (kind_) { |
| 584 | case NONE: return None(); |
| 585 | case EQ: return Eq(); |
| 586 | case GT: return Lt(); |
| 587 | case GE: return Le(); |
| 588 | case LT: return Gt(); |
| 589 | case LE: return Ge(); |
| 590 | case NE: return Ne(); |
| 591 | } |
| 592 | UNREACHABLE(); |
| 593 | return None(); |
| 594 | } |
| 595 | |
| 596 | // The semantics of "Negated" is that if "x rel y" is true then also |
| 597 | // "!(x rel.Negated() y)" is true. |
| 598 | NumericRelation Negated() { |
| 599 | switch (kind_) { |
| 600 | case NONE: return None(); |
| 601 | case EQ: return Ne(); |
| 602 | case GT: return Le(); |
| 603 | case GE: return Lt(); |
| 604 | case LT: return Ge(); |
| 605 | case LE: return Gt(); |
| 606 | case NE: return Eq(); |
| 607 | } |
| 608 | UNREACHABLE(); |
| 609 | return None(); |
| 610 | } |
| 611 | |
| 612 | // The semantics of "Implies" is that if "x rel y" is true |
| 613 | // then also "x other_relation y" is true. |
| 614 | bool Implies(NumericRelation other_relation) { |
| 615 | switch (kind_) { |
| 616 | case NONE: return false; |
| 617 | case EQ: return (other_relation.kind_ == EQ) |
| 618 | || (other_relation.kind_ == GE) |
| 619 | || (other_relation.kind_ == LE); |
| 620 | case GT: return (other_relation.kind_ == GT) |
| 621 | || (other_relation.kind_ == GE) |
| 622 | || (other_relation.kind_ == NE); |
| 623 | case LT: return (other_relation.kind_ == LT) |
| 624 | || (other_relation.kind_ == LE) |
| 625 | || (other_relation.kind_ == NE); |
| 626 | case GE: return (other_relation.kind_ == GE); |
| 627 | case LE: return (other_relation.kind_ == LE); |
| 628 | case NE: return (other_relation.kind_ == NE); |
| 629 | } |
| 630 | UNREACHABLE(); |
| 631 | return false; |
| 632 | } |
| 633 | |
| 634 | // The semantics of "IsExtendable" is that if |
| 635 | // "rel.IsExtendable(direction)" is true then |
| 636 | // "x rel y" implies "(x + direction) rel y" . |
| 637 | bool IsExtendable(int direction) { |
| 638 | switch (kind_) { |
| 639 | case NONE: return false; |
| 640 | case EQ: return false; |
| 641 | case GT: return (direction >= 0); |
| 642 | case GE: return (direction >= 0); |
| 643 | case LT: return (direction <= 0); |
| 644 | case LE: return (direction <= 0); |
| 645 | case NE: return false; |
| 646 | } |
| 647 | UNREACHABLE(); |
| 648 | return false; |
| 649 | } |
| 650 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 651 | // CompoundImplies returns true when |
| 652 | // "((x + my_offset) >> my_scale) rel y" implies |
| 653 | // "((x + other_offset) >> other_scale) other_relation y". |
| 654 | bool CompoundImplies(NumericRelation other_relation, |
| 655 | int my_offset, |
| 656 | int my_scale, |
| 657 | int other_offset = 0, |
| 658 | int other_scale = 0) { |
| 659 | return Implies(other_relation) && ComponentsImply( |
| 660 | my_offset, my_scale, other_offset, other_scale); |
| 661 | } |
| 662 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 663 | private: |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 664 | // ComponentsImply returns true when |
| 665 | // "((x + my_offset) >> my_scale) rel y" implies |
| 666 | // "((x + other_offset) >> other_scale) rel y". |
| 667 | bool ComponentsImply(int my_offset, |
| 668 | int my_scale, |
| 669 | int other_offset, |
| 670 | int other_scale) { |
| 671 | switch (kind_) { |
| 672 | case NONE: break; // Fall through to UNREACHABLE(). |
| 673 | case EQ: |
| 674 | case NE: return my_offset == other_offset && my_scale == other_scale; |
| 675 | case GT: |
| 676 | case GE: return my_offset <= other_offset && my_scale >= other_scale; |
| 677 | case LT: |
| 678 | case LE: return my_offset >= other_offset && my_scale <= other_scale; |
| 679 | } |
| 680 | UNREACHABLE(); |
| 681 | return false; |
| 682 | } |
| 683 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 684 | explicit NumericRelation(Kind kind) : kind_(kind) {} |
| 685 | |
| 686 | Kind kind_; |
| 687 | }; |
| 688 | |
| 689 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 690 | class DecompositionResult BASE_EMBEDDED { |
| 691 | public: |
| 692 | DecompositionResult() : base_(NULL), offset_(0), scale_(0) {} |
| 693 | |
| 694 | HValue* base() { return base_; } |
| 695 | int offset() { return offset_; } |
| 696 | int scale() { return scale_; } |
| 697 | |
| 698 | bool Apply(HValue* other_base, int other_offset, int other_scale = 0) { |
| 699 | if (base_ == NULL) { |
| 700 | base_ = other_base; |
| 701 | offset_ = other_offset; |
| 702 | scale_ = other_scale; |
| 703 | return true; |
| 704 | } else { |
| 705 | if (scale_ == 0) { |
| 706 | base_ = other_base; |
| 707 | offset_ += other_offset; |
| 708 | scale_ = other_scale; |
| 709 | return true; |
| 710 | } else { |
| 711 | return false; |
| 712 | } |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | void SwapValues(HValue** other_base, int* other_offset, int* other_scale) { |
| 717 | swap(&base_, other_base); |
| 718 | swap(&offset_, other_offset); |
| 719 | swap(&scale_, other_scale); |
| 720 | } |
| 721 | |
| 722 | private: |
| 723 | template <class T> void swap(T* a, T* b) { |
| 724 | T c(*a); |
| 725 | *a = *b; |
| 726 | *b = c; |
| 727 | } |
| 728 | |
| 729 | HValue* base_; |
| 730 | int offset_; |
| 731 | int scale_; |
| 732 | }; |
| 733 | |
| 734 | |
| 735 | class RangeEvaluationContext BASE_EMBEDDED { |
| 736 | public: |
| 737 | RangeEvaluationContext(HValue* value, HValue* upper); |
| 738 | |
| 739 | HValue* lower_bound() { return lower_bound_; } |
| 740 | HValue* lower_bound_guarantee() { return lower_bound_guarantee_; } |
| 741 | HValue* candidate() { return candidate_; } |
| 742 | HValue* upper_bound() { return upper_bound_; } |
| 743 | HValue* upper_bound_guarantee() { return upper_bound_guarantee_; } |
| 744 | int offset() { return offset_; } |
| 745 | int scale() { return scale_; } |
| 746 | |
| 747 | bool is_range_satisfied() { |
| 748 | return lower_bound_guarantee() != NULL && upper_bound_guarantee() != NULL; |
| 749 | } |
| 750 | |
| 751 | void set_lower_bound_guarantee(HValue* guarantee) { |
| 752 | lower_bound_guarantee_ = ConvertGuarantee(guarantee); |
| 753 | } |
| 754 | void set_upper_bound_guarantee(HValue* guarantee) { |
| 755 | upper_bound_guarantee_ = ConvertGuarantee(guarantee); |
| 756 | } |
| 757 | |
| 758 | void swap_candidate(DecompositionResult* other_candicate) { |
| 759 | other_candicate->SwapValues(&candidate_, &offset_, &scale_); |
| 760 | } |
| 761 | |
| 762 | private: |
| 763 | HValue* ConvertGuarantee(HValue* guarantee); |
| 764 | |
| 765 | HValue* lower_bound_; |
| 766 | HValue* lower_bound_guarantee_; |
| 767 | HValue* candidate_; |
| 768 | HValue* upper_bound_; |
| 769 | HValue* upper_bound_guarantee_; |
| 770 | int offset_; |
| 771 | int scale_; |
| 772 | }; |
| 773 | |
| 774 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 775 | typedef EnumSet<GVNFlag> GVNFlagSet; |
| 776 | |
| 777 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 778 | class HValue: public ZoneObject { |
| 779 | public: |
| 780 | static const int kNoNumber = -1; |
| 781 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 782 | enum Flag { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 783 | kFlexibleRepresentation, |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 784 | // Participate in Global Value Numbering, i.e. elimination of |
| 785 | // unnecessary recomputations. If an instruction sets this flag, it must |
| 786 | // implement DataEquals(), which will be used to determine if other |
| 787 | // occurrences of the instruction are indeed the same. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 788 | kUseGVN, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 789 | // Track instructions that are dominating side effects. If an instruction |
| 790 | // sets this flag, it must implement SetSideEffectDominator() and should |
| 791 | // indicate which side effects to track by setting GVN flags. |
| 792 | kTrackSideEffectDominators, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 793 | kCanOverflow, |
| 794 | kBailoutOnMinusZero, |
| 795 | kCanBeDivByZero, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 796 | kDeoptimizeOnUndefined, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 797 | kIsArguments, |
| 798 | kTruncatingToInt32, |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 799 | kIsDead, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 800 | // Instructions that are allowed to produce full range unsigned integer |
| 801 | // values are marked with kUint32 flag. If arithmetic shift or a load from |
| 802 | // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag |
| 803 | // it will deoptimize if result does not fit into signed integer range. |
| 804 | // HGraph::ComputeSafeUint32Operations is responsible for setting this |
| 805 | // flag. |
| 806 | kUint32, |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 807 | // If a phi is involved in the evaluation of a numeric constraint the |
| 808 | // recursion can cause an endless cycle: we use this flag to exit the loop. |
| 809 | kNumericConstraintEvaluationInProgress, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 810 | // This flag is set to true after the SetupInformativeDefinitions() pass |
| 811 | // has processed this instruction. |
| 812 | kIDefsProcessingDone, |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 813 | kHasNoObservableSideEffects, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 814 | kLastFlag = kIDefsProcessingDone |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 815 | }; |
| 816 | |
| 817 | STATIC_ASSERT(kLastFlag < kBitsPerInt); |
| 818 | |
| 819 | static const int kChangesToDependsFlagsLeftShift = 1; |
| 820 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 821 | static GVNFlag ChangesFlagFromInt(int x) { |
| 822 | return static_cast<GVNFlag>(x * 2); |
| 823 | } |
| 824 | static GVNFlag DependsOnFlagFromInt(int x) { |
| 825 | return static_cast<GVNFlag>(x * 2 + 1); |
| 826 | } |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 827 | static GVNFlagSet ConvertChangesToDependsFlags(GVNFlagSet flags) { |
| 828 | return GVNFlagSet(flags.ToIntegral() << kChangesToDependsFlagsLeftShift); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 829 | } |
| 830 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 831 | static HValue* cast(HValue* value) { return value; } |
| 832 | |
| 833 | enum Opcode { |
| 834 | // Declare a unique enum value for each hydrogen instruction. |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 835 | #define DECLARE_OPCODE(type) k##type, |
| 836 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 837 | kPhi |
| 838 | #undef DECLARE_OPCODE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 839 | }; |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 840 | virtual Opcode opcode() const = 0; |
| 841 | |
| 842 | // Declare a non-virtual predicates for each concrete HInstruction or HValue. |
| 843 | #define DECLARE_PREDICATE(type) \ |
| 844 | bool Is##type() const { return opcode() == k##type; } |
| 845 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 846 | #undef DECLARE_PREDICATE |
| 847 | bool IsPhi() const { return opcode() == kPhi; } |
| 848 | |
| 849 | // Declare virtual predicates for abstract HInstruction or HValue |
| 850 | #define DECLARE_PREDICATE(type) \ |
| 851 | virtual bool Is##type() const { return false; } |
| 852 | HYDROGEN_ABSTRACT_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 853 | #undef DECLARE_PREDICATE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 854 | |
| 855 | HValue() : block_(NULL), |
| 856 | id_(kNoNumber), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 857 | type_(HType::Tagged()), |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 858 | use_list_(NULL), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 859 | range_(NULL), |
| 860 | flags_(0) {} |
| 861 | virtual ~HValue() {} |
| 862 | |
| 863 | HBasicBlock* block() const { return block_; } |
| 864 | void SetBlock(HBasicBlock* block); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 865 | int LoopWeight() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 866 | |
ulan@chromium.org | 09d7ab5 | 2013-02-25 15:50:35 +0000 | [diff] [blame] | 867 | // Note: Never call this method for an unlinked value. |
| 868 | Isolate* isolate() const; |
| 869 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 870 | int id() const { return id_; } |
| 871 | void set_id(int id) { id_ = id; } |
| 872 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 873 | HUseIterator uses() const { return HUseIterator(use_list_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 874 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 875 | virtual bool EmitAtUses() { return false; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 876 | Representation representation() const { return representation_; } |
| 877 | void ChangeRepresentation(Representation r) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 878 | ASSERT(CheckFlag(kFlexibleRepresentation)); |
| 879 | RepresentationChanged(r); |
| 880 | representation_ = r; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 881 | if (r.IsTagged()) { |
| 882 | // Tagged is the bottom of the lattice, don't go any further. |
| 883 | ClearFlag(kFlexibleRepresentation); |
| 884 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 885 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 886 | virtual void AssumeRepresentation(Representation r); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 887 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 888 | virtual bool IsConvertibleToInteger() const { return true; } |
| 889 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 890 | HType type() const { return type_; } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 891 | void set_type(HType new_type) { |
| 892 | ASSERT(new_type.IsSubtypeOf(type_)); |
| 893 | type_ = new_type; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | // An operation needs to override this function iff: |
| 897 | // 1) it can produce an int32 output. |
| 898 | // 2) the true value of its output can potentially be minus zero. |
| 899 | // The implementation must set a flag so that it bails out in the case where |
| 900 | // it would otherwise output what should be a minus zero as an int32 zero. |
| 901 | // If the operation also exists in a form that takes int32 and outputs int32 |
| 902 | // 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] | 903 | // back. There are three operations that need to propagate back to more than |
| 904 | // one input. They are phi and binary div and mul. They always return NULL |
| 905 | // and expect the caller to take care of things. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 906 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited) { |
| 907 | visited->Add(id()); |
| 908 | return NULL; |
| 909 | } |
| 910 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 911 | // There are HInstructions that do not really change a value, they |
| 912 | // only add pieces of information to it (like bounds checks, map checks, |
| 913 | // smi checks...). |
| 914 | // We call these instructions "informative definitions", or "iDef". |
| 915 | // One of the iDef operands is special because it is the value that is |
| 916 | // "transferred" to the output, we call it the "redefined operand". |
| 917 | // If an HValue is an iDef it must override RedefinedOperandIndex() so that |
| 918 | // it does not return kNoRedefinedOperand; |
| 919 | static const int kNoRedefinedOperand = -1; |
| 920 | virtual int RedefinedOperandIndex() { return kNoRedefinedOperand; } |
| 921 | bool IsInformativeDefinition() { |
| 922 | return RedefinedOperandIndex() != kNoRedefinedOperand; |
| 923 | } |
| 924 | HValue* RedefinedOperand() { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 925 | return IsInformativeDefinition() ? OperandAt(RedefinedOperandIndex()) |
| 926 | : NULL; |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 927 | } |
| 928 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 929 | // A purely informative definition is an idef that will not emit code and |
| 930 | // should therefore be removed from the graph in the RestoreActualValues |
| 931 | // phase (so that live ranges will be shorter). |
| 932 | virtual bool IsPurelyInformativeDefinition() { return false; } |
| 933 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 934 | // This method must always return the original HValue SSA definition |
| 935 | // (regardless of any iDef of this value). |
| 936 | HValue* ActualValue() { |
| 937 | return IsInformativeDefinition() ? RedefinedOperand()->ActualValue() |
| 938 | : this; |
| 939 | } |
| 940 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 941 | virtual void AddInformativeDefinitions() {} |
| 942 | |
| 943 | void UpdateRedefinedUsesWhileSettingUpInformativeDefinitions() { |
| 944 | UpdateRedefinedUsesInner<TestDominanceUsingProcessedFlag>(); |
| 945 | } |
| 946 | void UpdateRedefinedUses() { |
| 947 | UpdateRedefinedUsesInner<Dominates>(); |
| 948 | } |
| 949 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 950 | bool IsInteger32Constant(); |
| 951 | int32_t GetInteger32Constant(); |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 952 | bool EqualsInteger32Constant(int32_t value); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 953 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 954 | bool IsDefinedAfter(HBasicBlock* other) const; |
| 955 | |
| 956 | // Operands. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 957 | virtual int OperandCount() = 0; |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 958 | virtual HValue* OperandAt(int index) const = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 959 | void SetOperandAt(int index, HValue* value); |
| 960 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 961 | void DeleteAndReplaceWith(HValue* other); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 962 | void ReplaceAllUsesWith(HValue* other); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 963 | bool HasNoUses() const { return use_list_ == NULL; } |
| 964 | bool HasMultipleUses() const { |
| 965 | return use_list_ != NULL && use_list_->tail() != NULL; |
| 966 | } |
| 967 | int UseCount() const; |
yangguo@chromium.org | ab30bb8 | 2012-02-24 14:41:46 +0000 | [diff] [blame] | 968 | |
| 969 | // Mark this HValue as dead and to be removed from other HValues' use lists. |
| 970 | void Kill(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 971 | |
| 972 | int flags() const { return flags_; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 973 | void SetFlag(Flag f) { flags_ |= (1 << f); } |
| 974 | void ClearFlag(Flag f) { flags_ &= ~(1 << f); } |
| 975 | bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } |
| 976 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 977 | // Returns true if the flag specified is set for all uses, false otherwise. |
| 978 | bool CheckUsesForFlag(Flag f); |
| 979 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 980 | GVNFlagSet gvn_flags() const { return gvn_flags_; } |
| 981 | void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } |
| 982 | void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } |
| 983 | bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } |
| 984 | void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } |
| 985 | void ClearAllSideEffects() { |
| 986 | gvn_flags_.Remove(AllSideEffectsFlagSet()); |
| 987 | } |
| 988 | bool HasSideEffects() const { |
| 989 | return gvn_flags_.ContainsAnyOf(AllSideEffectsFlagSet()); |
| 990 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 991 | bool HasObservableSideEffects() const { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 992 | return !CheckFlag(kHasNoObservableSideEffects) && |
| 993 | gvn_flags_.ContainsAnyOf(AllObservableSideEffectsFlagSet()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 994 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 995 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 996 | GVNFlagSet DependsOnFlags() const { |
| 997 | GVNFlagSet result = gvn_flags_; |
| 998 | result.Intersect(AllDependsOnFlagSet()); |
| 999 | return result; |
| 1000 | } |
| 1001 | |
| 1002 | GVNFlagSet SideEffectFlags() const { |
| 1003 | GVNFlagSet result = gvn_flags_; |
| 1004 | result.Intersect(AllSideEffectsFlagSet()); |
| 1005 | return result; |
| 1006 | } |
| 1007 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1008 | GVNFlagSet ChangesFlags() const { |
| 1009 | GVNFlagSet result = gvn_flags_; |
| 1010 | result.Intersect(AllChangesFlagSet()); |
| 1011 | return result; |
| 1012 | } |
| 1013 | |
| 1014 | GVNFlagSet ObservableChangesFlags() const { |
| 1015 | GVNFlagSet result = gvn_flags_; |
| 1016 | result.Intersect(AllChangesFlagSet()); |
| 1017 | result.Intersect(AllObservableSideEffectsFlagSet()); |
| 1018 | return result; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1019 | } |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 1020 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1021 | Range* range() const { return range_; } |
| 1022 | bool HasRange() const { return range_ != NULL; } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1023 | void AddNewRange(Range* r, Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1024 | void RemoveLastAddedRange(); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1025 | void ComputeInitialRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1026 | |
| 1027 | // Representation helpers. |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1028 | virtual Representation observed_input_representation(int index) { |
| 1029 | return Representation::None(); |
| 1030 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1031 | virtual Representation RequiredInputRepresentation(int index) = 0; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1032 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1033 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1034 | // This gives the instruction an opportunity to replace itself with an |
| 1035 | // instruction that does the same in some better way. To replace an |
| 1036 | // instruction with a new one, first add the new instruction to the graph, |
| 1037 | // then return it. Return NULL to have the instruction deleted. |
| 1038 | virtual HValue* Canonicalize() { return this; } |
| 1039 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1040 | bool Equals(HValue* other); |
| 1041 | virtual intptr_t Hashcode(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1042 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1043 | // Compute unique ids upfront that is safe wrt GC and parallel recompilation. |
| 1044 | virtual void FinalizeUniqueValueId() { } |
| 1045 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1046 | // Printing support. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1047 | virtual void PrintTo(StringStream* stream) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1048 | void PrintNameTo(StringStream* stream); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1049 | void PrintTypeTo(StringStream* stream); |
| 1050 | void PrintRangeTo(StringStream* stream); |
| 1051 | void PrintChangesTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1052 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1053 | const char* Mnemonic() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1054 | |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 1055 | // Type information helpers. |
| 1056 | bool HasMonomorphicJSObjectType(); |
| 1057 | |
| 1058 | // TODO(mstarzinger): For now instructions can override this function to |
| 1059 | // specify statically known types, once HType can convey more information |
| 1060 | // it should be based on the HType. |
| 1061 | virtual Handle<Map> GetMonomorphicJSObjectMap() { return Handle<Map>(); } |
| 1062 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1063 | // Updated the inferred type of this instruction and returns true if |
| 1064 | // it has changed. |
| 1065 | bool UpdateInferredType(); |
| 1066 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1067 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1068 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1069 | // This function must be overridden for instructions which have the |
| 1070 | // kTrackSideEffectDominators flag set, to track instructions that are |
| 1071 | // dominating side effects. |
| 1072 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
| 1073 | UNREACHABLE(); |
| 1074 | } |
| 1075 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1076 | bool IsDead() const { |
| 1077 | return HasNoUses() && !HasObservableSideEffects() && IsDeletable(); |
| 1078 | } |
| 1079 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1080 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1081 | virtual void Verify() = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1082 | #endif |
| 1083 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1084 | bool IsRelationTrue(NumericRelation relation, |
| 1085 | HValue* other, |
| 1086 | int offset = 0, |
| 1087 | int scale = 0); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1088 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1089 | bool TryGuaranteeRange(HValue* upper_bound); |
| 1090 | virtual bool TryDecompose(DecompositionResult* decomposition) { |
| 1091 | if (RedefinedOperand() != NULL) { |
| 1092 | return RedefinedOperand()->TryDecompose(decomposition); |
| 1093 | } else { |
| 1094 | return false; |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1095 | } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1096 | } |
| 1097 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1098 | protected: |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1099 | void TryGuaranteeRangeRecursive(RangeEvaluationContext* context); |
| 1100 | |
| 1101 | enum RangeGuaranteeDirection { |
| 1102 | DIRECTION_NONE = 0, |
| 1103 | DIRECTION_UPPER = 1, |
| 1104 | DIRECTION_LOWER = 2, |
| 1105 | DIRECTION_BOTH = DIRECTION_UPPER | DIRECTION_LOWER |
| 1106 | }; |
| 1107 | virtual void SetResponsibilityForRange(RangeGuaranteeDirection direction) {} |
| 1108 | virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context) {} |
| 1109 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1110 | // This function must be overridden for instructions with flag kUseGVN, to |
| 1111 | // compare the non-Operand parts of the instruction. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1112 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1113 | UNREACHABLE(); |
| 1114 | return false; |
| 1115 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1116 | |
| 1117 | virtual Representation RepresentationFromInputs() { |
| 1118 | return representation(); |
| 1119 | } |
| 1120 | Representation RepresentationFromUses(); |
| 1121 | virtual void UpdateRepresentation(Representation new_rep, |
| 1122 | HInferRepresentation* h_infer, |
| 1123 | const char* reason); |
| 1124 | void AddDependantsToWorklist(HInferRepresentation* h_infer); |
| 1125 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1126 | virtual void RepresentationChanged(Representation to) { } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1127 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1128 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1129 | virtual void DeleteFromGraph() = 0; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1130 | virtual void InternalSetOperandAt(int index, HValue* value) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1131 | void clear_block() { |
| 1132 | ASSERT(block_ != NULL); |
| 1133 | block_ = NULL; |
| 1134 | } |
| 1135 | |
| 1136 | void set_representation(Representation r) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1137 | ASSERT(representation_.IsNone() && !r.IsNone()); |
| 1138 | representation_ = r; |
| 1139 | } |
| 1140 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 1141 | // Signature of a function testing if a HValue properly dominates another. |
| 1142 | typedef bool (*DominanceTest)(HValue*, HValue*); |
| 1143 | |
| 1144 | // Simple implementation of DominanceTest implemented walking the chain |
| 1145 | // of Hinstructions (used in UpdateRedefinedUsesInner). |
| 1146 | static bool Dominates(HValue* dominator, HValue* dominated); |
| 1147 | |
| 1148 | // A fast implementation of DominanceTest that works only for the |
| 1149 | // "current" instruction in the SetupInformativeDefinitions() phase. |
| 1150 | // During that phase we use a flag to mark processed instructions, and by |
| 1151 | // checking the flag we can quickly test if an instruction comes before or |
| 1152 | // after the "current" one. |
| 1153 | static bool TestDominanceUsingProcessedFlag(HValue* dominator, |
| 1154 | HValue* dominated); |
| 1155 | |
| 1156 | // If we are redefining an operand, update all its dominated uses (the |
| 1157 | // function that checks if a use is dominated is the template argument). |
| 1158 | template<DominanceTest TestDominance> |
| 1159 | void UpdateRedefinedUsesInner() { |
| 1160 | HValue* input = RedefinedOperand(); |
| 1161 | if (input != NULL) { |
| 1162 | for (HUseIterator uses = input->uses(); !uses.Done(); uses.Advance()) { |
| 1163 | HValue* use = uses.value(); |
| 1164 | if (TestDominance(this, use)) { |
| 1165 | use->SetOperandAt(uses.index(), this); |
| 1166 | } |
| 1167 | } |
| 1168 | } |
| 1169 | } |
| 1170 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1171 | // Informative definitions can override this method to state any numeric |
| 1172 | // relation they provide on the redefined value. |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1173 | // Returns true if it is guaranteed that: |
| 1174 | // ((this + offset) >> scale) relation other |
| 1175 | virtual bool IsRelationTrueInternal(NumericRelation relation, |
| 1176 | HValue* other, |
| 1177 | int offset = 0, |
| 1178 | int scale = 0) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1179 | return false; |
| 1180 | } |
| 1181 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1182 | static GVNFlagSet AllDependsOnFlagSet() { |
| 1183 | GVNFlagSet result; |
| 1184 | // Create changes mask. |
| 1185 | #define ADD_FLAG(type) result.Add(kDependsOn##type); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1186 | GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
| 1187 | GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1188 | #undef ADD_FLAG |
| 1189 | return result; |
| 1190 | } |
| 1191 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1192 | static GVNFlagSet AllChangesFlagSet() { |
| 1193 | GVNFlagSet result; |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 1194 | // Create changes mask. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1195 | #define ADD_FLAG(type) result.Add(kChanges##type); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1196 | GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
| 1197 | GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 1198 | #undef ADD_FLAG |
| 1199 | return result; |
| 1200 | } |
| 1201 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1202 | // 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] | 1203 | static GVNFlagSet AllSideEffectsFlagSet() { |
| 1204 | GVNFlagSet result = AllChangesFlagSet(); |
| 1205 | result.Remove(kChangesOsrEntries); |
| 1206 | return result; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1207 | } |
| 1208 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1209 | // A flag mask of all side effects that can make observable changes in |
| 1210 | // 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] | 1211 | static GVNFlagSet AllObservableSideEffectsFlagSet() { |
| 1212 | GVNFlagSet result = AllChangesFlagSet(); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1213 | result.Remove(kChangesNewSpacePromotion); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1214 | result.Remove(kChangesElementsKind); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1215 | result.Remove(kChangesElementsPointer); |
| 1216 | result.Remove(kChangesMaps); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1217 | return result; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1218 | } |
| 1219 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 1220 | // Remove the matching use from the use list if present. Returns the |
| 1221 | // removed list node or NULL. |
| 1222 | HUseListNode* RemoveUse(HValue* value, int index); |
| 1223 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1224 | void RegisterUse(int index, HValue* new_value); |
| 1225 | |
| 1226 | HBasicBlock* block_; |
| 1227 | |
| 1228 | // The id of this instruction in the hydrogen graph, assigned when first |
| 1229 | // added to the graph. Reflects creation order. |
| 1230 | int id_; |
| 1231 | |
| 1232 | Representation representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1233 | HType type_; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 1234 | HUseListNode* use_list_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1235 | Range* range_; |
| 1236 | int flags_; |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1237 | GVNFlagSet gvn_flags_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1238 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1239 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1240 | virtual bool IsDeletable() const { return false; } |
| 1241 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1242 | DISALLOW_COPY_AND_ASSIGN(HValue); |
| 1243 | }; |
| 1244 | |
| 1245 | |
| 1246 | class HInstruction: public HValue { |
| 1247 | public: |
| 1248 | HInstruction* next() const { return next_; } |
| 1249 | HInstruction* previous() const { return previous_; } |
| 1250 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1251 | virtual void PrintTo(StringStream* stream); |
| 1252 | virtual void PrintDataTo(StringStream* stream) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1253 | |
| 1254 | bool IsLinked() const { return block() != NULL; } |
| 1255 | void Unlink(); |
| 1256 | void InsertBefore(HInstruction* next); |
| 1257 | void InsertAfter(HInstruction* previous); |
| 1258 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 1259 | // The position is a write-once variable. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1260 | int position() const { return position_; } |
| 1261 | bool has_position() const { return position_ != RelocInfo::kNoPosition; } |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 1262 | void set_position(int position) { |
| 1263 | ASSERT(!has_position()); |
| 1264 | ASSERT(position != RelocInfo::kNoPosition); |
| 1265 | position_ = position; |
| 1266 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1267 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1268 | bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } |
| 1269 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1270 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; |
| 1271 | |
| 1272 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1273 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1274 | #endif |
| 1275 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1276 | virtual bool IsCall() { return false; } |
| 1277 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1278 | DECLARE_ABSTRACT_INSTRUCTION(Instruction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1279 | |
| 1280 | protected: |
| 1281 | HInstruction() |
| 1282 | : next_(NULL), |
| 1283 | previous_(NULL), |
| 1284 | position_(RelocInfo::kNoPosition) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1285 | SetGVNFlag(kDependsOnOsrEntries); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1286 | } |
| 1287 | |
| 1288 | virtual void DeleteFromGraph() { Unlink(); } |
| 1289 | |
| 1290 | private: |
| 1291 | void InitializeAsFirst(HBasicBlock* block) { |
| 1292 | ASSERT(!IsLinked()); |
| 1293 | SetBlock(block); |
| 1294 | } |
| 1295 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1296 | void PrintMnemonicTo(StringStream* stream); |
| 1297 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1298 | HInstruction* next_; |
| 1299 | HInstruction* previous_; |
| 1300 | int position_; |
| 1301 | |
| 1302 | friend class HBasicBlock; |
| 1303 | }; |
| 1304 | |
| 1305 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1306 | template<int V> |
| 1307 | class HTemplateInstruction : public HInstruction { |
| 1308 | public: |
| 1309 | int OperandCount() { return V; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1310 | HValue* OperandAt(int i) const { return inputs_[i]; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1311 | |
| 1312 | protected: |
| 1313 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 1314 | |
| 1315 | private: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1316 | EmbeddedContainer<HValue*, V> inputs_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1317 | }; |
| 1318 | |
| 1319 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1320 | class HControlInstruction: public HInstruction { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1321 | public: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1322 | virtual HBasicBlock* SuccessorAt(int i) = 0; |
| 1323 | virtual int SuccessorCount() = 0; |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1324 | virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0; |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1325 | |
| 1326 | virtual void PrintDataTo(StringStream* stream); |
| 1327 | |
| 1328 | HBasicBlock* FirstSuccessor() { |
| 1329 | return SuccessorCount() > 0 ? SuccessorAt(0) : NULL; |
| 1330 | } |
| 1331 | HBasicBlock* SecondSuccessor() { |
| 1332 | return SuccessorCount() > 1 ? SuccessorAt(1) : NULL; |
| 1333 | } |
| 1334 | |
| 1335 | DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction) |
| 1336 | }; |
| 1337 | |
| 1338 | |
| 1339 | class HSuccessorIterator BASE_EMBEDDED { |
| 1340 | public: |
| 1341 | explicit HSuccessorIterator(HControlInstruction* instr) |
| 1342 | : instr_(instr), current_(0) { } |
| 1343 | |
| 1344 | bool Done() { return current_ >= instr_->SuccessorCount(); } |
| 1345 | HBasicBlock* Current() { return instr_->SuccessorAt(current_); } |
| 1346 | void Advance() { current_++; } |
| 1347 | |
| 1348 | private: |
| 1349 | HControlInstruction* instr_; |
| 1350 | int current_; |
| 1351 | }; |
| 1352 | |
| 1353 | |
| 1354 | template<int S, int V> |
| 1355 | class HTemplateControlInstruction: public HControlInstruction { |
| 1356 | public: |
| 1357 | int SuccessorCount() { return S; } |
| 1358 | HBasicBlock* SuccessorAt(int i) { return successors_[i]; } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1359 | void SetSuccessorAt(int i, HBasicBlock* block) { successors_[i] = block; } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1360 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1361 | int OperandCount() { return V; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1362 | HValue* OperandAt(int i) const { return inputs_[i]; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1363 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1364 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1365 | protected: |
| 1366 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 1367 | |
| 1368 | private: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1369 | EmbeddedContainer<HBasicBlock*, S> successors_; |
| 1370 | EmbeddedContainer<HValue*, V> inputs_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1371 | }; |
| 1372 | |
| 1373 | |
| 1374 | class HBlockEntry: public HTemplateInstruction<0> { |
| 1375 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1376 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1377 | return Representation::None(); |
| 1378 | } |
| 1379 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1380 | DECLARE_CONCRETE_INSTRUCTION(BlockEntry) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1381 | }; |
| 1382 | |
| 1383 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1384 | class HDummyUse: public HTemplateInstruction<1> { |
| 1385 | public: |
| 1386 | explicit HDummyUse(HValue* value) { |
| 1387 | SetOperandAt(0, value); |
| 1388 | // Pretend to be a Smi so that the HChange instructions inserted |
| 1389 | // before any use generate as little code as possible. |
| 1390 | set_representation(Representation::Tagged()); |
| 1391 | set_type(HType::Smi()); |
| 1392 | } |
| 1393 | |
| 1394 | HValue* value() { return OperandAt(0); } |
| 1395 | |
| 1396 | virtual Representation RequiredInputRepresentation(int index) { |
| 1397 | return Representation::None(); |
| 1398 | } |
| 1399 | |
| 1400 | virtual void PrintDataTo(StringStream* stream); |
| 1401 | |
| 1402 | DECLARE_CONCRETE_INSTRUCTION(DummyUse); |
| 1403 | }; |
| 1404 | |
| 1405 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1406 | class HNumericConstraint : public HTemplateInstruction<2> { |
| 1407 | public: |
| 1408 | static HNumericConstraint* AddToGraph(HValue* constrained_value, |
| 1409 | NumericRelation relation, |
| 1410 | HValue* related_value, |
| 1411 | HInstruction* insertion_point = NULL); |
| 1412 | |
| 1413 | HValue* constrained_value() { return OperandAt(0); } |
| 1414 | HValue* related_value() { return OperandAt(1); } |
| 1415 | NumericRelation relation() { return relation_; } |
| 1416 | |
| 1417 | virtual int RedefinedOperandIndex() { return 0; } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 1418 | virtual bool IsPurelyInformativeDefinition() { return true; } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1419 | |
| 1420 | virtual Representation RequiredInputRepresentation(int index) { |
| 1421 | return representation(); |
| 1422 | } |
| 1423 | |
| 1424 | virtual void PrintDataTo(StringStream* stream); |
| 1425 | |
| 1426 | virtual bool IsRelationTrueInternal(NumericRelation other_relation, |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1427 | HValue* other_related_value, |
| 1428 | int offset = 0, |
| 1429 | int scale = 0) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1430 | if (related_value() == other_related_value) { |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 1431 | return relation().CompoundImplies(other_relation, offset, scale); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1432 | } else { |
| 1433 | return false; |
| 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | DECLARE_CONCRETE_INSTRUCTION(NumericConstraint) |
| 1438 | |
| 1439 | private: |
| 1440 | HNumericConstraint(HValue* constrained_value, |
| 1441 | NumericRelation relation, |
| 1442 | HValue* related_value) |
| 1443 | : relation_(relation) { |
| 1444 | SetOperandAt(0, constrained_value); |
| 1445 | SetOperandAt(1, related_value); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | NumericRelation relation_; |
| 1449 | }; |
| 1450 | |
| 1451 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 1452 | // We insert soft-deoptimize when we hit code with unknown typefeedback, |
| 1453 | // so that we get a chance of re-optimizing with useful typefeedback. |
| 1454 | // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize. |
| 1455 | class HSoftDeoptimize: public HTemplateInstruction<0> { |
| 1456 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1457 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 1458 | return Representation::None(); |
| 1459 | } |
| 1460 | |
| 1461 | DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) |
| 1462 | }; |
| 1463 | |
| 1464 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1465 | class HDeoptimize: public HControlInstruction { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1466 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1467 | HDeoptimize(int environment_length, Zone* zone) |
| 1468 | : values_(environment_length, zone) { } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1469 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1470 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1471 | return Representation::None(); |
| 1472 | } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1473 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1474 | virtual int OperandCount() { return values_.length(); } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1475 | virtual HValue* OperandAt(int index) const { return values_[index]; } |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 1476 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1477 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1478 | virtual int SuccessorCount() { return 0; } |
| 1479 | virtual HBasicBlock* SuccessorAt(int i) { |
| 1480 | UNREACHABLE(); |
| 1481 | return NULL; |
| 1482 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1483 | virtual void SetSuccessorAt(int i, HBasicBlock* block) { |
| 1484 | UNREACHABLE(); |
| 1485 | } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1486 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1487 | void AddEnvironmentValue(HValue* value, Zone* zone) { |
| 1488 | values_.Add(NULL, zone); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1489 | SetOperandAt(values_.length() - 1, value); |
| 1490 | } |
| 1491 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1492 | DECLARE_CONCRETE_INSTRUCTION(Deoptimize) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1493 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 1494 | enum UseEnvironment { |
| 1495 | kNoUses, |
| 1496 | kUseAll |
| 1497 | }; |
| 1498 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1499 | protected: |
| 1500 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1501 | values_[index] = value; |
| 1502 | } |
| 1503 | |
| 1504 | private: |
| 1505 | ZoneList<HValue*> values_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1506 | }; |
| 1507 | |
| 1508 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1509 | class HGoto: public HTemplateControlInstruction<1, 0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1510 | public: |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1511 | explicit HGoto(HBasicBlock* target) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1512 | SetSuccessorAt(0, target); |
| 1513 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1514 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1515 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1516 | return Representation::None(); |
| 1517 | } |
| 1518 | |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 1519 | virtual void PrintDataTo(StringStream* stream); |
| 1520 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1521 | DECLARE_CONCRETE_INSTRUCTION(Goto) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1522 | }; |
| 1523 | |
| 1524 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1525 | class HUnaryControlInstruction: public HTemplateControlInstruction<2, 1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1526 | public: |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1527 | HUnaryControlInstruction(HValue* value, |
| 1528 | HBasicBlock* true_target, |
| 1529 | HBasicBlock* false_target) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1530 | SetOperandAt(0, value); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1531 | SetSuccessorAt(0, true_target); |
| 1532 | SetSuccessorAt(1, false_target); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1533 | } |
| 1534 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1535 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1536 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1537 | HValue* value() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1538 | }; |
| 1539 | |
| 1540 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1541 | class HBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1542 | public: |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1543 | HBranch(HValue* value, |
| 1544 | HBasicBlock* true_target, |
| 1545 | HBasicBlock* false_target, |
| 1546 | ToBooleanStub::Types expected_input_types = ToBooleanStub::no_types()) |
| 1547 | : HUnaryControlInstruction(value, true_target, false_target), |
| 1548 | expected_input_types_(expected_input_types) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1549 | ASSERT(true_target != NULL && false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1550 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1551 | explicit HBranch(HValue* value) |
| 1552 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 1553 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1554 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1555 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1556 | return Representation::None(); |
| 1557 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1558 | virtual Representation observed_input_representation(int index); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1559 | |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1560 | ToBooleanStub::Types expected_input_types() const { |
| 1561 | return expected_input_types_; |
| 1562 | } |
| 1563 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1564 | DECLARE_CONCRETE_INSTRUCTION(Branch) |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 1565 | |
| 1566 | private: |
| 1567 | ToBooleanStub::Types expected_input_types_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1568 | }; |
| 1569 | |
| 1570 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1571 | class HCompareMap: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1572 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1573 | HCompareMap(HValue* value, |
| 1574 | Handle<Map> map, |
| 1575 | HBasicBlock* true_target, |
| 1576 | HBasicBlock* false_target) |
| 1577 | : HUnaryControlInstruction(value, true_target, false_target), |
| 1578 | map_(map) { |
| 1579 | ASSERT(true_target != NULL); |
| 1580 | ASSERT(false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1581 | ASSERT(!map.is_null()); |
| 1582 | } |
| 1583 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1584 | virtual void PrintDataTo(StringStream* stream); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 1585 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1586 | Handle<Map> map() const { return map_; } |
| 1587 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1588 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1589 | return Representation::Tagged(); |
| 1590 | } |
| 1591 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1592 | DECLARE_CONCRETE_INSTRUCTION(CompareMap) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1593 | |
| 1594 | private: |
| 1595 | Handle<Map> map_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1596 | }; |
| 1597 | |
| 1598 | |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 1599 | class HReturn: public HTemplateControlInstruction<0, 3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1600 | public: |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 1601 | HReturn(HValue* value, HValue* context, HValue* parameter_count) { |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1602 | SetOperandAt(0, value); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1603 | SetOperandAt(1, context); |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 1604 | SetOperandAt(2, parameter_count); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1605 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1606 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1607 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1608 | return Representation::Tagged(); |
| 1609 | } |
| 1610 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1611 | virtual void PrintDataTo(StringStream* stream); |
| 1612 | |
| 1613 | HValue* value() { return OperandAt(0); } |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1614 | HValue* context() { return OperandAt(1); } |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 1615 | HValue* parameter_count() { return OperandAt(2); } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1616 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1617 | DECLARE_CONCRETE_INSTRUCTION(Return) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1618 | }; |
| 1619 | |
| 1620 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1621 | class HAbnormalExit: public HTemplateControlInstruction<0, 0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1622 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1623 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1624 | return Representation::None(); |
| 1625 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1626 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1627 | DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1628 | }; |
| 1629 | |
| 1630 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1631 | class HUnaryOperation: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1632 | public: |
| 1633 | explicit HUnaryOperation(HValue* value) { |
| 1634 | SetOperandAt(0, value); |
| 1635 | } |
| 1636 | |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 1637 | static HUnaryOperation* cast(HValue* value) { |
| 1638 | return reinterpret_cast<HUnaryOperation*>(value); |
| 1639 | } |
| 1640 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1641 | HValue* value() const { return OperandAt(0); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1642 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1643 | }; |
| 1644 | |
| 1645 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1646 | class HThrow: public HTemplateInstruction<2> { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1647 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1648 | HThrow(HValue* context, HValue* value) { |
| 1649 | SetOperandAt(0, context); |
| 1650 | SetOperandAt(1, value); |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1651 | SetAllSideEffects(); |
| 1652 | } |
| 1653 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1654 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1655 | return Representation::Tagged(); |
| 1656 | } |
| 1657 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1658 | HValue* context() { return OperandAt(0); } |
| 1659 | HValue* value() { return OperandAt(1); } |
| 1660 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1661 | DECLARE_CONCRETE_INSTRUCTION(Throw) |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1662 | }; |
| 1663 | |
| 1664 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1665 | class HUseConst: public HUnaryOperation { |
| 1666 | public: |
| 1667 | explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } |
| 1668 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1669 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1670 | return Representation::None(); |
| 1671 | } |
| 1672 | |
| 1673 | DECLARE_CONCRETE_INSTRUCTION(UseConst) |
| 1674 | }; |
| 1675 | |
| 1676 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1677 | class HForceRepresentation: public HTemplateInstruction<1> { |
| 1678 | public: |
| 1679 | HForceRepresentation(HValue* value, Representation required_representation) { |
| 1680 | SetOperandAt(0, value); |
| 1681 | set_representation(required_representation); |
| 1682 | } |
| 1683 | |
| 1684 | HValue* value() { return OperandAt(0); } |
| 1685 | |
| 1686 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1687 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1688 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1689 | return representation(); // Same as the output representation. |
| 1690 | } |
| 1691 | |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 1692 | virtual void PrintDataTo(StringStream* stream); |
| 1693 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1694 | DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation) |
| 1695 | }; |
| 1696 | |
| 1697 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1698 | class HChange: public HUnaryOperation { |
| 1699 | public: |
| 1700 | HChange(HValue* value, |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1701 | Representation to, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1702 | bool is_truncating, |
| 1703 | bool deoptimize_on_undefined) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1704 | : HUnaryOperation(value) { |
| 1705 | ASSERT(!value->representation().IsNone() && !to.IsNone()); |
| 1706 | ASSERT(!value->representation().Equals(to)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1707 | set_representation(to); |
| 1708 | SetFlag(kUseGVN); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1709 | if (deoptimize_on_undefined) SetFlag(kDeoptimizeOnUndefined); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1710 | if (is_truncating) SetFlag(kTruncatingToInt32); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1711 | if (value->type().IsSmi()) { |
| 1712 | set_type(HType::Smi()); |
| 1713 | } else { |
| 1714 | set_type(HType::TaggedNumber()); |
| 1715 | if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); |
| 1716 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
| 1719 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1720 | virtual HType CalculateInferredType(); |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1721 | virtual HValue* Canonicalize(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1722 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1723 | Representation from() const { return value()->representation(); } |
| 1724 | Representation to() const { return representation(); } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1725 | bool deoptimize_on_undefined() const { |
| 1726 | return CheckFlag(kDeoptimizeOnUndefined); |
| 1727 | } |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1728 | bool deoptimize_on_minus_zero() const { |
| 1729 | return CheckFlag(kBailoutOnMinusZero); |
| 1730 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1731 | virtual Representation RequiredInputRepresentation(int index) { |
| 1732 | return from(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1733 | } |
| 1734 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 1735 | virtual Range* InferRange(Zone* zone); |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 1736 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1737 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1738 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1739 | DECLARE_CONCRETE_INSTRUCTION(Change) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1740 | |
| 1741 | protected: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1742 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1743 | |
| 1744 | private: |
| 1745 | virtual bool IsDeletable() const { |
| 1746 | return !from().IsTagged() || value()->type().IsSmi(); |
| 1747 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1748 | }; |
| 1749 | |
| 1750 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1751 | class HClampToUint8: public HUnaryOperation { |
| 1752 | public: |
| 1753 | explicit HClampToUint8(HValue* value) |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 1754 | : HUnaryOperation(value) { |
| 1755 | set_representation(Representation::Integer32()); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1756 | SetFlag(kUseGVN); |
| 1757 | } |
| 1758 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1759 | virtual Representation RequiredInputRepresentation(int index) { |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 1760 | return Representation::None(); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) |
| 1764 | |
| 1765 | protected: |
| 1766 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1767 | |
| 1768 | private: |
| 1769 | virtual bool IsDeletable() const { return true; } |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1770 | }; |
| 1771 | |
| 1772 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1773 | enum RemovableSimulate { |
| 1774 | REMOVABLE_SIMULATE, |
| 1775 | FIXED_SIMULATE |
| 1776 | }; |
| 1777 | |
| 1778 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1779 | class HSimulate: public HInstruction { |
| 1780 | public: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1781 | HSimulate(BailoutId ast_id, |
| 1782 | int pop_count, |
| 1783 | Zone* zone, |
| 1784 | RemovableSimulate removable) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1785 | : ast_id_(ast_id), |
| 1786 | pop_count_(pop_count), |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1787 | values_(2, zone), |
| 1788 | assigned_indexes_(2, zone), |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1789 | zone_(zone), |
| 1790 | removable_(removable) {} |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1791 | virtual ~HSimulate() {} |
| 1792 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1793 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1794 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1795 | bool HasAstId() const { return !ast_id_.IsNone(); } |
| 1796 | BailoutId ast_id() const { return ast_id_; } |
| 1797 | void set_ast_id(BailoutId id) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1798 | ASSERT(!HasAstId()); |
| 1799 | ast_id_ = id; |
| 1800 | } |
| 1801 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1802 | int pop_count() const { return pop_count_; } |
| 1803 | const ZoneList<HValue*>* values() const { return &values_; } |
| 1804 | int GetAssignedIndexAt(int index) const { |
| 1805 | ASSERT(HasAssignedIndexAt(index)); |
| 1806 | return assigned_indexes_[index]; |
| 1807 | } |
| 1808 | bool HasAssignedIndexAt(int index) const { |
| 1809 | return assigned_indexes_[index] != kNoIndex; |
| 1810 | } |
| 1811 | void AddAssignedValue(int index, HValue* value) { |
| 1812 | AddValue(index, value); |
| 1813 | } |
| 1814 | void AddPushedValue(HValue* value) { |
| 1815 | AddValue(kNoIndex, value); |
| 1816 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1817 | virtual int OperandCount() { return values_.length(); } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1818 | virtual HValue* OperandAt(int index) const { return values_[index]; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1819 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1820 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1821 | return Representation::None(); |
| 1822 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1823 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1824 | void MergeWith(ZoneList<HSimulate*>* list); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1825 | bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } |
| 1826 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1827 | DECLARE_CONCRETE_INSTRUCTION(Simulate) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1828 | |
| 1829 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1830 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1831 | #endif |
| 1832 | |
| 1833 | protected: |
| 1834 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1835 | values_[index] = value; |
| 1836 | } |
| 1837 | |
| 1838 | private: |
| 1839 | static const int kNoIndex = -1; |
| 1840 | void AddValue(int index, HValue* value) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1841 | assigned_indexes_.Add(index, zone_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1842 | // Resize the list of pushed values. |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1843 | values_.Add(NULL, zone_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1844 | // Set the operand through the base method in HValue to make sure that the |
| 1845 | // use lists are correctly updated. |
| 1846 | SetOperandAt(values_.length() - 1, value); |
| 1847 | } |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1848 | BailoutId ast_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1849 | int pop_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1850 | ZoneList<HValue*> values_; |
| 1851 | ZoneList<int> assigned_indexes_; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1852 | Zone* zone_; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1853 | RemovableSimulate removable_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1854 | }; |
| 1855 | |
| 1856 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1857 | class HStackCheck: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1858 | public: |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1859 | enum Type { |
| 1860 | kFunctionEntry, |
| 1861 | kBackwardsBranch |
| 1862 | }; |
| 1863 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1864 | HStackCheck(HValue* context, Type type) : type_(type) { |
| 1865 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1866 | SetGVNFlag(kChangesNewSpacePromotion); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1867 | } |
| 1868 | |
| 1869 | HValue* context() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1870 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1871 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1872 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1873 | } |
| 1874 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1875 | void Eliminate() { |
| 1876 | // The stack check eliminator might try to eliminate the same stack |
| 1877 | // check instruction multiple times. |
| 1878 | if (IsLinked()) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1879 | DeleteAndReplaceWith(NULL); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | bool is_function_entry() { return type_ == kFunctionEntry; } |
| 1884 | bool is_backwards_branch() { return type_ == kBackwardsBranch; } |
| 1885 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1886 | DECLARE_CONCRETE_INSTRUCTION(StackCheck) |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 1887 | |
| 1888 | private: |
| 1889 | Type type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1890 | }; |
| 1891 | |
| 1892 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1893 | enum InliningKind { |
| 1894 | NORMAL_RETURN, // Normal function/method call and return. |
| 1895 | DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return. |
| 1896 | CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value. |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 1897 | GETTER_CALL_RETURN, // Returning from a getter, need to restore context. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1898 | SETTER_CALL_RETURN // Use the RHS of the assignment as the return value. |
| 1899 | }; |
| 1900 | |
| 1901 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1902 | class HEnterInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1903 | public: |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1904 | HEnterInlined(Handle<JSFunction> closure, |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1905 | int arguments_count, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1906 | FunctionLiteral* function, |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1907 | InliningKind inlining_kind, |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1908 | Variable* arguments_var, |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1909 | ZoneList<HValue*>* arguments_values, |
| 1910 | bool undefined_receiver) |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1911 | : closure_(closure), |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1912 | arguments_count_(arguments_count), |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 1913 | arguments_pushed_(false), |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1914 | function_(function), |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1915 | inlining_kind_(inlining_kind), |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1916 | arguments_var_(arguments_var), |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1917 | arguments_values_(arguments_values), |
| 1918 | undefined_receiver_(undefined_receiver) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1919 | } |
| 1920 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1921 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1922 | |
| 1923 | Handle<JSFunction> closure() const { return closure_; } |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1924 | int arguments_count() const { return arguments_count_; } |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 1925 | bool arguments_pushed() const { return arguments_pushed_; } |
| 1926 | void set_arguments_pushed() { arguments_pushed_ = true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1927 | FunctionLiteral* function() const { return function_; } |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1928 | InliningKind inlining_kind() const { return inlining_kind_; } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1929 | bool undefined_receiver() const { return undefined_receiver_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1930 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1931 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1932 | return Representation::None(); |
| 1933 | } |
| 1934 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1935 | Variable* arguments_var() { return arguments_var_; } |
| 1936 | ZoneList<HValue*>* arguments_values() { return arguments_values_; } |
danno@chromium.org | 8c0a43f | 2012-04-03 08:37:53 +0000 | [diff] [blame] | 1937 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1938 | DECLARE_CONCRETE_INSTRUCTION(EnterInlined) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1939 | |
| 1940 | private: |
| 1941 | Handle<JSFunction> closure_; |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1942 | int arguments_count_; |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 1943 | bool arguments_pushed_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1944 | FunctionLiteral* function_; |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1945 | InliningKind inlining_kind_; |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1946 | Variable* arguments_var_; |
| 1947 | ZoneList<HValue*>* arguments_values_; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 1948 | bool undefined_receiver_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1949 | }; |
| 1950 | |
| 1951 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1952 | class HLeaveInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1953 | public: |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 1954 | HLeaveInlined() { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1955 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1956 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1957 | return Representation::None(); |
| 1958 | } |
| 1959 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1960 | DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1961 | }; |
| 1962 | |
| 1963 | |
| 1964 | class HPushArgument: public HUnaryOperation { |
| 1965 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1966 | explicit HPushArgument(HValue* value) : HUnaryOperation(value) { |
| 1967 | set_representation(Representation::Tagged()); |
| 1968 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1969 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1970 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1971 | return Representation::Tagged(); |
| 1972 | } |
| 1973 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1974 | HValue* argument() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1975 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1976 | DECLARE_CONCRETE_INSTRUCTION(PushArgument) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1977 | }; |
| 1978 | |
| 1979 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1980 | class HThisFunction: public HTemplateInstruction<0> { |
| 1981 | public: |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1982 | HThisFunction() { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1983 | set_representation(Representation::Tagged()); |
| 1984 | SetFlag(kUseGVN); |
| 1985 | } |
| 1986 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1987 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1988 | return Representation::None(); |
| 1989 | } |
| 1990 | |
| 1991 | DECLARE_CONCRETE_INSTRUCTION(ThisFunction) |
| 1992 | |
| 1993 | protected: |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1994 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 1995 | |
| 1996 | private: |
| 1997 | virtual bool IsDeletable() const { return true; } |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1998 | }; |
| 1999 | |
| 2000 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2001 | class HContext: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2002 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2003 | HContext() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2004 | set_representation(Representation::Tagged()); |
| 2005 | SetFlag(kUseGVN); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2006 | } |
| 2007 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2008 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2009 | return Representation::None(); |
| 2010 | } |
| 2011 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2012 | DECLARE_CONCRETE_INSTRUCTION(Context) |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2013 | |
| 2014 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2015 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2016 | |
| 2017 | private: |
| 2018 | virtual bool IsDeletable() const { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2019 | }; |
| 2020 | |
| 2021 | |
| 2022 | class HOuterContext: public HUnaryOperation { |
| 2023 | public: |
| 2024 | explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { |
| 2025 | set_representation(Representation::Tagged()); |
| 2026 | SetFlag(kUseGVN); |
| 2027 | } |
| 2028 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2029 | DECLARE_CONCRETE_INSTRUCTION(OuterContext); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2030 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2031 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2032 | return Representation::Tagged(); |
| 2033 | } |
| 2034 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2035 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2036 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2037 | |
| 2038 | private: |
| 2039 | virtual bool IsDeletable() const { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2040 | }; |
| 2041 | |
| 2042 | |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 2043 | class HDeclareGlobals: public HUnaryOperation { |
| 2044 | public: |
| 2045 | HDeclareGlobals(HValue* context, |
| 2046 | Handle<FixedArray> pairs, |
| 2047 | int flags) |
| 2048 | : HUnaryOperation(context), |
| 2049 | pairs_(pairs), |
| 2050 | flags_(flags) { |
| 2051 | set_representation(Representation::Tagged()); |
| 2052 | SetAllSideEffects(); |
| 2053 | } |
| 2054 | |
| 2055 | HValue* context() { return OperandAt(0); } |
| 2056 | Handle<FixedArray> pairs() const { return pairs_; } |
| 2057 | int flags() const { return flags_; } |
| 2058 | |
| 2059 | DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals) |
| 2060 | |
| 2061 | virtual Representation RequiredInputRepresentation(int index) { |
| 2062 | return Representation::Tagged(); |
| 2063 | } |
| 2064 | private: |
| 2065 | Handle<FixedArray> pairs_; |
| 2066 | int flags_; |
| 2067 | }; |
| 2068 | |
| 2069 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2070 | class HGlobalObject: public HUnaryOperation { |
| 2071 | public: |
| 2072 | explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { |
| 2073 | set_representation(Representation::Tagged()); |
| 2074 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2075 | } |
| 2076 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2077 | DECLARE_CONCRETE_INSTRUCTION(GlobalObject) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2078 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2079 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2080 | return Representation::Tagged(); |
| 2081 | } |
| 2082 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2083 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2084 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2085 | |
| 2086 | private: |
| 2087 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2088 | }; |
| 2089 | |
| 2090 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2091 | class HGlobalReceiver: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2092 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 2093 | explicit HGlobalReceiver(HValue* global_object) |
| 2094 | : HUnaryOperation(global_object) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2095 | set_representation(Representation::Tagged()); |
| 2096 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2097 | } |
| 2098 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2099 | DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2100 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2101 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2102 | return Representation::Tagged(); |
| 2103 | } |
| 2104 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2105 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2106 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2107 | |
| 2108 | private: |
| 2109 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2110 | }; |
| 2111 | |
| 2112 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2113 | template <int V> |
| 2114 | class HCall: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2115 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2116 | // The argument count includes the receiver. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2117 | explicit HCall<V>(int argument_count) : argument_count_(argument_count) { |
| 2118 | this->set_representation(Representation::Tagged()); |
| 2119 | this->SetAllSideEffects(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2120 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2121 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2122 | virtual HType CalculateInferredType() { return HType::Tagged(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2123 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2124 | virtual int argument_count() const { return argument_count_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2125 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2126 | virtual bool IsCall() { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2127 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2128 | private: |
| 2129 | int argument_count_; |
| 2130 | }; |
| 2131 | |
| 2132 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2133 | class HUnaryCall: public HCall<1> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2134 | public: |
| 2135 | HUnaryCall(HValue* value, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2136 | : HCall<1>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2137 | SetOperandAt(0, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2138 | } |
| 2139 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2140 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2141 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2142 | } |
| 2143 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2144 | virtual void PrintDataTo(StringStream* stream); |
| 2145 | |
| 2146 | HValue* value() { return OperandAt(0); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2147 | }; |
| 2148 | |
| 2149 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2150 | class HBinaryCall: public HCall<2> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2151 | public: |
| 2152 | HBinaryCall(HValue* first, HValue* second, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2153 | : HCall<2>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2154 | SetOperandAt(0, first); |
| 2155 | SetOperandAt(1, second); |
| 2156 | } |
| 2157 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2158 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2159 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2160 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2161 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2162 | } |
| 2163 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2164 | HValue* first() { return OperandAt(0); } |
| 2165 | HValue* second() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2166 | }; |
| 2167 | |
| 2168 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2169 | class HInvokeFunction: public HBinaryCall { |
| 2170 | public: |
| 2171 | HInvokeFunction(HValue* context, HValue* function, int argument_count) |
| 2172 | : HBinaryCall(context, function, argument_count) { |
| 2173 | } |
| 2174 | |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2175 | HInvokeFunction(HValue* context, |
| 2176 | HValue* function, |
| 2177 | Handle<JSFunction> known_function, |
| 2178 | int argument_count) |
| 2179 | : HBinaryCall(context, function, argument_count), |
| 2180 | known_function_(known_function) { |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2181 | formal_parameter_count_ = known_function.is_null() |
| 2182 | ? 0 : known_function->shared()->formal_parameter_count(); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2183 | } |
| 2184 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2185 | virtual Representation RequiredInputRepresentation(int index) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2186 | return Representation::Tagged(); |
| 2187 | } |
| 2188 | |
| 2189 | HValue* context() { return first(); } |
| 2190 | HValue* function() { return second(); } |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2191 | Handle<JSFunction> known_function() { return known_function_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2192 | int formal_parameter_count() const { return formal_parameter_count_; } |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2193 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2194 | DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2195 | |
| 2196 | private: |
| 2197 | Handle<JSFunction> known_function_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2198 | int formal_parameter_count_; |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2199 | }; |
| 2200 | |
| 2201 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2202 | class HCallConstantFunction: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2203 | public: |
| 2204 | HCallConstantFunction(Handle<JSFunction> function, int argument_count) |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2205 | : HCall<0>(argument_count), |
| 2206 | function_(function), |
| 2207 | formal_parameter_count_(function->shared()->formal_parameter_count()) {} |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2208 | |
| 2209 | Handle<JSFunction> function() const { return function_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2210 | int formal_parameter_count() const { return formal_parameter_count_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2211 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2212 | bool IsApplyFunction() const { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2213 | return function_->code() == |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2214 | Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2215 | } |
| 2216 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2217 | virtual void PrintDataTo(StringStream* stream); |
| 2218 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2219 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2220 | return Representation::None(); |
| 2221 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2222 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2223 | DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2224 | |
| 2225 | private: |
| 2226 | Handle<JSFunction> function_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2227 | int formal_parameter_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2228 | }; |
| 2229 | |
| 2230 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2231 | class HCallKeyed: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2232 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2233 | HCallKeyed(HValue* context, HValue* key, int argument_count) |
| 2234 | : HBinaryCall(context, key, argument_count) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2235 | } |
| 2236 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2237 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2238 | return Representation::Tagged(); |
| 2239 | } |
| 2240 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2241 | HValue* context() { return first(); } |
| 2242 | HValue* key() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2243 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2244 | DECLARE_CONCRETE_INSTRUCTION(CallKeyed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2245 | }; |
| 2246 | |
| 2247 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2248 | class HCallNamed: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2249 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2250 | HCallNamed(HValue* context, Handle<String> name, int argument_count) |
| 2251 | : HUnaryCall(context, argument_count), name_(name) { |
| 2252 | } |
| 2253 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2254 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2255 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2256 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2257 | Handle<String> name() const { return name_; } |
| 2258 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2259 | DECLARE_CONCRETE_INSTRUCTION(CallNamed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2260 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2261 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2262 | return Representation::Tagged(); |
| 2263 | } |
| 2264 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2265 | private: |
| 2266 | Handle<String> name_; |
| 2267 | }; |
| 2268 | |
| 2269 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2270 | class HCallFunction: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2271 | public: |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2272 | HCallFunction(HValue* context, HValue* function, int argument_count) |
| 2273 | : HBinaryCall(context, function, argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2274 | } |
| 2275 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2276 | HValue* context() { return first(); } |
| 2277 | HValue* function() { return second(); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2278 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2279 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2280 | return Representation::Tagged(); |
| 2281 | } |
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(CallFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2284 | }; |
| 2285 | |
| 2286 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2287 | class HCallGlobal: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2288 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2289 | HCallGlobal(HValue* context, Handle<String> name, int argument_count) |
| 2290 | : HUnaryCall(context, argument_count), name_(name) { |
| 2291 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2292 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2293 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2294 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2295 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2296 | Handle<String> name() const { return name_; } |
| 2297 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2298 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2299 | return Representation::Tagged(); |
| 2300 | } |
| 2301 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2302 | DECLARE_CONCRETE_INSTRUCTION(CallGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2303 | |
| 2304 | private: |
| 2305 | Handle<String> name_; |
| 2306 | }; |
| 2307 | |
| 2308 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2309 | class HCallKnownGlobal: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2310 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2311 | HCallKnownGlobal(Handle<JSFunction> target, int argument_count) |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2312 | : HCall<0>(argument_count), |
| 2313 | target_(target), |
| 2314 | formal_parameter_count_(target->shared()->formal_parameter_count()) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2315 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2316 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2317 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2318 | Handle<JSFunction> target() const { return target_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2319 | int formal_parameter_count() const { return formal_parameter_count_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2320 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2321 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2322 | return Representation::None(); |
| 2323 | } |
| 2324 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2325 | DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2326 | |
| 2327 | private: |
| 2328 | Handle<JSFunction> target_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2329 | int formal_parameter_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2330 | }; |
| 2331 | |
| 2332 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2333 | class HCallNew: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2334 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2335 | HCallNew(HValue* context, HValue* constructor, int argument_count) |
| 2336 | : HBinaryCall(context, constructor, argument_count) { |
| 2337 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2338 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2339 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2340 | return Representation::Tagged(); |
| 2341 | } |
| 2342 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2343 | HValue* context() { return first(); } |
| 2344 | HValue* constructor() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2345 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2346 | DECLARE_CONCRETE_INSTRUCTION(CallNew) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2347 | }; |
| 2348 | |
| 2349 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2350 | class HCallNewArray: public HCallNew { |
| 2351 | public: |
| 2352 | HCallNewArray(HValue* context, HValue* constructor, int argument_count, |
| 2353 | Handle<JSGlobalPropertyCell> type_cell) |
| 2354 | : HCallNew(context, constructor, argument_count), |
| 2355 | type_cell_(type_cell) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 2356 | elements_kind_ = static_cast<ElementsKind>( |
| 2357 | Smi::cast(type_cell->value())->value()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2358 | } |
| 2359 | |
| 2360 | Handle<JSGlobalPropertyCell> property_cell() const { |
| 2361 | return type_cell_; |
| 2362 | } |
| 2363 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 2364 | ElementsKind elements_kind() const { return elements_kind_; } |
| 2365 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2366 | DECLARE_CONCRETE_INSTRUCTION(CallNewArray) |
| 2367 | |
| 2368 | private: |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 2369 | ElementsKind elements_kind_; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2370 | Handle<JSGlobalPropertyCell> type_cell_; |
| 2371 | }; |
| 2372 | |
| 2373 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2374 | class HCallRuntime: public HCall<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2375 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2376 | HCallRuntime(HValue* context, |
| 2377 | Handle<String> name, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2378 | const Runtime::Function* c_function, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2379 | int argument_count) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2380 | : HCall<1>(argument_count), c_function_(c_function), name_(name) { |
| 2381 | SetOperandAt(0, context); |
| 2382 | } |
| 2383 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2384 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2385 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2386 | HValue* context() { return OperandAt(0); } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2387 | const Runtime::Function* function() const { return c_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2388 | Handle<String> name() const { return name_; } |
| 2389 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2390 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2391 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2392 | } |
| 2393 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2394 | DECLARE_CONCRETE_INSTRUCTION(CallRuntime) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2395 | |
| 2396 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2397 | const Runtime::Function* c_function_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2398 | Handle<String> name_; |
| 2399 | }; |
| 2400 | |
| 2401 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 2402 | class HFixedArrayBaseLength: public HUnaryOperation { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2403 | public: |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 2404 | explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 2405 | set_type(HType::Smi()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2406 | set_representation(Representation::Tagged()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2407 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2408 | SetGVNFlag(kDependsOnArrayLengths); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2409 | } |
| 2410 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2411 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2412 | return Representation::Tagged(); |
| 2413 | } |
| 2414 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 2415 | DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2416 | |
| 2417 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2418 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2419 | |
| 2420 | private: |
| 2421 | virtual bool IsDeletable() const { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2422 | }; |
| 2423 | |
| 2424 | |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 2425 | class HMapEnumLength: public HUnaryOperation { |
| 2426 | public: |
| 2427 | explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) { |
| 2428 | set_type(HType::Smi()); |
| 2429 | set_representation(Representation::Tagged()); |
| 2430 | SetFlag(kUseGVN); |
| 2431 | SetGVNFlag(kDependsOnMaps); |
| 2432 | } |
| 2433 | |
| 2434 | virtual Representation RequiredInputRepresentation(int index) { |
| 2435 | return Representation::Tagged(); |
| 2436 | } |
| 2437 | |
| 2438 | DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) |
| 2439 | |
| 2440 | protected: |
| 2441 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2442 | |
| 2443 | private: |
| 2444 | virtual bool IsDeletable() const { return true; } |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 2445 | }; |
| 2446 | |
| 2447 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2448 | class HElementsKind: public HUnaryOperation { |
| 2449 | public: |
| 2450 | explicit HElementsKind(HValue* value) : HUnaryOperation(value) { |
| 2451 | set_representation(Representation::Integer32()); |
| 2452 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2453 | SetGVNFlag(kDependsOnElementsKind); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2454 | } |
| 2455 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2456 | virtual Representation RequiredInputRepresentation(int index) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2457 | return Representation::Tagged(); |
| 2458 | } |
| 2459 | |
| 2460 | DECLARE_CONCRETE_INSTRUCTION(ElementsKind) |
| 2461 | |
| 2462 | protected: |
| 2463 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2464 | |
| 2465 | private: |
| 2466 | virtual bool IsDeletable() const { return true; } |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2467 | }; |
| 2468 | |
| 2469 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2470 | class HBitNot: public HUnaryOperation { |
| 2471 | public: |
| 2472 | explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
| 2473 | set_representation(Representation::Integer32()); |
| 2474 | SetFlag(kUseGVN); |
| 2475 | SetFlag(kTruncatingToInt32); |
| 2476 | } |
| 2477 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2478 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2479 | return Representation::Integer32(); |
| 2480 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2481 | virtual Representation observed_input_representation(int index) { |
| 2482 | return Representation::Integer32(); |
| 2483 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2484 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2485 | |
mstarzinger@chromium.org | 88d326b | 2012-04-23 12:57:22 +0000 | [diff] [blame] | 2486 | virtual HValue* Canonicalize(); |
| 2487 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2488 | DECLARE_CONCRETE_INSTRUCTION(BitNot) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2489 | |
| 2490 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2491 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2492 | |
| 2493 | private: |
| 2494 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2495 | }; |
| 2496 | |
| 2497 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2498 | class HUnaryMathOperation: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2499 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 2500 | static HInstruction* New(Zone* zone, |
| 2501 | HValue* context, |
| 2502 | HValue* value, |
| 2503 | BuiltinFunctionId op); |
| 2504 | |
| 2505 | HValue* context() { return OperandAt(0); } |
| 2506 | HValue* value() { return OperandAt(1); } |
| 2507 | |
| 2508 | virtual void PrintDataTo(StringStream* stream); |
| 2509 | |
| 2510 | virtual HType CalculateInferredType(); |
| 2511 | |
| 2512 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2513 | |
| 2514 | virtual Representation RequiredInputRepresentation(int index) { |
| 2515 | if (index == 0) { |
| 2516 | return Representation::Tagged(); |
| 2517 | } else { |
| 2518 | switch (op_) { |
| 2519 | case kMathFloor: |
| 2520 | case kMathRound: |
| 2521 | case kMathSqrt: |
| 2522 | case kMathPowHalf: |
| 2523 | case kMathLog: |
| 2524 | case kMathExp: |
| 2525 | case kMathSin: |
| 2526 | case kMathCos: |
| 2527 | case kMathTan: |
| 2528 | return Representation::Double(); |
| 2529 | case kMathAbs: |
| 2530 | return representation(); |
| 2531 | default: |
| 2532 | UNREACHABLE(); |
| 2533 | return Representation::None(); |
| 2534 | } |
| 2535 | } |
| 2536 | } |
| 2537 | |
| 2538 | virtual HValue* Canonicalize(); |
| 2539 | |
| 2540 | BuiltinFunctionId op() const { return op_; } |
| 2541 | const char* OpName() const; |
| 2542 | |
| 2543 | DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
| 2544 | |
| 2545 | protected: |
| 2546 | virtual bool DataEquals(HValue* other) { |
| 2547 | HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
| 2548 | return op_ == b->op(); |
| 2549 | } |
| 2550 | |
| 2551 | private: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 2552 | HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) |
| 2553 | : op_(op) { |
| 2554 | SetOperandAt(0, context); |
| 2555 | SetOperandAt(1, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2556 | switch (op) { |
| 2557 | case kMathFloor: |
| 2558 | case kMathRound: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2559 | set_representation(Representation::Integer32()); |
| 2560 | break; |
| 2561 | case kMathAbs: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2562 | // Not setting representation here: it is None intentionally. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2563 | SetFlag(kFlexibleRepresentation); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2564 | // TODO(svenpanne) This flag is actually only needed if representation() |
| 2565 | // is tagged, and not when it is an unboxed double or unboxed integer. |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2566 | SetGVNFlag(kChangesNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2567 | break; |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2568 | case kMathLog: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2569 | case kMathSin: |
| 2570 | case kMathCos: |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 2571 | case kMathTan: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2572 | set_representation(Representation::Double()); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2573 | // These operations use the TranscendentalCache, so they may allocate. |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 2574 | SetGVNFlag(kChangesNewSpacePromotion); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2575 | break; |
danno@chromium.org | 1f34ad3 | 2012-11-26 14:53:56 +0000 | [diff] [blame] | 2576 | case kMathExp: |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2577 | case kMathSqrt: |
| 2578 | case kMathPowHalf: |
danno@chromium.org | 1f34ad3 | 2012-11-26 14:53:56 +0000 | [diff] [blame] | 2579 | set_representation(Representation::Double()); |
| 2580 | break; |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2581 | default: |
| 2582 | UNREACHABLE(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2583 | } |
| 2584 | SetFlag(kUseGVN); |
| 2585 | } |
| 2586 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2587 | virtual bool IsDeletable() const { return true; } |
| 2588 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2589 | BuiltinFunctionId op_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2590 | }; |
| 2591 | |
| 2592 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2593 | class HLoadExternalArrayPointer: public HUnaryOperation { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2594 | public: |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2595 | explicit HLoadExternalArrayPointer(HValue* value) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2596 | : HUnaryOperation(value) { |
| 2597 | set_representation(Representation::External()); |
| 2598 | // 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] | 2599 | // change. The external array of a specialized array elements object cannot |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2600 | // change once set, so it's no necessary to introduce any additional |
| 2601 | // dependencies on top of the inputs. |
| 2602 | SetFlag(kUseGVN); |
| 2603 | } |
| 2604 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2605 | virtual Representation RequiredInputRepresentation(int index) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2606 | return Representation::Tagged(); |
| 2607 | } |
| 2608 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2609 | DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2610 | |
| 2611 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2612 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2613 | |
| 2614 | private: |
| 2615 | virtual bool IsDeletable() const { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2616 | }; |
| 2617 | |
| 2618 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2619 | class HCheckMaps: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2620 | public: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2621 | static HCheckMaps* New(HValue* value, Handle<Map> map, Zone* zone, |
| 2622 | HValue *typecheck = NULL) { |
| 2623 | HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); |
| 2624 | check_map->map_set_.Add(map, zone); |
| 2625 | return check_map; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2626 | } |
| 2627 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2628 | static HCheckMaps* New(HValue* value, SmallMapList* maps, Zone* zone, |
| 2629 | HValue *typecheck = NULL) { |
| 2630 | HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); |
| 2631 | for (int i = 0; i < maps->length(); i++) { |
| 2632 | check_map->map_set_.Add(maps->at(i), zone); |
| 2633 | } |
| 2634 | check_map->map_set_.Sort(); |
| 2635 | return check_map; |
| 2636 | } |
| 2637 | |
| 2638 | static HCheckMaps* NewWithTransitions(HValue* value, Handle<Map> map, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2639 | Zone* zone) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2640 | HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, value); |
| 2641 | check_map->map_set_.Add(map, zone); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2642 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2643 | // Since transitioned elements maps of the initial map don't fail the map |
| 2644 | // check, the CheckMaps instruction doesn't need to depend on ElementsKinds. |
| 2645 | check_map->ClearGVNFlag(kDependsOnElementsKind); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2646 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2647 | ElementsKind kind = map->elements_kind(); |
| 2648 | bool packed = IsFastPackedElementsKind(kind); |
| 2649 | while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) { |
| 2650 | kind = GetNextMoreGeneralFastElementsKind(kind, packed); |
| 2651 | Map* transitioned_map = |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2652 | map->LookupElementsTransitionMap(kind); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2653 | if (transitioned_map) { |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2654 | check_map->map_set_.Add(Handle<Map>(transitioned_map), zone); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 2655 | } |
| 2656 | }; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2657 | check_map->map_set_.Sort(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2658 | return check_map; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2659 | } |
| 2660 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2661 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2662 | return Representation::Tagged(); |
| 2663 | } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2664 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2665 | virtual void PrintDataTo(StringStream* stream); |
| 2666 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2667 | |
ricow@chromium.org | 9fa0967 | 2011-07-25 11:05:35 +0000 | [diff] [blame] | 2668 | HValue* value() { return OperandAt(0); } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2669 | SmallMapList* map_set() { return &map_set_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2670 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2671 | virtual void FinalizeUniqueValueId(); |
| 2672 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2673 | DECLARE_CONCRETE_INSTRUCTION(CheckMaps) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2674 | |
| 2675 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2676 | virtual bool DataEquals(HValue* other) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2677 | ASSERT_EQ(map_set_.length(), map_unique_ids_.length()); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2678 | HCheckMaps* b = HCheckMaps::cast(other); |
| 2679 | // Relies on the fact that map_set has been sorted before. |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2680 | if (map_unique_ids_.length() != b->map_unique_ids_.length()) { |
| 2681 | return false; |
| 2682 | } |
| 2683 | for (int i = 0; i < map_unique_ids_.length(); i++) { |
| 2684 | if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { |
| 2685 | return false; |
| 2686 | } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2687 | } |
| 2688 | return true; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2689 | } |
| 2690 | |
| 2691 | private: |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2692 | // Clients should use one of the static New* methods above. |
| 2693 | HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) |
| 2694 | : map_unique_ids_(0, zone) { |
| 2695 | SetOperandAt(0, value); |
| 2696 | // Use the object value for the dependency if NULL is passed. |
| 2697 | // TODO(titzer): do GVN flags already express this dependency? |
| 2698 | SetOperandAt(1, typecheck != NULL ? typecheck : value); |
| 2699 | set_representation(Representation::Tagged()); |
| 2700 | SetFlag(kUseGVN); |
| 2701 | SetFlag(kTrackSideEffectDominators); |
| 2702 | SetGVNFlag(kDependsOnMaps); |
| 2703 | SetGVNFlag(kDependsOnElementsKind); |
| 2704 | } |
| 2705 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 2706 | SmallMapList map_set_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2707 | ZoneList<UniqueValueId> map_unique_ids_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2708 | }; |
| 2709 | |
| 2710 | |
| 2711 | class HCheckFunction: public HUnaryOperation { |
| 2712 | public: |
| 2713 | HCheckFunction(HValue* value, Handle<JSFunction> function) |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2714 | : HUnaryOperation(value), target_(function), target_unique_id_() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2715 | set_representation(Representation::Tagged()); |
| 2716 | SetFlag(kUseGVN); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2717 | target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2718 | } |
| 2719 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2720 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2721 | return Representation::Tagged(); |
| 2722 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2723 | virtual void PrintDataTo(StringStream* stream); |
| 2724 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2725 | |
| 2726 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2727 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2728 | #endif |
| 2729 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2730 | virtual void FinalizeUniqueValueId() { |
| 2731 | target_unique_id_ = UniqueValueId(target_); |
| 2732 | } |
| 2733 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2734 | Handle<JSFunction> target() const { return target_; } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2735 | bool target_in_new_space() const { return target_in_new_space_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2736 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2737 | DECLARE_CONCRETE_INSTRUCTION(CheckFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2738 | |
| 2739 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2740 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2741 | HCheckFunction* b = HCheckFunction::cast(other); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2742 | return target_unique_id_ == b->target_unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2743 | } |
| 2744 | |
| 2745 | private: |
| 2746 | Handle<JSFunction> target_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2747 | UniqueValueId target_unique_id_; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 2748 | bool target_in_new_space_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2749 | }; |
| 2750 | |
| 2751 | |
| 2752 | class HCheckInstanceType: public HUnaryOperation { |
| 2753 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2754 | static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { |
| 2755 | return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2756 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2757 | static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { |
| 2758 | return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2759 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2760 | static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) { |
| 2761 | return new(zone) HCheckInstanceType(value, IS_STRING); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2762 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2763 | static HCheckInstanceType* NewIsInternalizedString( |
| 2764 | HValue* value, Zone* zone) { |
| 2765 | return new(zone) HCheckInstanceType(value, IS_INTERNALIZED_STRING); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2766 | } |
| 2767 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2768 | virtual void PrintDataTo(StringStream* stream); |
| 2769 | |
| 2770 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2771 | return Representation::Tagged(); |
| 2772 | } |
| 2773 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 2774 | virtual HValue* Canonicalize(); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2775 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2776 | bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; } |
| 2777 | void GetCheckInterval(InstanceType* first, InstanceType* last); |
| 2778 | void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2779 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2780 | DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2781 | |
| 2782 | protected: |
| 2783 | // TODO(ager): It could be nice to allow the ommision of instance |
| 2784 | // type checks if we have already performed an instance type check |
| 2785 | // with a larger range. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2786 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2787 | HCheckInstanceType* b = HCheckInstanceType::cast(other); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2788 | return check_ == b->check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2789 | } |
| 2790 | |
| 2791 | private: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2792 | enum Check { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2793 | IS_SPEC_OBJECT, |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2794 | IS_JS_ARRAY, |
| 2795 | IS_STRING, |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2796 | IS_INTERNALIZED_STRING, |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2797 | LAST_INTERVAL_CHECK = IS_JS_ARRAY |
| 2798 | }; |
| 2799 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2800 | const char* GetCheckName(); |
| 2801 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 2802 | HCheckInstanceType(HValue* value, Check check) |
| 2803 | : HUnaryOperation(value), check_(check) { |
| 2804 | set_representation(Representation::Tagged()); |
| 2805 | SetFlag(kUseGVN); |
| 2806 | } |
| 2807 | |
| 2808 | const Check check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2809 | }; |
| 2810 | |
| 2811 | |
| 2812 | class HCheckNonSmi: public HUnaryOperation { |
| 2813 | public: |
| 2814 | explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { |
| 2815 | set_representation(Representation::Tagged()); |
| 2816 | SetFlag(kUseGVN); |
| 2817 | } |
| 2818 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2819 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2820 | return Representation::Tagged(); |
| 2821 | } |
| 2822 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2823 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2824 | |
| 2825 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2826 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2827 | #endif |
| 2828 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2829 | virtual HValue* Canonicalize() { |
| 2830 | HType value_type = value()->type(); |
| 2831 | if (!value_type.IsUninitialized() && |
| 2832 | (value_type.IsHeapNumber() || |
| 2833 | value_type.IsString() || |
| 2834 | value_type.IsBoolean() || |
| 2835 | value_type.IsNonPrimitive())) { |
| 2836 | return NULL; |
| 2837 | } |
| 2838 | return this; |
| 2839 | } |
| 2840 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2841 | DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2842 | |
| 2843 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2844 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2845 | }; |
| 2846 | |
| 2847 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2848 | class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2849 | public: |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 2850 | HCheckPrototypeMaps(Handle<JSObject> prototype, |
| 2851 | Handle<JSObject> holder, |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2852 | Zone* zone) |
| 2853 | : prototypes_(2, zone), |
| 2854 | maps_(2, zone), |
| 2855 | first_prototype_unique_id_(), |
| 2856 | last_prototype_unique_id_() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2857 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2858 | SetGVNFlag(kDependsOnMaps); |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 2859 | // Keep a list of all objects on the prototype chain up to the holder |
| 2860 | // and the expected maps. |
| 2861 | while (true) { |
| 2862 | prototypes_.Add(prototype, zone); |
| 2863 | maps_.Add(Handle<Map>(prototype->map()), zone); |
| 2864 | if (prototype.is_identical_to(holder)) break; |
| 2865 | prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype())); |
| 2866 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2867 | } |
| 2868 | |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 2869 | ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } |
| 2870 | |
| 2871 | ZoneList<Handle<Map> >* maps() { return &maps_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2872 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2873 | DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2874 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2875 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2876 | return Representation::None(); |
| 2877 | } |
| 2878 | |
danno@chromium.org | 81cac2b | 2012-07-10 11:28:27 +0000 | [diff] [blame] | 2879 | virtual void PrintDataTo(StringStream* stream); |
| 2880 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2881 | virtual intptr_t Hashcode() { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2882 | return first_prototype_unique_id_.Hashcode() * 17 + |
| 2883 | last_prototype_unique_id_.Hashcode(); |
| 2884 | } |
| 2885 | |
| 2886 | virtual void FinalizeUniqueValueId() { |
| 2887 | first_prototype_unique_id_ = UniqueValueId(prototypes_.first()); |
| 2888 | last_prototype_unique_id_ = UniqueValueId(prototypes_.last()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2889 | } |
| 2890 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 2891 | bool CanOmitPrototypeChecks() { |
| 2892 | for (int i = 0; i < maps()->length(); i++) { |
| 2893 | if (!maps()->at(i)->CanOmitPrototypeChecks()) return false; |
| 2894 | } |
| 2895 | return true; |
| 2896 | } |
| 2897 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2898 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2899 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2900 | HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2901 | return first_prototype_unique_id_ == b->first_prototype_unique_id_ && |
| 2902 | last_prototype_unique_id_ == b->last_prototype_unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2903 | } |
| 2904 | |
| 2905 | private: |
mvstanton@chromium.org | 6bec009 | 2013-01-23 13:46:53 +0000 | [diff] [blame] | 2906 | ZoneList<Handle<JSObject> > prototypes_; |
| 2907 | ZoneList<Handle<Map> > maps_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 2908 | UniqueValueId first_prototype_unique_id_; |
| 2909 | UniqueValueId last_prototype_unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2910 | }; |
| 2911 | |
| 2912 | |
| 2913 | class HCheckSmi: public HUnaryOperation { |
| 2914 | public: |
| 2915 | explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { |
| 2916 | set_representation(Representation::Tagged()); |
| 2917 | SetFlag(kUseGVN); |
| 2918 | } |
| 2919 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2920 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2921 | return Representation::Tagged(); |
| 2922 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2923 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2924 | |
| 2925 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2926 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2927 | #endif |
| 2928 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2929 | DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2930 | |
| 2931 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2932 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2933 | }; |
| 2934 | |
| 2935 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 2936 | class HCheckSmiOrInt32: public HUnaryOperation { |
| 2937 | public: |
| 2938 | explicit HCheckSmiOrInt32(HValue* value) : HUnaryOperation(value) { |
| 2939 | SetFlag(kFlexibleRepresentation); |
| 2940 | SetFlag(kUseGVN); |
| 2941 | } |
| 2942 | |
| 2943 | virtual int RedefinedOperandIndex() { return 0; } |
| 2944 | virtual Representation RequiredInputRepresentation(int index) { |
| 2945 | return representation(); |
| 2946 | } |
| 2947 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 2948 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 2949 | virtual Representation observed_input_representation(int index) { |
| 2950 | return Representation::Integer32(); |
| 2951 | } |
| 2952 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 2953 | virtual HValue* Canonicalize() { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2954 | if (representation().IsTagged() && !value()->type().IsSmi()) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 2955 | return this; |
| 2956 | } else { |
| 2957 | return value(); |
| 2958 | } |
| 2959 | } |
| 2960 | |
| 2961 | DECLARE_CONCRETE_INSTRUCTION(CheckSmiOrInt32) |
| 2962 | |
| 2963 | protected: |
| 2964 | virtual bool DataEquals(HValue* other) { return true; } |
| 2965 | }; |
| 2966 | |
| 2967 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2968 | class HPhi: public HValue { |
| 2969 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 2970 | HPhi(int merged_index, Zone* zone) |
| 2971 | : inputs_(2, zone), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2972 | merged_index_(merged_index), |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2973 | phi_id_(-1), |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2974 | is_live_(false), |
| 2975 | is_convertible_to_integer_(true) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2976 | for (int i = 0; i < Representation::kNumRepresentations; i++) { |
| 2977 | non_phi_uses_[i] = 0; |
| 2978 | indirect_uses_[i] = 0; |
| 2979 | } |
| 2980 | ASSERT(merged_index >= 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2981 | SetFlag(kFlexibleRepresentation); |
| 2982 | } |
| 2983 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2984 | virtual Representation RepresentationFromInputs(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2985 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2986 | virtual Range* InferRange(Zone* zone); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2987 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2988 | Representation RepresentationFromUseRequirements(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2989 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2990 | return representation(); |
| 2991 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2992 | virtual HType CalculateInferredType(); |
| 2993 | virtual int OperandCount() { return inputs_.length(); } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 2994 | virtual HValue* OperandAt(int index) const { return inputs_[index]; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2995 | HValue* GetRedundantReplacement(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2996 | void AddInput(HValue* value); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2997 | bool HasRealUses(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2998 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2999 | bool IsReceiver() { return merged_index_ == 0; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3000 | |
| 3001 | int merged_index() const { return merged_index_; } |
| 3002 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3003 | virtual void AddInformativeDefinitions(); |
| 3004 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3005 | virtual void PrintTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3006 | |
| 3007 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3008 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3009 | #endif |
| 3010 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3011 | void InitRealUses(int id); |
| 3012 | void AddNonPhiUsesFrom(HPhi* other); |
| 3013 | void AddIndirectUsesTo(int* use_count); |
| 3014 | |
| 3015 | int tagged_non_phi_uses() const { |
| 3016 | return non_phi_uses_[Representation::kTagged]; |
| 3017 | } |
| 3018 | int int32_non_phi_uses() const { |
| 3019 | return non_phi_uses_[Representation::kInteger32]; |
| 3020 | } |
| 3021 | int double_non_phi_uses() const { |
| 3022 | return non_phi_uses_[Representation::kDouble]; |
| 3023 | } |
| 3024 | int tagged_indirect_uses() const { |
| 3025 | return indirect_uses_[Representation::kTagged]; |
| 3026 | } |
| 3027 | int int32_indirect_uses() const { |
| 3028 | return indirect_uses_[Representation::kInteger32]; |
| 3029 | } |
| 3030 | int double_indirect_uses() const { |
| 3031 | return indirect_uses_[Representation::kDouble]; |
| 3032 | } |
| 3033 | int phi_id() { return phi_id_; } |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 3034 | bool is_live() { return is_live_; } |
| 3035 | void set_is_live(bool b) { is_live_ = b; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3036 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3037 | static HPhi* cast(HValue* value) { |
| 3038 | ASSERT(value->IsPhi()); |
| 3039 | return reinterpret_cast<HPhi*>(value); |
| 3040 | } |
| 3041 | virtual Opcode opcode() const { return HValue::kPhi; } |
| 3042 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 3043 | virtual bool IsConvertibleToInteger() const { |
| 3044 | return is_convertible_to_integer_; |
| 3045 | } |
| 3046 | |
| 3047 | void set_is_convertible_to_integer(bool b) { |
| 3048 | is_convertible_to_integer_ = b; |
| 3049 | } |
| 3050 | |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 3051 | bool AllOperandsConvertibleToInteger() { |
| 3052 | for (int i = 0; i < OperandCount(); ++i) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3053 | if (!OperandAt(i)->IsConvertibleToInteger()) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3054 | if (FLAG_trace_representation) { |
| 3055 | HValue* input = OperandAt(i); |
| 3056 | PrintF("#%d %s: Input #%d %s at %d is NCTI\n", |
| 3057 | id(), Mnemonic(), input->id(), input->Mnemonic(), i); |
| 3058 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3059 | return false; |
| 3060 | } |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 3061 | } |
| 3062 | return true; |
| 3063 | } |
| 3064 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 3065 | void SimplifyConstantInputs(); |
| 3066 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3067 | protected: |
| 3068 | virtual void DeleteFromGraph(); |
| 3069 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 3070 | inputs_[index] = value; |
| 3071 | } |
| 3072 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3073 | virtual bool IsRelationTrueInternal(NumericRelation relation, |
| 3074 | HValue* other, |
| 3075 | int offset = 0, |
| 3076 | int scale = 0); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3077 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3078 | private: |
| 3079 | ZoneList<HValue*> inputs_; |
| 3080 | int merged_index_; |
| 3081 | |
| 3082 | int non_phi_uses_[Representation::kNumRepresentations]; |
| 3083 | int indirect_uses_[Representation::kNumRepresentations]; |
| 3084 | int phi_id_; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 3085 | bool is_live_; |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 3086 | bool is_convertible_to_integer_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3087 | }; |
| 3088 | |
| 3089 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3090 | class HInductionVariableAnnotation : public HUnaryOperation { |
| 3091 | public: |
| 3092 | static HInductionVariableAnnotation* AddToGraph(HPhi* phi, |
| 3093 | NumericRelation relation, |
| 3094 | int operand_index); |
| 3095 | |
| 3096 | NumericRelation relation() { return relation_; } |
| 3097 | HValue* induction_base() { return phi_->OperandAt(operand_index_); } |
| 3098 | |
| 3099 | virtual int RedefinedOperandIndex() { return 0; } |
| 3100 | virtual bool IsPurelyInformativeDefinition() { return true; } |
| 3101 | virtual Representation RequiredInputRepresentation(int index) { |
| 3102 | return representation(); |
| 3103 | } |
| 3104 | |
| 3105 | virtual void PrintDataTo(StringStream* stream); |
| 3106 | |
| 3107 | virtual bool IsRelationTrueInternal(NumericRelation other_relation, |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3108 | HValue* other_related_value, |
| 3109 | int offset = 0, |
| 3110 | int scale = 0) { |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3111 | if (induction_base() == other_related_value) { |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3112 | return relation().CompoundImplies(other_relation, offset, scale); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3113 | } else { |
| 3114 | return false; |
| 3115 | } |
| 3116 | } |
| 3117 | |
| 3118 | DECLARE_CONCRETE_INSTRUCTION(InductionVariableAnnotation) |
| 3119 | |
| 3120 | private: |
| 3121 | HInductionVariableAnnotation(HPhi* phi, |
| 3122 | NumericRelation relation, |
| 3123 | int operand_index) |
| 3124 | : HUnaryOperation(phi), |
| 3125 | phi_(phi), relation_(relation), operand_index_(operand_index) { |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3126 | } |
| 3127 | |
| 3128 | // We need to store the phi both here and in the instruction operand because |
| 3129 | // the operand can change if a new idef of the phi is added between the phi |
| 3130 | // and this instruction (inserting an idef updates every use). |
| 3131 | HPhi* phi_; |
| 3132 | NumericRelation relation_; |
| 3133 | int operand_index_; |
| 3134 | }; |
| 3135 | |
| 3136 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3137 | class HArgumentsObject: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3138 | public: |
| 3139 | HArgumentsObject() { |
| 3140 | set_representation(Representation::Tagged()); |
| 3141 | SetFlag(kIsArguments); |
| 3142 | } |
| 3143 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3144 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3145 | return Representation::None(); |
| 3146 | } |
| 3147 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3148 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3149 | |
| 3150 | private: |
| 3151 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3152 | }; |
| 3153 | |
| 3154 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3155 | class HConstant: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3156 | public: |
| 3157 | HConstant(Handle<Object> handle, Representation r); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3158 | HConstant(int32_t value, |
| 3159 | Representation r, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3160 | bool is_not_in_new_space = true, |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3161 | Handle<Object> optional_handle = Handle<Object>::null()); |
| 3162 | HConstant(double value, |
| 3163 | Representation r, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3164 | bool is_not_in_new_space = true, |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3165 | Handle<Object> optional_handle = Handle<Object>::null()); |
| 3166 | HConstant(Handle<Object> handle, |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3167 | UniqueValueId unique_id, |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3168 | Representation r, |
| 3169 | HType type, |
| 3170 | bool is_internalized_string, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3171 | bool is_not_in_new_space, |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3172 | bool boolean_value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3173 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3174 | Handle<Object> handle() { |
| 3175 | if (handle_.is_null()) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3176 | // Default arguments to is_not_in_new_space depend on this heap number |
| 3177 | // to be tenured so that it's guaranteed not be be located in new space. |
yangguo@chromium.org | 4db2640 | 2013-04-25 11:02:09 +0000 | [diff] [blame] | 3178 | handle_ = FACTORY->NewNumber(double_value_, TENURED); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3179 | } |
yangguo@chromium.org | 4db2640 | 2013-04-25 11:02:09 +0000 | [diff] [blame] | 3180 | ALLOW_HANDLE_DEREF(Isolate::Current(), "smi check"); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3181 | ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| 3182 | return handle_; |
| 3183 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3184 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3185 | bool IsSpecialDouble() const { |
| 3186 | return has_double_value_ && |
| 3187 | (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) || |
| 3188 | FixedDoubleArray::is_the_hole_nan(double_value_) || |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 3189 | std::isnan(double_value_)); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3190 | } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3191 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3192 | bool NotInNewSpace() const { |
| 3193 | return is_not_in_new_space_; |
| 3194 | } |
| 3195 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3196 | bool ImmortalImmovable() const { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3197 | if (has_int32_value_) { |
| 3198 | return false; |
| 3199 | } |
| 3200 | if (has_double_value_) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3201 | if (IsSpecialDouble()) { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3202 | return true; |
| 3203 | } |
| 3204 | return false; |
| 3205 | } |
| 3206 | |
| 3207 | ASSERT(!handle_.is_null()); |
ulan@chromium.org | 09d7ab5 | 2013-02-25 15:50:35 +0000 | [diff] [blame] | 3208 | Heap* heap = isolate()->heap(); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3209 | ASSERT(unique_id_ != UniqueValueId(heap->minus_zero_value())); |
| 3210 | ASSERT(unique_id_ != UniqueValueId(heap->nan_value())); |
| 3211 | return unique_id_ == UniqueValueId(heap->undefined_value()) || |
| 3212 | unique_id_ == UniqueValueId(heap->null_value()) || |
| 3213 | unique_id_ == UniqueValueId(heap->true_value()) || |
| 3214 | unique_id_ == UniqueValueId(heap->false_value()) || |
| 3215 | unique_id_ == UniqueValueId(heap->the_hole_value()) || |
| 3216 | unique_id_ == UniqueValueId(heap->empty_string()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
| 3219 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3220 | return Representation::None(); |
| 3221 | } |
| 3222 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 3223 | virtual bool IsConvertibleToInteger() const { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3224 | return has_int32_value_; |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 3225 | } |
| 3226 | |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 3227 | virtual bool EmitAtUses() { return !representation().IsDouble(); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3228 | virtual void PrintDataTo(StringStream* stream); |
| 3229 | virtual HType CalculateInferredType(); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3230 | bool IsInteger() { return handle()->IsSmi(); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3231 | HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
| 3232 | HConstant* CopyToTruncatedInt32(Zone* zone) const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3233 | bool HasInteger32Value() const { return has_int32_value_; } |
| 3234 | int32_t Integer32Value() const { |
| 3235 | ASSERT(HasInteger32Value()); |
| 3236 | return int32_value_; |
| 3237 | } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3238 | bool HasSmiValue() const { |
| 3239 | return HasInteger32Value() && Smi::IsValid(Integer32Value()); |
| 3240 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3241 | bool HasDoubleValue() const { return has_double_value_; } |
| 3242 | double DoubleValue() const { |
| 3243 | ASSERT(HasDoubleValue()); |
| 3244 | return double_value_; |
| 3245 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3246 | bool IsTheHole() const { |
| 3247 | if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { |
| 3248 | return true; |
| 3249 | } |
| 3250 | Heap* heap = isolate()->heap(); |
| 3251 | if (!handle_.is_null() && *handle_ == heap->the_hole_value()) { |
| 3252 | return true; |
| 3253 | } |
| 3254 | return false; |
| 3255 | } |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3256 | bool HasNumberValue() const { return has_double_value_; } |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3257 | int32_t NumberValueAsInteger32() const { |
| 3258 | ASSERT(HasNumberValue()); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3259 | // Irrespective of whether a numeric HConstant can be safely |
| 3260 | // represented as an int32, we store the (in some cases lossy) |
| 3261 | // representation of the number in int32_value_. |
| 3262 | return int32_value_; |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3263 | } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3264 | bool HasStringValue() const { |
| 3265 | if (has_double_value_ || has_int32_value_) return false; |
| 3266 | ASSERT(!handle_.is_null()); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3267 | return type_from_value_.IsString(); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3268 | } |
| 3269 | Handle<String> StringValue() const { |
| 3270 | ASSERT(HasStringValue()); |
| 3271 | return Handle<String>::cast(handle_); |
| 3272 | } |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3273 | bool HasInternalizedStringValue() const { |
| 3274 | return HasStringValue() && is_internalized_string_; |
| 3275 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3276 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3277 | bool BooleanValue() const { return boolean_value_; } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3278 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3279 | virtual intptr_t Hashcode() { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3280 | if (has_int32_value_) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3281 | return static_cast<intptr_t>(int32_value_); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3282 | } else if (has_double_value_) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3283 | return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3284 | } else { |
| 3285 | ASSERT(!handle_.is_null()); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3286 | return unique_id_.Hashcode(); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3287 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3288 | } |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3289 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3290 | virtual void FinalizeUniqueValueId() { |
| 3291 | if (!has_double_value_) { |
| 3292 | ASSERT(!handle_.is_null()); |
| 3293 | unique_id_ = UniqueValueId(handle_); |
| 3294 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3295 | } |
| 3296 | |
| 3297 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3298 | virtual void Verify() { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3299 | #endif |
| 3300 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3301 | DECLARE_CONCRETE_INSTRUCTION(Constant) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3302 | |
| 3303 | protected: |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 3304 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3305 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3306 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3307 | HConstant* other_constant = HConstant::cast(other); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3308 | if (has_int32_value_) { |
| 3309 | return other_constant->has_int32_value_ && |
| 3310 | int32_value_ == other_constant->int32_value_; |
| 3311 | } else if (has_double_value_) { |
| 3312 | return other_constant->has_double_value_ && |
| 3313 | BitCast<int64_t>(double_value_) == |
| 3314 | BitCast<int64_t>(other_constant->double_value_); |
| 3315 | } else { |
| 3316 | ASSERT(!handle_.is_null()); |
| 3317 | return !other_constant->handle_.is_null() && |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3318 | unique_id_ == other_constant->unique_id_; |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3319 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3320 | } |
| 3321 | |
| 3322 | private: |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 3323 | void Initialize(Representation r); |
| 3324 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3325 | virtual bool IsDeletable() const { return true; } |
| 3326 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3327 | // If this is a numerical constant, handle_ either points to to the |
| 3328 | // HeapObject the constant originated from or is null. If the |
| 3329 | // constant is non-numeric, handle_ always points to a valid |
| 3330 | // constant HeapObject. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3331 | Handle<Object> handle_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3332 | UniqueValueId unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3333 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 3334 | // We store the HConstant in the most specific form safely possible. |
| 3335 | // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3336 | // int32_value_ and double_value_ hold valid, safe representations |
| 3337 | // of the constant. has_int32_value_ implies has_double_value_ but |
| 3338 | // not the converse. |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3339 | bool has_int32_value_ : 1; |
| 3340 | bool has_double_value_ : 1; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3341 | bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3342 | bool is_not_in_new_space_ : 1; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3343 | bool boolean_value_ : 1; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3344 | int32_t int32_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3345 | double double_value_; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3346 | HType type_from_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3347 | }; |
| 3348 | |
| 3349 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3350 | class HBinaryOperation: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3351 | public: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3352 | HBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 3353 | : observed_output_representation_(Representation::None()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3354 | ASSERT(left != NULL && right != NULL); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3355 | SetOperandAt(0, context); |
| 3356 | SetOperandAt(1, left); |
| 3357 | SetOperandAt(2, right); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3358 | observed_input_representation_[0] = Representation::None(); |
| 3359 | observed_input_representation_[1] = Representation::None(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3360 | } |
| 3361 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3362 | HValue* context() { return OperandAt(0); } |
| 3363 | HValue* left() { return OperandAt(1); } |
| 3364 | HValue* right() { return OperandAt(2); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3365 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 3366 | // True if switching left and right operands likely generates better code. |
| 3367 | bool AreOperandsBetterSwitched() { |
| 3368 | if (!IsCommutative()) return false; |
| 3369 | |
| 3370 | // Constant operands are better off on the right, they can be inlined in |
| 3371 | // many situations on most platforms. |
| 3372 | if (left()->IsConstant()) return true; |
| 3373 | if (right()->IsConstant()) return false; |
| 3374 | |
| 3375 | // Otherwise, if there is only one use of the right operand, it would be |
| 3376 | // better off on the left for platforms that only have 2-arg arithmetic |
| 3377 | // ops (e.g ia32, x64) that clobber the left operand. |
| 3378 | return (right()->UseCount() == 1); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3379 | } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3380 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 3381 | HValue* BetterLeftOperand() { |
| 3382 | return AreOperandsBetterSwitched() ? right() : left(); |
| 3383 | } |
| 3384 | |
| 3385 | HValue* BetterRightOperand() { |
| 3386 | return AreOperandsBetterSwitched() ? left() : right(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3387 | } |
| 3388 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 3389 | void set_observed_input_representation(int index, Representation rep) { |
| 3390 | ASSERT(index >= 1 && index <= 2); |
| 3391 | observed_input_representation_[index - 1] = rep; |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3392 | } |
| 3393 | |
| 3394 | virtual void initialize_output_representation(Representation observed) { |
| 3395 | observed_output_representation_ = observed; |
| 3396 | } |
| 3397 | |
| 3398 | virtual Representation observed_input_representation(int index) { |
| 3399 | if (index == 0) return Representation::Tagged(); |
| 3400 | return observed_input_representation_[index - 1]; |
| 3401 | } |
| 3402 | |
| 3403 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 3404 | virtual Representation RepresentationFromInputs(); |
| 3405 | virtual void AssumeRepresentation(Representation r); |
| 3406 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3407 | virtual bool IsCommutative() const { return false; } |
| 3408 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3409 | virtual void PrintDataTo(StringStream* stream); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 3410 | |
| 3411 | DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3412 | |
| 3413 | private: |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 3414 | bool IgnoreObservedOutputRepresentation(Representation current_rep); |
| 3415 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3416 | Representation observed_input_representation_[2]; |
| 3417 | Representation observed_output_representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3418 | }; |
| 3419 | |
| 3420 | |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 3421 | class HWrapReceiver: public HTemplateInstruction<2> { |
| 3422 | public: |
| 3423 | HWrapReceiver(HValue* receiver, HValue* function) { |
| 3424 | set_representation(Representation::Tagged()); |
| 3425 | SetOperandAt(0, receiver); |
| 3426 | SetOperandAt(1, function); |
| 3427 | } |
| 3428 | |
| 3429 | virtual Representation RequiredInputRepresentation(int index) { |
| 3430 | return Representation::Tagged(); |
| 3431 | } |
| 3432 | |
| 3433 | HValue* receiver() { return OperandAt(0); } |
| 3434 | HValue* function() { return OperandAt(1); } |
| 3435 | |
| 3436 | virtual HValue* Canonicalize(); |
| 3437 | |
yangguo@chromium.org | 3911019 | 2013-01-16 09:55:08 +0000 | [diff] [blame] | 3438 | virtual void PrintDataTo(StringStream* stream); |
| 3439 | |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 3440 | DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) |
| 3441 | }; |
| 3442 | |
| 3443 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3444 | class HApplyArguments: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3445 | public: |
| 3446 | HApplyArguments(HValue* function, |
| 3447 | HValue* receiver, |
| 3448 | HValue* length, |
| 3449 | HValue* elements) { |
| 3450 | set_representation(Representation::Tagged()); |
| 3451 | SetOperandAt(0, function); |
| 3452 | SetOperandAt(1, receiver); |
| 3453 | SetOperandAt(2, length); |
| 3454 | SetOperandAt(3, elements); |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 3455 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3456 | } |
| 3457 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3458 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3459 | // The length is untagged, all other inputs are tagged. |
| 3460 | return (index == 2) |
| 3461 | ? Representation::Integer32() |
| 3462 | : Representation::Tagged(); |
| 3463 | } |
| 3464 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3465 | HValue* function() { return OperandAt(0); } |
| 3466 | HValue* receiver() { return OperandAt(1); } |
| 3467 | HValue* length() { return OperandAt(2); } |
| 3468 | HValue* elements() { return OperandAt(3); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3469 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3470 | DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3471 | }; |
| 3472 | |
| 3473 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3474 | class HArgumentsElements: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3475 | public: |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 3476 | explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3477 | // The value produced by this instruction is a pointer into the stack |
| 3478 | // that looks as if it was a smi because of alignment. |
| 3479 | set_representation(Representation::Tagged()); |
| 3480 | SetFlag(kUseGVN); |
| 3481 | } |
| 3482 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3483 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3484 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3485 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3486 | return Representation::None(); |
| 3487 | } |
| 3488 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 3489 | bool from_inlined() const { return from_inlined_; } |
| 3490 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3491 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3492 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 3493 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3494 | private: |
| 3495 | virtual bool IsDeletable() const { return true; } |
| 3496 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 3497 | bool from_inlined_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3498 | }; |
| 3499 | |
| 3500 | |
| 3501 | class HArgumentsLength: public HUnaryOperation { |
| 3502 | public: |
| 3503 | explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { |
| 3504 | set_representation(Representation::Integer32()); |
| 3505 | SetFlag(kUseGVN); |
| 3506 | } |
| 3507 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3508 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3509 | return Representation::Tagged(); |
| 3510 | } |
| 3511 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3512 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3513 | |
| 3514 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3515 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3516 | |
| 3517 | private: |
| 3518 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3519 | }; |
| 3520 | |
| 3521 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3522 | class HAccessArgumentsAt: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3523 | public: |
| 3524 | HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { |
| 3525 | set_representation(Representation::Tagged()); |
| 3526 | SetFlag(kUseGVN); |
| 3527 | SetOperandAt(0, arguments); |
| 3528 | SetOperandAt(1, length); |
| 3529 | SetOperandAt(2, index); |
| 3530 | } |
| 3531 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3532 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3533 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3534 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3535 | // The arguments elements is considered tagged. |
| 3536 | return index == 0 |
| 3537 | ? Representation::Tagged() |
| 3538 | : Representation::Integer32(); |
| 3539 | } |
| 3540 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3541 | HValue* arguments() { return OperandAt(0); } |
| 3542 | HValue* length() { return OperandAt(1); } |
| 3543 | HValue* index() { return OperandAt(2); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3544 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3545 | DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3546 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3547 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3548 | }; |
| 3549 | |
| 3550 | |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 3551 | enum BoundsCheckKeyMode { |
| 3552 | DONT_ALLOW_SMI_KEY, |
| 3553 | ALLOW_SMI_KEY |
| 3554 | }; |
| 3555 | |
| 3556 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3557 | class HBoundsCheckBaseIndexInformation; |
| 3558 | |
| 3559 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3560 | class HBoundsCheck: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3561 | public: |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3562 | // Normally HBoundsCheck should be created using the |
| 3563 | // HGraphBuilder::AddBoundsCheck() helper, which also guards the index with |
| 3564 | // a HCheckSmiOrInt32 check. |
| 3565 | // However when building stubs, where we know that the arguments are Int32, |
| 3566 | // it makes sense to invoke this constructor directly. |
| 3567 | HBoundsCheck(HValue* index, |
| 3568 | HValue* length, |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3569 | BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, |
| 3570 | Representation r = Representation::None()) |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3571 | : key_mode_(key_mode), skip_check_(false), |
| 3572 | base_(NULL), offset_(0), scale_(0), |
| 3573 | responsibility_direction_(DIRECTION_NONE) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3574 | SetOperandAt(0, index); |
| 3575 | SetOperandAt(1, length); |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3576 | if (r.IsNone()) { |
| 3577 | // In the normal compilation pipeline the representation is flexible |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3578 | // (see InferRepresentation). |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3579 | SetFlag(kFlexibleRepresentation); |
| 3580 | } else { |
| 3581 | // When compiling stubs we want to set the representation explicitly |
| 3582 | // so the compilation pipeline can skip the HInferRepresentation phase. |
| 3583 | set_representation(r); |
| 3584 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3585 | SetFlag(kUseGVN); |
| 3586 | } |
| 3587 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3588 | bool skip_check() { return skip_check_; } |
| 3589 | void set_skip_check(bool skip_check) { skip_check_ = skip_check; } |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3590 | HValue* base() { return base_; } |
| 3591 | int offset() { return offset_; } |
| 3592 | int scale() { return scale_; } |
| 3593 | bool index_can_increase() { |
| 3594 | return (responsibility_direction_ & DIRECTION_LOWER) == 0; |
| 3595 | } |
| 3596 | bool index_can_decrease() { |
| 3597 | return (responsibility_direction_ & DIRECTION_UPPER) == 0; |
| 3598 | } |
| 3599 | |
| 3600 | void ApplyIndexChange(); |
| 3601 | bool DetectCompoundIndex() { |
| 3602 | ASSERT(base() == NULL); |
| 3603 | |
| 3604 | DecompositionResult decomposition; |
| 3605 | if (index()->TryDecompose(&decomposition)) { |
| 3606 | base_ = decomposition.base(); |
| 3607 | offset_ = decomposition.offset(); |
| 3608 | scale_ = decomposition.scale(); |
| 3609 | return true; |
| 3610 | } else { |
| 3611 | base_ = index(); |
| 3612 | offset_ = 0; |
| 3613 | scale_ = 0; |
| 3614 | return false; |
| 3615 | } |
| 3616 | } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3617 | |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 3618 | virtual Representation RequiredInputRepresentation(int arg_index) { |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3619 | return representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3620 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3621 | virtual Representation observed_input_representation(int index) { |
| 3622 | return Representation::Integer32(); |
| 3623 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3624 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3625 | virtual bool IsRelationTrueInternal(NumericRelation relation, |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3626 | HValue* related_value, |
| 3627 | int offset = 0, |
| 3628 | int scale = 0); |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3629 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 3630 | virtual void PrintDataTo(StringStream* stream); |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3631 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 3632 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3633 | HValue* index() { return OperandAt(0); } |
| 3634 | HValue* length() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3635 | |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3636 | virtual int RedefinedOperandIndex() { return 0; } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 3637 | virtual bool IsPurelyInformativeDefinition() { return skip_check(); } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3638 | virtual void AddInformativeDefinitions(); |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 3639 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3640 | DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3641 | |
| 3642 | protected: |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3643 | friend class HBoundsCheckBaseIndexInformation; |
| 3644 | |
| 3645 | virtual void SetResponsibilityForRange(RangeGuaranteeDirection direction) { |
| 3646 | responsibility_direction_ = static_cast<RangeGuaranteeDirection>( |
| 3647 | responsibility_direction_ | direction); |
| 3648 | } |
| 3649 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3650 | virtual bool DataEquals(HValue* other) { return true; } |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3651 | virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context); |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 3652 | BoundsCheckKeyMode key_mode_; |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3653 | bool skip_check_; |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 3654 | HValue* base_; |
| 3655 | int offset_; |
| 3656 | int scale_; |
| 3657 | RangeGuaranteeDirection responsibility_direction_; |
| 3658 | }; |
| 3659 | |
| 3660 | |
| 3661 | class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> { |
| 3662 | public: |
| 3663 | explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) { |
| 3664 | DecompositionResult decomposition; |
| 3665 | if (check->index()->TryDecompose(&decomposition)) { |
| 3666 | SetOperandAt(0, decomposition.base()); |
| 3667 | SetOperandAt(1, check); |
| 3668 | } else { |
| 3669 | UNREACHABLE(); |
| 3670 | } |
| 3671 | } |
| 3672 | |
| 3673 | HValue* base_index() { return OperandAt(0); } |
| 3674 | HBoundsCheck* bounds_check() { return HBoundsCheck::cast(OperandAt(1)); } |
| 3675 | |
| 3676 | DECLARE_CONCRETE_INSTRUCTION(BoundsCheckBaseIndexInformation) |
| 3677 | |
| 3678 | virtual Representation RequiredInputRepresentation(int arg_index) { |
| 3679 | return representation(); |
| 3680 | } |
| 3681 | |
| 3682 | virtual bool IsRelationTrueInternal(NumericRelation relation, |
| 3683 | HValue* related_value, |
| 3684 | int offset = 0, |
| 3685 | int scale = 0); |
| 3686 | virtual void PrintDataTo(StringStream* stream); |
| 3687 | |
| 3688 | virtual int RedefinedOperandIndex() { return 0; } |
| 3689 | virtual bool IsPurelyInformativeDefinition() { return true; } |
| 3690 | |
| 3691 | protected: |
| 3692 | virtual void SetResponsibilityForRange(RangeGuaranteeDirection direction) { |
| 3693 | bounds_check()->SetResponsibilityForRange(direction); |
| 3694 | } |
| 3695 | virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context) { |
| 3696 | bounds_check()->TryGuaranteeRangeChanging(context); |
| 3697 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3698 | }; |
| 3699 | |
| 3700 | |
| 3701 | class HBitwiseBinaryOperation: public HBinaryOperation { |
| 3702 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3703 | HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 3704 | : HBinaryOperation(context, left, right) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3705 | SetFlag(kFlexibleRepresentation); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3706 | SetFlag(kTruncatingToInt32); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3707 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3708 | } |
| 3709 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3710 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3711 | return index == 0 |
| 3712 | ? Representation::Tagged() |
| 3713 | : representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3714 | } |
| 3715 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3716 | virtual void RepresentationChanged(Representation to) { |
| 3717 | if (!to.IsTagged()) { |
| 3718 | ASSERT(to.IsInteger32()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3719 | ClearAllSideEffects(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3720 | SetFlag(kUseGVN); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3721 | } else { |
| 3722 | SetAllSideEffects(); |
| 3723 | ClearFlag(kUseGVN); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3724 | } |
| 3725 | } |
| 3726 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3727 | virtual void UpdateRepresentation(Representation new_rep, |
| 3728 | HInferRepresentation* h_infer, |
| 3729 | const char* reason) { |
| 3730 | // We only generate either int32 or generic tagged bitwise operations. |
| 3731 | if (new_rep.IsDouble()) new_rep = Representation::Integer32(); |
| 3732 | HValue::UpdateRepresentation(new_rep, h_infer, reason); |
| 3733 | } |
| 3734 | |
| 3735 | virtual void initialize_output_representation(Representation observed) { |
| 3736 | if (observed.IsDouble()) observed = Representation::Integer32(); |
| 3737 | HBinaryOperation::initialize_output_representation(observed); |
| 3738 | } |
| 3739 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3740 | virtual HType CalculateInferredType(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3741 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3742 | DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 3743 | |
| 3744 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3745 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3746 | }; |
| 3747 | |
| 3748 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 3749 | class HMathFloorOfDiv: public HBinaryOperation { |
| 3750 | public: |
| 3751 | HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) |
| 3752 | : HBinaryOperation(context, left, right) { |
| 3753 | set_representation(Representation::Integer32()); |
| 3754 | SetFlag(kUseGVN); |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 3755 | SetFlag(kCanOverflow); |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 3756 | if (!right->IsConstant()) { |
| 3757 | SetFlag(kCanBeDivByZero); |
| 3758 | } |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 3759 | } |
| 3760 | |
yangguo@chromium.org | d2899aa | 2012-06-21 11:16:20 +0000 | [diff] [blame] | 3761 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3762 | |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 3763 | virtual Representation RequiredInputRepresentation(int index) { |
| 3764 | return Representation::Integer32(); |
| 3765 | } |
| 3766 | |
| 3767 | DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) |
| 3768 | |
| 3769 | protected: |
| 3770 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3771 | |
| 3772 | private: |
| 3773 | virtual bool IsDeletable() const { return true; } |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 3774 | }; |
| 3775 | |
| 3776 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3777 | class HArithmeticBinaryOperation: public HBinaryOperation { |
| 3778 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3779 | HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
| 3780 | : HBinaryOperation(context, left, right) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3781 | SetAllSideEffects(); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3782 | SetFlag(kFlexibleRepresentation); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3783 | } |
| 3784 | |
| 3785 | virtual void RepresentationChanged(Representation to) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3786 | if (to.IsTagged()) { |
| 3787 | SetAllSideEffects(); |
| 3788 | ClearFlag(kUseGVN); |
| 3789 | } else { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3790 | ClearAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3791 | SetFlag(kUseGVN); |
| 3792 | } |
| 3793 | } |
| 3794 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3795 | virtual HType CalculateInferredType(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3796 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3797 | return index == 0 |
| 3798 | ? Representation::Tagged() |
| 3799 | : representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3800 | } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3801 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 3802 | virtual HValue* Canonicalize(); |
| 3803 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 3804 | private: |
| 3805 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3806 | }; |
| 3807 | |
| 3808 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3809 | class HCompareGeneric: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3810 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3811 | HCompareGeneric(HValue* context, |
| 3812 | HValue* left, |
| 3813 | HValue* right, |
| 3814 | Token::Value token) |
| 3815 | : HBinaryOperation(context, left, right), token_(token) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3816 | ASSERT(Token::IsCompareOp(token)); |
| 3817 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3818 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3819 | } |
| 3820 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3821 | virtual Representation RequiredInputRepresentation(int index) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3822 | return index == 0 |
| 3823 | ? Representation::Tagged() |
| 3824 | : representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3825 | } |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3826 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3827 | Token::Value token() const { return token_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3828 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3829 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3830 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3831 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3832 | DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) |
| 3833 | |
| 3834 | private: |
| 3835 | Token::Value token_; |
| 3836 | }; |
| 3837 | |
| 3838 | |
| 3839 | class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> { |
| 3840 | public: |
| 3841 | HCompareIDAndBranch(HValue* left, HValue* right, Token::Value token) |
| 3842 | : token_(token) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3843 | SetFlag(kFlexibleRepresentation); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3844 | ASSERT(Token::IsCompareOp(token)); |
| 3845 | SetOperandAt(0, left); |
| 3846 | SetOperandAt(1, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3847 | } |
| 3848 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3849 | HValue* left() { return OperandAt(0); } |
| 3850 | HValue* right() { return OperandAt(1); } |
| 3851 | Token::Value token() const { return token_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3852 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3853 | void set_observed_input_representation(Representation left, |
| 3854 | Representation right) { |
| 3855 | observed_input_representation_[0] = left; |
| 3856 | observed_input_representation_[1] = right; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3857 | } |
| 3858 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3859 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 3860 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3861 | virtual Representation RequiredInputRepresentation(int index) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3862 | return representation(); |
| 3863 | } |
| 3864 | virtual Representation observed_input_representation(int index) { |
| 3865 | return observed_input_representation_[index]; |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3866 | } |
| 3867 | virtual void PrintDataTo(StringStream* stream); |
| 3868 | |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 3869 | virtual void AddInformativeDefinitions(); |
| 3870 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3871 | DECLARE_CONCRETE_INSTRUCTION(CompareIDAndBranch) |
| 3872 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3873 | private: |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3874 | Representation observed_input_representation_[2]; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3875 | Token::Value token_; |
| 3876 | }; |
| 3877 | |
| 3878 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3879 | class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3880 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3881 | HCompareObjectEqAndBranch(HValue* left, HValue* right) { |
| 3882 | SetOperandAt(0, left); |
| 3883 | SetOperandAt(1, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3884 | } |
| 3885 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3886 | HValue* left() { return OperandAt(0); } |
| 3887 | HValue* right() { return OperandAt(1); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3888 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3889 | virtual void PrintDataTo(StringStream* stream); |
| 3890 | |
| 3891 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3892 | return Representation::Tagged(); |
| 3893 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3894 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 3895 | virtual Representation observed_input_representation(int index) { |
| 3896 | return Representation::Tagged(); |
| 3897 | } |
| 3898 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3899 | DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3900 | }; |
| 3901 | |
| 3902 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3903 | class HCompareConstantEqAndBranch: public HUnaryControlInstruction { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3904 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3905 | HCompareConstantEqAndBranch(HValue* left, int right, Token::Value op) |
| 3906 | : HUnaryControlInstruction(left, NULL, NULL), op_(op), right_(right) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3907 | ASSERT(op == Token::EQ_STRICT); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3908 | } |
| 3909 | |
| 3910 | Token::Value op() const { return op_; } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 3911 | HValue* left() { return value(); } |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3912 | int right() const { return right_; } |
| 3913 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3914 | virtual Representation RequiredInputRepresentation(int index) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3915 | return Representation::Integer32(); |
| 3916 | } |
| 3917 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3918 | DECLARE_CONCRETE_INSTRUCTION(CompareConstantEqAndBranch); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3919 | |
| 3920 | private: |
| 3921 | const Token::Value op_; |
| 3922 | const int right_; |
| 3923 | }; |
| 3924 | |
| 3925 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3926 | class HIsNilAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3927 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3928 | HIsNilAndBranch(HValue* value, EqualityKind kind, NilValue nil) |
| 3929 | : HUnaryControlInstruction(value, NULL, NULL), kind_(kind), nil_(nil) { } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3930 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3931 | EqualityKind kind() const { return kind_; } |
| 3932 | NilValue nil() const { return nil_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3933 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3934 | virtual void PrintDataTo(StringStream* stream); |
| 3935 | |
| 3936 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3937 | return Representation::Tagged(); |
| 3938 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 3939 | virtual Representation observed_input_representation(int index) { |
| 3940 | return Representation::Tagged(); |
| 3941 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3942 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3943 | DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch) |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3944 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3945 | private: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3946 | EqualityKind kind_; |
| 3947 | NilValue nil_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3948 | }; |
| 3949 | |
| 3950 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3951 | class HIsObjectAndBranch: public HUnaryControlInstruction { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3952 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3953 | explicit HIsObjectAndBranch(HValue* value) |
| 3954 | : HUnaryControlInstruction(value, NULL, NULL) { } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 3955 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3956 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3957 | return Representation::Tagged(); |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 3958 | } |
| 3959 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3960 | DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) |
| 3961 | }; |
| 3962 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 3963 | class HIsStringAndBranch: public HUnaryControlInstruction { |
| 3964 | public: |
| 3965 | explicit HIsStringAndBranch(HValue* value) |
| 3966 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3967 | |
| 3968 | virtual Representation RequiredInputRepresentation(int index) { |
| 3969 | return Representation::Tagged(); |
| 3970 | } |
| 3971 | |
| 3972 | DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch) |
| 3973 | }; |
| 3974 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3975 | |
| 3976 | class HIsSmiAndBranch: public HUnaryControlInstruction { |
| 3977 | public: |
| 3978 | explicit HIsSmiAndBranch(HValue* value) |
| 3979 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3980 | |
| 3981 | DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) |
| 3982 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3983 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3984 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3985 | } |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 3986 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3987 | protected: |
| 3988 | virtual bool DataEquals(HValue* other) { return true; } |
| 3989 | }; |
| 3990 | |
| 3991 | |
| 3992 | class HIsUndetectableAndBranch: public HUnaryControlInstruction { |
| 3993 | public: |
| 3994 | explicit HIsUndetectableAndBranch(HValue* value) |
| 3995 | : HUnaryControlInstruction(value, NULL, NULL) { } |
| 3996 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3997 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3998 | return Representation::Tagged(); |
| 3999 | } |
| 4000 | |
| 4001 | DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) |
| 4002 | }; |
| 4003 | |
| 4004 | |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 4005 | class HStringCompareAndBranch: public HTemplateControlInstruction<2, 3> { |
| 4006 | public: |
| 4007 | HStringCompareAndBranch(HValue* context, |
| 4008 | HValue* left, |
| 4009 | HValue* right, |
| 4010 | Token::Value token) |
| 4011 | : token_(token) { |
| 4012 | ASSERT(Token::IsCompareOp(token)); |
| 4013 | SetOperandAt(0, context); |
| 4014 | SetOperandAt(1, left); |
| 4015 | SetOperandAt(2, right); |
| 4016 | set_representation(Representation::Tagged()); |
| 4017 | } |
| 4018 | |
| 4019 | HValue* context() { return OperandAt(0); } |
| 4020 | HValue* left() { return OperandAt(1); } |
| 4021 | HValue* right() { return OperandAt(2); } |
| 4022 | Token::Value token() const { return token_; } |
| 4023 | |
| 4024 | virtual void PrintDataTo(StringStream* stream); |
| 4025 | |
| 4026 | virtual Representation RequiredInputRepresentation(int index) { |
| 4027 | return Representation::Tagged(); |
| 4028 | } |
| 4029 | |
| 4030 | Representation GetInputRepresentation() const { |
| 4031 | return Representation::Tagged(); |
| 4032 | } |
| 4033 | |
| 4034 | DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch) |
| 4035 | |
| 4036 | private: |
| 4037 | Token::Value token_; |
| 4038 | }; |
| 4039 | |
| 4040 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4041 | class HIsConstructCallAndBranch: public HTemplateControlInstruction<2, 0> { |
| 4042 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4043 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4044 | return Representation::None(); |
| 4045 | } |
| 4046 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4047 | DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch) |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 4048 | }; |
| 4049 | |
| 4050 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4051 | class HHasInstanceTypeAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4052 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4053 | HHasInstanceTypeAndBranch(HValue* value, InstanceType type) |
| 4054 | : HUnaryControlInstruction(value, NULL, NULL), from_(type), to_(type) { } |
| 4055 | HHasInstanceTypeAndBranch(HValue* value, InstanceType from, InstanceType to) |
| 4056 | : HUnaryControlInstruction(value, NULL, NULL), from_(from), to_(to) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4057 | ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. |
| 4058 | } |
| 4059 | |
| 4060 | InstanceType from() { return from_; } |
| 4061 | InstanceType to() { return to_; } |
| 4062 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4063 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4064 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4065 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4066 | return Representation::Tagged(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4067 | } |
| 4068 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4069 | DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch) |
| 4070 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4071 | private: |
| 4072 | InstanceType from_; |
| 4073 | InstanceType to_; // Inclusive range, not all combinations work. |
| 4074 | }; |
| 4075 | |
| 4076 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4077 | class HHasCachedArrayIndexAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4078 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4079 | explicit HHasCachedArrayIndexAndBranch(HValue* value) |
| 4080 | : HUnaryControlInstruction(value, NULL, NULL) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4081 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4082 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4083 | return Representation::Tagged(); |
| 4084 | } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4085 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4086 | DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4087 | }; |
| 4088 | |
| 4089 | |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4090 | class HGetCachedArrayIndex: public HUnaryOperation { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4091 | public: |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4092 | explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) { |
| 4093 | set_representation(Representation::Tagged()); |
| 4094 | SetFlag(kUseGVN); |
| 4095 | } |
| 4096 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4097 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4098 | return Representation::Tagged(); |
| 4099 | } |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4100 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4101 | DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex) |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4102 | |
| 4103 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4104 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4105 | |
| 4106 | private: |
| 4107 | virtual bool IsDeletable() const { return true; } |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4108 | }; |
| 4109 | |
| 4110 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4111 | class HClassOfTestAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4112 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4113 | HClassOfTestAndBranch(HValue* value, Handle<String> class_name) |
| 4114 | : HUnaryControlInstruction(value, NULL, NULL), |
| 4115 | class_name_(class_name) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4116 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4117 | DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch) |
| 4118 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4119 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4120 | return Representation::Tagged(); |
| 4121 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4122 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4123 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4124 | |
| 4125 | Handle<String> class_name() const { return class_name_; } |
| 4126 | |
| 4127 | private: |
| 4128 | Handle<String> class_name_; |
| 4129 | }; |
| 4130 | |
| 4131 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4132 | class HTypeofIsAndBranch: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4133 | public: |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4134 | HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) |
| 4135 | : HUnaryControlInstruction(value, NULL, NULL), |
| 4136 | type_literal_(type_literal) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4137 | |
| 4138 | Handle<String> type_literal() { return type_literal_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4139 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4140 | |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4141 | DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4142 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4143 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4144 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4145 | } |
| 4146 | |
| 4147 | private: |
| 4148 | Handle<String> type_literal_; |
| 4149 | }; |
| 4150 | |
| 4151 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4152 | class HInstanceOf: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4153 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4154 | HInstanceOf(HValue* context, HValue* left, HValue* right) |
| 4155 | : HBinaryOperation(context, left, right) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4156 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4157 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4158 | } |
| 4159 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4160 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4161 | return Representation::Tagged(); |
| 4162 | } |
| 4163 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4164 | virtual HType CalculateInferredType(); |
| 4165 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4166 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4167 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4168 | DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4169 | }; |
| 4170 | |
| 4171 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4172 | class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4173 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4174 | HInstanceOfKnownGlobal(HValue* context, |
| 4175 | HValue* left, |
| 4176 | Handle<JSFunction> right) |
| 4177 | : function_(right) { |
| 4178 | SetOperandAt(0, context); |
| 4179 | SetOperandAt(1, left); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4180 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4181 | SetAllSideEffects(); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4182 | } |
| 4183 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4184 | HValue* context() { return OperandAt(0); } |
| 4185 | HValue* left() { return OperandAt(1); } |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4186 | Handle<JSFunction> function() { return function_; } |
| 4187 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4188 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4189 | return Representation::Tagged(); |
| 4190 | } |
| 4191 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 4192 | virtual HType CalculateInferredType(); |
| 4193 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4194 | DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 4195 | |
| 4196 | private: |
| 4197 | Handle<JSFunction> function_; |
| 4198 | }; |
| 4199 | |
| 4200 | |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 4201 | // TODO(mstarzinger): This instruction should be modeled as a load of the map |
| 4202 | // field followed by a load of the instance size field once HLoadNamedField is |
| 4203 | // flexible enough to accommodate byte-field loads. |
| 4204 | class HInstanceSize: public HTemplateInstruction<1> { |
| 4205 | public: |
| 4206 | explicit HInstanceSize(HValue* object) { |
| 4207 | SetOperandAt(0, object); |
| 4208 | set_representation(Representation::Integer32()); |
| 4209 | } |
| 4210 | |
| 4211 | HValue* object() { return OperandAt(0); } |
| 4212 | |
| 4213 | virtual Representation RequiredInputRepresentation(int index) { |
| 4214 | return Representation::Tagged(); |
| 4215 | } |
| 4216 | |
| 4217 | DECLARE_CONCRETE_INSTRUCTION(InstanceSize) |
| 4218 | }; |
| 4219 | |
| 4220 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4221 | class HPower: public HTemplateInstruction<2> { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4222 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4223 | static HInstruction* New(Zone* zone, HValue* left, HValue* right); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4224 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4225 | HValue* left() { return OperandAt(0); } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4226 | HValue* right() const { return OperandAt(1); } |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4227 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4228 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4229 | return index == 0 |
| 4230 | ? Representation::Double() |
| 4231 | : Representation::None(); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4232 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4233 | virtual Representation observed_input_representation(int index) { |
| 4234 | return RequiredInputRepresentation(index); |
| 4235 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4236 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4237 | DECLARE_CONCRETE_INSTRUCTION(Power) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4238 | |
| 4239 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4240 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4241 | |
| 4242 | private: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4243 | HPower(HValue* left, HValue* right) { |
| 4244 | SetOperandAt(0, left); |
| 4245 | SetOperandAt(1, right); |
| 4246 | set_representation(Representation::Double()); |
| 4247 | SetFlag(kUseGVN); |
| 4248 | SetGVNFlag(kChangesNewSpacePromotion); |
| 4249 | } |
| 4250 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4251 | virtual bool IsDeletable() const { |
| 4252 | return !right()->representation().IsTagged(); |
| 4253 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4254 | }; |
| 4255 | |
| 4256 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 4257 | class HRandom: public HTemplateInstruction<1> { |
| 4258 | public: |
| 4259 | explicit HRandom(HValue* global_object) { |
| 4260 | SetOperandAt(0, global_object); |
| 4261 | set_representation(Representation::Double()); |
| 4262 | } |
| 4263 | |
| 4264 | HValue* global_object() { return OperandAt(0); } |
| 4265 | |
| 4266 | virtual Representation RequiredInputRepresentation(int index) { |
| 4267 | return Representation::Tagged(); |
| 4268 | } |
| 4269 | |
| 4270 | DECLARE_CONCRETE_INSTRUCTION(Random) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4271 | |
| 4272 | private: |
| 4273 | virtual bool IsDeletable() const { return true; } |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 4274 | }; |
| 4275 | |
| 4276 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4277 | class HAdd: public HArithmeticBinaryOperation { |
| 4278 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4279 | static HInstruction* New(Zone* zone, |
| 4280 | HValue* context, |
| 4281 | HValue* left, |
| 4282 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4283 | |
| 4284 | // Add is only commutative if two integer values are added and not if two |
| 4285 | // tagged values are added (because it might be a String concatenation). |
| 4286 | virtual bool IsCommutative() const { |
| 4287 | return !representation().IsTagged(); |
| 4288 | } |
| 4289 | |
| 4290 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 4291 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4292 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4293 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4294 | virtual HValue* Canonicalize(); |
| 4295 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4296 | virtual bool TryDecompose(DecompositionResult* decomposition) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4297 | if (left()->IsInteger32Constant()) { |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4298 | decomposition->Apply(right(), left()->GetInteger32Constant()); |
| 4299 | return true; |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4300 | } else if (right()->IsInteger32Constant()) { |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4301 | decomposition->Apply(left(), right()->GetInteger32Constant()); |
| 4302 | return true; |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4303 | } else { |
| 4304 | return false; |
| 4305 | } |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4306 | } |
| 4307 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4308 | DECLARE_CONCRETE_INSTRUCTION(Add) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4309 | |
| 4310 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4311 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4312 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4313 | virtual Range* InferRange(Zone* zone); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4314 | |
| 4315 | private: |
| 4316 | HAdd(HValue* context, HValue* left, HValue* right) |
| 4317 | : HArithmeticBinaryOperation(context, left, right) { |
| 4318 | SetFlag(kCanOverflow); |
| 4319 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4320 | }; |
| 4321 | |
| 4322 | |
| 4323 | class HSub: public HArithmeticBinaryOperation { |
| 4324 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4325 | static HInstruction* New(Zone* zone, |
| 4326 | HValue* context, |
| 4327 | HValue* left, |
| 4328 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4329 | |
| 4330 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 4331 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4332 | virtual HValue* Canonicalize(); |
| 4333 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4334 | virtual bool TryDecompose(DecompositionResult* decomposition) { |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4335 | if (right()->IsInteger32Constant()) { |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4336 | decomposition->Apply(left(), -right()->GetInteger32Constant()); |
| 4337 | return true; |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 4338 | } else { |
| 4339 | return false; |
| 4340 | } |
| 4341 | } |
| 4342 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4343 | DECLARE_CONCRETE_INSTRUCTION(Sub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4344 | |
| 4345 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4346 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4347 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4348 | virtual Range* InferRange(Zone* zone); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4349 | |
| 4350 | private: |
| 4351 | HSub(HValue* context, HValue* left, HValue* right) |
| 4352 | : HArithmeticBinaryOperation(context, left, right) { |
| 4353 | SetFlag(kCanOverflow); |
| 4354 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4355 | }; |
| 4356 | |
| 4357 | |
| 4358 | class HMul: public HArithmeticBinaryOperation { |
| 4359 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4360 | static HInstruction* New(Zone* zone, |
| 4361 | HValue* context, |
| 4362 | HValue* left, |
| 4363 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4364 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 4365 | static HInstruction* NewImul(Zone* zone, |
| 4366 | HValue* context, |
| 4367 | HValue* left, |
| 4368 | HValue* right) { |
| 4369 | HMul* mul = new(zone) HMul(context, left, right); |
| 4370 | // TODO(mstarzinger): Prevent bailout on minus zero for imul. |
| 4371 | mul->AssumeRepresentation(Representation::Integer32()); |
| 4372 | mul->ClearFlag(HValue::kCanOverflow); |
| 4373 | return mul; |
| 4374 | } |
| 4375 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4376 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 4377 | |
mstarzinger@chromium.org | b228be0 | 2013-04-18 14:56:59 +0000 | [diff] [blame] | 4378 | virtual HValue* Canonicalize(); |
| 4379 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4380 | // Only commutative if it is certain that not two objects are multiplicated. |
| 4381 | virtual bool IsCommutative() const { |
| 4382 | return !representation().IsTagged(); |
| 4383 | } |
| 4384 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4385 | DECLARE_CONCRETE_INSTRUCTION(Mul) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4386 | |
| 4387 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4388 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4389 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4390 | virtual Range* InferRange(Zone* zone); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4391 | |
| 4392 | private: |
| 4393 | HMul(HValue* context, HValue* left, HValue* right) |
| 4394 | : HArithmeticBinaryOperation(context, left, right) { |
| 4395 | SetFlag(kCanOverflow); |
| 4396 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4397 | }; |
| 4398 | |
| 4399 | |
| 4400 | class HMod: public HArithmeticBinaryOperation { |
| 4401 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4402 | static HInstruction* New(Zone* zone, |
| 4403 | HValue* context, |
| 4404 | HValue* left, |
| 4405 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4406 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 4407 | bool HasPowerOf2Divisor() { |
| 4408 | if (right()->IsConstant() && |
| 4409 | HConstant::cast(right())->HasInteger32Value()) { |
| 4410 | int32_t value = HConstant::cast(right())->Integer32Value(); |
| 4411 | return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
| 4412 | } |
| 4413 | |
| 4414 | return false; |
| 4415 | } |
| 4416 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4417 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 4418 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4419 | DECLARE_CONCRETE_INSTRUCTION(Mod) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4420 | |
| 4421 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4422 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4423 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4424 | virtual Range* InferRange(Zone* zone); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4425 | |
| 4426 | private: |
| 4427 | HMod(HValue* context, HValue* left, HValue* right) |
| 4428 | : HArithmeticBinaryOperation(context, left, right) { |
| 4429 | SetFlag(kCanBeDivByZero); |
| 4430 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4431 | }; |
| 4432 | |
| 4433 | |
| 4434 | class HDiv: public HArithmeticBinaryOperation { |
| 4435 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4436 | static HInstruction* New(Zone* zone, |
| 4437 | HValue* context, |
| 4438 | HValue* left, |
| 4439 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4440 | |
jkummerow@chromium.org | 5323a9c | 2012-12-10 19:00:50 +0000 | [diff] [blame] | 4441 | bool HasPowerOf2Divisor() { |
| 4442 | if (right()->IsConstant() && |
| 4443 | HConstant::cast(right())->HasInteger32Value()) { |
| 4444 | int32_t value = HConstant::cast(right())->Integer32Value(); |
| 4445 | return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
| 4446 | } |
| 4447 | |
| 4448 | return false; |
| 4449 | } |
| 4450 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4451 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 4452 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4453 | DECLARE_CONCRETE_INSTRUCTION(Div) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4454 | |
| 4455 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4456 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4457 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4458 | virtual Range* InferRange(Zone* zone); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4459 | |
| 4460 | private: |
| 4461 | HDiv(HValue* context, HValue* left, HValue* right) |
| 4462 | : HArithmeticBinaryOperation(context, left, right) { |
| 4463 | SetFlag(kCanBeDivByZero); |
| 4464 | SetFlag(kCanOverflow); |
| 4465 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4466 | }; |
| 4467 | |
| 4468 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4469 | class HMathMinMax: public HArithmeticBinaryOperation { |
| 4470 | public: |
| 4471 | enum Operation { kMathMin, kMathMax }; |
| 4472 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4473 | static HInstruction* New(Zone* zone, |
| 4474 | HValue* context, |
| 4475 | HValue* left, |
| 4476 | HValue* right, |
| 4477 | Operation op); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4478 | |
| 4479 | virtual Representation RequiredInputRepresentation(int index) { |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4480 | return index == 0 ? Representation::Tagged() |
| 4481 | : representation(); |
| 4482 | } |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4483 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4484 | virtual Representation observed_input_representation(int index) { |
| 4485 | return RequiredInputRepresentation(index); |
| 4486 | } |
| 4487 | |
jkummerow@chromium.org | 5323a9c | 2012-12-10 19:00:50 +0000 | [diff] [blame] | 4488 | virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 4489 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4490 | virtual Representation RepresentationFromInputs() { |
| 4491 | Representation left_rep = left()->representation(); |
| 4492 | Representation right_rep = right()->representation(); |
| 4493 | if ((left_rep.IsNone() || left_rep.IsInteger32()) && |
| 4494 | (right_rep.IsNone() || right_rep.IsInteger32())) { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4495 | return Representation::Integer32(); |
| 4496 | } |
| 4497 | return Representation::Double(); |
| 4498 | } |
| 4499 | |
| 4500 | virtual bool IsCommutative() const { return true; } |
| 4501 | |
| 4502 | Operation operation() { return operation_; } |
| 4503 | |
| 4504 | DECLARE_CONCRETE_INSTRUCTION(MathMinMax) |
| 4505 | |
| 4506 | protected: |
| 4507 | virtual bool DataEquals(HValue* other) { |
| 4508 | return other->IsMathMinMax() && |
| 4509 | HMathMinMax::cast(other)->operation_ == operation_; |
| 4510 | } |
| 4511 | |
| 4512 | virtual Range* InferRange(Zone* zone); |
| 4513 | |
| 4514 | private: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4515 | HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
| 4516 | : HArithmeticBinaryOperation(context, left, right), |
| 4517 | operation_(op) { } |
| 4518 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4519 | Operation operation_; |
| 4520 | }; |
| 4521 | |
| 4522 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4523 | class HBitwise: public HBitwiseBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4524 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4525 | static HInstruction* New(Zone* zone, |
| 4526 | Token::Value op, |
| 4527 | HValue* context, |
| 4528 | HValue* left, |
| 4529 | HValue* right); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4530 | |
| 4531 | Token::Value op() const { return op_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4532 | |
| 4533 | virtual bool IsCommutative() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4534 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 4535 | virtual HValue* Canonicalize(); |
| 4536 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 4537 | virtual void PrintDataTo(StringStream* stream); |
| 4538 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4539 | DECLARE_CONCRETE_INSTRUCTION(Bitwise) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4540 | |
| 4541 | protected: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4542 | virtual bool DataEquals(HValue* other) { |
| 4543 | return op() == HBitwise::cast(other)->op(); |
| 4544 | } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4545 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4546 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4547 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4548 | private: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4549 | HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) |
| 4550 | : HBitwiseBinaryOperation(context, left, right), op_(op) { |
| 4551 | ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); |
| 4552 | } |
| 4553 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4554 | Token::Value op_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4555 | }; |
| 4556 | |
| 4557 | |
| 4558 | class HShl: public HBitwiseBinaryOperation { |
| 4559 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4560 | static HInstruction* New(Zone* zone, |
| 4561 | HValue* context, |
| 4562 | HValue* left, |
| 4563 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4564 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4565 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4566 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4567 | DECLARE_CONCRETE_INSTRUCTION(Shl) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4568 | |
| 4569 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4570 | virtual bool DataEquals(HValue* other) { return true; } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4571 | |
| 4572 | private: |
| 4573 | HShl(HValue* context, HValue* left, HValue* right) |
| 4574 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4575 | }; |
| 4576 | |
| 4577 | |
| 4578 | class HShr: public HBitwiseBinaryOperation { |
| 4579 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4580 | static HInstruction* New(Zone* zone, |
| 4581 | HValue* context, |
| 4582 | HValue* left, |
| 4583 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4584 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4585 | virtual bool TryDecompose(DecompositionResult* decomposition) { |
| 4586 | if (right()->IsInteger32Constant()) { |
| 4587 | if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { |
| 4588 | // This is intended to look for HAdd and HSub, to handle compounds |
| 4589 | // like ((base + offset) >> scale) with one single decomposition. |
| 4590 | left()->TryDecompose(decomposition); |
| 4591 | return true; |
| 4592 | } |
| 4593 | } |
| 4594 | return false; |
| 4595 | } |
| 4596 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4597 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4598 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4599 | DECLARE_CONCRETE_INSTRUCTION(Shr) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4600 | |
| 4601 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4602 | virtual bool DataEquals(HValue* other) { return true; } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4603 | |
| 4604 | private: |
| 4605 | HShr(HValue* context, HValue* left, HValue* right) |
| 4606 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4607 | }; |
| 4608 | |
| 4609 | |
| 4610 | class HSar: public HBitwiseBinaryOperation { |
| 4611 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4612 | static HInstruction* New(Zone* zone, |
| 4613 | HValue* context, |
| 4614 | HValue* left, |
| 4615 | HValue* right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4616 | |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 4617 | virtual bool TryDecompose(DecompositionResult* decomposition) { |
| 4618 | if (right()->IsInteger32Constant()) { |
| 4619 | if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { |
| 4620 | // This is intended to look for HAdd and HSub, to handle compounds |
| 4621 | // like ((base + offset) >> scale) with one single decomposition. |
| 4622 | left()->TryDecompose(decomposition); |
| 4623 | return true; |
| 4624 | } |
| 4625 | } |
| 4626 | return false; |
| 4627 | } |
| 4628 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 4629 | virtual Range* InferRange(Zone* zone); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4630 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4631 | DECLARE_CONCRETE_INSTRUCTION(Sar) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4632 | |
| 4633 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4634 | virtual bool DataEquals(HValue* other) { return true; } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4635 | |
| 4636 | private: |
| 4637 | HSar(HValue* context, HValue* left, HValue* right) |
| 4638 | : HBitwiseBinaryOperation(context, left, right) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4639 | }; |
| 4640 | |
| 4641 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 4642 | class HRor: public HBitwiseBinaryOperation { |
| 4643 | public: |
| 4644 | HRor(HValue* context, HValue* left, HValue* right) |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 4645 | : HBitwiseBinaryOperation(context, left, right) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 4646 | ChangeRepresentation(Representation::Integer32()); |
| 4647 | } |
| 4648 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 4649 | DECLARE_CONCRETE_INSTRUCTION(Ror) |
| 4650 | |
| 4651 | protected: |
| 4652 | virtual bool DataEquals(HValue* other) { return true; } |
| 4653 | }; |
| 4654 | |
| 4655 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4656 | class HOsrEntry: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4657 | public: |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4658 | explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4659 | SetGVNFlag(kChangesOsrEntries); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4660 | } |
| 4661 | |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4662 | BailoutId ast_id() const { return ast_id_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4663 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4664 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4665 | return Representation::None(); |
| 4666 | } |
| 4667 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4668 | DECLARE_CONCRETE_INSTRUCTION(OsrEntry) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4669 | |
| 4670 | private: |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4671 | BailoutId ast_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4672 | }; |
| 4673 | |
| 4674 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4675 | class HParameter: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4676 | public: |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 4677 | enum ParameterKind { |
| 4678 | STACK_PARAMETER, |
| 4679 | REGISTER_PARAMETER |
| 4680 | }; |
| 4681 | |
| 4682 | explicit HParameter(unsigned index, |
| 4683 | ParameterKind kind = STACK_PARAMETER) |
| 4684 | : index_(index), |
| 4685 | kind_(kind) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4686 | set_representation(Representation::Tagged()); |
| 4687 | } |
| 4688 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 4689 | explicit HParameter(unsigned index, |
| 4690 | ParameterKind kind, |
| 4691 | Representation r) |
| 4692 | : index_(index), |
| 4693 | kind_(kind) { |
| 4694 | set_representation(r); |
| 4695 | } |
| 4696 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4697 | unsigned index() const { return index_; } |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 4698 | ParameterKind kind() const { return kind_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4699 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4700 | virtual void PrintDataTo(StringStream* stream); |
| 4701 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4702 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4703 | return Representation::None(); |
| 4704 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4705 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4706 | DECLARE_CONCRETE_INSTRUCTION(Parameter) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4707 | |
| 4708 | private: |
| 4709 | unsigned index_; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 4710 | ParameterKind kind_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4711 | }; |
| 4712 | |
| 4713 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4714 | class HCallStub: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4715 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4716 | HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) |
| 4717 | : HUnaryCall(context, argument_count), |
| 4718 | major_key_(major_key), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4719 | transcendental_type_(TranscendentalCache::kNumberOfCaches) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4720 | } |
| 4721 | |
| 4722 | CodeStub::Major major_key() { return major_key_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4723 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4724 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4725 | |
| 4726 | void set_transcendental_type(TranscendentalCache::Type transcendental_type) { |
| 4727 | transcendental_type_ = transcendental_type; |
| 4728 | } |
| 4729 | TranscendentalCache::Type transcendental_type() { |
| 4730 | return transcendental_type_; |
| 4731 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4732 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4733 | virtual void PrintDataTo(StringStream* stream); |
| 4734 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4735 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4736 | return Representation::Tagged(); |
| 4737 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4738 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4739 | DECLARE_CONCRETE_INSTRUCTION(CallStub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4740 | |
| 4741 | private: |
| 4742 | CodeStub::Major major_key_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4743 | TranscendentalCache::Type transcendental_type_; |
| 4744 | }; |
| 4745 | |
| 4746 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4747 | class HUnknownOSRValue: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4748 | public: |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 4749 | HUnknownOSRValue() |
| 4750 | : incoming_value_(NULL) { |
| 4751 | set_representation(Representation::Tagged()); |
| 4752 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4753 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4754 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4755 | return Representation::None(); |
| 4756 | } |
| 4757 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 4758 | void set_incoming_value(HPhi* value) { |
| 4759 | incoming_value_ = value; |
| 4760 | } |
| 4761 | |
| 4762 | HPhi* incoming_value() { |
| 4763 | return incoming_value_; |
| 4764 | } |
| 4765 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4766 | DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 4767 | |
| 4768 | private: |
| 4769 | HPhi* incoming_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4770 | }; |
| 4771 | |
| 4772 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4773 | class HLoadGlobalCell: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4774 | public: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4775 | HLoadGlobalCell(Handle<JSGlobalPropertyCell> cell, PropertyDetails details) |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 4776 | : cell_(cell), details_(details), unique_id_() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4777 | set_representation(Representation::Tagged()); |
| 4778 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 4779 | SetGVNFlag(kDependsOnGlobalVars); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4780 | } |
| 4781 | |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 4782 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4783 | bool RequiresHoleCheck() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4784 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4785 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4786 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4787 | virtual intptr_t Hashcode() { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 4788 | return unique_id_.Hashcode(); |
| 4789 | } |
| 4790 | |
| 4791 | virtual void FinalizeUniqueValueId() { |
| 4792 | unique_id_ = UniqueValueId(cell_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4793 | } |
| 4794 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4795 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4796 | return Representation::None(); |
| 4797 | } |
| 4798 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4799 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4800 | |
| 4801 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4802 | virtual bool DataEquals(HValue* other) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4803 | HLoadGlobalCell* b = HLoadGlobalCell::cast(other); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 4804 | return unique_id_ == b->unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4805 | } |
| 4806 | |
| 4807 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 4808 | virtual bool IsDeletable() const { return !RequiresHoleCheck(); } |
| 4809 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4810 | Handle<JSGlobalPropertyCell> cell_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4811 | PropertyDetails details_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 4812 | UniqueValueId unique_id_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4813 | }; |
| 4814 | |
| 4815 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4816 | class HLoadGlobalGeneric: public HTemplateInstruction<2> { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4817 | public: |
| 4818 | HLoadGlobalGeneric(HValue* context, |
| 4819 | HValue* global_object, |
| 4820 | Handle<Object> name, |
| 4821 | bool for_typeof) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4822 | : name_(name), |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4823 | for_typeof_(for_typeof) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 4824 | SetOperandAt(0, context); |
| 4825 | SetOperandAt(1, global_object); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4826 | set_representation(Representation::Tagged()); |
| 4827 | SetAllSideEffects(); |
| 4828 | } |
| 4829 | |
| 4830 | HValue* context() { return OperandAt(0); } |
| 4831 | HValue* global_object() { return OperandAt(1); } |
| 4832 | Handle<Object> name() const { return name_; } |
| 4833 | bool for_typeof() const { return for_typeof_; } |
| 4834 | |
| 4835 | virtual void PrintDataTo(StringStream* stream); |
| 4836 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4837 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4838 | return Representation::Tagged(); |
| 4839 | } |
| 4840 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 4841 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4842 | |
| 4843 | private: |
| 4844 | Handle<Object> name_; |
| 4845 | bool for_typeof_; |
| 4846 | }; |
| 4847 | |
| 4848 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4849 | class HAllocateObject: public HTemplateInstruction<1> { |
| 4850 | public: |
| 4851 | HAllocateObject(HValue* context, Handle<JSFunction> constructor) |
| 4852 | : constructor_(constructor) { |
| 4853 | SetOperandAt(0, context); |
| 4854 | set_representation(Representation::Tagged()); |
| 4855 | SetGVNFlag(kChangesNewSpacePromotion); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 4856 | constructor_initial_map_ = constructor->has_initial_map() |
| 4857 | ? Handle<Map>(constructor->initial_map()) |
| 4858 | : Handle<Map>::null(); |
| 4859 | // If slack tracking finished, the instance size and property counts |
| 4860 | // remain unchanged so that we can allocate memory for the object. |
| 4861 | ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4862 | } |
| 4863 | |
| 4864 | // Maximum instance size for which allocations will be inlined. |
| 4865 | static const int kMaxSize = 64 * kPointerSize; |
| 4866 | |
| 4867 | HValue* context() { return OperandAt(0); } |
| 4868 | Handle<JSFunction> constructor() { return constructor_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 4869 | Handle<Map> constructor_initial_map() { return constructor_initial_map_; } |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4870 | |
| 4871 | virtual Representation RequiredInputRepresentation(int index) { |
| 4872 | return Representation::Tagged(); |
| 4873 | } |
| 4874 | virtual Handle<Map> GetMonomorphicJSObjectMap() { |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 4875 | ASSERT(!constructor_initial_map_.is_null()); |
| 4876 | return constructor_initial_map_; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4877 | } |
| 4878 | virtual HType CalculateInferredType(); |
| 4879 | |
| 4880 | DECLARE_CONCRETE_INSTRUCTION(AllocateObject) |
| 4881 | |
| 4882 | private: |
| 4883 | // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
| 4884 | // virtual bool IsDeletable() const { return true; } |
| 4885 | |
| 4886 | Handle<JSFunction> constructor_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 4887 | Handle<Map> constructor_initial_map_; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4888 | }; |
| 4889 | |
| 4890 | |
| 4891 | class HAllocate: public HTemplateInstruction<2> { |
| 4892 | public: |
| 4893 | enum Flags { |
| 4894 | CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, |
| 4895 | CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, |
| 4896 | CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, |
| 4897 | ALLOCATE_DOUBLE_ALIGNED = 1 << 3 |
| 4898 | }; |
| 4899 | |
| 4900 | HAllocate(HValue* context, HValue* size, HType type, Flags flags) |
| 4901 | : type_(type), |
| 4902 | flags_(flags) { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4903 | SetOperandAt(0, context); |
| 4904 | SetOperandAt(1, size); |
| 4905 | set_representation(Representation::Tagged()); |
| 4906 | SetGVNFlag(kChangesNewSpacePromotion); |
| 4907 | } |
| 4908 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 4909 | static Flags DefaultFlags() { |
| 4910 | return CAN_ALLOCATE_IN_NEW_SPACE; |
| 4911 | } |
| 4912 | |
| 4913 | static Flags DefaultFlags(ElementsKind kind) { |
| 4914 | Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; |
| 4915 | if (IsFastDoubleElementsKind(kind)) { |
| 4916 | flags = static_cast<HAllocate::Flags>( |
| 4917 | flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
| 4918 | } |
| 4919 | return flags; |
| 4920 | } |
| 4921 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4922 | HValue* context() { return OperandAt(0); } |
| 4923 | HValue* size() { return OperandAt(1); } |
| 4924 | |
| 4925 | virtual Representation RequiredInputRepresentation(int index) { |
| 4926 | if (index == 0) { |
| 4927 | return Representation::Tagged(); |
| 4928 | } else { |
| 4929 | return Representation::Integer32(); |
| 4930 | } |
| 4931 | } |
| 4932 | |
| 4933 | virtual HType CalculateInferredType(); |
| 4934 | |
| 4935 | bool CanAllocateInNewSpace() const { |
| 4936 | return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; |
| 4937 | } |
| 4938 | |
| 4939 | bool CanAllocateInOldDataSpace() const { |
| 4940 | return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; |
| 4941 | } |
| 4942 | |
| 4943 | bool CanAllocateInOldPointerSpace() const { |
| 4944 | return (flags_ & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) != 0; |
| 4945 | } |
| 4946 | |
| 4947 | bool CanAllocateInOldSpace() const { |
| 4948 | return CanAllocateInOldDataSpace() || |
| 4949 | CanAllocateInOldPointerSpace(); |
| 4950 | } |
| 4951 | |
| 4952 | bool GuaranteedInNewSpace() const { |
| 4953 | return CanAllocateInNewSpace() && !CanAllocateInOldSpace(); |
| 4954 | } |
| 4955 | |
| 4956 | bool MustAllocateDoubleAligned() const { |
| 4957 | return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; |
| 4958 | } |
| 4959 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 4960 | virtual void PrintDataTo(StringStream* stream); |
| 4961 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 4962 | DECLARE_CONCRETE_INSTRUCTION(Allocate) |
| 4963 | |
| 4964 | private: |
| 4965 | HType type_; |
| 4966 | Flags flags_; |
| 4967 | }; |
| 4968 | |
| 4969 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 4970 | class HInnerAllocatedObject: public HTemplateInstruction<1> { |
| 4971 | public: |
| 4972 | HInnerAllocatedObject(HValue* value, int offset) |
| 4973 | : offset_(offset) { |
| 4974 | ASSERT(value->IsAllocate()); |
| 4975 | SetOperandAt(0, value); |
| 4976 | set_representation(Representation::Tagged()); |
| 4977 | } |
| 4978 | |
| 4979 | HValue* base_object() { return OperandAt(0); } |
| 4980 | int offset() { return offset_; } |
| 4981 | |
| 4982 | virtual Representation RequiredInputRepresentation(int index) { |
| 4983 | return Representation::Tagged(); |
| 4984 | } |
| 4985 | |
| 4986 | virtual void PrintDataTo(StringStream* stream); |
| 4987 | |
| 4988 | DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) |
| 4989 | |
| 4990 | private: |
| 4991 | int offset_; |
| 4992 | }; |
| 4993 | |
| 4994 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4995 | inline bool StoringValueNeedsWriteBarrier(HValue* value) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4996 | return !value->type().IsBoolean() |
| 4997 | && !value->type().IsSmi() |
| 4998 | && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); |
| 4999 | } |
| 5000 | |
| 5001 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5002 | inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
| 5003 | HValue* new_space_dominator) { |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 5004 | if (object->IsInnerAllocatedObject()) { |
| 5005 | return ReceiverObjectNeedsWriteBarrier( |
| 5006 | HInnerAllocatedObject::cast(object)->base_object(), |
| 5007 | new_space_dominator); |
| 5008 | } |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5009 | if (object != new_space_dominator) return true; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5010 | if (object->IsAllocateObject()) return false; |
| 5011 | if (object->IsAllocate()) { |
| 5012 | return !HAllocate::cast(object)->GuaranteedInNewSpace(); |
| 5013 | } |
| 5014 | return true; |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5015 | } |
| 5016 | |
| 5017 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5018 | class HStoreGlobalCell: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5019 | public: |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5020 | HStoreGlobalCell(HValue* value, |
| 5021 | Handle<JSGlobalPropertyCell> cell, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5022 | PropertyDetails details) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5023 | : HUnaryOperation(value), |
| 5024 | cell_(cell), |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5025 | details_(details) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5026 | SetGVNFlag(kChangesGlobalVars); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5030 | bool RequiresHoleCheck() { |
| 5031 | return !details_.IsDontDelete() || details_.IsReadOnly(); |
| 5032 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5033 | bool NeedsWriteBarrier() { |
| 5034 | return StoringValueNeedsWriteBarrier(value()); |
| 5035 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5036 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5037 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5038 | return Representation::Tagged(); |
| 5039 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5040 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5041 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5042 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5043 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5044 | private: |
| 5045 | Handle<JSGlobalPropertyCell> cell_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5046 | PropertyDetails details_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5047 | }; |
| 5048 | |
| 5049 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5050 | class HStoreGlobalGeneric: public HTemplateInstruction<3> { |
| 5051 | public: |
| 5052 | HStoreGlobalGeneric(HValue* context, |
| 5053 | HValue* global_object, |
| 5054 | Handle<Object> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5055 | HValue* value, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5056 | StrictModeFlag strict_mode_flag) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5057 | : name_(name), |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5058 | strict_mode_flag_(strict_mode_flag) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5059 | SetOperandAt(0, context); |
| 5060 | SetOperandAt(1, global_object); |
| 5061 | SetOperandAt(2, value); |
| 5062 | set_representation(Representation::Tagged()); |
| 5063 | SetAllSideEffects(); |
| 5064 | } |
| 5065 | |
| 5066 | HValue* context() { return OperandAt(0); } |
| 5067 | HValue* global_object() { return OperandAt(1); } |
| 5068 | Handle<Object> name() const { return name_; } |
| 5069 | HValue* value() { return OperandAt(2); } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5070 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5071 | |
| 5072 | virtual void PrintDataTo(StringStream* stream); |
| 5073 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5074 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5075 | return Representation::Tagged(); |
| 5076 | } |
| 5077 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5078 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5079 | |
| 5080 | private: |
| 5081 | Handle<Object> name_; |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5082 | StrictModeFlag strict_mode_flag_; |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 5083 | }; |
| 5084 | |
| 5085 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5086 | class HLoadContextSlot: public HUnaryOperation { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5087 | public: |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5088 | enum Mode { |
| 5089 | // 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] | 5090 | kNoCheck, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5091 | // Load and check the value of the context slot. Deoptimize if it's the |
| 5092 | // hole value. This is used for checking for loading of uninitialized |
| 5093 | // harmony bindings where we deoptimize into full-codegen generated code |
| 5094 | // which will subsequently throw a reference error. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5095 | kCheckDeoptimize, |
| 5096 | // Load and check the value of the context slot. Return undefined if it's |
| 5097 | // the hole value. This is used for non-harmony const assignments |
| 5098 | kCheckReturnUndefined |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5099 | }; |
| 5100 | |
| 5101 | HLoadContextSlot(HValue* context, Variable* var) |
| 5102 | : HUnaryOperation(context), slot_index_(var->index()) { |
| 5103 | ASSERT(var->IsContextSlot()); |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5104 | switch (var->mode()) { |
| 5105 | case LET: |
| 5106 | case CONST_HARMONY: |
| 5107 | mode_ = kCheckDeoptimize; |
| 5108 | break; |
| 5109 | case CONST: |
| 5110 | mode_ = kCheckReturnUndefined; |
| 5111 | break; |
| 5112 | default: |
| 5113 | mode_ = kNoCheck; |
| 5114 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5115 | set_representation(Representation::Tagged()); |
| 5116 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5117 | SetGVNFlag(kDependsOnContextSlots); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5118 | } |
| 5119 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5120 | int slot_index() const { return slot_index_; } |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5121 | Mode mode() const { return mode_; } |
| 5122 | |
| 5123 | bool DeoptimizesOnHole() { |
| 5124 | return mode_ == kCheckDeoptimize; |
| 5125 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5126 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5127 | bool RequiresHoleCheck() const { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5128 | return mode_ != kNoCheck; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5129 | } |
| 5130 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5131 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5132 | return Representation::Tagged(); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5133 | } |
| 5134 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5135 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5136 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5137 | DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5138 | |
| 5139 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5140 | virtual bool DataEquals(HValue* other) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5141 | HLoadContextSlot* b = HLoadContextSlot::cast(other); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5142 | return (slot_index() == b->slot_index()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5143 | } |
| 5144 | |
| 5145 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5146 | virtual bool IsDeletable() const { return !RequiresHoleCheck(); } |
| 5147 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5148 | int slot_index_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5149 | Mode mode_; |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5150 | }; |
| 5151 | |
| 5152 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5153 | class HStoreContextSlot: public HTemplateInstruction<2> { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5154 | public: |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5155 | enum Mode { |
| 5156 | // Perform a normal store to the context slot without checking its previous |
| 5157 | // value. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5158 | kNoCheck, |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5159 | // Check the previous value of the context slot and deoptimize if it's the |
| 5160 | // hole value. This is used for checking for assignments to uninitialized |
| 5161 | // harmony bindings where we deoptimize into full-codegen generated code |
| 5162 | // which will subsequently throw a reference error. |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5163 | kCheckDeoptimize, |
| 5164 | // Check the previous value and ignore assignment if it isn't a hole value |
| 5165 | kCheckIgnoreAssignment |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5166 | }; |
| 5167 | |
| 5168 | HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) |
| 5169 | : slot_index_(slot_index), mode_(mode) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5170 | SetOperandAt(0, context); |
| 5171 | SetOperandAt(1, value); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5172 | SetGVNFlag(kChangesContextSlots); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5173 | } |
| 5174 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5175 | HValue* context() { return OperandAt(0); } |
| 5176 | HValue* value() { return OperandAt(1); } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5177 | int slot_index() const { return slot_index_; } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5178 | Mode mode() const { return mode_; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5179 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5180 | bool NeedsWriteBarrier() { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5181 | return StoringValueNeedsWriteBarrier(value()); |
| 5182 | } |
| 5183 | |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5184 | bool DeoptimizesOnHole() { |
| 5185 | return mode_ == kCheckDeoptimize; |
| 5186 | } |
| 5187 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5188 | bool RequiresHoleCheck() { |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 5189 | return mode_ != kNoCheck; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5190 | } |
| 5191 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5192 | virtual Representation RequiredInputRepresentation(int index) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5193 | return Representation::Tagged(); |
| 5194 | } |
| 5195 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5196 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5197 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5198 | DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5199 | |
| 5200 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5201 | int slot_index_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 5202 | Mode mode_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 5203 | }; |
| 5204 | |
| 5205 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5206 | class HLoadNamedField: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5207 | public: |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5208 | HLoadNamedField(HValue* object, bool is_in_object, |
| 5209 | Representation field_representation, |
| 5210 | int offset, HValue* typecheck = NULL) |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5211 | : is_in_object_(is_in_object), |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5212 | field_representation_(field_representation), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5213 | offset_(offset) { |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5214 | ASSERT(object != NULL); |
| 5215 | SetOperandAt(0, object); |
| 5216 | SetOperandAt(1, typecheck != NULL ? typecheck : object); |
| 5217 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5218 | if (FLAG_track_fields && field_representation.IsSmi()) { |
| 5219 | set_type(HType::Smi()); |
| 5220 | set_representation(Representation::Tagged()); |
| 5221 | } else if (FLAG_track_double_fields && field_representation.IsDouble()) { |
| 5222 | set_representation(field_representation); |
| 5223 | } else { |
| 5224 | set_representation(Representation::Tagged()); |
| 5225 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5226 | SetFlag(kUseGVN); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5227 | if (FLAG_track_double_fields && representation().IsDouble()) { |
| 5228 | ASSERT(is_in_object); |
| 5229 | ASSERT(offset == HeapNumber::kValueOffset); |
| 5230 | SetGVNFlag(kDependsOnDoubleFields); |
| 5231 | } else if (is_in_object) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5232 | SetGVNFlag(kDependsOnInobjectFields); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5233 | SetGVNFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5234 | } else { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5235 | SetGVNFlag(kDependsOnBackingStoreFields); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5236 | SetGVNFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5237 | } |
| 5238 | } |
| 5239 | |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5240 | static HLoadNamedField* NewArrayLength(Zone* zone, HValue* object, |
| 5241 | HValue* typecheck, |
| 5242 | HType type = HType::Tagged()) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5243 | Representation representation = |
| 5244 | type.IsSmi() ? Representation::Smi() : Representation::Tagged(); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5245 | HLoadNamedField* result = new(zone) HLoadNamedField( |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5246 | object, true, representation, JSArray::kLengthOffset, typecheck); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5247 | result->set_type(type); |
| 5248 | result->SetGVNFlag(kDependsOnArrayLengths); |
| 5249 | result->ClearGVNFlag(kDependsOnInobjectFields); |
| 5250 | return result; |
| 5251 | } |
| 5252 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5253 | HValue* object() { return OperandAt(0); } |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 5254 | HValue* typecheck() { |
| 5255 | ASSERT(HasTypeCheck()); |
| 5256 | return OperandAt(1); |
| 5257 | } |
| 5258 | |
| 5259 | bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5260 | bool is_in_object() const { return is_in_object_; } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5261 | Representation field_representation() const { return representation_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5262 | int offset() const { return offset_; } |
| 5263 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5264 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5265 | return Representation::Tagged(); |
| 5266 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5267 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5268 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5269 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5270 | |
| 5271 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5272 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5273 | HLoadNamedField* b = HLoadNamedField::cast(other); |
| 5274 | return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; |
| 5275 | } |
| 5276 | |
| 5277 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5278 | virtual bool IsDeletable() const { return true; } |
| 5279 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5280 | bool is_in_object_; |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5281 | Representation field_representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5282 | int offset_; |
| 5283 | }; |
| 5284 | |
| 5285 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5286 | class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5287 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5288 | HLoadNamedFieldPolymorphic(HValue* context, |
| 5289 | HValue* object, |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 5290 | SmallMapList* types, |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5291 | Handle<String> name, |
| 5292 | Zone* zone); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5293 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5294 | HValue* context() { return OperandAt(0); } |
| 5295 | HValue* object() { return OperandAt(1); } |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 5296 | SmallMapList* types() { return &types_; } |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5297 | Handle<String> name() { return name_; } |
| 5298 | bool need_generic() { return need_generic_; } |
| 5299 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5300 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5301 | return Representation::Tagged(); |
| 5302 | } |
| 5303 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 5304 | virtual void PrintDataTo(StringStream* stream); |
| 5305 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5306 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic) |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5307 | |
| 5308 | static const int kMaxLoadPolymorphism = 4; |
| 5309 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5310 | virtual void FinalizeUniqueValueId(); |
| 5311 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5312 | protected: |
| 5313 | virtual bool DataEquals(HValue* value); |
| 5314 | |
| 5315 | private: |
ricow@chromium.org | ddd545c | 2011-08-24 12:02:41 +0000 | [diff] [blame] | 5316 | SmallMapList types_; |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5317 | Handle<String> name_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5318 | ZoneList<UniqueValueId> types_unique_ids_; |
| 5319 | UniqueValueId name_unique_id_; |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5320 | bool need_generic_; |
| 5321 | }; |
| 5322 | |
| 5323 | |
| 5324 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5325 | class HLoadNamedGeneric: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5326 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5327 | HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5328 | : name_(name) { |
| 5329 | SetOperandAt(0, context); |
| 5330 | SetOperandAt(1, object); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5331 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5332 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5333 | } |
| 5334 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5335 | HValue* context() { return OperandAt(0); } |
| 5336 | HValue* object() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5337 | Handle<Object> name() const { return name_; } |
| 5338 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5339 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5340 | return Representation::Tagged(); |
| 5341 | } |
| 5342 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 5343 | virtual void PrintDataTo(StringStream* stream); |
| 5344 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5345 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5346 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5347 | private: |
| 5348 | Handle<Object> name_; |
| 5349 | }; |
| 5350 | |
| 5351 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5352 | class HLoadFunctionPrototype: public HUnaryOperation { |
| 5353 | public: |
| 5354 | explicit HLoadFunctionPrototype(HValue* function) |
| 5355 | : HUnaryOperation(function) { |
| 5356 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5357 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5358 | SetGVNFlag(kDependsOnCalls); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5359 | } |
| 5360 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5361 | HValue* function() { return OperandAt(0); } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5362 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5363 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5364 | return Representation::Tagged(); |
| 5365 | } |
| 5366 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5367 | DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype) |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5368 | |
| 5369 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5370 | virtual bool DataEquals(HValue* other) { return true; } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5371 | }; |
| 5372 | |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5373 | class ArrayInstructionInterface { |
| 5374 | public: |
| 5375 | virtual HValue* GetKey() = 0; |
| 5376 | virtual void SetKey(HValue* key) = 0; |
| 5377 | virtual void SetIndexOffset(uint32_t index_offset) = 0; |
| 5378 | virtual bool IsDehoisted() = 0; |
| 5379 | virtual void SetDehoisted(bool is_dehoisted) = 0; |
| 5380 | virtual ~ArrayInstructionInterface() { }; |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 5381 | |
| 5382 | static Representation KeyedAccessIndexRequirement(Representation r) { |
| 5383 | return r.IsInteger32() ? Representation::Integer32() |
| 5384 | : Representation::Tagged(); |
| 5385 | } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5386 | }; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 5387 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5388 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5389 | enum LoadKeyedHoleMode { |
| 5390 | NEVER_RETURN_HOLE, |
| 5391 | ALLOW_RETURN_HOLE |
| 5392 | }; |
| 5393 | |
| 5394 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5395 | class HLoadKeyed |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 5396 | : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5397 | public: |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5398 | HLoadKeyed(HValue* obj, |
| 5399 | HValue* key, |
| 5400 | HValue* dependency, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5401 | ElementsKind elements_kind, |
| 5402 | LoadKeyedHoleMode mode = NEVER_RETURN_HOLE) |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5403 | : bit_field_(0) { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5404 | bit_field_ = ElementsKindField::encode(elements_kind) | |
| 5405 | HoleModeField::encode(mode); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5406 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5407 | SetOperandAt(0, obj); |
| 5408 | SetOperandAt(1, key); |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 5409 | SetOperandAt(2, dependency != NULL ? dependency : obj); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5410 | |
| 5411 | if (!is_external()) { |
| 5412 | // I can detect the case between storing double (holey and fast) and |
| 5413 | // smi/object by looking at elements_kind_. |
| 5414 | ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || |
| 5415 | IsFastDoubleElementsKind(elements_kind)); |
| 5416 | |
| 5417 | if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5418 | if (IsFastSmiElementsKind(elements_kind)) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5419 | set_type(HType::Smi()); |
| 5420 | } |
| 5421 | |
| 5422 | set_representation(Representation::Tagged()); |
| 5423 | SetGVNFlag(kDependsOnArrayElements); |
| 5424 | } else { |
| 5425 | set_representation(Representation::Double()); |
| 5426 | SetGVNFlag(kDependsOnDoubleArrayElements); |
| 5427 | } |
| 5428 | } else { |
| 5429 | if (elements_kind == EXTERNAL_FLOAT_ELEMENTS || |
| 5430 | elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 5431 | set_representation(Representation::Double()); |
| 5432 | } else { |
| 5433 | set_representation(Representation::Integer32()); |
| 5434 | } |
| 5435 | |
| 5436 | SetGVNFlag(kDependsOnSpecializedArrayElements); |
| 5437 | // Native code could change the specialized array. |
| 5438 | SetGVNFlag(kDependsOnCalls); |
| 5439 | } |
| 5440 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5441 | SetFlag(kUseGVN); |
| 5442 | } |
| 5443 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5444 | bool is_external() const { |
| 5445 | return IsExternalArrayElementsKind(elements_kind()); |
| 5446 | } |
| 5447 | HValue* elements() { return OperandAt(0); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5448 | HValue* key() { return OperandAt(1); } |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 5449 | HValue* dependency() { |
| 5450 | ASSERT(HasDependency()); |
| 5451 | return OperandAt(2); |
| 5452 | } |
| 5453 | bool HasDependency() const { return OperandAt(0) != OperandAt(2); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5454 | uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| 5455 | void SetIndexOffset(uint32_t index_offset) { |
| 5456 | bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 5457 | } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5458 | HValue* GetKey() { return key(); } |
| 5459 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5460 | bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| 5461 | void SetDehoisted(bool is_dehoisted) { |
| 5462 | bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 5463 | } |
| 5464 | ElementsKind elements_kind() const { |
| 5465 | return ElementsKindField::decode(bit_field_); |
| 5466 | } |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5467 | LoadKeyedHoleMode hole_mode() const { |
| 5468 | return HoleModeField::decode(bit_field_); |
| 5469 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5470 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5471 | virtual Representation RequiredInputRepresentation(int index) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5472 | // kind_fast: tagged[int32] (none) |
| 5473 | // kind_double: tagged[int32] (none) |
| 5474 | // kind_external: external[int32] (none) |
| 5475 | if (index == 0) { |
| 5476 | return is_external() ? Representation::External() |
| 5477 | : Representation::Tagged(); |
| 5478 | } |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 5479 | if (index == 1) { |
| 5480 | return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
| 5481 | OperandAt(1)->representation()); |
| 5482 | } |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 5483 | return Representation::None(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5484 | } |
| 5485 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 5486 | virtual Representation observed_input_representation(int index) { |
| 5487 | return RequiredInputRepresentation(index); |
| 5488 | } |
| 5489 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5490 | virtual void PrintDataTo(StringStream* stream); |
| 5491 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5492 | bool UsesMustHandleHole() const; |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5493 | bool RequiresHoleCheck() const; |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 5494 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5495 | virtual Range* InferRange(Zone* zone); |
| 5496 | |
| 5497 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyed) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5498 | |
| 5499 | protected: |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 5500 | virtual bool DataEquals(HValue* other) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5501 | if (!other->IsLoadKeyed()) return false; |
| 5502 | HLoadKeyed* other_load = HLoadKeyed::cast(other); |
| 5503 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5504 | if (IsDehoisted() && index_offset() != other_load->index_offset()) |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5505 | return false; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5506 | return elements_kind() == other_load->elements_kind(); |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 5507 | } |
| 5508 | |
| 5509 | private: |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5510 | virtual bool IsDeletable() const { |
| 5511 | return !RequiresHoleCheck(); |
| 5512 | } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5513 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5514 | // Establish some checks around our packed fields |
| 5515 | enum LoadKeyedBits { |
| 5516 | kBitsForElementsKind = 5, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5517 | kBitsForHoleMode = 1, |
| 5518 | kBitsForIndexOffset = 25, |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5519 | kBitsForIsDehoisted = 1, |
| 5520 | |
| 5521 | kStartElementsKind = 0, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5522 | kStartHoleMode = kStartElementsKind + kBitsForElementsKind, |
| 5523 | kStartIndexOffset = kStartHoleMode + kBitsForHoleMode, |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5524 | kStartIsDehoisted = kStartIndexOffset + kBitsForIndexOffset |
| 5525 | }; |
| 5526 | |
| 5527 | STATIC_ASSERT((kBitsForElementsKind + kBitsForIndexOffset + |
| 5528 | kBitsForIsDehoisted) <= sizeof(uint32_t)*8); |
| 5529 | STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind)); |
| 5530 | class ElementsKindField: |
| 5531 | public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind> |
| 5532 | {}; // NOLINT |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5533 | class HoleModeField: |
| 5534 | public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode> |
| 5535 | {}; // NOLINT |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5536 | class IndexOffsetField: |
| 5537 | public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset> |
| 5538 | {}; // NOLINT |
| 5539 | class IsDehoistedField: |
| 5540 | public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> |
| 5541 | {}; // NOLINT |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 5542 | uint32_t bit_field_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5543 | }; |
| 5544 | |
| 5545 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5546 | class HLoadKeyedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5547 | public: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 5548 | HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5549 | set_representation(Representation::Tagged()); |
| 5550 | SetOperandAt(0, obj); |
| 5551 | SetOperandAt(1, key); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5552 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5553 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5554 | } |
| 5555 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5556 | HValue* object() { return OperandAt(0); } |
| 5557 | HValue* key() { return OperandAt(1); } |
| 5558 | HValue* context() { return OperandAt(2); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5559 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5560 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5561 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5562 | virtual Representation RequiredInputRepresentation(int index) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5563 | // tagged[tagged] |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5564 | return Representation::Tagged(); |
| 5565 | } |
| 5566 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 5567 | virtual HValue* Canonicalize(); |
| 5568 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5569 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5570 | }; |
| 5571 | |
| 5572 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5573 | class HStoreNamedField: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5574 | public: |
| 5575 | HStoreNamedField(HValue* obj, |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5576 | Handle<Name> name, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5577 | HValue* val, |
| 5578 | bool in_object, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5579 | Representation field_representation, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5580 | int offset) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5581 | : name_(name), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5582 | is_in_object_(in_object), |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5583 | field_representation_(field_representation), |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5584 | offset_(offset), |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5585 | transition_unique_id_(), |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5586 | new_space_dominator_(NULL) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5587 | SetOperandAt(0, obj); |
| 5588 | SetOperandAt(1, val); |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5589 | SetFlag(kTrackSideEffectDominators); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5590 | if (FLAG_track_double_fields && field_representation.IsDouble()) { |
| 5591 | SetGVNFlag(kChangesDoubleFields); |
| 5592 | } else if (is_in_object_) { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5593 | SetGVNFlag(kChangesInobjectFields); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5594 | SetGVNFlag(kDependsOnNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5595 | } else { |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5596 | SetGVNFlag(kChangesBackingStoreFields); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5597 | SetGVNFlag(kDependsOnNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5598 | } |
| 5599 | } |
| 5600 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5601 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5602 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5603 | virtual Representation RequiredInputRepresentation(int index) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5604 | if (FLAG_track_double_fields && |
| 5605 | index == 1 && field_representation_.IsDouble()) { |
| 5606 | return field_representation_; |
| 5607 | } else if (FLAG_track_fields && |
| 5608 | index == 1 && field_representation_.IsSmi()) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5609 | return Representation::Integer32(); |
| 5610 | } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5611 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5612 | } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5613 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
| 5614 | ASSERT(side_effect == kChangesNewSpacePromotion); |
| 5615 | new_space_dominator_ = dominator; |
| 5616 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5617 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5618 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5619 | HValue* object() { return OperandAt(0); } |
| 5620 | HValue* value() { return OperandAt(1); } |
| 5621 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5622 | Handle<Name> name() const { return name_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5623 | bool is_in_object() const { return is_in_object_; } |
| 5624 | int offset() const { return offset_; } |
| 5625 | Handle<Map> transition() const { return transition_; } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5626 | UniqueValueId transition_unique_id() const { return transition_unique_id_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5627 | void set_transition(Handle<Map> map) { transition_ = map; } |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5628 | HValue* new_space_dominator() const { return new_space_dominator_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5629 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5630 | bool NeedsWriteBarrier() { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5631 | ASSERT(!(FLAG_track_double_fields && field_representation_.IsDouble()) || |
| 5632 | transition_.is_null()); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5633 | return (!FLAG_track_fields || !field_representation_.IsSmi()) && |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5634 | // If there is a transition, a new storage object needs to be allocated. |
| 5635 | !(FLAG_track_double_fields && field_representation_.IsDouble()) && |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5636 | StoringValueNeedsWriteBarrier(value()) && |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5637 | ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 5638 | } |
| 5639 | |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 5640 | bool NeedsWriteBarrierForMap() { |
| 5641 | return ReceiverObjectNeedsWriteBarrier(object(), new_space_dominator()); |
| 5642 | } |
| 5643 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5644 | virtual void FinalizeUniqueValueId() { |
| 5645 | transition_unique_id_ = UniqueValueId(transition_); |
| 5646 | } |
| 5647 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5648 | Representation field_representation() const { |
| 5649 | return field_representation_; |
| 5650 | } |
| 5651 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5652 | private: |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 5653 | Handle<Name> name_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5654 | bool is_in_object_; |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 5655 | Representation field_representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5656 | int offset_; |
| 5657 | Handle<Map> transition_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5658 | UniqueValueId transition_unique_id_; |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5659 | HValue* new_space_dominator_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5660 | }; |
| 5661 | |
| 5662 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5663 | class HStoreNamedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5664 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5665 | HStoreNamedGeneric(HValue* context, |
| 5666 | HValue* object, |
| 5667 | Handle<String> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5668 | HValue* value, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5669 | StrictModeFlag strict_mode_flag) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5670 | : name_(name), |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5671 | strict_mode_flag_(strict_mode_flag) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5672 | SetOperandAt(0, object); |
| 5673 | SetOperandAt(1, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5674 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5675 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5676 | } |
| 5677 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5678 | HValue* object() { return OperandAt(0); } |
| 5679 | HValue* value() { return OperandAt(1); } |
| 5680 | HValue* context() { return OperandAt(2); } |
| 5681 | Handle<String> name() { return name_; } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5682 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5683 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5684 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5685 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5686 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5687 | return Representation::Tagged(); |
| 5688 | } |
| 5689 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5690 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5691 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5692 | private: |
| 5693 | Handle<String> name_; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5694 | StrictModeFlag strict_mode_flag_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5695 | }; |
| 5696 | |
| 5697 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5698 | class HStoreKeyed |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5699 | : public HTemplateInstruction<3>, public ArrayInstructionInterface { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5700 | public: |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5701 | HStoreKeyed(HValue* obj, HValue* key, HValue* val, |
| 5702 | ElementsKind elements_kind) |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5703 | : elements_kind_(elements_kind), |
| 5704 | index_offset_(0), |
| 5705 | is_dehoisted_(false), |
| 5706 | new_space_dominator_(NULL) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5707 | SetOperandAt(0, obj); |
| 5708 | SetOperandAt(1, key); |
| 5709 | SetOperandAt(2, val); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5710 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5711 | if (IsFastObjectElementsKind(elements_kind)) { |
| 5712 | SetFlag(kTrackSideEffectDominators); |
| 5713 | SetGVNFlag(kDependsOnNewSpacePromotion); |
| 5714 | } |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5715 | if (is_external()) { |
| 5716 | SetGVNFlag(kChangesSpecializedArrayElements); |
| 5717 | } else if (IsFastDoubleElementsKind(elements_kind)) { |
| 5718 | SetGVNFlag(kChangesDoubleArrayElements); |
| 5719 | SetFlag(kDeoptimizeOnUndefined); |
| 5720 | } else { |
| 5721 | SetGVNFlag(kChangesArrayElements); |
| 5722 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 5723 | |
| 5724 | // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating. |
| 5725 | if (elements_kind >= EXTERNAL_BYTE_ELEMENTS && |
| 5726 | elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) { |
| 5727 | SetFlag(kTruncatingToInt32); |
| 5728 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5729 | } |
| 5730 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5731 | virtual Representation RequiredInputRepresentation(int index) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5732 | // kind_fast: tagged[int32] = tagged |
| 5733 | // kind_double: tagged[int32] = double |
| 5734 | // kind_external: external[int32] = (double | int32) |
| 5735 | if (index == 0) { |
| 5736 | return is_external() ? Representation::External() |
| 5737 | : Representation::Tagged(); |
| 5738 | } else if (index == 1) { |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 5739 | return ArrayInstructionInterface::KeyedAccessIndexRequirement( |
| 5740 | OperandAt(1)->representation()); |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5741 | } |
| 5742 | |
| 5743 | ASSERT_EQ(index, 2); |
| 5744 | if (IsDoubleOrFloatElementsKind(elements_kind())) { |
| 5745 | return Representation::Double(); |
| 5746 | } |
| 5747 | |
| 5748 | return is_external() ? Representation::Integer32() |
| 5749 | : Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5750 | } |
| 5751 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5752 | bool is_external() const { |
| 5753 | return IsExternalArrayElementsKind(elements_kind()); |
| 5754 | } |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 5755 | |
| 5756 | virtual Representation observed_input_representation(int index) { |
| 5757 | if (index < 2) return RequiredInputRepresentation(index); |
| 5758 | if (IsDoubleOrFloatElementsKind(elements_kind())) { |
| 5759 | return Representation::Double(); |
| 5760 | } |
| 5761 | if (is_external()) { |
| 5762 | return Representation::Integer32(); |
| 5763 | } |
| 5764 | // For fast object elements kinds, don't assume anything. |
| 5765 | return Representation::None(); |
| 5766 | } |
| 5767 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5768 | HValue* elements() { return OperandAt(0); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5769 | HValue* key() { return OperandAt(1); } |
| 5770 | HValue* value() { return OperandAt(2); } |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5771 | bool value_is_smi() const { |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 5772 | return IsFastSmiElementsKind(elements_kind_); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5773 | } |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5774 | ElementsKind elements_kind() const { return elements_kind_; } |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5775 | uint32_t index_offset() { return index_offset_; } |
| 5776 | void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| 5777 | HValue* GetKey() { return key(); } |
| 5778 | void SetKey(HValue* key) { SetOperandAt(1, key); } |
| 5779 | bool IsDehoisted() { return is_dehoisted_; } |
| 5780 | void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5781 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5782 | bool IsConstantHoleStore() { |
| 5783 | return value()->IsConstant() && HConstant::cast(value())->IsTheHole(); |
| 5784 | } |
| 5785 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5786 | virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
| 5787 | ASSERT(side_effect == kChangesNewSpacePromotion); |
| 5788 | new_space_dominator_ = dominator; |
| 5789 | } |
| 5790 | |
| 5791 | HValue* new_space_dominator() const { return new_space_dominator_; } |
| 5792 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5793 | bool NeedsWriteBarrier() { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5794 | if (value_is_smi()) { |
| 5795 | return false; |
| 5796 | } else { |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5797 | return StoringValueNeedsWriteBarrier(value()) && |
| 5798 | ReceiverObjectNeedsWriteBarrier(elements(), new_space_dominator()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5799 | } |
| 5800 | } |
| 5801 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 5802 | bool NeedsCanonicalization(); |
| 5803 | |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 5804 | virtual void PrintDataTo(StringStream* stream); |
| 5805 | |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5806 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5807 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 5808 | private: |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 5809 | ElementsKind elements_kind_; |
ulan@chromium.org | 0e3f88b | 2012-05-22 09:16:05 +0000 | [diff] [blame] | 5810 | uint32_t index_offset_; |
| 5811 | bool is_dehoisted_; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5812 | HValue* new_space_dominator_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5813 | }; |
| 5814 | |
| 5815 | |
| 5816 | class HStoreKeyedGeneric: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5817 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5818 | HStoreKeyedGeneric(HValue* context, |
| 5819 | HValue* object, |
| 5820 | HValue* key, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5821 | HValue* value, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5822 | StrictModeFlag strict_mode_flag) |
| 5823 | : strict_mode_flag_(strict_mode_flag) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5824 | SetOperandAt(0, object); |
| 5825 | SetOperandAt(1, key); |
| 5826 | SetOperandAt(2, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5827 | SetOperandAt(3, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5828 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5829 | } |
| 5830 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5831 | HValue* object() { return OperandAt(0); } |
| 5832 | HValue* key() { return OperandAt(1); } |
| 5833 | HValue* value() { return OperandAt(2); } |
| 5834 | HValue* context() { return OperandAt(3); } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5835 | StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5836 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5837 | virtual Representation RequiredInputRepresentation(int index) { |
verwaest@chromium.org | e4ee6de | 2012-11-06 12:13:00 +0000 | [diff] [blame] | 5838 | // tagged[tagged] = tagged |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5839 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 5840 | } |
| 5841 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5842 | virtual void PrintDataTo(StringStream* stream); |
| 5843 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5844 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 5845 | |
| 5846 | private: |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 5847 | StrictModeFlag strict_mode_flag_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 5848 | }; |
| 5849 | |
| 5850 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5851 | class HTransitionElementsKind: public HTemplateInstruction<2> { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5852 | public: |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5853 | HTransitionElementsKind(HValue* context, |
| 5854 | HValue* object, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5855 | Handle<Map> original_map, |
| 5856 | Handle<Map> transitioned_map) |
| 5857 | : original_map_(original_map), |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 5858 | transitioned_map_(transitioned_map), |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5859 | original_map_unique_id_(), |
| 5860 | transitioned_map_unique_id_(), |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 5861 | from_kind_(original_map->elements_kind()), |
| 5862 | to_kind_(transitioned_map->elements_kind()) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5863 | SetOperandAt(0, object); |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5864 | SetOperandAt(1, context); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5865 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5866 | SetGVNFlag(kChangesElementsKind); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 5867 | if (original_map->has_fast_double_elements()) { |
| 5868 | SetGVNFlag(kChangesElementsPointer); |
| 5869 | SetGVNFlag(kChangesNewSpacePromotion); |
| 5870 | } |
| 5871 | if (transitioned_map->has_fast_double_elements()) { |
| 5872 | SetGVNFlag(kChangesElementsPointer); |
| 5873 | SetGVNFlag(kChangesNewSpacePromotion); |
| 5874 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5875 | set_representation(Representation::Tagged()); |
| 5876 | } |
| 5877 | |
| 5878 | virtual Representation RequiredInputRepresentation(int index) { |
| 5879 | return Representation::Tagged(); |
| 5880 | } |
| 5881 | |
| 5882 | HValue* object() { return OperandAt(0); } |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 5883 | HValue* context() { return OperandAt(1); } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5884 | Handle<Map> original_map() { return original_map_; } |
| 5885 | Handle<Map> transitioned_map() { return transitioned_map_; } |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 5886 | ElementsKind from_kind() { return from_kind_; } |
| 5887 | ElementsKind to_kind() { return to_kind_; } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5888 | |
| 5889 | virtual void PrintDataTo(StringStream* stream); |
| 5890 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5891 | virtual void FinalizeUniqueValueId() { |
| 5892 | original_map_unique_id_ = UniqueValueId(original_map_); |
| 5893 | transitioned_map_unique_id_ = UniqueValueId(transitioned_map_); |
| 5894 | } |
| 5895 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5896 | DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) |
| 5897 | |
| 5898 | protected: |
| 5899 | virtual bool DataEquals(HValue* other) { |
| 5900 | HTransitionElementsKind* instr = HTransitionElementsKind::cast(other); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5901 | return original_map_unique_id_ == instr->original_map_unique_id_ && |
| 5902 | transitioned_map_unique_id_ == instr->transitioned_map_unique_id_; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5903 | } |
| 5904 | |
| 5905 | private: |
| 5906 | Handle<Map> original_map_; |
| 5907 | Handle<Map> transitioned_map_; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 5908 | UniqueValueId original_map_unique_id_; |
| 5909 | UniqueValueId transitioned_map_unique_id_; |
yangguo@chromium.org | 003650e | 2013-01-24 16:31:08 +0000 | [diff] [blame] | 5910 | ElementsKind from_kind_; |
| 5911 | ElementsKind to_kind_; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5912 | }; |
| 5913 | |
| 5914 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 5915 | class HStringAdd: public HBinaryOperation { |
| 5916 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 5917 | static HInstruction* New(Zone* zone, |
| 5918 | HValue* context, |
| 5919 | HValue* left, |
| 5920 | HValue* right); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 5921 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5922 | virtual Representation RequiredInputRepresentation(int index) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 5923 | return Representation::Tagged(); |
| 5924 | } |
| 5925 | |
| 5926 | virtual HType CalculateInferredType() { |
| 5927 | return HType::String(); |
| 5928 | } |
| 5929 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5930 | DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 5931 | |
| 5932 | protected: |
| 5933 | virtual bool DataEquals(HValue* other) { return true; } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5934 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 5935 | |
| 5936 | private: |
| 5937 | HStringAdd(HValue* context, HValue* left, HValue* right) |
| 5938 | : HBinaryOperation(context, left, right) { |
| 5939 | set_representation(Representation::Tagged()); |
| 5940 | SetFlag(kUseGVN); |
| 5941 | SetGVNFlag(kDependsOnMaps); |
| 5942 | SetGVNFlag(kChangesNewSpacePromotion); |
| 5943 | } |
| 5944 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5945 | // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5946 | // virtual bool IsDeletable() const { return true; } |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 5947 | }; |
| 5948 | |
| 5949 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5950 | class HStringCharCodeAt: public HTemplateInstruction<3> { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5951 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5952 | HStringCharCodeAt(HValue* context, HValue* string, HValue* index) { |
| 5953 | SetOperandAt(0, context); |
| 5954 | SetOperandAt(1, string); |
| 5955 | SetOperandAt(2, index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5956 | set_representation(Representation::Integer32()); |
| 5957 | SetFlag(kUseGVN); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 5958 | SetGVNFlag(kDependsOnMaps); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 5959 | SetGVNFlag(kChangesNewSpacePromotion); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5960 | } |
| 5961 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5962 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5963 | // The index is supposed to be Integer32. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5964 | return index == 2 |
| 5965 | ? Representation::Integer32() |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5966 | : Representation::Tagged(); |
| 5967 | } |
| 5968 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5969 | HValue* context() { return OperandAt(0); } |
| 5970 | HValue* string() { return OperandAt(1); } |
| 5971 | HValue* index() { return OperandAt(2); } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5972 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 5973 | DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5974 | |
| 5975 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 5976 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 5977 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 5978 | virtual Range* InferRange(Zone* zone) { |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 5979 | return new(zone) Range(0, String::kMaxUtf16CodeUnit); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5980 | } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 5981 | |
| 5982 | // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
| 5983 | // private: |
| 5984 | // virtual bool IsDeletable() const { return true; } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 5985 | }; |
| 5986 | |
| 5987 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5988 | class HStringCharFromCode: public HTemplateInstruction<2> { |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 5989 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 5990 | static HInstruction* New(Zone* zone, |
| 5991 | HValue* context, |
| 5992 | HValue* char_code); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 5993 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 5994 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 5995 | return index == 0 |
| 5996 | ? Representation::Tagged() |
| 5997 | : Representation::Integer32(); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 5998 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 5999 | virtual HType CalculateInferredType(); |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 6000 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6001 | HValue* context() { return OperandAt(0); } |
| 6002 | HValue* value() { return OperandAt(1); } |
| 6003 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 6004 | virtual bool DataEquals(HValue* other) { return true; } |
| 6005 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6006 | DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6007 | |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 6008 | private: |
| 6009 | HStringCharFromCode(HValue* context, HValue* char_code) { |
| 6010 | SetOperandAt(0, context); |
| 6011 | SetOperandAt(1, char_code); |
| 6012 | set_representation(Representation::Tagged()); |
| 6013 | SetFlag(kUseGVN); |
| 6014 | SetGVNFlag(kChangesNewSpacePromotion); |
| 6015 | } |
| 6016 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6017 | // TODO(svenpanne) Might be safe, but leave it out until we know for sure. |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 6018 | // virtual bool IsDeletable() const { return true; } |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 6019 | }; |
| 6020 | |
| 6021 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6022 | class HStringLength: public HUnaryOperation { |
| 6023 | public: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 6024 | static HInstruction* New(Zone* zone, HValue* string); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6025 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6026 | virtual Representation RequiredInputRepresentation(int index) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6027 | return Representation::Tagged(); |
| 6028 | } |
| 6029 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6030 | virtual HType CalculateInferredType() { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6031 | STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
| 6032 | return HType::Smi(); |
| 6033 | } |
| 6034 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6035 | DECLARE_CONCRETE_INSTRUCTION(StringLength) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6036 | |
| 6037 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6038 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 6039 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 6040 | virtual Range* InferRange(Zone* zone) { |
| 6041 | return new(zone) Range(0, String::kMaxLength); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6042 | } |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6043 | |
| 6044 | private: |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 6045 | explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
| 6046 | set_representation(Representation::Tagged()); |
| 6047 | SetFlag(kUseGVN); |
| 6048 | SetGVNFlag(kDependsOnMaps); |
| 6049 | } |
| 6050 | |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6051 | virtual bool IsDeletable() const { return true; } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 6052 | }; |
| 6053 | |
| 6054 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6055 | template <int V> |
| 6056 | class HMaterializedLiteral: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6057 | public: |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 6058 | HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) |
| 6059 | : literal_index_(index), depth_(depth), allocation_site_mode_(mode) { |
| 6060 | this->set_representation(Representation::Tagged()); |
| 6061 | } |
| 6062 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6063 | HMaterializedLiteral<V>(int index, int depth) |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 6064 | : literal_index_(index), depth_(depth), |
| 6065 | allocation_site_mode_(DONT_TRACK_ALLOCATION_SITE) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6066 | this->set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6067 | } |
| 6068 | |
| 6069 | int literal_index() const { return literal_index_; } |
| 6070 | int depth() const { return depth_; } |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 6071 | AllocationSiteMode allocation_site_mode() const { |
| 6072 | return allocation_site_mode_; |
| 6073 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6074 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6075 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6076 | virtual bool IsDeletable() const { return true; } |
| 6077 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6078 | int literal_index_; |
| 6079 | int depth_; |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 6080 | AllocationSiteMode allocation_site_mode_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6081 | }; |
| 6082 | |
| 6083 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6084 | class HArrayLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6085 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6086 | HArrayLiteral(HValue* context, |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 6087 | Handle<HeapObject> boilerplate_object, |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6088 | Handle<FixedArray> literals, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6089 | int length, |
| 6090 | int literal_index, |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 6091 | int depth, |
| 6092 | AllocationSiteMode mode) |
| 6093 | : HMaterializedLiteral<1>(literal_index, depth, mode), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6094 | length_(length), |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6095 | boilerplate_object_(boilerplate_object), |
| 6096 | literals_(literals) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6097 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 6098 | SetGVNFlag(kChangesNewSpacePromotion); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6099 | |
| 6100 | boilerplate_elements_kind_ = boilerplate_object_->IsJSObject() |
| 6101 | ? Handle<JSObject>::cast(boilerplate_object_)->GetElementsKind() |
| 6102 | : TERMINAL_FAST_ELEMENTS_KIND; |
| 6103 | |
| 6104 | is_copy_on_write_ = boilerplate_object_->IsJSObject() && |
| 6105 | (Handle<JSObject>::cast(boilerplate_object_)->elements()->map() == |
| 6106 | HEAP->fixed_cow_array_map()); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6107 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6108 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6109 | HValue* context() { return OperandAt(0); } |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 6110 | ElementsKind boilerplate_elements_kind() const { |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6111 | return boilerplate_elements_kind_; |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 6112 | } |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 6113 | Handle<HeapObject> boilerplate_object() const { return boilerplate_object_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6114 | Handle<FixedArray> literals() const { return literals_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6115 | int length() const { return length_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6116 | bool IsCopyOnWrite() const { return is_copy_on_write_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6117 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6118 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6119 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6120 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 6121 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6122 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6123 | DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6124 | |
| 6125 | private: |
| 6126 | int length_; |
ricow@chromium.org | 7ad6522 | 2011-12-19 12:13:11 +0000 | [diff] [blame] | 6127 | Handle<HeapObject> boilerplate_object_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6128 | Handle<FixedArray> literals_; |
| 6129 | ElementsKind boilerplate_elements_kind_; |
| 6130 | bool is_copy_on_write_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6131 | }; |
| 6132 | |
| 6133 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 6134 | class HObjectLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6135 | public: |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 6136 | HObjectLiteral(HValue* context, |
| 6137 | Handle<FixedArray> constant_properties, |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6138 | Handle<FixedArray> literals, |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 6139 | bool fast_elements, |
| 6140 | int literal_index, |
| 6141 | int depth, |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 6142 | bool may_store_doubles, |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 6143 | bool has_function) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6144 | : HMaterializedLiteral<1>(literal_index, depth), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6145 | constant_properties_(constant_properties), |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6146 | constant_properties_length_(constant_properties->length()), |
| 6147 | literals_(literals), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6148 | fast_elements_(fast_elements), |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 6149 | may_store_doubles_(may_store_doubles), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6150 | has_function_(has_function) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 6151 | SetOperandAt(0, context); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 6152 | SetGVNFlag(kChangesNewSpacePromotion); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 6153 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6154 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6155 | HValue* context() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6156 | Handle<FixedArray> constant_properties() const { |
| 6157 | return constant_properties_; |
| 6158 | } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6159 | int constant_properties_length() const { |
| 6160 | return constant_properties_length_; |
| 6161 | } |
| 6162 | Handle<FixedArray> literals() const { return literals_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6163 | bool fast_elements() const { return fast_elements_; } |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 6164 | bool may_store_doubles() const { return may_store_doubles_; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6165 | bool has_function() const { return has_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6166 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6167 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6168 | return Representation::Tagged(); |
| 6169 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 6170 | virtual HType CalculateInferredType(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 6171 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 6172 | DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6173 | |
| 6174 | private: |
| 6175 | Handle<FixedArray> constant_properties_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6176 | int constant_properties_length_; |
| 6177 | Handle<FixedArray> literals_; |
| 6178 | bool fast_elements_ : 1; |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 6179 | bool may_store_doubles_ : 1; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6180 | bool has_function_ : 1; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6181 | }; |
| 6182 | |
| 6183 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6184 | class HRegExpLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6185 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6186 | HRegExpLiteral(HValue* context, |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 6187 | Handle<FixedArray> literals, |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6188 | Handle<String> pattern, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6189 | Handle<String> flags, |
| 6190 | int literal_index) |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6191 | : HMaterializedLiteral<1>(literal_index, 0), |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 6192 | literals_(literals), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6193 | pattern_(pattern), |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6194 | flags_(flags) { |
| 6195 | SetOperandAt(0, context); |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 6196 | SetAllSideEffects(); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6197 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6198 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6199 | HValue* context() { return OperandAt(0); } |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 6200 | Handle<FixedArray> literals() { return literals_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6201 | Handle<String> pattern() { return pattern_; } |
| 6202 | Handle<String> flags() { return flags_; } |
| 6203 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6204 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6205 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6206 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 6207 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6208 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6209 | DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6210 | |
| 6211 | private: |
yangguo@chromium.org | 9c741c8 | 2012-06-28 15:04:22 +0000 | [diff] [blame] | 6212 | Handle<FixedArray> literals_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6213 | Handle<String> pattern_; |
| 6214 | Handle<String> flags_; |
| 6215 | }; |
| 6216 | |
| 6217 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6218 | class HFunctionLiteral: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6219 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6220 | HFunctionLiteral(HValue* context, |
| 6221 | Handle<SharedFunctionInfo> shared, |
| 6222 | bool pretenure) |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6223 | : shared_info_(shared), |
| 6224 | pretenure_(pretenure), |
| 6225 | has_no_literals_(shared->num_literals() == 0), |
| 6226 | is_generator_(shared->is_generator()), |
| 6227 | language_mode_(shared->language_mode()) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6228 | SetOperandAt(0, context); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6229 | set_representation(Representation::Tagged()); |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 6230 | SetGVNFlag(kChangesNewSpacePromotion); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6231 | } |
| 6232 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6233 | HValue* context() { return OperandAt(0); } |
| 6234 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6235 | virtual Representation RequiredInputRepresentation(int index) { |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6236 | return Representation::Tagged(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6237 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 6238 | virtual HType CalculateInferredType(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6239 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6240 | DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6241 | |
| 6242 | Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 6243 | bool pretenure() const { return pretenure_; } |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6244 | bool has_no_literals() const { return has_no_literals_; } |
| 6245 | bool is_generator() const { return is_generator_; } |
| 6246 | LanguageMode language_mode() const { return language_mode_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6247 | |
| 6248 | private: |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6249 | virtual bool IsDeletable() const { return true; } |
| 6250 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6251 | Handle<SharedFunctionInfo> shared_info_; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 6252 | bool pretenure_ : 1; |
| 6253 | bool has_no_literals_ : 1; |
| 6254 | bool is_generator_ : 1; |
| 6255 | LanguageMode language_mode_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6256 | }; |
| 6257 | |
| 6258 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6259 | class HTypeof: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6260 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6261 | explicit HTypeof(HValue* context, HValue* value) { |
| 6262 | SetOperandAt(0, context); |
| 6263 | SetOperandAt(1, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6264 | set_representation(Representation::Tagged()); |
| 6265 | } |
| 6266 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6267 | HValue* context() { return OperandAt(0); } |
| 6268 | HValue* value() { return OperandAt(1); } |
| 6269 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6270 | virtual void PrintDataTo(StringStream* stream); |
| 6271 | |
| 6272 | virtual Representation RequiredInputRepresentation(int index) { |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 6273 | return Representation::Tagged(); |
| 6274 | } |
| 6275 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6276 | DECLARE_CONCRETE_INSTRUCTION(Typeof) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6277 | |
| 6278 | private: |
| 6279 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6280 | }; |
| 6281 | |
| 6282 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 6283 | class HTrapAllocationMemento : public HTemplateInstruction<1> { |
| 6284 | public: |
| 6285 | explicit HTrapAllocationMemento(HValue* obj) { |
| 6286 | SetOperandAt(0, obj); |
| 6287 | } |
| 6288 | |
| 6289 | virtual Representation RequiredInputRepresentation(int index) { |
| 6290 | return Representation::Tagged(); |
| 6291 | } |
| 6292 | |
| 6293 | HValue* object() { return OperandAt(0); } |
| 6294 | |
| 6295 | DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento) |
| 6296 | }; |
| 6297 | |
| 6298 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6299 | class HToFastProperties: public HUnaryOperation { |
| 6300 | public: |
| 6301 | explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { |
| 6302 | // This instruction is not marked as having side effects, but |
| 6303 | // changes the map of the input operand. Use it only when creating |
| 6304 | // object literals. |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 6305 | ASSERT(value->IsObjectLiteral()); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6306 | set_representation(Representation::Tagged()); |
| 6307 | } |
| 6308 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6309 | virtual Representation RequiredInputRepresentation(int index) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6310 | return Representation::Tagged(); |
| 6311 | } |
| 6312 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6313 | DECLARE_CONCRETE_INSTRUCTION(ToFastProperties) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6314 | |
| 6315 | private: |
| 6316 | virtual bool IsDeletable() const { return true; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 6317 | }; |
| 6318 | |
| 6319 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6320 | class HValueOf: public HUnaryOperation { |
| 6321 | public: |
| 6322 | explicit HValueOf(HValue* value) : HUnaryOperation(value) { |
| 6323 | set_representation(Representation::Tagged()); |
| 6324 | } |
| 6325 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6326 | virtual Representation RequiredInputRepresentation(int index) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6327 | return Representation::Tagged(); |
| 6328 | } |
| 6329 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6330 | DECLARE_CONCRETE_INSTRUCTION(ValueOf) |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6331 | |
| 6332 | private: |
| 6333 | virtual bool IsDeletable() const { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6334 | }; |
| 6335 | |
| 6336 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 6337 | class HDateField: public HUnaryOperation { |
| 6338 | public: |
| 6339 | HDateField(HValue* date, Smi* index) |
| 6340 | : HUnaryOperation(date), index_(index) { |
| 6341 | set_representation(Representation::Tagged()); |
| 6342 | } |
| 6343 | |
| 6344 | Smi* index() const { return index_; } |
| 6345 | |
| 6346 | virtual Representation RequiredInputRepresentation(int index) { |
| 6347 | return Representation::Tagged(); |
| 6348 | } |
| 6349 | |
| 6350 | DECLARE_CONCRETE_INSTRUCTION(DateField) |
| 6351 | |
| 6352 | private: |
| 6353 | Smi* index_; |
| 6354 | }; |
| 6355 | |
| 6356 | |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 6357 | class HSeqStringSetChar: public HTemplateInstruction<3> { |
| 6358 | public: |
| 6359 | HSeqStringSetChar(String::Encoding encoding, |
| 6360 | HValue* string, |
| 6361 | HValue* index, |
| 6362 | HValue* value) : encoding_(encoding) { |
| 6363 | SetOperandAt(0, string); |
| 6364 | SetOperandAt(1, index); |
| 6365 | SetOperandAt(2, value); |
| 6366 | } |
| 6367 | |
| 6368 | String::Encoding encoding() { return encoding_; } |
| 6369 | HValue* string() { return OperandAt(0); } |
| 6370 | HValue* index() { return OperandAt(1); } |
| 6371 | HValue* value() { return OperandAt(2); } |
| 6372 | |
| 6373 | virtual Representation RequiredInputRepresentation(int index) { |
| 6374 | return Representation::Tagged(); |
| 6375 | } |
| 6376 | |
| 6377 | DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) |
| 6378 | |
| 6379 | private: |
| 6380 | String::Encoding encoding_; |
| 6381 | }; |
| 6382 | |
| 6383 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6384 | class HDeleteProperty: public HBinaryOperation { |
| 6385 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6386 | HDeleteProperty(HValue* context, HValue* obj, HValue* key) |
| 6387 | : HBinaryOperation(context, obj, key) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6388 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 6389 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6390 | } |
| 6391 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6392 | virtual Representation RequiredInputRepresentation(int index) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6393 | return Representation::Tagged(); |
| 6394 | } |
| 6395 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 6396 | virtual HType CalculateInferredType(); |
| 6397 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 6398 | DECLARE_CONCRETE_INSTRUCTION(DeleteProperty) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6399 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 6400 | HValue* object() { return left(); } |
| 6401 | HValue* key() { return right(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6402 | }; |
| 6403 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 6404 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6405 | class HIn: public HTemplateInstruction<3> { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 6406 | public: |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6407 | HIn(HValue* context, HValue* key, HValue* object) { |
| 6408 | SetOperandAt(0, context); |
| 6409 | SetOperandAt(1, key); |
| 6410 | SetOperandAt(2, object); |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 6411 | set_representation(Representation::Tagged()); |
| 6412 | SetAllSideEffects(); |
| 6413 | } |
| 6414 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 6415 | HValue* context() { return OperandAt(0); } |
| 6416 | HValue* key() { return OperandAt(1); } |
| 6417 | HValue* object() { return OperandAt(2); } |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 6418 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 6419 | virtual Representation RequiredInputRepresentation(int index) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 6420 | return Representation::Tagged(); |
| 6421 | } |
| 6422 | |
| 6423 | virtual HType CalculateInferredType() { |
| 6424 | return HType::Boolean(); |
| 6425 | } |
| 6426 | |
| 6427 | virtual void PrintDataTo(StringStream* stream); |
| 6428 | |
| 6429 | DECLARE_CONCRETE_INSTRUCTION(In) |
| 6430 | }; |
| 6431 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 6432 | |
| 6433 | class HCheckMapValue: public HTemplateInstruction<2> { |
| 6434 | public: |
| 6435 | HCheckMapValue(HValue* value, |
| 6436 | HValue* map) { |
| 6437 | SetOperandAt(0, value); |
| 6438 | SetOperandAt(1, map); |
| 6439 | set_representation(Representation::Tagged()); |
| 6440 | SetFlag(kUseGVN); |
| 6441 | SetGVNFlag(kDependsOnMaps); |
| 6442 | SetGVNFlag(kDependsOnElementsKind); |
| 6443 | } |
| 6444 | |
| 6445 | virtual Representation RequiredInputRepresentation(int index) { |
| 6446 | return Representation::Tagged(); |
| 6447 | } |
| 6448 | |
| 6449 | virtual void PrintDataTo(StringStream* stream); |
| 6450 | |
| 6451 | virtual HType CalculateInferredType() { |
| 6452 | return HType::Tagged(); |
| 6453 | } |
| 6454 | |
| 6455 | HValue* value() { return OperandAt(0); } |
| 6456 | HValue* map() { return OperandAt(1); } |
| 6457 | |
| 6458 | DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) |
| 6459 | |
| 6460 | protected: |
| 6461 | virtual bool DataEquals(HValue* other) { |
| 6462 | return true; |
| 6463 | } |
| 6464 | }; |
| 6465 | |
| 6466 | |
| 6467 | class HForInPrepareMap : public HTemplateInstruction<2> { |
| 6468 | public: |
| 6469 | HForInPrepareMap(HValue* context, |
| 6470 | HValue* object) { |
| 6471 | SetOperandAt(0, context); |
| 6472 | SetOperandAt(1, object); |
| 6473 | set_representation(Representation::Tagged()); |
| 6474 | SetAllSideEffects(); |
| 6475 | } |
| 6476 | |
| 6477 | virtual Representation RequiredInputRepresentation(int index) { |
| 6478 | return Representation::Tagged(); |
| 6479 | } |
| 6480 | |
| 6481 | HValue* context() { return OperandAt(0); } |
| 6482 | HValue* enumerable() { return OperandAt(1); } |
| 6483 | |
| 6484 | virtual void PrintDataTo(StringStream* stream); |
| 6485 | |
| 6486 | virtual HType CalculateInferredType() { |
| 6487 | return HType::Tagged(); |
| 6488 | } |
| 6489 | |
| 6490 | DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap); |
| 6491 | }; |
| 6492 | |
| 6493 | |
| 6494 | class HForInCacheArray : public HTemplateInstruction<2> { |
| 6495 | public: |
| 6496 | HForInCacheArray(HValue* enumerable, |
| 6497 | HValue* keys, |
| 6498 | int idx) : idx_(idx) { |
| 6499 | SetOperandAt(0, enumerable); |
| 6500 | SetOperandAt(1, keys); |
| 6501 | set_representation(Representation::Tagged()); |
| 6502 | } |
| 6503 | |
| 6504 | virtual Representation RequiredInputRepresentation(int index) { |
| 6505 | return Representation::Tagged(); |
| 6506 | } |
| 6507 | |
| 6508 | HValue* enumerable() { return OperandAt(0); } |
| 6509 | HValue* map() { return OperandAt(1); } |
| 6510 | int idx() { return idx_; } |
| 6511 | |
| 6512 | HForInCacheArray* index_cache() { |
| 6513 | return index_cache_; |
| 6514 | } |
| 6515 | |
| 6516 | void set_index_cache(HForInCacheArray* index_cache) { |
| 6517 | index_cache_ = index_cache; |
| 6518 | } |
| 6519 | |
| 6520 | virtual void PrintDataTo(StringStream* stream); |
| 6521 | |
| 6522 | virtual HType CalculateInferredType() { |
| 6523 | return HType::Tagged(); |
| 6524 | } |
| 6525 | |
| 6526 | DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray); |
| 6527 | |
| 6528 | private: |
| 6529 | int idx_; |
| 6530 | HForInCacheArray* index_cache_; |
| 6531 | }; |
| 6532 | |
| 6533 | |
| 6534 | class HLoadFieldByIndex : public HTemplateInstruction<2> { |
| 6535 | public: |
| 6536 | HLoadFieldByIndex(HValue* object, |
| 6537 | HValue* index) { |
| 6538 | SetOperandAt(0, object); |
| 6539 | SetOperandAt(1, index); |
| 6540 | set_representation(Representation::Tagged()); |
| 6541 | } |
| 6542 | |
| 6543 | virtual Representation RequiredInputRepresentation(int index) { |
| 6544 | return Representation::Tagged(); |
| 6545 | } |
| 6546 | |
| 6547 | HValue* object() { return OperandAt(0); } |
| 6548 | HValue* index() { return OperandAt(1); } |
| 6549 | |
| 6550 | virtual void PrintDataTo(StringStream* stream); |
| 6551 | |
| 6552 | virtual HType CalculateInferredType() { |
| 6553 | return HType::Tagged(); |
| 6554 | } |
| 6555 | |
| 6556 | DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); |
jkummerow@chromium.org | c195667 | 2012-10-11 15:57:38 +0000 | [diff] [blame] | 6557 | |
| 6558 | private: |
| 6559 | virtual bool IsDeletable() const { return true; } |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 6560 | }; |
| 6561 | |
| 6562 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 6563 | #undef DECLARE_INSTRUCTION |
| 6564 | #undef DECLARE_CONCRETE_INSTRUCTION |
| 6565 | |
| 6566 | } } // namespace v8::internal |
| 6567 | |
| 6568 | #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |