Commit 05ec0c40 authored by jgruber's avatar jgruber Committed by Commit Bot

[builtins] Remove unused predicate IsOffHeapSafe

Builtins::IsOffHeapSafe is unused now that embedded builtins are
shipped in the snapshot.

A longer explanation: there used to be a difference between
IsOffHeapSafe and IsIsolateIndependent back at an earlier stage when
we still copied off-heap-safe builtins off the heap on isolate startup.
At that point, off-heap builtins didn't need to be isolate-independent,
e.g. they could still contain embedded external references.
Now that embedded builtins are shipped in the snapshot, this
distinction is no longer needed.

Bug: v8:6666
Change-Id: I0be6120b94b01480262f472f0904ea9037941e2a
Reviewed-on: https://chromium-review.googlesource.com/1002652Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52473}
parent b8950aaf
......@@ -200,10 +200,10 @@ bool Builtins::IsBuiltin(const Code* code) {
}
// static
bool Builtins::IsOffHeapBuiltin(const Code* code) {
bool Builtins::IsEmbeddedBuiltin(const Code* code) {
#ifdef V8_EMBEDDED_BUILTINS
return Builtins::IsBuiltinId(code->builtin_index()) &&
Builtins::IsOffHeapSafe(code->builtin_index());
Builtins::IsIsolateIndependent(code->builtin_index());
#else
return false;
#endif
......@@ -215,7 +215,7 @@ bool Builtins::IsLazy(int index) {
#ifdef V8_EMBEDDED_BUILTINS
// We don't want to lazy-deserialize off-heap builtins.
if (Builtins::IsOffHeapSafe(index)) return false;
if (Builtins::IsIsolateIndependent(index)) return false;
#endif
// There are a couple of reasons that builtins can require eager-loading,
......@@ -643,28 +643,6 @@ bool Builtins::IsIsolateIndependent(int index) {
UNREACHABLE();
}
// static
bool Builtins::IsOffHeapSafe(int index) {
#if !defined(V8_EMBEDDED_BUILTINS) || !defined(V8_USE_SNAPSHOT)
return false;
#else
DCHECK(IsBuiltinId(index));
if (IsTooShortForOffHeapTrampoline(index)) return false;
return IsIsolateIndependent(index);
#endif // V8_EMBEDDED_BUILTINS
}
// static
bool Builtins::IsTooShortForOffHeapTrampoline(int index) {
switch (index) {
case kLoadIC_StringLength:
case kLoadIC_StringWrapperLength:
return true;
default:
return false;
}
}
#ifdef V8_EMBEDDED_BUILTINS
// static
Handle<Code> Builtins::GenerateOffHeapTrampolineFor(Isolate* isolate,
......
......@@ -113,8 +113,8 @@ class Builtins {
// necessarily mean that its kind is Code::BUILTIN.
static bool IsBuiltin(const Code* code);
// True, iff the given code object is a builtin with off-heap code.
static bool IsOffHeapBuiltin(const Code* code);
// True, iff the given code object is a builtin with off-heap embedded code.
static bool IsEmbeddedBuiltin(const Code* code);
// Returns true iff the given builtin can be lazy-loaded from the snapshot.
// This is true in general for most builtins with the exception of a few
......@@ -125,17 +125,6 @@ class Builtins {
// TODO(jgruber,v8:6666): Remove once all builtins have been migrated.
static bool IsIsolateIndependent(int index);
// This is the condition we currently use to determine whether a builtin is
// copied off-heap when --stress-off-heap-code is passed. Such builtins do not
// need to be isolate-independent, e.g. they can contain external references
// that point to one specific isolate. A further restrictions is that there
// must be enough space for the trampoline.
static bool IsOffHeapSafe(int index);
// The off-heap trampoline is short but requires a certain minimal instruction
// size. This function states whether a given builtin is too short.
static bool IsTooShortForOffHeapTrampoline(int index);
bool is_initialized() const { return initialized_; }
// Used by SetupIsolateDelegate and Deserializer.
......
......@@ -1214,8 +1214,9 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl(
static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
// Set the return address to the correct point in the interpreter entry
// trampoline.
// TODO(jgruber,v8:6666): Update logic once builtin is off-heap-safe.
DCHECK(!Builtins::IsOffHeapSafe(Builtins::kInterpreterEntryTrampoline));
// TODO(jgruber,v8:6666): Update logic once builtin is isolate-independent.
DCHECK(
!Builtins::IsIsolateIndependent(Builtins::kInterpreterEntryTrampoline));
Smi* interpreter_entry_return_pc_offset(
masm->isolate()->heap()->interpreter_entry_return_pc_offset());
DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero);
......
......@@ -1861,7 +1861,7 @@ Handle<Code> Factory::NewOffHeapTrampolineFor(Handle<Code> code,
DCHECK(isolate()->serializer_enabled());
DCHECK_NOT_NULL(isolate()->embedded_blob());
DCHECK_NE(0, isolate()->embedded_blob_size());
DCHECK(Builtins::IsOffHeapBuiltin(*code));
DCHECK(Builtins::IsEmbeddedBuiltin(*code));
Handle<Code> result =
Builtins::GenerateOffHeapTrampolineFor(isolate(), off_heap_entry);
......
......@@ -2897,7 +2897,7 @@ void CreateOffHeapTrampolines(Isolate* isolate) {
CodeSpaceMemoryModificationScope code_allocation(isolate->heap());
for (int i = 0; i < Builtins::builtin_count; i++) {
if (!Builtins::IsOffHeapSafe(i)) continue;
if (!Builtins::IsIsolateIndependent(i)) continue;
const uint8_t* instruction_start = d.InstructionStartOfBuiltin(i);
Handle<Code> trampoline = isolate->factory()->NewOffHeapTrampolineFor(
......
......@@ -14056,14 +14056,14 @@ SafepointEntry Code::GetSafepointEntry(Address pc) {
#ifdef V8_EMBEDDED_BUILTINS
int Code::OffHeapInstructionSize() const {
DCHECK(Builtins::IsOffHeapBuiltin(this));
DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_size();
EmbeddedData d = EmbeddedData::FromBlob();
return d.InstructionSizeOfBuiltin(builtin_index());
}
Address Code::OffHeapInstructionStart() const {
DCHECK(Builtins::IsOffHeapBuiltin(this));
DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_start();
EmbeddedData d = EmbeddedData::FromBlob();
return reinterpret_cast<Address>(
......@@ -14071,7 +14071,7 @@ Address Code::OffHeapInstructionStart() const {
}
Address Code::OffHeapInstructionEnd() const {
DCHECK(Builtins::IsOffHeapBuiltin(this));
DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_end();
EmbeddedData d = EmbeddedData::FromBlob();
return reinterpret_cast<Address>(
......
......@@ -226,7 +226,7 @@ void Code::set_next_code_link(Object* value) {
int Code::InstructionSize() const {
#ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionSize();
if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionSize();
#endif
return raw_instruction_size();
}
......@@ -237,7 +237,7 @@ byte* Code::raw_instruction_start() const {
Address Code::InstructionStart() const {
#ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionStart();
if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionStart();
#endif
return raw_instruction_start();
}
......@@ -248,7 +248,7 @@ byte* Code::raw_instruction_end() const {
Address Code::InstructionEnd() const {
#ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionEnd();
if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionEnd();
#endif
return raw_instruction_end();
}
......
......@@ -825,7 +825,7 @@ void Serializer<AllocatorT>::ObjectSerializer::VisitOffHeapTarget(
#ifdef V8_EMBEDDED_BUILTINS
{
STATIC_ASSERT(EmbeddedData::kTableSize == Builtins::builtin_count);
CHECK(Builtins::IsOffHeapBuiltin(host));
CHECK(Builtins::IsEmbeddedBuiltin(host));
Address addr = rinfo->target_off_heap_target();
CHECK_NOT_NULL(addr);
CHECK_NOT_NULL(
......
......@@ -296,7 +296,7 @@ v8::StartupData Snapshot::CreateSnapshotBlob(
#ifdef V8_EMBEDDED_BUILTINS
namespace {
bool BuiltinAliasesOffHeapTrampolineRegister(Isolate* isolate, Code* code) {
DCHECK(Builtins::IsOffHeapSafe(code->builtin_index()));
DCHECK(Builtins::IsIsolateIndependent(code->builtin_index()));
switch (Builtins::KindOf(code->builtin_index())) {
case Builtins::CPP:
case Builtins::TFC:
......@@ -340,7 +340,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) {
for (int i = 0; i < Builtins::builtin_count; i++) {
Code* code = builtins->builtin(i);
if (Builtins::IsOffHeapSafe(i)) {
if (Builtins::IsIsolateIndependent(i)) {
DCHECK(!Builtins::IsLazy(i));
// Sanity-check that the given builtin is process-independent and does not
......@@ -383,7 +383,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) {
// Write the raw data section.
for (int i = 0; i < Builtins::builtin_count; i++) {
if (!Builtins::IsOffHeapSafe(i)) continue;
if (!Builtins::IsIsolateIndependent(i)) continue;
Code* code = builtins->builtin(i);
uint32_t offset = offsets[i];
uint8_t* dst = blob + RawDataOffset() + offset;
......
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