| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/simplified-operator.h" | 5 #include "src/compiler/simplified-operator.h" |
| 6 | 6 |
| 7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
| 8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
| 9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
| 10 #include "src/types.h" | 10 #include "src/types.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 const ElementAccess& ElementAccessOf(const Operator* op) { | 168 const ElementAccess& ElementAccessOf(const Operator* op) { |
| 169 DCHECK_NOT_NULL(op); | 169 DCHECK_NOT_NULL(op); |
| 170 DCHECK(op->opcode() == IrOpcode::kLoadElement || | 170 DCHECK(op->opcode() == IrOpcode::kLoadElement || |
| 171 op->opcode() == IrOpcode::kStoreElement); | 171 op->opcode() == IrOpcode::kStoreElement); |
| 172 return OpParameter<ElementAccess>(op); | 172 return OpParameter<ElementAccess>(op); |
| 173 } | 173 } |
| 174 | 174 |
| 175 size_t hash_value(CheckHoleMode mode) { return static_cast<size_t>(mode); } |
| 176 |
| 177 std::ostream& operator<<(std::ostream& os, CheckHoleMode mode) { |
| 178 switch (mode) { |
| 179 case CheckHoleMode::kAllowReturnHole: |
| 180 return os << "allow-return-hole"; |
| 181 case CheckHoleMode::kNeverReturnHole: |
| 182 return os << "never-return-hole"; |
| 183 } |
| 184 UNREACHABLE(); |
| 185 return os; |
| 186 } |
| 187 |
| 188 CheckHoleMode CheckHoleModeOf(const Operator* op) { |
| 189 DCHECK(op->opcode() == IrOpcode::kCheckHole || |
| 190 op->opcode() == IrOpcode::kCheckHoleNaN); |
| 191 return OpParameter<CheckHoleMode>(op); |
| 192 } |
| 193 |
| 175 Type* TypeOf(const Operator* op) { | 194 Type* TypeOf(const Operator* op) { |
| 176 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); | 195 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); |
| 177 return OpParameter<Type*>(op); | 196 return OpParameter<Type*>(op); |
| 178 } | 197 } |
| 179 | 198 |
| 180 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) { | 199 BinaryOperationHints::Hint BinaryOperationHintOf(const Operator* op) { |
| 181 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || | 200 DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd || |
| 182 op->opcode() == IrOpcode::kSpeculativeNumberSubtract); | 201 op->opcode() == IrOpcode::kSpeculativeNumberSubtract); |
| 183 return OpParameter<BinaryOperationHints::Hint>(op); | 202 return OpParameter<BinaryOperationHints::Hint>(op); |
| 184 } | 203 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 207 V(NumberFround, Operator::kNoProperties, 1) \ | 226 V(NumberFround, Operator::kNoProperties, 1) \ |
| 208 V(NumberAtan, Operator::kNoProperties, 1) \ | 227 V(NumberAtan, Operator::kNoProperties, 1) \ |
| 209 V(NumberAtan2, Operator::kNoProperties, 2) \ | 228 V(NumberAtan2, Operator::kNoProperties, 2) \ |
| 210 V(NumberLog, Operator::kNoProperties, 1) \ | 229 V(NumberLog, Operator::kNoProperties, 1) \ |
| 211 V(NumberLog1p, Operator::kNoProperties, 1) \ | 230 V(NumberLog1p, Operator::kNoProperties, 1) \ |
| 212 V(NumberRound, Operator::kNoProperties, 1) \ | 231 V(NumberRound, Operator::kNoProperties, 1) \ |
| 213 V(NumberSqrt, Operator::kNoProperties, 1) \ | 232 V(NumberSqrt, Operator::kNoProperties, 1) \ |
| 214 V(NumberTrunc, Operator::kNoProperties, 1) \ | 233 V(NumberTrunc, Operator::kNoProperties, 1) \ |
| 215 V(NumberToInt32, Operator::kNoProperties, 1) \ | 234 V(NumberToInt32, Operator::kNoProperties, 1) \ |
| 216 V(NumberToUint32, Operator::kNoProperties, 1) \ | 235 V(NumberToUint32, Operator::kNoProperties, 1) \ |
| 217 V(NumberIsHoleNaN, Operator::kNoProperties, 1) \ | |
| 218 V(NumberSilenceNaN, Operator::kNoProperties, 1) \ | 236 V(NumberSilenceNaN, Operator::kNoProperties, 1) \ |
| 219 V(NumberConvertHoleNaN, Operator::kNoProperties, 1) \ | |
| 220 V(StringFromCharCode, Operator::kNoProperties, 1) \ | 237 V(StringFromCharCode, Operator::kNoProperties, 1) \ |
| 221 V(StringToNumber, Operator::kNoProperties, 1) \ | 238 V(StringToNumber, Operator::kNoProperties, 1) \ |
| 222 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \ | 239 V(PlainPrimitiveToNumber, Operator::kNoProperties, 1) \ |
| 223 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1) \ | 240 V(PlainPrimitiveToWord32, Operator::kNoProperties, 1) \ |
| 224 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1) \ | 241 V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1) \ |
| 225 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1) \ | 242 V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1) \ |
| 226 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ | 243 V(ChangeTaggedToInt32, Operator::kNoProperties, 1) \ |
| 227 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ | 244 V(ChangeTaggedToUint32, Operator::kNoProperties, 1) \ |
| 228 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ | 245 V(ChangeTaggedToFloat64, Operator::kNoProperties, 1) \ |
| 229 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \ | 246 V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1) \ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 #define CHECKED(Name) \ | 281 #define CHECKED(Name) \ |
| 265 struct Name##Operator final : public Operator { \ | 282 struct Name##Operator final : public Operator { \ |
| 266 Name##Operator() \ | 283 Name##Operator() \ |
| 267 : Operator(IrOpcode::k##Name, Operator::kNoThrow, #Name, 1, 1, 1, 1, \ | 284 : Operator(IrOpcode::k##Name, Operator::kNoThrow, #Name, 1, 1, 1, 1, \ |
| 268 1, 1) {} \ | 285 1, 1) {} \ |
| 269 }; \ | 286 }; \ |
| 270 Name##Operator k##Name; | 287 Name##Operator k##Name; |
| 271 CHECKED_OP_LIST(CHECKED) | 288 CHECKED_OP_LIST(CHECKED) |
| 272 #undef CHECKED | 289 #undef CHECKED |
| 273 | 290 |
| 291 template <CheckHoleMode kMode> |
| 292 struct CheckHoleOperator final : public Operator1<CheckHoleMode> { |
| 293 CheckHoleOperator() |
| 294 : Operator1<CheckHoleMode>(IrOpcode::kCheckHole, Operator::kFoldable, |
| 295 "CheckHole", 1, 1, 1, 1, 1, 0, kMode) {} |
| 296 }; |
| 297 CheckHoleOperator<CheckHoleMode::kAllowReturnHole> |
| 298 kCheckHoleAllowReturnHoleOperator; |
| 299 CheckHoleOperator<CheckHoleMode::kNeverReturnHole> |
| 300 kCheckHoleNeverReturnHoleOperator; |
| 301 |
| 302 template <CheckHoleMode kMode> |
| 303 struct CheckHoleNaNOperatortor final : public Operator1<CheckHoleMode> { |
| 304 CheckHoleNaNOperatortor() |
| 305 : Operator1<CheckHoleMode>(IrOpcode::kCheckHoleNaN, Operator::kFoldable, |
| 306 "CheckHoleNaN", 1, 1, 1, 1, 1, 0, kMode) {} |
| 307 }; |
| 308 CheckHoleNaNOperatortor<CheckHoleMode::kAllowReturnHole> |
| 309 kCheckHoleNaNAllowReturnHoleOperator; |
| 310 CheckHoleNaNOperatortor<CheckHoleMode::kNeverReturnHole> |
| 311 kCheckHoleNaNNeverReturnHoleOperator; |
| 312 |
| 274 struct CheckIfOperator final : public Operator { | 313 struct CheckIfOperator final : public Operator { |
| 275 CheckIfOperator() | 314 CheckIfOperator() |
| 276 : Operator(IrOpcode::kCheckIf, Operator::kFoldable, "CheckIf", 1, 1, 1, | 315 : Operator(IrOpcode::kCheckIf, Operator::kFoldable, "CheckIf", 1, 1, 1, |
| 277 0, 1, 1) {} | 316 0, 1, 1) {} |
| 278 }; | 317 }; |
| 279 CheckIfOperator kCheckIf; | 318 CheckIfOperator kCheckIf; |
| 280 | 319 |
| 281 template <PretenureFlag kPretenure> | 320 template <PretenureFlag kPretenure> |
| 282 struct AllocateOperator final : public Operator1<PretenureFlag> { | 321 struct AllocateOperator final : public Operator1<PretenureFlag> { |
| 283 AllocateOperator() | 322 AllocateOperator() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 #define GET_FROM_CACHE(Name, properties, input_count) \ | 358 #define GET_FROM_CACHE(Name, properties, input_count) \ |
| 320 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 359 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
| 321 PURE_OP_LIST(GET_FROM_CACHE) | 360 PURE_OP_LIST(GET_FROM_CACHE) |
| 322 #undef GET_FROM_CACHE | 361 #undef GET_FROM_CACHE |
| 323 | 362 |
| 324 #define GET_FROM_CACHE(Name) \ | 363 #define GET_FROM_CACHE(Name) \ |
| 325 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } | 364 const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; } |
| 326 CHECKED_OP_LIST(GET_FROM_CACHE) | 365 CHECKED_OP_LIST(GET_FROM_CACHE) |
| 327 #undef GET_FROM_CACHE | 366 #undef GET_FROM_CACHE |
| 328 | 367 |
| 368 const Operator* SimplifiedOperatorBuilder::CheckHole(CheckHoleMode mode) { |
| 369 switch (mode) { |
| 370 case CheckHoleMode::kAllowReturnHole: |
| 371 return &cache_.kCheckHoleAllowReturnHoleOperator; |
| 372 case CheckHoleMode::kNeverReturnHole: |
| 373 return &cache_.kCheckHoleNeverReturnHoleOperator; |
| 374 } |
| 375 UNREACHABLE(); |
| 376 return nullptr; |
| 377 } |
| 378 |
| 379 const Operator* SimplifiedOperatorBuilder::CheckHoleNaN(CheckHoleMode mode) { |
| 380 switch (mode) { |
| 381 case CheckHoleMode::kAllowReturnHole: |
| 382 return &cache_.kCheckHoleNaNAllowReturnHoleOperator; |
| 383 case CheckHoleMode::kNeverReturnHole: |
| 384 return &cache_.kCheckHoleNaNNeverReturnHoleOperator; |
| 385 } |
| 386 UNREACHABLE(); |
| 387 return nullptr; |
| 388 } |
| 389 |
| 329 const Operator* SimplifiedOperatorBuilder::CheckIf() { | 390 const Operator* SimplifiedOperatorBuilder::CheckIf() { |
| 330 return &cache_.kCheckIf; | 391 return &cache_.kCheckIf; |
| 331 } | 392 } |
| 332 | 393 |
| 333 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 394 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
| 334 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 395 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
| 335 Operator::kCommutative | Operator::kPure, | 396 Operator::kCommutative | Operator::kPure, |
| 336 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 397 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
| 337 } | 398 } |
| 338 | 399 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 479 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
| 419 #Name, value_input_count, 1, control_input_count, \ | 480 #Name, value_input_count, 1, control_input_count, \ |
| 420 output_count, 1, 0, access); \ | 481 output_count, 1, 0, access); \ |
| 421 } | 482 } |
| 422 ACCESS_OP_LIST(ACCESS) | 483 ACCESS_OP_LIST(ACCESS) |
| 423 #undef ACCESS | 484 #undef ACCESS |
| 424 | 485 |
| 425 } // namespace compiler | 486 } // namespace compiler |
| 426 } // namespace internal | 487 } // namespace internal |
| 427 } // namespace v8 | 488 } // namespace v8 |
| OLD | NEW |