/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/src/interpreter/bytecode-jump-table.h
95 строк
3 KB
Michaël Zasso
deps: update V8 to 14.6.202.33
24 апр 2026, 19:01
Не верифицирован
24 апр 2026, 19:01
f1e0b83
Код
Авторство
О чём код?
// Copyright 2017 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_INTERPRETER_BYTECODE_JUMP_TABLE_H_ #define V8_INTERPRETER_BYTECODE_JUMP_TABLE_H_ #include "src/interpreter/bytecode-operands.h" #include "src/utils/bit-vector.h" #include "src/zone/zone.h" namespace v8 { namespace internal { namespace interpreter { class ConstantArrayBuilder; // A jump table for a set of targets in a bytecode array. When an entry in the // table is bound, it represents a known position in the bytecode array. If no // entries match, the switch falls through. class V8_EXPORT_PRIVATE BytecodeJumpTable final : public ZoneObject { public: // Constructs a new BytecodeJumpTable starting at |constant_pool_index|, with // the given |size|, where the case values of the table start at // |case_value_base|. BytecodeJumpTable(size_t constant_pool_index, int size, int case_value_base, Zone* zone) : #ifdef DEBUG bound_(size, zone), #endif constant_pool_index_(constant_pool_index), size_(size), case_value_base_(case_value_base) { } size_t constant_pool_index() const { return constant_pool_index_; } size_t switch_bytecode_offset() const { return switch_bytecode_offset_; } OperandScale switch_bytecode_operand_scale() const { return switch_bytecode_operand_scale_; } int case_value_base() const { return case_value_base_; } int size() const { return size_; } #ifdef DEBUG bool is_bound(int case_value) const { DCHECK_GE(case_value, case_value_base_); DCHECK_LT(case_value, case_value_base_ + size()); return bound_.Contains(case_value - case_value_base_); } #endif size_t ConstantPoolEntryFor(int case_value) { DCHECK_GE(case_value, case_value_base_); return constant_pool_index_ + case_value - case_value_base_; } void set_size(int size) { size_ = size; } private: static const size_t kInvalidIndex = static_cast<size_t>(-1); static const size_t kInvalidOffset = static_cast<size_t>(-1); void mark_bound(int case_value) { #ifdef DEBUG DCHECK_GE(case_value, case_value_base_); DCHECK_LT(case_value, case_value_base_ + size()); bound_.Add(case_value - case_value_base_); #endif } void set_switch_bytecode_offset(size_t offset, OperandScale scale) { DCHECK_EQ(switch_bytecode_offset_, kInvalidOffset); switch_bytecode_offset_ = offset; switch_bytecode_operand_scale_ = scale; } #ifdef DEBUG // This bit vector is only used for DCHECKS, so only store the field in debug // builds. BitVector bound_; #endif size_t constant_pool_index_; size_t switch_bytecode_offset_ = kInvalidOffset; OperandScale switch_bytecode_operand_scale_ = OperandScale::kSingle; int size_; int case_value_base_; friend class BytecodeArrayWriter; }; } // namespace interpreter } // namespace internal } // namespace v8 #endif // V8_INTERPRETER_BYTECODE_JUMP_TABLE_H_