v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
handler-table-builder.cc
Go to the documentation of this file.
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
6
8#include "src/heap/factory.h"
11
12namespace v8 {
13namespace internal {
14namespace interpreter {
15
17
18template <typename IsolateT>
20 IsolateT* isolate) {
21 int handler_table_size = static_cast<int>(entries_.size());
22 DirectHandle<TrustedByteArray> table_byte_array =
23 isolate->factory()->NewTrustedByteArray(
24 HandlerTable::LengthForRange(handler_table_size));
25 HandlerTable table(*table_byte_array);
26 for (int i = 0; i < handler_table_size; ++i) {
27 Entry& entry = entries_[i];
29 table.SetRangeStart(i, static_cast<int>(entry.offset_start));
30 table.SetRangeEnd(i, static_cast<int>(entry.offset_end));
31 table.SetRangeHandler(i, static_cast<int>(entry.offset_target), pred);
32 table.SetRangeData(i, entry.context.index());
33 }
34 return table_byte_array;
35}
36
38 Isolate* isolate);
40 LocalIsolate* isolate);
41
43 int handler_id = static_cast<int>(entries_.size());
45 entries_.push_back(entry);
46 return handler_id;
47}
48
49
50void HandlerTableBuilder::SetTryRegionStart(int handler_id, size_t offset) {
51 DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
52 entries_[handler_id].offset_start = offset;
53}
54
55
56void HandlerTableBuilder::SetTryRegionEnd(int handler_id, size_t offset) {
57 DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
58 entries_[handler_id].offset_end = offset;
59}
60
61
62void HandlerTableBuilder::SetHandlerTarget(int handler_id, size_t offset) {
63 DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
64 entries_[handler_id].offset_target = offset;
65}
66
68 int handler_id, HandlerTable::CatchPrediction prediction) {
69 entries_[handler_id].catch_prediction_ = prediction;
70}
71
72
74 entries_[handler_id].context = reg;
75}
76
77} // namespace interpreter
78} // namespace internal
79} // namespace v8
static int LengthForRange(int entries)
static bool constexpr IsValid(T value)
Definition smi.h:67
void SetContextRegister(int handler_id, Register reg)
void SetTryRegionStart(int handler_id, size_t offset)
void SetPrediction(int handler_id, HandlerTable::CatchPrediction prediction)
void SetHandlerTarget(int handler_id, size_t offset)
DirectHandle< TrustedByteArray > ToHandlerTable(IsolateT *isolate)
void SetTryRegionEnd(int handler_id, size_t offset)
static constexpr Register invalid_value()
int32_t offset
LiftoffRegister reg
std::vector< EntryBuilder > entries_
#define DCHECK(condition)
Definition logging.h:482