Commit 575aa7b8 authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

Add primitives-based constructor for RelocIterator

This is meant to be used from the native wasm datastructures

Bug: v8:6876
Change-Id: Ie865cf3277b24f25e1845bf32837be1a24047472
Reviewed-on: https://chromium-review.googlesource.com/764502
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49310}
parent fbb008a6
...@@ -552,6 +552,7 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) { ...@@ -552,6 +552,7 @@ RelocIterator::RelocIterator(Code* code, int mode_mask) {
rinfo_.host_ = code; rinfo_.host_ = code;
rinfo_.pc_ = code->instruction_start(); rinfo_.pc_ = code->instruction_start();
rinfo_.data_ = 0; rinfo_.data_ = 0;
rinfo_.constant_pool_ = code->constant_pool();
// Relocation info is read backwards. // Relocation info is read backwards.
pos_ = code->relocation_start() + code->relocation_size(); pos_ = code->relocation_start() + code->relocation_size();
end_ = code->relocation_start(); end_ = code->relocation_start();
...@@ -573,6 +574,21 @@ RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) { ...@@ -573,6 +574,21 @@ RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask) {
next(); next();
} }
RelocIterator::RelocIterator(Vector<byte> instructions,
Vector<const byte> reloc_info, Address const_pool,
int mode_mask) {
rinfo_.pc_ = instructions.start();
rinfo_.data_ = 0;
rinfo_.constant_pool_ = const_pool;
// Relocation info is read backwards.
pos_ = reloc_info.start() + reloc_info.size();
end_ = reloc_info.start();
done_ = false;
mode_mask_ = mode_mask;
if (mode_mask_ == 0) pos_ = end_;
next();
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Implementation of RelocInfo // Implementation of RelocInfo
......
...@@ -479,7 +479,6 @@ class RelocInfo { ...@@ -479,7 +479,6 @@ class RelocInfo {
Mode rmode() const { return rmode_; } Mode rmode() const { return rmode_; }
intptr_t data() const { return data_; } intptr_t data() const { return data_; }
Code* host() const { return host_; } Code* host() const { return host_; }
void set_host(Code* host) { host_ = host; }
// Apply a relocation by delta bytes. When the code object is moved, PC // Apply a relocation by delta bytes. When the code object is moved, PC
// relative addresses have to be updated as well as absolute addresses // relative addresses have to be updated as well as absolute addresses
...@@ -612,6 +611,7 @@ class RelocInfo { ...@@ -612,6 +611,7 @@ class RelocInfo {
Mode rmode_; Mode rmode_;
intptr_t data_; intptr_t data_;
Code* host_; Code* host_;
Address constant_pool_ = nullptr;
friend class RelocIterator; friend class RelocIterator;
}; };
...@@ -677,6 +677,11 @@ class RelocIterator: public Malloced { ...@@ -677,6 +677,11 @@ class RelocIterator: public Malloced {
// iteration iff bit k of mode_mask is set. // iteration iff bit k of mode_mask is set.
explicit RelocIterator(Code* code, int mode_mask = -1); explicit RelocIterator(Code* code, int mode_mask = -1);
explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1); explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1);
explicit RelocIterator(Vector<byte> instructions,
Vector<const byte> reloc_info, Address const_pool,
int mode_mask = -1);
RelocIterator(RelocIterator&&) = default;
RelocIterator& operator=(RelocIterator&&) = default;
// Iteration // Iteration
bool done() const { return done_; } bool done() const { return done_; }
...@@ -711,8 +716,8 @@ class RelocIterator: public Malloced { ...@@ -711,8 +716,8 @@ class RelocIterator: public Malloced {
return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
} }
byte* pos_; const byte* pos_;
byte* end_; const byte* end_;
RelocInfo rinfo_; RelocInfo rinfo_;
bool done_; bool done_;
int mode_mask_; int mode_mask_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment