Commit c4806ca7 authored by Maciej Goszczycki's avatar Maciej Goszczycki Committed by Commit Bot

[heap] Fix allocation types in CodeBuilder

CodeBuilder was calling AllocateRawWithLightRetry when it should have been
calling AllocateRawWithRetryOrFail (and vice versa).

Also improved variable naming.

Bug: chromium:957934
Change-Id: I03a95165f6d5b44c1f47d08d338d48bcc37c6d04
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1590075
Commit-Queue: Maciej Goszczycki <goszczycki@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61210}
parent 8f4063c6
......@@ -80,7 +80,8 @@ Factory::CodeBuilder::CodeBuilder(Isolate* isolate, const CodeDesc& desc,
kind_(kind),
source_position_table_(isolate_->factory()->empty_byte_array()) {}
MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(bool failing_allocation) {
MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(
bool retry_allocation_or_fail) {
const auto factory = isolate_->factory();
// Allocate objects needed for code initialization.
Handle<ByteArray> reloc_info =
......@@ -93,14 +94,14 @@ MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(bool failing_allocation) {
CodePageCollectionMemoryModificationScope code_allocation(heap);
HeapObject result;
if (failing_allocation) {
if (retry_allocation_or_fail) {
result =
heap->AllocateRawWithRetryOrFail(object_size, AllocationType::kCode);
} else {
result =
heap->AllocateRawWithLightRetry(object_size, AllocationType::kCode);
// Return an empty handle if we cannot allocate the code object.
if (result.is_null()) return MaybeHandle<Code>();
} else {
result =
heap->AllocateRawWithRetryOrFail(object_size, AllocationType::kCode);
}
if (!is_movable_) {
......
......@@ -982,7 +982,7 @@ class V8_EXPORT_PRIVATE Factory {
}
private:
MaybeHandle<Code> BuildInternal(bool failing_allocation);
MaybeHandle<Code> BuildInternal(bool retry_allocation_or_fail);
Isolate* const isolate_;
const CodeDesc& code_desc_;
......
......@@ -13,7 +13,7 @@ namespace v8 {
namespace internal {
namespace test_factory {
TEST(Factory_NewCode) {
TEST(Factory_CodeBuilder) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
......
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