diff options
Diffstat (limited to 'deps/v8/src/compiler/code-assembler.cc')
-rw-r--r-- | deps/v8/src/compiler/code-assembler.cc | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/deps/v8/src/compiler/code-assembler.cc b/deps/v8/src/compiler/code-assembler.cc index 0b77d100723..4f400846d42 100644 --- a/deps/v8/src/compiler/code-assembler.cc +++ b/deps/v8/src/compiler/code-assembler.cc @@ -1378,12 +1378,64 @@ void CodeAssembler::GotoIfNot(SloppyTNode<IntegralT> condition, void CodeAssembler::Branch(SloppyTNode<IntegralT> condition, Label* true_label, Label* false_label) { + int32_t constant; + if (ToInt32Constant(condition, constant)) { + if ((true_label->is_used() || true_label->is_bound()) && + (false_label->is_used() || false_label->is_bound())) { + return Goto(constant ? true_label : false_label); + } + } true_label->MergeVariables(); false_label->MergeVariables(); return raw_assembler()->Branch(condition, true_label->label_, false_label->label_); } +void CodeAssembler::Branch(TNode<BoolT> condition, + std::function<void()> true_body, + std::function<void()> false_body) { + int32_t constant; + if (ToInt32Constant(condition, constant)) { + return constant ? true_body() : false_body(); + } + + Label vtrue(this), vfalse(this); + Branch(condition, &vtrue, &vfalse); + + Bind(&vtrue); + true_body(); + + Bind(&vfalse); + false_body(); +} + +void CodeAssembler::Branch(TNode<BoolT> condition, Label* true_label, + std::function<void()> false_body) { + int32_t constant; + if (ToInt32Constant(condition, constant)) { + return constant ? Goto(true_label) : false_body(); + } + + Label vfalse(this); + Branch(condition, true_label, &vfalse); + Bind(&vfalse); + false_body(); +} + +void CodeAssembler::Branch(TNode<BoolT> condition, + std::function<void()> true_body, + Label* false_label) { + int32_t constant; + if (ToInt32Constant(condition, constant)) { + return constant ? true_body() : Goto(false_label); + } + + Label vtrue(this); + Branch(condition, &vtrue, false_label); + Bind(&vtrue); + true_body(); +} + void CodeAssembler::Switch(Node* index, Label* default_label, const int32_t* case_values, Label** case_labels, size_t case_count) { @@ -1685,8 +1737,7 @@ void CodeAssemblerLabel::UpdateVariablesAfterBind() { } // namespace compiler -Smi* CheckObjectType(Isolate* isolate, Object* value, Smi* type, - String* location) { +Smi* CheckObjectType(Object* value, Smi* type, String* location) { #ifdef DEBUG const char* expected; switch (static_cast<ObjectType>(type->value())) { |