| 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 Type* TypeOf(const Operator* op) { |
| 176 DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode()); |
| 177 return OpParameter<Type*>(op); |
| 178 } |
| 179 |
| 175 #define PURE_OP_LIST(V) \ | 180 #define PURE_OP_LIST(V) \ |
| 176 V(BooleanNot, Operator::kNoProperties, 1) \ | 181 V(BooleanNot, Operator::kNoProperties, 1) \ |
| 177 V(BooleanToNumber, Operator::kNoProperties, 1) \ | 182 V(BooleanToNumber, Operator::kNoProperties, 1) \ |
| 178 V(NumberEqual, Operator::kCommutative, 2) \ | 183 V(NumberEqual, Operator::kCommutative, 2) \ |
| 179 V(NumberLessThan, Operator::kNoProperties, 2) \ | 184 V(NumberLessThan, Operator::kNoProperties, 2) \ |
| 180 V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \ | 185 V(NumberLessThanOrEqual, Operator::kNoProperties, 2) \ |
| 181 V(NumberAdd, Operator::kCommutative, 2) \ | 186 V(NumberAdd, Operator::kCommutative, 2) \ |
| 182 V(NumberSubtract, Operator::kNoProperties, 2) \ | 187 V(NumberSubtract, Operator::kNoProperties, 2) \ |
| 183 V(NumberMultiply, Operator::kCommutative, 2) \ | 188 V(NumberMultiply, Operator::kCommutative, 2) \ |
| 184 V(NumberDivide, Operator::kNoProperties, 2) \ | 189 V(NumberDivide, Operator::kNoProperties, 2) \ |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 PURE_OP_LIST(GET_FROM_CACHE) | 280 PURE_OP_LIST(GET_FROM_CACHE) |
| 276 #undef GET_FROM_CACHE | 281 #undef GET_FROM_CACHE |
| 277 | 282 |
| 278 | 283 |
| 279 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { | 284 const Operator* SimplifiedOperatorBuilder::ReferenceEqual(Type* type) { |
| 280 return new (zone()) Operator(IrOpcode::kReferenceEqual, | 285 return new (zone()) Operator(IrOpcode::kReferenceEqual, |
| 281 Operator::kCommutative | Operator::kPure, | 286 Operator::kCommutative | Operator::kPure, |
| 282 "ReferenceEqual", 2, 0, 0, 1, 0, 0); | 287 "ReferenceEqual", 2, 0, 0, 1, 0, 0); |
| 283 } | 288 } |
| 284 | 289 |
| 290 const Operator* SimplifiedOperatorBuilder::TypeGuard(Type* type) { |
| 291 class TypeGuardOperator final : public Operator1<Type*> { |
| 292 public: |
| 293 explicit TypeGuardOperator(Type* type) |
| 294 : Operator1<Type*>( // -- |
| 295 IrOpcode::kTypeGuard, Operator::kPure, // opcode |
| 296 "TypeGuard", // name |
| 297 1, 0, 1, 1, 0, 0, // counts |
| 298 type) {} // parameter |
| 299 |
| 300 void PrintParameter(std::ostream& os) const final { |
| 301 parameter()->PrintTo(os); |
| 302 } |
| 303 }; |
| 304 return new (zone()) TypeGuardOperator(type); |
| 305 } |
| 285 | 306 |
| 286 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { | 307 const Operator* SimplifiedOperatorBuilder::Allocate(PretenureFlag pretenure) { |
| 287 switch (pretenure) { | 308 switch (pretenure) { |
| 288 case NOT_TENURED: | 309 case NOT_TENURED: |
| 289 return &cache_.kAllocateNotTenuredOperator; | 310 return &cache_.kAllocateNotTenuredOperator; |
| 290 case TENURED: | 311 case TENURED: |
| 291 return &cache_.kAllocateTenuredOperator; | 312 return &cache_.kAllocateTenuredOperator; |
| 292 } | 313 } |
| 293 UNREACHABLE(); | 314 UNREACHABLE(); |
| 294 return nullptr; | 315 return nullptr; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ | 356 Operator1<Type>(IrOpcode::k##Name, Operator::kNoThrow | properties, \ |
| 336 #Name, value_input_count, 1, control_input_count, \ | 357 #Name, value_input_count, 1, control_input_count, \ |
| 337 output_count, 1, 0, access); \ | 358 output_count, 1, 0, access); \ |
| 338 } | 359 } |
| 339 ACCESS_OP_LIST(ACCESS) | 360 ACCESS_OP_LIST(ACCESS) |
| 340 #undef ACCESS | 361 #undef ACCESS |
| 341 | 362 |
| 342 } // namespace compiler | 363 } // namespace compiler |
| 343 } // namespace internal | 364 } // namespace internal |
| 344 } // namespace v8 | 365 } // namespace v8 |
| OLD | NEW |