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        4431 : void IfBuilder::If(Node* condition, BranchHint hint) {
      15        4431 :   builder_->NewBranch(condition, hint);
      16        8862 :   else_environment_ = environment()->CopyForConditional();
      17        4431 : }
      18             : 
      19             : 
      20        4431 : void IfBuilder::Then() { builder_->NewIfTrue(); }
      21             : 
      22             : 
      23        4431 : void IfBuilder::Else() {
      24        4431 :   builder_->NewMerge();
      25        8862 :   then_environment_ = environment();
      26        4431 :   set_environment(else_environment_);
      27        4431 :   builder_->NewIfFalse();
      28        4431 : }
      29             : 
      30             : 
      31        3597 : void IfBuilder::End() {
      32       13293 :   then_environment_->Merge(environment());
      33        4431 :   set_environment(then_environment_);
      34        3597 : }
      35             : 
      36             : 
      37         834 : void LoopBuilder::BeginLoop(BitVector* assigned, bool is_osr) {
      38        2502 :   loop_environment_ = environment()->CopyForLoop(assigned, is_osr);
      39         834 :   continue_environment_ = environment()->CopyAsUnreachable();
      40         834 :   break_environment_ = environment()->CopyAsUnreachable();
      41         834 :   assigned_ = assigned;
      42         834 : }
      43             : 
      44             : 
      45         101 : void LoopBuilder::Continue() {
      46         202 :   continue_environment_->Merge(environment());
      47             :   environment()->MarkAsUnreachable();
      48         101 : }
      49             : 
      50             : 
      51        1820 : void LoopBuilder::Break() {
      52        3640 :   break_environment_->Merge(environment());
      53             :   environment()->MarkAsUnreachable();
      54        1820 : }
      55             : 
      56             : 
      57         834 : void LoopBuilder::EndBody() {
      58        2502 :   continue_environment_->Merge(environment());
      59         834 :   set_environment(continue_environment_);
      60         834 : }
      61             : 
      62             : 
      63         834 : void LoopBuilder::EndLoop() {
      64        2502 :   loop_environment_->Merge(environment());
      65         834 :   set_environment(break_environment_);
      66         834 :   ExitLoop();
      67         834 : }
      68             : 
      69             : 
      70         834 : void LoopBuilder::BreakUnless(Node* condition) {
      71         834 :   IfBuilder control_if(builder_);
      72         834 :   control_if.If(condition);
      73             :   control_if.Then();
      74         834 :   control_if.Else();
      75         834 :   Break();
      76             :   control_if.End();
      77         834 : }
      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        1247 : void LoopBuilder::ExitLoop(Node** extra_value_to_rename) {
      90        1247 :   if (extra_value_to_rename) {
      91        2073 :     environment()->Push(*extra_value_to_rename);
      92             :   }
      93             :   environment()->PrepareForLoopExit(loop_environment_->GetControlDependency(),
      94        2494 :                                     assigned_);
      95        1247 :   if (extra_value_to_rename) {
      96         413 :     *extra_value_to_rename = environment()->Pop();
      97             :   }
      98        1247 : }
      99             : 
     100          76 : void SwitchBuilder::BeginSwitch() {
     101         228 :   body_environment_ = environment()->CopyAsUnreachable();
     102          76 :   label_environment_ = environment()->CopyAsUnreachable();
     103          76 :   break_environment_ = environment()->CopyAsUnreachable();
     104          76 : }
     105             : 
     106             : 
     107         390 : void SwitchBuilder::BeginLabel(int index, Node* condition) {
     108         390 :   builder_->NewBranch(condition);
     109        1170 :   label_environment_ = environment()->CopyForConditional();
     110         390 :   builder_->NewIfTrue();
     111         780 :   body_environments_[index] = environment();
     112         390 : }
     113             : 
     114             : 
     115         390 : void SwitchBuilder::EndLabel() {
     116         390 :   set_environment(label_environment_);
     117         390 :   builder_->NewIfFalse();
     118         390 : }
     119             : 
     120             : 
     121          61 : void SwitchBuilder::DefaultAt(int index) {
     122         183 :   label_environment_ = environment()->CopyAsUnreachable();
     123         122 :   body_environments_[index] = environment();
     124          61 : }
     125             : 
     126             : 
     127         451 : void SwitchBuilder::BeginCase(int index) {
     128        1353 :   set_environment(body_environments_[index]);
     129         902 :   environment()->Merge(body_environment_);
     130         451 : }
     131             : 
     132             : 
     133         159 : void SwitchBuilder::Break() {
     134         318 :   break_environment_->Merge(environment());
     135             :   environment()->MarkAsUnreachable();
     136         159 : }
     137             : 
     138             : 
     139         902 : void SwitchBuilder::EndCase() { body_environment_ = environment(); }
     140             : 
     141             : 
     142          76 : void SwitchBuilder::EndSwitch() {
     143          76 :   break_environment_->Merge(label_environment_);
     144         228 :   break_environment_->Merge(environment());
     145          76 :   set_environment(break_environment_);
     146          76 : }
     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