LCOV - code coverage report
Current view: top level - src/compiler - js-frame-specialization.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 18 31 58.1 %
Date: 2017-04-26 Functions: 3 5 60.0 %

          Line data    Source code
       1             : // Copyright 2015 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/js-frame-specialization.h"
       6             : 
       7             : #include "src/compiler/js-graph.h"
       8             : #include "src/compiler/linkage.h"
       9             : #include "src/frames-inl.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : namespace compiler {
      14             : 
      15       38449 : Reduction JSFrameSpecialization::Reduce(Node* node) {
      16       38449 :   switch (node->opcode()) {
      17             :     case IrOpcode::kOsrValue:
      18         912 :       return ReduceOsrValue(node);
      19             :     case IrOpcode::kOsrGuard:
      20         912 :       return ReduceOsrGuard(node);
      21             :     case IrOpcode::kParameter:
      22           0 :       return ReduceParameter(node);
      23             :     default:
      24             :       break;
      25             :   }
      26             :   return NoChange();
      27             : }
      28             : 
      29        3648 : Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) {
      30             :   // JSFrameSpecialization should never run on interpreted frames, since the
      31             :   // code below assumes standard stack frame layouts.
      32             :   DCHECK(!frame()->is_interpreted());
      33             :   DCHECK_EQ(IrOpcode::kOsrValue, node->opcode());
      34             :   Handle<Object> value;
      35         912 :   int index = OsrValueIndexOf(node->op());
      36         912 :   int const parameters_count = frame()->ComputeParametersCount() + 1;
      37         912 :   if (index == Linkage::kOsrContextSpillSlotIndex) {
      38         136 :     value = handle(frame()->context(), isolate());
      39         844 :   } else if (index >= parameters_count) {
      40        2022 :     value = handle(frame()->GetExpression(index - parameters_count), isolate());
      41             :   } else {
      42             :     // The OsrValue index 0 is the receiver.
      43             :     value =
      44         170 :         handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(),
      45         510 :                isolate());
      46             :   }
      47         912 :   return Replace(jsgraph()->Constant(value));
      48             : }
      49             : 
      50         912 : Reduction JSFrameSpecialization::ReduceOsrGuard(Node* node) {
      51             :   DCHECK_EQ(IrOpcode::kOsrGuard, node->opcode());
      52             :   ReplaceWithValue(node, node->InputAt(0),
      53        1824 :                    NodeProperties::GetEffectInput(node));
      54         912 :   return Changed(node);
      55             : }
      56             : 
      57           0 : Reduction JSFrameSpecialization::ReduceParameter(Node* node) {
      58             :   DCHECK_EQ(IrOpcode::kParameter, node->opcode());
      59             :   Handle<Object> value;
      60           0 :   int const index = ParameterIndexOf(node->op());
      61           0 :   int const parameters_count = frame()->ComputeParametersCount() + 1;
      62           0 :   if (index == Linkage::kJSCallClosureParamIndex) {
      63             :     // The Parameter index references the closure.
      64           0 :     value = handle(frame()->function(), isolate());
      65           0 :   } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) {
      66             :     // The Parameter index references the parameter count.
      67           0 :     value = handle(Smi::FromInt(parameters_count - 1), isolate());
      68           0 :   } else if (index == Linkage::GetJSCallContextParamIndex(parameters_count)) {
      69             :     // The Parameter index references the context.
      70           0 :     value = handle(frame()->context(), isolate());
      71             :   } else {
      72             :     // The Parameter index 0 is the receiver.
      73             :     value =
      74           0 :         handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(),
      75           0 :                isolate());
      76             :   }
      77           0 :   return Replace(jsgraph()->Constant(value));
      78             : }
      79             : 
      80             : 
      81         912 : Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); }
      82             : 
      83             : }  // namespace compiler
      84             : }  // namespace internal
      85             : }  // namespace v8

Generated by: LCOV version 1.10