| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_COMPILER_GRAPH_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_GRAPH_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_GRAPH_ASSEMBLER_H_ | 6 #define V8_COMPILER_GRAPH_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 V(ChangeInt32ToInt64) \ | 21 V(ChangeInt32ToInt64) \ |
| 22 V(ChangeInt32ToFloat64) \ | 22 V(ChangeInt32ToFloat64) \ |
| 23 V(ChangeUint32ToFloat64) \ | 23 V(ChangeUint32ToFloat64) \ |
| 24 V(ChangeUint32ToUint64) \ | 24 V(ChangeUint32ToUint64) \ |
| 25 V(ChangeFloat64ToInt32) \ | 25 V(ChangeFloat64ToInt32) \ |
| 26 V(ChangeFloat64ToUint32) \ | 26 V(ChangeFloat64ToUint32) \ |
| 27 V(TruncateInt64ToInt32) \ | 27 V(TruncateInt64ToInt32) \ |
| 28 V(RoundFloat64ToInt32) \ | 28 V(RoundFloat64ToInt32) \ |
| 29 V(TruncateFloat64ToWord32) \ | 29 V(TruncateFloat64ToWord32) \ |
| 30 V(Float64ExtractHighWord32) \ | 30 V(Float64ExtractHighWord32) \ |
| 31 V(Float64Abs) | 31 V(Float64Abs) \ |
| 32 V(BitcastWordToTagged) |
| 32 | 33 |
| 33 #define PURE_ASSEMBLER_MACH_BINOP_LIST(V) \ | 34 #define PURE_ASSEMBLER_MACH_BINOP_LIST(V) \ |
| 34 V(WordShl) \ | 35 V(WordShl) \ |
| 35 V(WordSar) \ | 36 V(WordSar) \ |
| 36 V(WordAnd) \ | 37 V(WordAnd) \ |
| 37 V(Word32Or) \ | 38 V(Word32Or) \ |
| 38 V(Word32And) \ | 39 V(Word32And) \ |
| 39 V(Word32Shr) \ | 40 V(Word32Shr) \ |
| 40 V(Word32Shl) \ | 41 V(Word32Shl) \ |
| 42 V(IntAdd) \ |
| 43 V(IntSub) \ |
| 44 V(UintLessThan) \ |
| 41 V(Int32Add) \ | 45 V(Int32Add) \ |
| 42 V(Int32Sub) \ | 46 V(Int32Sub) \ |
| 43 V(Int32Mul) \ | 47 V(Int32Mul) \ |
| 44 V(Int32LessThanOrEqual) \ | 48 V(Int32LessThanOrEqual) \ |
| 45 V(Uint32LessThanOrEqual) \ | 49 V(Uint32LessThanOrEqual) \ |
| 46 V(Uint32LessThan) \ | 50 V(Uint32LessThan) \ |
| 47 V(Int32LessThan) \ | 51 V(Int32LessThan) \ |
| 48 V(Float64Add) \ | 52 V(Float64Add) \ |
| 49 V(Float64Sub) \ | 53 V(Float64Sub) \ |
| 50 V(Float64Mod) \ | 54 V(Float64Mod) \ |
| 51 V(Float64Equal) \ | 55 V(Float64Equal) \ |
| 52 V(Float64LessThan) \ | 56 V(Float64LessThan) \ |
| 53 V(Float64LessThanOrEqual) \ | 57 V(Float64LessThanOrEqual) \ |
| 54 V(Word32Equal) \ | 58 V(Word32Equal) \ |
| 55 V(WordEqual) | 59 V(WordEqual) |
| 56 | 60 |
| 57 #define CHECKED_ASSEMBLER_MACH_BINOP_LIST(V) \ | 61 #define CHECKED_ASSEMBLER_MACH_BINOP_LIST(V) \ |
| 58 V(Int32AddWithOverflow) \ | 62 V(Int32AddWithOverflow) \ |
| 59 V(Int32SubWithOverflow) \ | 63 V(Int32SubWithOverflow) \ |
| 60 V(Int32MulWithOverflow) \ | 64 V(Int32MulWithOverflow) \ |
| 61 V(Int32Mod) \ | 65 V(Int32Mod) \ |
| 62 V(Int32Div) \ | 66 V(Int32Div) \ |
| 63 V(Uint32Mod) \ | 67 V(Uint32Mod) \ |
| 64 V(Uint32Div) | 68 V(Uint32Div) |
| 65 | 69 |
| 70 #define JSGRAPH_SINGLETON_CONSTANT_LIST(V) \ |
| 71 V(TrueConstant) \ |
| 72 V(FalseConstant) \ |
| 73 V(HeapNumberMapConstant) \ |
| 74 V(NoContextConstant) \ |
| 75 V(EmptyStringConstant) \ |
| 76 V(UndefinedConstant) \ |
| 77 V(TheHoleConstant) \ |
| 78 V(FixedArrayMapConstant) \ |
| 79 V(ToNumberBuiltinConstant) \ |
| 80 V(AllocateInNewSpaceStubConstant) \ |
| 81 V(AllocateInOldSpaceStubConstant) |
| 82 |
| 66 class GraphAssembler; | 83 class GraphAssembler; |
| 67 | 84 |
| 68 enum class GraphAssemblerLabelType { kDeferred, kNonDeferred }; | 85 enum class GraphAssemblerLabelType { kDeferred, kNonDeferred }; |
| 69 | 86 |
| 70 // Label with statically known count of incoming branches and phis. | 87 // Label with statically known count of incoming branches and phis. |
| 71 template <size_t MergeCount, size_t VarCount = 0u> | 88 template <size_t MergeCount, size_t VarCount = 0u> |
| 72 class GraphAssemblerStaticLabel { | 89 class GraphAssemblerStaticLabel { |
| 73 public: | 90 public: |
| 74 Node* PhiAt(size_t index); | 91 Node* PhiAt(size_t index); |
| 75 | 92 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 template <typename... Reps> | 226 template <typename... Reps> |
| 210 GraphAssemblerLabel MakeLabelFor(GraphAssemblerLabelType is_deferred, | 227 GraphAssemblerLabel MakeLabelFor(GraphAssemblerLabelType is_deferred, |
| 211 size_t merge_count, Reps... reps) { | 228 size_t merge_count, Reps... reps) { |
| 212 MachineRepresentation reps_array[] = {MachineRepresentation::kNone, | 229 MachineRepresentation reps_array[] = {MachineRepresentation::kNone, |
| 213 reps...}; | 230 reps...}; |
| 214 return GraphAssemblerLabel(is_deferred, merge_count, sizeof...(reps), | 231 return GraphAssemblerLabel(is_deferred, merge_count, sizeof...(reps), |
| 215 &(reps_array[1]), temp_zone()); | 232 &(reps_array[1]), temp_zone()); |
| 216 } | 233 } |
| 217 | 234 |
| 218 // Value creation. | 235 // Value creation. |
| 219 Node* TrueConstant(); | |
| 220 Node* FalseConstant(); | |
| 221 Node* HeapNumberMapConstant(); | |
| 222 Node* IntPtrConstant(intptr_t value); | 236 Node* IntPtrConstant(intptr_t value); |
| 223 Node* Uint32Constant(int32_t value); | 237 Node* Uint32Constant(int32_t value); |
| 224 Node* Int32Constant(int32_t value); | 238 Node* Int32Constant(int32_t value); |
| 239 Node* UniqueInt32Constant(int32_t value); |
| 225 Node* SmiConstant(int32_t value); | 240 Node* SmiConstant(int32_t value); |
| 226 Node* Float64Constant(double value); | 241 Node* Float64Constant(double value); |
| 227 Node* Projection(int index, Node* value); | 242 Node* Projection(int index, Node* value); |
| 228 Node* HeapConstant(Handle<HeapObject> object); | 243 Node* HeapConstant(Handle<HeapObject> object); |
| 229 Node* NoContextConstant(); | |
| 230 Node* CEntryStubConstant(int result_size); | 244 Node* CEntryStubConstant(int result_size); |
| 231 Node* ExternalConstant(ExternalReference ref); | 245 Node* ExternalConstant(ExternalReference ref); |
| 232 Node* EmptyStringConstant(); | 246 |
| 233 Node* UndefinedConstant(); | 247 #define SINGLETON_CONST_DECL(Name) Node* Name(); |
| 234 Node* TheHoleConstant(); | 248 JSGRAPH_SINGLETON_CONSTANT_LIST(SINGLETON_CONST_DECL) |
| 235 Node* FixedArrayMapConstant(); | 249 #undef SINGLETON_CONST_DECL |
| 236 | 250 |
| 237 #define PURE_UNOP_DECL(Name) Node* Name(Node* input); | 251 #define PURE_UNOP_DECL(Name) Node* Name(Node* input); |
| 238 PURE_ASSEMBLER_MACH_UNOP_LIST(PURE_UNOP_DECL) | 252 PURE_ASSEMBLER_MACH_UNOP_LIST(PURE_UNOP_DECL) |
| 239 #undef PURE_UNOP_DECL | 253 #undef PURE_UNOP_DECL |
| 240 | 254 |
| 241 #define BINOP_DECL(Name) Node* Name(Node* left, Node* right); | 255 #define BINOP_DECL(Name) Node* Name(Node* left, Node* right); |
| 242 PURE_ASSEMBLER_MACH_BINOP_LIST(BINOP_DECL) | 256 PURE_ASSEMBLER_MACH_BINOP_LIST(BINOP_DECL) |
| 243 CHECKED_ASSEMBLER_MACH_BINOP_LIST(BINOP_DECL) | 257 CHECKED_ASSEMBLER_MACH_BINOP_LIST(BINOP_DECL) |
| 244 #undef BINOP_DECL | 258 #undef BINOP_DECL |
| 245 | 259 |
| 246 Node* Float64RoundDown(Node* value); | 260 Node* Float64RoundDown(Node* value); |
| 247 | 261 |
| 248 Node* ToNumber(Node* value); | 262 Node* ToNumber(Node* value); |
| 249 Node* Allocate(PretenureFlag pretenure, Node* size); | 263 Node* Allocate(PretenureFlag pretenure, Node* size); |
| 250 Node* LoadField(FieldAccess const&, Node* object); | 264 Node* LoadField(FieldAccess const&, Node* object); |
| 251 Node* LoadElement(ElementAccess const&, Node* object, Node* index); | 265 Node* LoadElement(ElementAccess const&, Node* object, Node* index); |
| 252 Node* StoreField(FieldAccess const&, Node* object, Node* value); | 266 Node* StoreField(FieldAccess const&, Node* object, Node* value); |
| 253 Node* StoreElement(ElementAccess const&, Node* object, Node* index, | 267 Node* StoreElement(ElementAccess const&, Node* object, Node* index, |
| 254 Node* value); | 268 Node* value); |
| 255 | 269 |
| 256 Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value); | 270 Node* Store(StoreRepresentation rep, Node* object, Node* offset, Node* value); |
| 271 Node* Load(MachineType rep, Node* object, Node* offset); |
| 257 | 272 |
| 258 Node* Retain(Node* buffer); | 273 Node* Retain(Node* buffer); |
| 259 Node* UnsafePointerAdd(Node* base, Node* external); | 274 Node* UnsafePointerAdd(Node* base, Node* external); |
| 260 | 275 |
| 261 Node* DeoptimizeIf(DeoptimizeReason reason, Node* condition, | 276 Node* DeoptimizeIf(DeoptimizeReason reason, Node* condition, |
| 262 Node* frame_state); | 277 Node* frame_state); |
| 263 Node* DeoptimizeUnless(DeoptimizeReason reason, Node* condition, | 278 Node* DeoptimizeUnless(DeoptimizeReason reason, Node* condition, |
| 264 Node* frame_state); | 279 Node* frame_state); |
| 265 template <typename... Args> | 280 template <typename... Args> |
| 266 Node* Call(const CallDescriptor* desc, Args... args); | 281 Node* Call(const CallDescriptor* desc, Args... args); |
| 282 template <typename... Args> |
| 283 Node* Call(const Operator* op, Args... args); |
| 267 | 284 |
| 268 // Basic control operations. | 285 // Basic control operations. |
| 269 template <class LabelType> | 286 template <class LabelType> |
| 270 void Bind(LabelType* label); | 287 void Bind(LabelType* label); |
| 271 | 288 |
| 272 template <class LabelType, typename... vars> | 289 template <class LabelType, typename... vars> |
| 273 void Goto(LabelType* label, vars...); | 290 void Goto(LabelType* label, vars...); |
| 274 | 291 |
| 275 void Branch(Node* condition, GraphAssemblerStaticLabel<1>* if_true, | 292 void Branch(Node* condition, GraphAssemblerStaticLabel<1>* if_true, |
| 276 GraphAssemblerStaticLabel<1>* if_false); | 293 GraphAssemblerStaticLabel<1>* if_false); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 | 420 |
| 404 current_control_ = graph()->NewNode(common()->IfFalse(), branch); | 421 current_control_ = graph()->NewNode(common()->IfFalse(), branch); |
| 405 MergeState(label, vars...); | 422 MergeState(label, vars...); |
| 406 | 423 |
| 407 current_control_ = graph()->NewNode(common()->IfTrue(), branch); | 424 current_control_ = graph()->NewNode(common()->IfTrue(), branch); |
| 408 } | 425 } |
| 409 | 426 |
| 410 template <typename... Args> | 427 template <typename... Args> |
| 411 Node* GraphAssembler::Call(const CallDescriptor* desc, Args... args) { | 428 Node* GraphAssembler::Call(const CallDescriptor* desc, Args... args) { |
| 412 const Operator* op = common()->Call(desc); | 429 const Operator* op = common()->Call(desc); |
| 430 return Call(op, args...); |
| 431 } |
| 432 |
| 433 template <typename... Args> |
| 434 Node* GraphAssembler::Call(const Operator* op, Args... args) { |
| 435 DCHECK_EQ(IrOpcode::kCall, op->opcode()); |
| 413 Node* args_array[] = {args..., current_effect_, current_control_}; | 436 Node* args_array[] = {args..., current_effect_, current_control_}; |
| 414 int size = static_cast<int>(sizeof...(args)) + op->EffectInputCount() + | 437 int size = static_cast<int>(sizeof...(args)) + op->EffectInputCount() + |
| 415 op->ControlInputCount(); | 438 op->ControlInputCount(); |
| 416 Node* call = graph()->NewNode(op, size, args_array); | 439 Node* call = graph()->NewNode(op, size, args_array); |
| 417 DCHECK_EQ(0, op->ControlOutputCount()); | 440 DCHECK_EQ(0, op->ControlOutputCount()); |
| 418 current_effect_ = call; | 441 current_effect_ = call; |
| 419 return call; | 442 return call; |
| 420 } | 443 } |
| 421 | 444 |
| 422 } // namespace compiler | 445 } // namespace compiler |
| 423 } // namespace internal | 446 } // namespace internal |
| 424 } // namespace v8 | 447 } // namespace v8 |
| 425 | 448 |
| 426 #endif // V8_COMPILER_GRAPH_ASSEMBLER_H_ | 449 #endif // V8_COMPILER_GRAPH_ASSEMBLER_H_ |
| OLD | NEW |