LCOV - code coverage report
Current view: top level - src/compiler - control-builders.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 91 109 83.5 %
Date: 2017-04-26 Functions: 22 25 88.0 %

          Line data    Source code
       1             : // Copyright 2013 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/compiler/control-builders.h"
       6             : 
       7             : #include "src/objects-inl.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : namespace compiler {
      12             : 
      13             : 
      14        4461 : void IfBuilder::If(Node* condition, BranchHint hint) {
      15        4461 :   builder_->NewBranch(condition, hint);
      16        8922 :   else_environment_ = environment()->CopyForConditional();
      17        4461 : }
      18             : 
      19             : 
      20        4461 : void IfBuilder::Then() { builder_->NewIfTrue(); }
      21             : 
      22             : 
      23        4461 : void IfBuilder::Else() {
      24        4461 :   builder_->NewMerge();
      25        8922 :   then_environment_ = environment();
      26        4461 :   set_environment(else_environment_);
      27        4461 :   builder_->NewIfFalse();
      28        4461 : }
      29             : 
      30             : 
      31        3621 : void IfBuilder::End() {
      32       13383 :   then_environment_->Merge(environment());
      33        4461 :   set_environment(then_environment_);
      34        3621 : }
      35             : 
      36             : 
      37         840 : void LoopBuilder::BeginLoop(BitVector* assigned, bool is_osr) {
      38        2520 :   loop_environment_ = environment()->CopyForLoop(assigned, is_osr);
      39         840 :   continue_environment_ = environment()->CopyAsUnreachable();
      40         840 :   break_environment_ = environment()->CopyAsUnreachable();
      41         840 :   assigned_ = assigned;
      42         840 : }
      43             : 
      44             : 
      45         101 : void LoopBuilder::Continue() {
      46         202 :   continue_environment_->Merge(environment());
      47             :   environment()->MarkAsUnreachable();
      48         101 : }
      49             : 
      50             : 
      51        1838 : void LoopBuilder::Break() {
      52        3676 :   break_environment_->Merge(environment());
      53             :   environment()->MarkAsUnreachable();
      54        1838 : }
      55             : 
      56             : 
      57         840 : void LoopBuilder::EndBody() {
      58        2520 :   continue_environment_->Merge(environment());
      59         840 :   set_environment(continue_environment_);
      60         840 : }
      61             : 
      62             : 
      63         840 : void LoopBuilder::EndLoop() {
      64        2520 :   loop_environment_->Merge(environment());
      65         840 :   set_environment(break_environment_);
      66         840 :   ExitLoop();
      67         840 : }
      68             : 
      69             : 
      70         840 : void LoopBuilder::BreakUnless(Node* condition) {
      71         840 :   IfBuilder control_if(builder_);
      72         840 :   control_if.If(condition);
      73             :   control_if.Then();
      74         840 :   control_if.Else();
      75         840 :   Break();
      76             :   control_if.End();
      77         840 : }
      78             : 
      79             : 
      80           0 : void LoopBuilder::BreakWhen(Node* condition) {
      81           0 :   IfBuilder control_if(builder_);
      82           0 :   control_if.If(condition);
      83             :   control_if.Then();
      84           0 :   Break();
      85           0 :   control_if.Else();
      86             :   control_if.End();
      87           0 : }
      88             : 
      89        1254 : void LoopBuilder::ExitLoop(Node** extra_value_to_rename) {
      90        1254 :   if (extra_value_to_rename) {
      91        2082 :     environment()->Push(*extra_value_to_rename);
      92             :   }
      93             :   environment()->PrepareForLoopExit(loop_environment_->GetControlDependency(),
      94        2508 :                                     assigned_);
      95        1254 :   if (extra_value_to_rename) {
      96         414 :     *extra_value_to_rename = environment()->Pop();
      97             :   }
      98        1254 : }
      99             : 
     100          79 : void SwitchBuilder::BeginSwitch() {
     101         237 :   body_environment_ = environment()->CopyAsUnreachable();
     102          79 :   label_environment_ = environment()->CopyAsUnreachable();
     103          79 :   break_environment_ = environment()->CopyAsUnreachable();
     104          79 : }
     105             : 
     106             : 
     107         401 : void SwitchBuilder::BeginLabel(int index, Node* condition) {
     108         401 :   builder_->NewBranch(condition);
     109        1203 :   label_environment_ = environment()->CopyForConditional();
     110         401 :   builder_->NewIfTrue();
     111         802 :   body_environments_[index] = environment();
     112         401 : }
     113             : 
     114             : 
     115         401 : void SwitchBuilder::EndLabel() {
     116         401 :   set_environment(label_environment_);
     117         401 :   builder_->NewIfFalse();
     118         401 : }
     119             : 
     120             : 
     121          64 : void SwitchBuilder::DefaultAt(int index) {
     122         192 :   label_environment_ = environment()->CopyAsUnreachable();
     123         128 :   body_environments_[index] = environment();
     124          64 : }
     125             : 
     126             : 
     127         465 : void SwitchBuilder::BeginCase(int index) {
     128        1395 :   set_environment(body_environments_[index]);
     129         930 :   environment()->Merge(body_environment_);
     130         465 : }
     131             : 
     132             : 
     133         167 : void SwitchBuilder::Break() {
     134         334 :   break_environment_->Merge(environment());
     135             :   environment()->MarkAsUnreachable();
     136         167 : }
     137             : 
     138             : 
     139         930 : void SwitchBuilder::EndCase() { body_environment_ = environment(); }
     140             : 
     141             : 
     142          79 : void SwitchBuilder::EndSwitch() {
     143          79 :   break_environment_->Merge(label_environment_);
     144         237 :   break_environment_->Merge(environment());
     145          79 :   set_environment(break_environment_);
     146          79 : }
     147             : 
     148             : 
     149           4 : void BlockBuilder::BeginBlock() {
     150           8 :   break_environment_ = environment()->CopyAsUnreachable();
     151           4 : }
     152             : 
     153             : 
     154           2 : void BlockBuilder::Break() {
     155           4 :   break_environment_->Merge(environment());
     156             :   environment()->MarkAsUnreachable();
     157           2 : }
     158             : 
     159             : 
     160           0 : void BlockBuilder::BreakWhen(Node* condition, BranchHint hint) {
     161           0 :   IfBuilder control_if(builder_);
     162           0 :   control_if.If(condition, hint);
     163             :   control_if.Then();
     164           0 :   Break();
     165           0 :   control_if.Else();
     166             :   control_if.End();
     167           0 : }
     168             : 
     169             : 
     170           0 : void BlockBuilder::BreakUnless(Node* condition, BranchHint hint) {
     171           0 :   IfBuilder control_if(builder_);
     172           0 :   control_if.If(condition, hint);
     173             :   control_if.Then();
     174           0 :   control_if.Else();
     175           0 :   Break();
     176             :   control_if.End();
     177           0 : }
     178             : 
     179             : 
     180           4 : void BlockBuilder::EndBlock() {
     181          12 :   break_environment_->Merge(environment());
     182           4 :   set_environment(break_environment_);
     183           4 : }
     184             : 
     185             : }  // namespace compiler
     186             : }  // namespace internal
     187             : }  // namespace v8

Generated by: LCOV version 1.10