[heap] Fix TPH link-time errors with MSVC

Provide a stub `third_party_heap::Heap` implementation to work around
linker erors with Visual Studio.

cl.exe in debug mode seems to eliminate dead code not as aggressively
as clang or gcc, resulting in references to `third_party_heap::Heap`
remaining in unreachable code paths.

Refs: https://github.com/bnoordhuis/v8-cmake/issues/10
Bug: v8:10427
Change-Id: I61fde11697adc663b182f60c132eda435a7f11bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2159490
Commit-Queue: Ben Noordhuis <info@bnoordhuis.nl>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Auto-Submit: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67293}
This commit is contained in:
Ben Noordhuis 2020-04-21 19:53:43 +02:00 committed by Commit Bot
parent ba84faeca0
commit de6ef577af
2 changed files with 55 additions and 0 deletions

View File

@ -3126,6 +3126,8 @@ v8_source_set("v8_base_without_compiler") {
if (v8_enable_third_party_heap) {
sources += v8_third_party_heap_files
} else {
sources += [ "src/heap/third-party/heap-api-stub.cc" ]
}
if (v8_enable_wasm_gdb_remote_debugging) {

53
src/heap/third-party/heap-api-stub.cc vendored Normal file
View File

@ -0,0 +1,53 @@
// Copyright 2020 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/execution/isolate-utils-inl.h"
#include "src/heap/heap-inl.h"
#include "src/heap/third-party/heap-api.h"
namespace v8 {
namespace internal {
Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) {
return GetHeapFromWritableObject(object)->isolate();
}
} // namespace internal
} // namespace v8
namespace v8 {
namespace internal {
namespace third_party_heap {
// static
std::unique_ptr<Heap> Heap::New(v8::internal::Isolate*) { return nullptr; }
// static
v8::internal::Isolate* Heap::GetIsolate(Address) { return nullptr; }
AllocationResult Heap::Allocate(size_t, AllocationType, AllocationAlignment) {
return AllocationResult();
}
Address Heap::GetObjectFromInnerPointer(Address) { return 0; }
const base::AddressRegion& Heap::GetCodeRange() {
static const base::AddressRegion no_region(0, 0);
return no_region;
}
// static
bool Heap::InCodeSpace(Address) { return false; }
// static
bool Heap::InReadOnlySpace(Address) { return false; }
// static
bool Heap::IsValidHeapObject(HeapObject) { return false; }
bool Heap::CollectGarbage() { return false; }
} // namespace third_party_heap
} // namespace internal
} // namespace v8