code-reference.cc 1.77 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2018 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.

#include "src/code-reference.h"

#include "src/handles-inl.h"
#include "src/objects-inl.h"
#include "src/wasm/wasm-code-manager.h"

namespace v8 {
namespace internal {

Address CodeReference::constant_pool() const {
15
  return kind_ == JS ? js_code_->constant_pool() : wasm_code_->constant_pool();
16 17 18
}

Address CodeReference::instruction_start() const {
19 20 21
  return kind_ == JS
             ? js_code_->InstructionStart()
             : reinterpret_cast<Address>(wasm_code_->instructions().start());
22 23 24
}

Address CodeReference::instruction_end() const {
25 26 27 28
  return kind_ == JS
             ? js_code_->InstructionEnd()
             : reinterpret_cast<Address>(wasm_code_->instructions().start() +
                                         wasm_code_->instructions().size());
29 30 31
}

int CodeReference::instruction_size() const {
32 33
  return kind_ == JS ? js_code_->InstructionSize()
                     : wasm_code_->instructions().length();
34 35 36
}

const byte* CodeReference::relocation_start() const {
37 38
  return kind_ == JS ? js_code_->relocation_start()
                     : wasm_code_->reloc_info().start();
39 40 41
}

const byte* CodeReference::relocation_end() const {
42 43 44
  return kind_ == JS ? js_code_->relocation_end()
                     : wasm_code_->reloc_info().start() +
                           wasm_code_->reloc_info().length();
45 46 47
}

int CodeReference::relocation_size() const {
48 49
  return kind_ == JS ? js_code_->relocation_size()
                     : wasm_code_->reloc_info().length();
50 51
}

52 53 54 55
Address CodeReference::code_comments() const {
  return kind_ == JS ? js_code_->code_comments() : wasm_code_->code_comments();
}

56 57
}  // namespace internal
}  // namespace v8