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) { ...@@ -200,10 +200,10 @@ bool Builtins::IsBuiltin(const Code* code) {
} }
// static // static
bool Builtins::IsOffHeapBuiltin(const Code* code) { bool Builtins::IsEmbeddedBuiltin(const Code* code) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
return Builtins::IsBuiltinId(code->builtin_index()) && return Builtins::IsBuiltinId(code->builtin_index()) &&
Builtins::IsOffHeapSafe(code->builtin_index()); Builtins::IsIsolateIndependent(code->builtin_index());
#else #else
return false; return false;
#endif #endif
...@@ -215,7 +215,7 @@ bool Builtins::IsLazy(int index) { ...@@ -215,7 +215,7 @@ bool Builtins::IsLazy(int index) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
// We don't want to lazy-deserialize off-heap builtins. // We don't want to lazy-deserialize off-heap builtins.
if (Builtins::IsOffHeapSafe(index)) return false; if (Builtins::IsIsolateIndependent(index)) return false;
#endif #endif
// There are a couple of reasons that builtins can require eager-loading, // There are a couple of reasons that builtins can require eager-loading,
...@@ -643,28 +643,6 @@ bool Builtins::IsIsolateIndependent(int index) { ...@@ -643,28 +643,6 @@ bool Builtins::IsIsolateIndependent(int index) {
UNREACHABLE(); 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 #ifdef V8_EMBEDDED_BUILTINS
// static // static
Handle<Code> Builtins::GenerateOffHeapTrampolineFor(Isolate* isolate, Handle<Code> Builtins::GenerateOffHeapTrampolineFor(Isolate* isolate,
......
...@@ -113,8 +113,8 @@ class Builtins { ...@@ -113,8 +113,8 @@ class Builtins {
// necessarily mean that its kind is Code::BUILTIN. // necessarily mean that its kind is Code::BUILTIN.
static bool IsBuiltin(const Code* code); static bool IsBuiltin(const Code* code);
// True, iff the given code object is a builtin with off-heap code. // True, iff the given code object is a builtin with off-heap embedded code.
static bool IsOffHeapBuiltin(const Code* code); static bool IsEmbeddedBuiltin(const Code* code);
// Returns true iff the given builtin can be lazy-loaded from the snapshot. // 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 // This is true in general for most builtins with the exception of a few
...@@ -125,17 +125,6 @@ class Builtins { ...@@ -125,17 +125,6 @@ class Builtins {
// TODO(jgruber,v8:6666): Remove once all builtins have been migrated. // TODO(jgruber,v8:6666): Remove once all builtins have been migrated.
static bool IsIsolateIndependent(int index); 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_; } bool is_initialized() const { return initialized_; }
// Used by SetupIsolateDelegate and Deserializer. // Used by SetupIsolateDelegate and Deserializer.
......
...@@ -1214,8 +1214,9 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl( ...@@ -1214,8 +1214,9 @@ void Builtins::Generate_InterpreterPushArgsThenConstructImpl(
static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
// Set the return address to the correct point in the interpreter entry // Set the return address to the correct point in the interpreter entry
// trampoline. // trampoline.
// TODO(jgruber,v8:6666): Update logic once builtin is off-heap-safe. // TODO(jgruber,v8:6666): Update logic once builtin is isolate-independent.
DCHECK(!Builtins::IsOffHeapSafe(Builtins::kInterpreterEntryTrampoline)); DCHECK(
!Builtins::IsIsolateIndependent(Builtins::kInterpreterEntryTrampoline));
Smi* interpreter_entry_return_pc_offset( Smi* interpreter_entry_return_pc_offset(
masm->isolate()->heap()->interpreter_entry_return_pc_offset()); masm->isolate()->heap()->interpreter_entry_return_pc_offset());
DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero); DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero);
......
...@@ -1861,7 +1861,7 @@ Handle<Code> Factory::NewOffHeapTrampolineFor(Handle<Code> code, ...@@ -1861,7 +1861,7 @@ Handle<Code> Factory::NewOffHeapTrampolineFor(Handle<Code> code,
DCHECK(isolate()->serializer_enabled()); DCHECK(isolate()->serializer_enabled());
DCHECK_NOT_NULL(isolate()->embedded_blob()); DCHECK_NOT_NULL(isolate()->embedded_blob());
DCHECK_NE(0, isolate()->embedded_blob_size()); DCHECK_NE(0, isolate()->embedded_blob_size());
DCHECK(Builtins::IsOffHeapBuiltin(*code)); DCHECK(Builtins::IsEmbeddedBuiltin(*code));
Handle<Code> result = Handle<Code> result =
Builtins::GenerateOffHeapTrampolineFor(isolate(), off_heap_entry); Builtins::GenerateOffHeapTrampolineFor(isolate(), off_heap_entry);
......
...@@ -2897,7 +2897,7 @@ void CreateOffHeapTrampolines(Isolate* isolate) { ...@@ -2897,7 +2897,7 @@ void CreateOffHeapTrampolines(Isolate* isolate) {
CodeSpaceMemoryModificationScope code_allocation(isolate->heap()); CodeSpaceMemoryModificationScope code_allocation(isolate->heap());
for (int i = 0; i < Builtins::builtin_count; i++) { 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); const uint8_t* instruction_start = d.InstructionStartOfBuiltin(i);
Handle<Code> trampoline = isolate->factory()->NewOffHeapTrampolineFor( Handle<Code> trampoline = isolate->factory()->NewOffHeapTrampolineFor(
......
...@@ -14056,14 +14056,14 @@ SafepointEntry Code::GetSafepointEntry(Address pc) { ...@@ -14056,14 +14056,14 @@ SafepointEntry Code::GetSafepointEntry(Address pc) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
int Code::OffHeapInstructionSize() const { int Code::OffHeapInstructionSize() const {
DCHECK(Builtins::IsOffHeapBuiltin(this)); DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_size(); if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_size();
EmbeddedData d = EmbeddedData::FromBlob(); EmbeddedData d = EmbeddedData::FromBlob();
return d.InstructionSizeOfBuiltin(builtin_index()); return d.InstructionSizeOfBuiltin(builtin_index());
} }
Address Code::OffHeapInstructionStart() const { Address Code::OffHeapInstructionStart() const {
DCHECK(Builtins::IsOffHeapBuiltin(this)); DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_start(); if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_start();
EmbeddedData d = EmbeddedData::FromBlob(); EmbeddedData d = EmbeddedData::FromBlob();
return reinterpret_cast<Address>( return reinterpret_cast<Address>(
...@@ -14071,7 +14071,7 @@ Address Code::OffHeapInstructionStart() const { ...@@ -14071,7 +14071,7 @@ Address Code::OffHeapInstructionStart() const {
} }
Address Code::OffHeapInstructionEnd() const { Address Code::OffHeapInstructionEnd() const {
DCHECK(Builtins::IsOffHeapBuiltin(this)); DCHECK(Builtins::IsEmbeddedBuiltin(this));
if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_end(); if (Isolate::CurrentEmbeddedBlob() == nullptr) return raw_instruction_end();
EmbeddedData d = EmbeddedData::FromBlob(); EmbeddedData d = EmbeddedData::FromBlob();
return reinterpret_cast<Address>( return reinterpret_cast<Address>(
......
...@@ -226,7 +226,7 @@ void Code::set_next_code_link(Object* value) { ...@@ -226,7 +226,7 @@ void Code::set_next_code_link(Object* value) {
int Code::InstructionSize() const { int Code::InstructionSize() const {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionSize(); if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionSize();
#endif #endif
return raw_instruction_size(); return raw_instruction_size();
} }
...@@ -237,7 +237,7 @@ byte* Code::raw_instruction_start() const { ...@@ -237,7 +237,7 @@ byte* Code::raw_instruction_start() const {
Address Code::InstructionStart() const { Address Code::InstructionStart() const {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionStart(); if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionStart();
#endif #endif
return raw_instruction_start(); return raw_instruction_start();
} }
...@@ -248,7 +248,7 @@ byte* Code::raw_instruction_end() const { ...@@ -248,7 +248,7 @@ byte* Code::raw_instruction_end() const {
Address Code::InstructionEnd() const { Address Code::InstructionEnd() const {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (Builtins::IsOffHeapBuiltin(this)) return OffHeapInstructionEnd(); if (Builtins::IsEmbeddedBuiltin(this)) return OffHeapInstructionEnd();
#endif #endif
return raw_instruction_end(); return raw_instruction_end();
} }
......
...@@ -825,7 +825,7 @@ void Serializer<AllocatorT>::ObjectSerializer::VisitOffHeapTarget( ...@@ -825,7 +825,7 @@ void Serializer<AllocatorT>::ObjectSerializer::VisitOffHeapTarget(
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
{ {
STATIC_ASSERT(EmbeddedData::kTableSize == Builtins::builtin_count); STATIC_ASSERT(EmbeddedData::kTableSize == Builtins::builtin_count);
CHECK(Builtins::IsOffHeapBuiltin(host)); CHECK(Builtins::IsEmbeddedBuiltin(host));
Address addr = rinfo->target_off_heap_target(); Address addr = rinfo->target_off_heap_target();
CHECK_NOT_NULL(addr); CHECK_NOT_NULL(addr);
CHECK_NOT_NULL( CHECK_NOT_NULL(
......
...@@ -296,7 +296,7 @@ v8::StartupData Snapshot::CreateSnapshotBlob( ...@@ -296,7 +296,7 @@ v8::StartupData Snapshot::CreateSnapshotBlob(
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
namespace { namespace {
bool BuiltinAliasesOffHeapTrampolineRegister(Isolate* isolate, Code* code) { bool BuiltinAliasesOffHeapTrampolineRegister(Isolate* isolate, Code* code) {
DCHECK(Builtins::IsOffHeapSafe(code->builtin_index())); DCHECK(Builtins::IsIsolateIndependent(code->builtin_index()));
switch (Builtins::KindOf(code->builtin_index())) { switch (Builtins::KindOf(code->builtin_index())) {
case Builtins::CPP: case Builtins::CPP:
case Builtins::TFC: case Builtins::TFC:
...@@ -340,7 +340,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) { ...@@ -340,7 +340,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) {
for (int i = 0; i < Builtins::builtin_count; i++) { for (int i = 0; i < Builtins::builtin_count; i++) {
Code* code = builtins->builtin(i); Code* code = builtins->builtin(i);
if (Builtins::IsOffHeapSafe(i)) { if (Builtins::IsIsolateIndependent(i)) {
DCHECK(!Builtins::IsLazy(i)); DCHECK(!Builtins::IsLazy(i));
// Sanity-check that the given builtin is process-independent and does not // Sanity-check that the given builtin is process-independent and does not
...@@ -383,7 +383,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) { ...@@ -383,7 +383,7 @@ EmbeddedData EmbeddedData::FromIsolate(Isolate* isolate) {
// Write the raw data section. // Write the raw data section.
for (int i = 0; i < Builtins::builtin_count; i++) { for (int i = 0; i < Builtins::builtin_count; i++) {
if (!Builtins::IsOffHeapSafe(i)) continue; if (!Builtins::IsIsolateIndependent(i)) continue;
Code* code = builtins->builtin(i); Code* code = builtins->builtin(i);
uint32_t offset = offsets[i]; uint32_t offset = offsets[i];
uint8_t* dst = blob + RawDataOffset() + offset; 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