Commit bd82f40a authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[baseline] Fallback to off-the-gc-heap when growing buffer

Bug: v8:11872
Change-Id: I16c6c0027b905215a789f8d47b19824b1c1f2491
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2992725
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75465}
parent 59b9aaf7
......@@ -142,8 +142,8 @@ class ExternalAssemblerBufferImpl : public AssemblerBuffer {
class OnHeapAssemblerBuffer : public AssemblerBuffer {
public:
OnHeapAssemblerBuffer(Isolate* isolate, Handle<Code> code, int size)
: isolate_(isolate), code_(code), size_(size) {}
OnHeapAssemblerBuffer(Handle<Code> code, int size)
: code_(code), size_(size) {}
byte* start() const override {
return reinterpret_cast<byte*>(code_->raw_instruction_start());
......@@ -153,13 +153,11 @@ class OnHeapAssemblerBuffer : public AssemblerBuffer {
std::unique_ptr<AssemblerBuffer> Grow(int new_size) override {
DCHECK_LT(size(), new_size);
MaybeHandle<Code> code =
isolate_->factory()->NewEmptyCode(code_->kind(), new_size);
if (code.is_null()) {
FATAL("Cannot grow on heap assembler buffer");
}
return std::make_unique<OnHeapAssemblerBuffer>(
isolate_, code.ToHandleChecked(), new_size);
// We fall back to the slow path using the default assembler buffer and
// compile the code off the GC heap. Compiling directly on heap makes less
// sense now, since we will need to allocate a new Code object, copy the
// content generated so far and relocate.
return std::make_unique<DefaultAssemblerBuffer>(new_size);
}
bool IsOnHeap() const override { return true; }
......@@ -167,7 +165,6 @@ class OnHeapAssemblerBuffer : public AssemblerBuffer {
MaybeHandle<Code> code() const override { return code_; }
private:
Isolate* isolate_;
Handle<Code> code_;
const int size_;
};
......@@ -209,12 +206,12 @@ std::unique_ptr<AssemblerBuffer> NewAssemblerBuffer(int size) {
}
std::unique_ptr<AssemblerBuffer> NewOnHeapAssemblerBuffer(Isolate* isolate,
int size) {
int estimated) {
int size = std::max(AssemblerBase::kMinimalBufferSize, estimated);
MaybeHandle<Code> code =
isolate->factory()->NewEmptyCode(CodeKind::BASELINE, size);
if (code.is_null()) return {};
return std::make_unique<OnHeapAssemblerBuffer>(isolate,
code.ToHandleChecked(), size);
return std::make_unique<OnHeapAssemblerBuffer>(code.ToHandleChecked(), size);
}
// -----------------------------------------------------------------------------
......
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