LCOV - code coverage report
Current view: top level - src/interpreter - handler-table-builder.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 34 34 100.0 %
Date: 2019-04-17 Functions: 9 9 100.0 %

          Line data    Source code
       1             : // Copyright 2016 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/interpreter/handler-table-builder.h"
       6             : 
       7             : #include "src/heap/factory.h"
       8             : #include "src/interpreter/bytecode-register.h"
       9             : #include "src/isolate.h"
      10             : #include "src/objects-inl.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : namespace interpreter {
      15             : 
      16     4272966 : HandlerTableBuilder::HandlerTableBuilder(Zone* zone) : entries_(zone) {}
      17             : 
      18     2111484 : Handle<ByteArray> HandlerTableBuilder::ToHandlerTable(Isolate* isolate) {
      19     2111484 :   int handler_table_size = static_cast<int>(entries_.size());
      20             :   Handle<ByteArray> table_byte_array = isolate->factory()->NewByteArray(
      21     2111484 :       HandlerTable::LengthForRange(handler_table_size), AllocationType::kOld);
      22     2111469 :   HandlerTable table(*table_byte_array);
      23     2405072 :   for (int i = 0; i < handler_table_size; ++i) {
      24      146803 :     Entry& entry = entries_[i];
      25      146803 :     HandlerTable::CatchPrediction pred = entry.catch_prediction_;
      26      146803 :     table.SetRangeStart(i, static_cast<int>(entry.offset_start));
      27      146806 :     table.SetRangeEnd(i, static_cast<int>(entry.offset_end));
      28      146805 :     table.SetRangeHandler(i, static_cast<int>(entry.offset_target), pred);
      29      146806 :     table.SetRangeData(i, entry.context.index());
      30             :   }
      31     2111464 :   return table_byte_array;
      32             : }
      33             : 
      34             : 
      35      154531 : int HandlerTableBuilder::NewHandlerEntry() {
      36      154531 :   int handler_id = static_cast<int>(entries_.size());
      37      154531 :   Entry entry = {0, 0, 0, Register::invalid_value(), HandlerTable::UNCAUGHT};
      38      154531 :   entries_.push_back(entry);
      39      154534 :   return handler_id;
      40             : }
      41             : 
      42             : 
      43      154537 : void HandlerTableBuilder::SetTryRegionStart(int handler_id, size_t offset) {
      44             :   DCHECK(Smi::IsValid(offset));  // Encoding of handler table requires this.
      45      309074 :   entries_[handler_id].offset_start = offset;
      46      154537 : }
      47             : 
      48             : 
      49      154532 : void HandlerTableBuilder::SetTryRegionEnd(int handler_id, size_t offset) {
      50             :   DCHECK(Smi::IsValid(offset));  // Encoding of handler table requires this.
      51      309064 :   entries_[handler_id].offset_end = offset;
      52      154532 : }
      53             : 
      54             : 
      55      154536 : void HandlerTableBuilder::SetHandlerTarget(int handler_id, size_t offset) {
      56             :   DCHECK(Smi::IsValid(offset));  // Encoding of handler table requires this.
      57      309072 :   entries_[handler_id].offset_target = offset;
      58      154536 : }
      59             : 
      60      154537 : void HandlerTableBuilder::SetPrediction(
      61             :     int handler_id, HandlerTable::CatchPrediction prediction) {
      62      309074 :   entries_[handler_id].catch_prediction_ = prediction;
      63      154537 : }
      64             : 
      65             : 
      66      154539 : void HandlerTableBuilder::SetContextRegister(int handler_id, Register reg) {
      67      309078 :   entries_[handler_id].context = reg;
      68      154539 : }
      69             : 
      70             : }  // namespace interpreter
      71             : }  // namespace internal
      72      121996 : }  // namespace v8

Generated by: LCOV version 1.10