summaryrefslogtreecommitdiff
path: root/deps/v8/src/code-reference.cc
blob: 3716ad04d9fee66be4a81f762788c10ce90cf66d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 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 {
  return kind_ == JS ? js_code_->constant_pool() : wasm_code_->constant_pool();
}

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

Address CodeReference::instruction_end() const {
  return kind_ == JS
             ? js_code_->InstructionEnd()
             : reinterpret_cast<Address>(wasm_code_->instructions().start() +
                                         wasm_code_->instructions().size());
}

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

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

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

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

}  // namespace internal
}  // namespace v8