12 using testing::MakeMatcher;
13 using testing::MatcherInterface;
14 using testing::MatchResultListener;
15 using testing::StringMatchResultListener;
23 return os << *value.
handle();
26 const ExternalReference& value) {
29 return os << ost.
c_str();
102 template <
typename T>
104 const Matcher<T>& value_matcher,
105 MatchResultListener* listener) {
106 StringMatchResultListener value_listener;
107 if (!value_matcher.MatchAndExplain(value, &value_listener)) {
108 *listener <<
"whose " << value_name <<
" " << value <<
" doesn't match";
109 if (value_listener.str() !=
"") {
110 *listener <<
", " << value_listener.str();
129 *listener <<
"which is NULL";
132 if (
node->opcode() != opcode_) {
148 const Matcher<Node*>& control_matcher)
150 value_matcher_(value_matcher),
151 control_matcher_(control_matcher) {}
154 NodeMatcher::DescribeTo(os);
155 *os <<
" whose value (";
156 value_matcher_.DescribeTo(os);
157 *os <<
") and control (";
158 control_matcher_.DescribeTo(os);
164 return (NodeMatcher::MatchAndExplain(node, listener) &&
166 "value", value_matcher_, listener) &&
168 "control", control_matcher_, listener));
180 const Matcher<Node*>& control1_matcher)
182 control0_matcher_(control0_matcher),
183 control1_matcher_(control1_matcher) {}
186 NodeMatcher::DescribeTo(os);
187 *os <<
" whose control0 (";
188 control0_matcher_.DescribeTo(os);
189 *os <<
") and control1 (";
190 control1_matcher_.DescribeTo(os);
196 return (NodeMatcher::MatchAndExplain(node, listener) &&
198 "control0", control0_matcher_, listener) &&
200 "control1", control1_matcher_, listener));
212 const Matcher<Node*>& control_matcher)
213 :
NodeMatcher(opcode), control_matcher_(control_matcher) {}
216 NodeMatcher::DescribeTo(os);
217 *os <<
" whose control (";
218 control_matcher_.DescribeTo(os);
224 return (NodeMatcher::MatchAndExplain(node, listener) &&
226 "control", control_matcher_, listener));
230 const Matcher<Node*> control_matcher_;
237 const Matcher<Node*>& effect_matcher)
239 value_matcher_(value_matcher),
240 effect_matcher_(effect_matcher) {}
243 NodeMatcher::DescribeTo(os);
244 *os <<
" whose value (";
245 value_matcher_.DescribeTo(os);
246 *os <<
") and effect (";
247 effect_matcher_.DescribeTo(os);
253 return (NodeMatcher::MatchAndExplain(node, listener) &&
255 "value", value_matcher_, listener) &&
257 effect_matcher_, listener));
261 const Matcher<Node*> value_matcher_;
266 template <
typename T>
270 :
NodeMatcher(opcode), value_matcher_(value_matcher) {}
273 NodeMatcher::DescribeTo(os);
274 *os <<
" whose value (";
275 value_matcher_.DescribeTo(os);
281 return (NodeMatcher::MatchAndExplain(node, listener) &&
294 const Matcher<Node*>& value0_matcher,
295 const Matcher<Node*>& value1_matcher,
296 const Matcher<Node*>& control_matcher)
298 type_matcher_(type_matcher),
299 value0_matcher_(value0_matcher),
300 value1_matcher_(value1_matcher),
301 control_matcher_(control_matcher) {}
304 NodeMatcher::DescribeTo(os);
305 *os <<
" whose type (";
306 type_matcher_.DescribeTo(os);
307 *os <<
"), value0 (";
308 value0_matcher_.DescribeTo(os);
309 *os <<
"), value1 (";
310 value1_matcher_.DescribeTo(os);
311 *os <<
") and control (";
312 control_matcher_.DescribeTo(os);
318 return (NodeMatcher::MatchAndExplain(node, listener) &&
320 type_matcher_, listener) &&
322 "value0", value0_matcher_, listener) &&
324 "value1", value1_matcher_, listener) &&
326 "control", control_matcher_, listener));
333 const Matcher<Node*> control_matcher_;
340 const Matcher<Node*>& base_matcher)
342 index_matcher_(index_matcher),
343 base_matcher_(base_matcher) {}
346 NodeMatcher::DescribeTo(os);
347 *os <<
" whose index (";
348 index_matcher_.DescribeTo(os);
349 *os <<
") and base (";
350 base_matcher_.DescribeTo(os);
356 return (NodeMatcher::MatchAndExplain(node, listener) &&
358 index_matcher_, listener) &&
360 base_matcher_, listener));
372 const Matcher<Node*>& value0_matcher,
373 const Matcher<Node*>& value1_matcher,
374 const Matcher<Node*>& value2_matcher,
375 const Matcher<Node*>& value3_matcher,
376 const Matcher<Node*>& effect_matcher,
377 const Matcher<Node*>& control_matcher)
379 descriptor_matcher_(descriptor_matcher),
380 value0_matcher_(value0_matcher),
381 value1_matcher_(value1_matcher),
382 value2_matcher_(value2_matcher),
383 value3_matcher_(value3_matcher),
384 effect_matcher_(effect_matcher),
385 control_matcher_(control_matcher) {}
388 NodeMatcher::DescribeTo(os);
389 *os <<
" whose value0 (";
390 value0_matcher_.DescribeTo(os);
391 *os <<
") and value1 (";
392 value1_matcher_.DescribeTo(os);
393 *os <<
") and value2 (";
394 value2_matcher_.DescribeTo(os);
395 *os <<
") and value3 (";
396 value3_matcher_.DescribeTo(os);
397 *os <<
") and effect (";
398 effect_matcher_.DescribeTo(os);
399 *os <<
") and control (";
400 control_matcher_.DescribeTo(os);
406 return (NodeMatcher::MatchAndExplain(node, listener) &&
408 "descriptor", descriptor_matcher_, listener) &&
410 "value0", value0_matcher_, listener) &&
412 "value1", value1_matcher_, listener) &&
414 "value2", value2_matcher_, listener) &&
416 "value3", value3_matcher_, listener) &&
418 effect_matcher_, listener) &&
420 "control", control_matcher_, listener));
425 const Matcher<Node*> value0_matcher_;
426 const Matcher<Node*> value1_matcher_;
429 const Matcher<Node*> effect_matcher_;
430 const Matcher<Node*> control_matcher_;
437 const Matcher<Node*>& base_matcher,
438 const Matcher<Node*>& index_matcher,
439 const Matcher<Node*>& effect_matcher)
441 rep_matcher_(rep_matcher),
442 base_matcher_(base_matcher),
443 index_matcher_(index_matcher),
444 effect_matcher_(effect_matcher) {}
447 NodeMatcher::DescribeTo(os);
448 *os <<
" whose rep (";
449 rep_matcher_.DescribeTo(os);
451 base_matcher_.DescribeTo(os);
453 index_matcher_.DescribeTo(os);
454 *os <<
") and effect (";
455 effect_matcher_.DescribeTo(os);
461 return (NodeMatcher::MatchAndExplain(node, listener) &&
463 rep_matcher_, listener) &&
465 base_matcher_, listener) &&
467 "index", index_matcher_, listener) &&
469 effect_matcher_, listener));
474 const Matcher<Node*> base_matcher_;
476 const Matcher<Node*> effect_matcher_;
483 const Matcher<WriteBarrierKind> write_barrier_matcher,
484 const Matcher<Node*>& base_matcher,
485 const Matcher<Node*>& index_matcher,
486 const Matcher<Node*>& value_matcher,
487 const Matcher<Node*>& effect_matcher,
488 const Matcher<Node*>& control_matcher)
490 type_matcher_(type_matcher),
491 write_barrier_matcher_(write_barrier_matcher),
492 base_matcher_(base_matcher),
493 index_matcher_(index_matcher),
494 value_matcher_(value_matcher),
495 effect_matcher_(effect_matcher),
496 control_matcher_(control_matcher) {}
499 NodeMatcher::DescribeTo(os);
500 *os <<
" whose type (";
501 type_matcher_.DescribeTo(os);
502 *os <<
"), write barrier (";
503 write_barrier_matcher_.DescribeTo(os);
505 base_matcher_.DescribeTo(os);
507 index_matcher_.DescribeTo(os);
509 value_matcher_.DescribeTo(os);
510 *os <<
"), effect (";
511 effect_matcher_.DescribeTo(os);
512 *os <<
") and control (";
513 control_matcher_.DescribeTo(os);
519 return (NodeMatcher::MatchAndExplain(node, listener) &&
521 OpParameter<StoreRepresentation>(node).machine_type(),
"type",
522 type_matcher_, listener) &&
524 OpParameter<StoreRepresentation>(node).write_barrier_kind(),
525 "write barrier", write_barrier_matcher_, listener) &&
527 base_matcher_, listener) &&
529 "index", index_matcher_, listener) &&
531 "value", value_matcher_, listener) &&
533 effect_matcher_, listener) &&
535 "control", control_matcher_, listener));
539 const Matcher<MachineType> type_matcher_;
541 const Matcher<Node*> base_matcher_;
542 const Matcher<Node*> index_matcher_;
543 const Matcher<Node*> value_matcher_;
544 const Matcher<Node*> effect_matcher_;
545 const Matcher<Node*> control_matcher_;
552 const Matcher<Node*>& rhs_matcher)
554 lhs_matcher_(lhs_matcher),
555 rhs_matcher_(rhs_matcher) {}
558 NodeMatcher::DescribeTo(os);
559 *os <<
" whose lhs (";
560 lhs_matcher_.DescribeTo(os);
561 *os <<
") and rhs (";
562 rhs_matcher_.DescribeTo(os);
568 return (NodeMatcher::MatchAndExplain(node, listener) &&
570 lhs_matcher_, listener) &&
572 rhs_matcher_, listener));
584 :
NodeMatcher(opcode), input_matcher_(input_matcher) {}
587 NodeMatcher::DescribeTo(os);
588 *os <<
" whose input (";
589 input_matcher_.DescribeTo(os);
595 return (NodeMatcher::MatchAndExplain(node, listener) &&
597 "input", input_matcher_, listener));
606 Matcher<Node*>
IsBranch(
const Matcher<Node*>& value_matcher,
607 const Matcher<Node*>& control_matcher) {
608 return MakeMatcher(
new IsBranchMatcher(value_matcher, control_matcher));
612 Matcher<Node*>
IsMerge(
const Matcher<Node*>& control0_matcher,
613 const Matcher<Node*>& control1_matcher) {
614 return MakeMatcher(
new IsMergeMatcher(control0_matcher, control1_matcher));
618 Matcher<Node*>
IsIfTrue(
const Matcher<Node*>& control_matcher) {
619 return MakeMatcher(
new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
623 Matcher<Node*>
IsIfFalse(
const Matcher<Node*>& control_matcher) {
625 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
631 new IsControl1Matcher(IrOpcode::kControlEffect, control_matcher));
636 return MakeMatcher(
new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher));
640 Matcher<Node*>
IsFinish(
const Matcher<Node*>& value_matcher,
641 const Matcher<Node*>& effect_matcher) {
642 return MakeMatcher(
new IsFinishMatcher(value_matcher, effect_matcher));
647 const Matcher<ExternalReference>& value_matcher) {
648 return MakeMatcher(
new IsConstantMatcher<ExternalReference>(
649 IrOpcode::kExternalConstant, value_matcher));
656 IrOpcode::kHeapConstant, value_matcher));
662 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
668 new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher));
674 new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher));
680 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
686 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
690 Matcher<Node*>
IsPhi(
const Matcher<MachineType>& type_matcher,
691 const Matcher<Node*>& value0_matcher,
692 const Matcher<Node*>& value1_matcher,
693 const Matcher<Node*>& merge_matcher) {
694 return MakeMatcher(
new IsPhiMatcher(type_matcher, value0_matcher,
695 value1_matcher, merge_matcher));
700 const Matcher<Node*>& base_matcher) {
701 return MakeMatcher(
new IsProjectionMatcher(index_matcher, base_matcher));
705 Matcher<Node*>
IsCall(
const Matcher<CallDescriptor*>& descriptor_matcher,
706 const Matcher<Node*>& value0_matcher,
707 const Matcher<Node*>& value1_matcher,
708 const Matcher<Node*>& value2_matcher,
709 const Matcher<Node*>& value3_matcher,
710 const Matcher<Node*>& effect_matcher,
711 const Matcher<Node*>& control_matcher) {
712 return MakeMatcher(
new IsCallMatcher(
713 descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
714 value3_matcher, effect_matcher, control_matcher));
718 Matcher<Node*>
IsLoad(
const Matcher<LoadRepresentation>& rep_matcher,
719 const Matcher<Node*>& base_matcher,
720 const Matcher<Node*>& index_matcher,
721 const Matcher<Node*>& effect_matcher) {
722 return MakeMatcher(
new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
727 Matcher<Node*>
IsStore(
const Matcher<MachineType>& type_matcher,
728 const Matcher<WriteBarrierKind>& write_barrier_matcher,
729 const Matcher<Node*>& base_matcher,
730 const Matcher<Node*>& index_matcher,
731 const Matcher<Node*>& value_matcher,
732 const Matcher<Node*>& effect_matcher,
733 const Matcher<Node*>& control_matcher) {
734 return MakeMatcher(
new IsStoreMatcher(
735 type_matcher, write_barrier_matcher, base_matcher, index_matcher,
736 value_matcher, effect_matcher, control_matcher));
740 #define IS_BINOP_MATCHER(Name) \
741 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
742 const Matcher<Node*>& rhs_matcher) { \
743 return MakeMatcher( \
744 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
760 #undef IS_BINOP_MATCHER
763 #define IS_UNOP_MATCHER(Name) \
764 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \
765 return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
777 #undef IS_UNOP_MATCHER
const char * c_str() const
Factory * factory() const
Handle< T > handle() const
Node * Int64Constant(int64_t value)
Node * Parameter(int32_t index)
CommonOperatorBuilder * common()
Matcher< Node * > IsTrueConstant()
Node * Float32Constant(volatile float value)
GraphTest(int parameters=1)
Node * HeapConstant(const Unique< HeapObject > &value)
Node * NumberConstant(volatile double value)
Node * Float64Constant(volatile double value)
Node * Int32Constant(int32_t value)
Matcher< Node * > IsFalseConstant()
Node * NewNode(const Operator *op, int input_count, Node **inputs)
static const char * Mnemonic(Value val)
static Node * GetValueInput(Node *node, int index)
static Node * GetEffectInput(Node *node, int index=0)
static Node * GetControlInput(Node *node, int index=0)
IsPhiMatcher(const Matcher< MachineType > &type_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &control_matcher)
const Matcher< CallDescriptor * > descriptor_matcher_
const Matcher< MachineType > type_matcher_
IsControl1Matcher(IrOpcode::Value opcode, const Matcher< Node * > &control_matcher)
IsConstantMatcher(IrOpcode::Value opcode, const Matcher< T > &value_matcher)
const Matcher< Node * > control0_matcher_
const Matcher< Node * > base_matcher_
IsUnopMatcher(IrOpcode::Value opcode, const Matcher< Node * > &input_matcher)
const Matcher< Node * > index_matcher_
IsLoadMatcher(const Matcher< LoadRepresentation > &rep_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &effect_matcher)
const Matcher< Node * > control1_matcher_
IsCallMatcher(const Matcher< CallDescriptor * > &descriptor_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &value2_matcher, const Matcher< Node * > &value3_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
const Matcher< WriteBarrierKind > write_barrier_matcher_
IsBinopMatcher(IrOpcode::Value opcode, const Matcher< Node * > &lhs_matcher, const Matcher< Node * > &rhs_matcher)
const Matcher< Node * > value0_matcher_
const Matcher< Node * > value3_matcher_
const Matcher< Node * > value1_matcher_
const Matcher< size_t > index_matcher_
IsFinishMatcher(const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher)
virtual bool MatchAndExplain(Node *node, MatchResultListener *listener) const OVERRIDE
IsStoreMatcher(const Matcher< MachineType > &type_matcher, const Matcher< WriteBarrierKind > write_barrier_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
const Matcher< Node * > value2_matcher_
const Matcher< LoadRepresentation > rep_matcher_
const Matcher< Node * > value_matcher_
IsMergeMatcher(const Matcher< Node * > &control0_matcher, const Matcher< Node * > &control1_matcher)
const Matcher< Node * > control_matcher_
const Matcher< Node * > lhs_matcher_
const Matcher< Node * > input_matcher_
const Matcher< T > value_matcher_
const Matcher< Node * > effect_matcher_
virtual void DescribeTo(std::ostream *os) const OVERRIDE
IsBranchMatcher(const Matcher< Node * > &value_matcher, const Matcher< Node * > &control_matcher)
IsProjectionMatcher(const Matcher< size_t > &index_matcher, const Matcher< Node * > &base_matcher)
const Matcher< Node * > rhs_matcher_
virtual void DescribeTo(std::ostream *os) const OVERRIDE
NodeMatcher(IrOpcode::Value opcode)
virtual bool MatchAndExplain(Node *node, MatchResultListener *listener) const OVERRIDE
const IrOpcode::Value opcode_
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define IS_UNOP_MATCHER(Name)
#define IS_BINOP_MATCHER(Name)
bool PrintMatchAndExplain(const T &value, const char *value_name, const Matcher< T > &value_matcher, MatchResultListener *listener)
Matcher< Node * > IsFloat64Constant(const Matcher< double > &value_matcher)
Matcher< Node * > IsMerge(const Matcher< Node * > &control0_matcher, const Matcher< Node * > &control1_matcher)
Matcher< Node * > IsInt64Constant(const Matcher< int64_t > &value_matcher)
Matcher< Node * > IsIfFalse(const Matcher< Node * > &control_matcher)
Matcher< Node * > IsBranch(const Matcher< Node * > &value_matcher, const Matcher< Node * > &control_matcher)
Matcher< Node * > IsFloat32Constant(const Matcher< float > &value_matcher)
Matcher< Node * > IsNumberConstant(const Matcher< double > &value_matcher)
Matcher< Node * > IsIfTrue(const Matcher< Node * > &control_matcher)
Matcher< Node * > IsControlEffect(const Matcher< Node * > &control_matcher)
Matcher< Node * > IsFinish(const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher)
Matcher< Node * > IsInt32Constant(const Matcher< int32_t > &value_matcher)
Matcher< Node * > IsCall(const Matcher< CallDescriptor * > &descriptor_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &value2_matcher, const Matcher< Node * > &value3_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
Matcher< Node * > IsExternalConstant(const Matcher< ExternalReference > &value_matcher)
Matcher< Node * > IsPhi(const Matcher< MachineType > &type_matcher, const Matcher< Node * > &value0_matcher, const Matcher< Node * > &value1_matcher, const Matcher< Node * > &merge_matcher)
Matcher< Node * > IsStore(const Matcher< MachineType > &type_matcher, const Matcher< WriteBarrierKind > &write_barrier_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &value_matcher, const Matcher< Node * > &effect_matcher, const Matcher< Node * > &control_matcher)
Matcher< Node * > IsValueEffect(const Matcher< Node * > &value_matcher)
Matcher< Node * > IsLoad(const Matcher< LoadRepresentation > &rep_matcher, const Matcher< Node * > &base_matcher, const Matcher< Node * > &index_matcher, const Matcher< Node * > &effect_matcher)
Matcher< Node * > IsProjection(const Matcher< size_t > &index_matcher, const Matcher< Node * > &base_matcher)
Matcher< Node * > IsHeapConstant(const Matcher< Unique< HeapObject > > &value_matcher)
OStream & operator<<(OStream &os, const BasicBlockProfiler &p)
Debugger support for the V8 JavaScript engine.
IrOpcode::Value opcode() const
static OStream & PrintTo(OStream &os, T val)
#define T(name, string, precedence)