Commit 37bc0358 authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[assembler] Factor up list of heap allocation requests

Lift the declaration of the heap allocation request list and the method
which adds to the list up to AssemblerBase.

Change-Id: I099260425af8cb579144998c71c538f19ba00e65
Reviewed-on: https://chromium-review.googlesource.com/1098959Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53708}
parent 9718d079
......@@ -1757,25 +1757,13 @@ class Assembler : public AssemblerBase {
void ConstantPoolAddEntry(int position, RelocInfo::Mode rmode,
intptr_t value);
void ConstantPoolAddEntry(int position, Double value);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
friend class RelocInfo;
friend class BlockConstPoolScope;
friend class BlockCodeTargetSharingScope;
friend class EnsureSpace;
friend class UseScratchRegisterScope;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void RequestHeapObject(HeapObjectRequest request);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
};
class EnsureSpace BASE_EMBEDDED {
......
......@@ -3649,20 +3649,8 @@ class Assembler : public AssemblerBase {
// the length of the label chain.
void DeleteUnresolvedBranchInfoForLabelTraverse(Label* label);
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void RequestHeapObject(HeapObjectRequest request);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
private:
friend class EnsureSpace;
friend class ConstPool;
};
......
......@@ -902,7 +902,7 @@ void Assembler::DataAlign(int m) {
}
}
void Assembler::RequestHeapObject(HeapObjectRequest request) {
void AssemblerBase::RequestHeapObject(HeapObjectRequest request) {
request.set_offset(pc_offset());
heap_object_requests_.push_front(request);
}
......
......@@ -87,6 +87,46 @@ class JumpOptimizationInfo {
std::vector<uint32_t> farjmp_bitmap_;
};
class HeapObjectRequest {
public:
explicit HeapObjectRequest(double heap_number, int offset = -1);
explicit HeapObjectRequest(CodeStub* code_stub, int offset = -1);
enum Kind { kHeapNumber, kCodeStub };
Kind kind() const { return kind_; }
double heap_number() const {
DCHECK_EQ(kind(), kHeapNumber);
return value_.heap_number;
}
CodeStub* code_stub() const {
DCHECK_EQ(kind(), kCodeStub);
return value_.code_stub;
}
// The code buffer offset at the time of the request.
int offset() const {
DCHECK_GE(offset_, 0);
return offset_;
}
void set_offset(int offset) {
DCHECK_LT(offset_, 0);
offset_ = offset;
DCHECK_GE(offset_, 0);
}
private:
Kind kind_;
union {
double heap_number;
CodeStub* code_stub;
} value_;
int offset_;
};
// -----------------------------------------------------------------------------
// Platform independent assembler base class.
......@@ -172,6 +212,10 @@ class AssemblerBase : public Malloced {
byte* buffer_;
int buffer_size_;
bool own_buffer_;
std::forward_list<HeapObjectRequest> heap_object_requests_;
// The program counter, which points into the buffer above and moves forward.
// TODO(jkummerow): This should probably have type {Address}.
byte* pc_;
void set_constant_pool_available(bool available) {
if (FLAG_enable_embedded_constant_pool) {
......@@ -182,9 +226,12 @@ class AssemblerBase : public Malloced {
}
}
// The program counter, which points into the buffer above and moves forward.
// TODO(jkummerow): This should probably have type {Address}.
byte* pc_;
// {RequestHeapObject} records the need for a future heap number allocation or
// code stub generation. After code assembly, each platform's
// {Assembler::AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request).
void RequestHeapObject(HeapObjectRequest request);
private:
IsolateData isolate_data_;
......@@ -885,46 +932,6 @@ class ConstantPoolBuilder BASE_EMBEDDED {
PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
};
class HeapObjectRequest {
public:
explicit HeapObjectRequest(double heap_number, int offset = -1);
explicit HeapObjectRequest(CodeStub* code_stub, int offset = -1);
enum Kind { kHeapNumber, kCodeStub };
Kind kind() const { return kind_; }
double heap_number() const {
DCHECK_EQ(kind(), kHeapNumber);
return value_.heap_number;
}
CodeStub* code_stub() const {
DCHECK_EQ(kind(), kCodeStub);
return value_.code_stub;
}
// The code buffer offset at the time of the request.
int offset() const {
DCHECK_GE(offset_, 0);
return offset_;
}
void set_offset(int offset) {
DCHECK_LT(offset_, 0);
offset_ = offset;
DCHECK_GE(offset_, 0);
}
private:
Kind kind_;
union {
double heap_number;
CodeStub* code_stub;
} value_;
int offset_;
};
// Base type for CPU Registers.
//
// 1) We would prefer to use an enum for registers, but enum values are
......
......@@ -1860,6 +1860,8 @@ class Assembler : public AssemblerBase {
bool is_optimizable_farjmp(int idx);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
friend class EnsureSpace;
// Internal reference positions, required for (potential) patching in
......@@ -1870,19 +1872,6 @@ class Assembler : public AssemblerBase {
// code generation
RelocInfoWriter reloc_info_writer;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void RequestHeapObject(HeapObjectRequest request);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
// Variables for this instance of assembler
int farjmp_num_ = 0;
std::deque<int> farjmp_positions_;
......
......@@ -2186,23 +2186,9 @@ class Assembler : public AssemblerBase {
Trampoline trampoline_;
bool internal_trampoline_exception_;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
protected:
// TODO(neis): Make private if its use can be moved out of TurboAssembler.
void RequestHeapObject(HeapObjectRequest request);
private:
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
friend class RegExpMacroAssemblerMIPS;
friend class RelocInfo;
friend class BlockTrampolinePoolScope;
......
......@@ -2250,23 +2250,9 @@ class Assembler : public AssemblerBase {
RegList scratch_register_list_;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
protected:
// TODO(neis): Make private if its use can be moved out of TurboAssembler.
void RequestHeapObject(HeapObjectRequest request);
private:
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
friend class RegExpMacroAssemblerMIPS;
friend class RelocInfo;
friend class BlockTrampolinePoolScope;
......
......@@ -1631,23 +1631,12 @@ class Assembler : public AssemblerBase {
Trampoline trampoline_;
bool internal_trampoline_exception_;
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
friend class RegExpMacroAssemblerPPC;
friend class RelocInfo;
friend class BlockTrampolinePoolScope;
friend class EnsureSpace;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void RequestHeapObject(HeapObjectRequest request);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
};
......
......@@ -1593,22 +1593,13 @@ inline void ss_a_format(Opcode op, int f1, int f2, int f3, int f4, int f5) {
void bind_to(Label* L, int pos);
void next(Label* L);
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
friend class RegExpMacroAssemblerS390;
friend class RelocInfo;
friend class EnsureSpace;
std::vector<Handle<Code>> code_targets_;
friend class EnsureSpace;
};
class EnsureSpace BASE_EMBEDDED {
......
......@@ -2359,6 +2359,8 @@ class Assembler : public AssemblerBase {
bool is_optimizable_farjmp(int idx);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
friend class EnsureSpace;
friend class RegExpMacroAssemblerX64;
......@@ -2372,19 +2374,6 @@ class Assembler : public AssemblerBase {
std::vector<Handle<Code>> code_targets_;
// The following functions help with avoiding allocations of embedded heap
// objects during the code assembly phase. {RequestHeapObject} records the
// need for a future heap number allocation or code stub generation. After
// code assembly, {AllocateAndInstallRequestedHeapObjects} will allocate these
// objects and place them where they are expected (determined by the pc offset
// associated with each request). That is, for each request, it will patch the
// dummy heap object handle that we emitted during code assembly with the
// actual heap object handle.
void RequestHeapObject(HeapObjectRequest request);
void AllocateAndInstallRequestedHeapObjects(Isolate* isolate);
std::forward_list<HeapObjectRequest> heap_object_requests_;
// Variables for this instance of assembler
int farjmp_num_ = 0;
std::deque<int> farjmp_positions_;
......
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