Remove CodeAssembler::LookupExternalReference

Indirections for external references are now handled completely in
macro assemblers, which can produce more efficient code.

Bug: v8:6666
Change-Id: I158f2e2517e2d97a1006cec6e3b4ac3a7ef3fab6
Reviewed-on: https://chromium-review.googlesource.com/1095307
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53666}
This commit is contained in:
jgruber 2018-06-12 13:49:58 +02:00 committed by Commit Bot
parent 68864d3990
commit faf64532d5
11 changed files with 14 additions and 55 deletions

View File

@ -381,9 +381,7 @@ void TurboAssembler::Move(Register dst, Handle<HeapObject> value) {
void TurboAssembler::Move(Register dst, ExternalReference reference) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList() &&
reference.address() !=
ExternalReference::roots_array_start(isolate()).address()) {
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList()) {
IndirectLoadExternalReference(dst, reference);
return;
}

View File

@ -3092,6 +3092,8 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
} else {
__ Move(dst, src_object);
}
} else if (src.type() == Constant::kExternalReference) {
__ Move(dst, src.ToExternalReference());
} else {
__ mov(dst, g.ToImmediate(source));
}

View File

@ -2592,6 +2592,8 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
} else {
__ Move(dst, src_object);
}
} else if (src.type() == Constant::kExternalReference) {
__ Mov(dst, src.ToExternalReference());
} else {
__ Mov(dst, g.ToImmediate(source));
}

View File

@ -6,7 +6,6 @@
#include <ostream>
#include "src/builtins/constants-table-builder.h"
#include "src/code-factory.h"
#include "src/compiler/graph.h"
#include "src/compiler/instruction-selector.h"
@ -22,7 +21,6 @@
#include "src/machine-type.h"
#include "src/macro-assembler.h"
#include "src/objects-inl.h"
#include "src/snapshot/serializer-common.h"
#include "src/utils.h"
#include "src/zone/zone.h"
@ -259,34 +257,6 @@ void CodeAssembler::GenerateCheckMaybeObjectIsObject(Node* node,
}
#endif
#ifdef V8_EMBEDDED_BUILTINS
// External references are stored in the external reference table.
TNode<ExternalReference> CodeAssembler::LookupExternalReference(
ExternalReference reference) {
DCHECK(isolate()->ShouldLoadConstantsFromRootList());
// Encode as an index into the external reference table stored on the isolate.
ExternalReferenceEncoder encoder(isolate());
ExternalReferenceEncoder::Value v = encoder.Encode(reference.address());
CHECK(!v.is_from_api());
uint32_t index = v.index();
// Generate code to load from the external reference table.
const intptr_t roots_to_external_reference_offset =
Heap::roots_to_external_reference_table_offset()
#ifdef V8_TARGET_ARCH_X64
- kRootRegisterBias
#endif
+ ExternalReferenceTable::OffsetOfEntry(index);
return UncheckedCast<ExternalReference>(
Load(MachineType::Pointer(), LoadRootsPointer(),
IntPtrConstant(roots_to_external_reference_offset)));
}
#endif // V8_EMBEDDED_BUILTINS
TNode<Int32T> CodeAssembler::Int32Constant(int32_t value) {
return UncheckedCast<Int32T>(raw_assembler()->Int32Constant(value));
}
@ -339,11 +309,6 @@ TNode<Oddball> CodeAssembler::BooleanConstant(bool value) {
TNode<ExternalReference> CodeAssembler::ExternalConstant(
ExternalReference address) {
#ifdef V8_EMBEDDED_BUILTINS
if (isolate()->ShouldLoadConstantsFromRootList()) {
return LookupExternalReference(address);
}
#endif // V8_EMBEDDED_BUILTINS
return UncheckedCast<ExternalReference>(
raw_assembler()->ExternalConstant(address));
}
@ -504,6 +469,7 @@ Node* CodeAssembler::LoadParentFramePointer() {
return raw_assembler()->LoadParentFramePointer();
}
// TODO(jgruber): This can be removed.
TNode<IntPtrT> CodeAssembler::LoadRootsPointer() {
return UncheckedCast<IntPtrT>(raw_assembler()->LoadRootsPointer());
}
@ -981,6 +947,9 @@ TNode<Object> CodeAssembler::LoadRoot(Heap::RootListIndex root_index) {
}
}
// TODO(jgruber): In theory we could generate better code for this by
// letting the macro assembler decide how to load from the roots list. In most
// cases, it would boil down to loading from a fixed kRootRegister offset.
Node* roots_array_start =
ExternalConstant(ExternalReference::roots_array_start(isolate()));
return UncheckedCast<Object>(Load(MachineType::AnyTagged(), roots_array_start,

View File

@ -694,10 +694,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
void GenerateCheckMaybeObjectIsObject(Node* node, const char* location);
#endif
#ifdef V8_EMBEDDED_BUILTINS
TNode<ExternalReference> LookupExternalReference(ExternalReference reference);
#endif
// Constants.
TNode<Int32T> Int32Constant(int32_t value);
TNode<Int64T> Int64Constant(int64_t value);

View File

@ -3359,7 +3359,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
__ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value()));
break;
case Constant::kExternalReference:
__ li(dst, Operand(src.ToExternalReference()));
__ li(dst, src.ToExternalReference());
break;
case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject();

View File

@ -3612,7 +3612,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
__ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value()));
break;
case Constant::kExternalReference:
__ li(dst, Operand(src.ToExternalReference()));
__ li(dst, src.ToExternalReference());
break;
case Constant::kHeapObject: {
Handle<HeapObject> src_object = src.ToHeapObject();

View File

@ -353,9 +353,7 @@ void TurboAssembler::Move(Register dst, Handle<HeapObject> value) {
void TurboAssembler::Move(Register dst, ExternalReference reference) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList() &&
reference.address() !=
ExternalReference::roots_array_start(isolate()).address()) {
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList()) {
IndirectLoadExternalReference(dst, reference);
return;
}

View File

@ -346,9 +346,7 @@ void TurboAssembler::Move(Register dst, Handle<HeapObject> value) {
void TurboAssembler::Move(Register dst, ExternalReference reference) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList() &&
reference.address() !=
ExternalReference::roots_array_start(isolate()).address()) {
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList()) {
IndirectLoadExternalReference(dst, reference);
return;
}

View File

@ -62,8 +62,6 @@ void TurboAssemblerBase::IndirectLoadConstant(Register destination,
void TurboAssemblerBase::IndirectLoadExternalReference(
Register destination, ExternalReference reference) {
CHECK(reference.address() !=
ExternalReference::roots_array_start(isolate()).address());
CHECK(isolate()->ShouldLoadConstantsFromRootList());
CHECK(root_array_available_);

View File

@ -1069,9 +1069,7 @@ void TurboAssembler::Move(Register dst, Smi* source) {
void TurboAssembler::Move(Register dst, ExternalReference ext) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList() &&
ext.address() !=
ExternalReference::roots_array_start(isolate()).address()) {
if (root_array_available_ && isolate()->ShouldLoadConstantsFromRootList()) {
IndirectLoadExternalReference(dst, ext);
return;
}