Introduce CodeAssembler::LoadRootsPointer

Loading external references from off-heap builtins will be
root-pointer-relative. At least initially, these loads will happen in
CSA and thus need access to the root pointer value.

Bug: v8:6666
Change-Id: Iae4c89061df442f5afd03f93e5ba35c4e125b850
Reviewed-on: https://chromium-review.googlesource.com/970264
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52069}
This commit is contained in:
jgruber 2018-03-20 11:16:24 +01:00 committed by Commit Bot
parent 5b7854f008
commit 377803f804
19 changed files with 52 additions and 0 deletions

View File

@ -915,6 +915,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), fp);
}
break;
case kArchRootsPointer:
__ mov(i.OutputRegister(), kRootRegister);
DCHECK_EQ(LeaveCC, i.OutputSBit());
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),
i.InputDoubleRegister(0));

View File

@ -839,6 +839,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), fp);
}
break;
case kArchRootsPointer:
__ mov(i.OutputRegister(), root);
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),
i.InputDoubleRegister(0));

View File

@ -497,6 +497,10 @@ Node* CodeAssembler::LoadParentFramePointer() {
return raw_assembler()->LoadParentFramePointer();
}
TNode<IntPtrT> CodeAssembler::LoadRootsPointer() {
return UncheckedCast<IntPtrT>(raw_assembler()->LoadRootsPointer());
}
Node* CodeAssembler::LoadStackPointer() {
return raw_assembler()->LoadStackPointer();
}

View File

@ -734,6 +734,9 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* LoadFramePointer();
Node* LoadParentFramePointer();
// Access to the roots pointer.
TNode<IntPtrT> LoadRootsPointer();
// Access to the stack pointer
Node* LoadStackPointer();

View File

@ -817,6 +817,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), ebp);
}
break;
case kArchRootsPointer:
// TODO(jgruber,v8:6666): Implement ia32 support.
UNREACHABLE();
case kArchTruncateDoubleToI: {
auto result = i.OutputRegister();
auto input = i.InputDoubleRegister(0);

View File

@ -66,6 +66,7 @@ enum class RecordWriteMode { kValueIsMap, kValueIsPointer, kValueIsAny };
V(ArchStackPointer) \
V(ArchFramePointer) \
V(ArchParentFramePointer) \
V(ArchRootsPointer) \
V(ArchTruncateDoubleToI) \
V(ArchStoreWithWriteBarrier) \
V(ArchStackSlot) \

View File

@ -247,6 +247,7 @@ int InstructionScheduler::GetInstructionFlags(const Instruction* instr) const {
case kArchNop:
case kArchFramePointer:
case kArchParentFramePointer:
case kArchRootsPointer:
case kArchStackSlot: // Despite its name this opcode will produce a
// reference to a frame slot, so it is not affected
// by the arm64 dual stack issues mentioned below.

View File

@ -1629,6 +1629,8 @@ void InstructionSelector::VisitNode(Node* node) {
return VisitLoadFramePointer(node);
case IrOpcode::kLoadParentFramePointer:
return VisitLoadParentFramePointer(node);
case IrOpcode::kLoadRootsPointer:
return VisitLoadRootsPointer(node);
case IrOpcode::kUnalignedLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node);
@ -1970,6 +1972,11 @@ void InstructionSelector::VisitLoadParentFramePointer(Node* node) {
Emit(kArchParentFramePointer, g.DefineAsRegister(node));
}
void InstructionSelector::VisitLoadRootsPointer(Node* node) {
OperandGenerator g(this);
Emit(kArchRootsPointer, g.DefineAsRegister(node));
}
void InstructionSelector::VisitFloat64Acos(Node* node) {
VisitFloat64Ieee754Unop(node, kIeee754Float64Acos);
}

View File

@ -119,6 +119,7 @@ class MachineRepresentationInferrer {
case IrOpcode::kLoadStackPointer:
case IrOpcode::kLoadFramePointer:
case IrOpcode::kLoadParentFramePointer:
case IrOpcode::kLoadRootsPointer:
case IrOpcode::kSpeculationPoison:
representation_vector_[node->id()] =
MachineType::PointerRepresentation();

View File

@ -225,6 +225,7 @@ MachineType AtomicOpRepresentationOf(Operator const* op) {
V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1) \
V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1) \
V(LoadParentFramePointer, Operator::kNoProperties, 0, 0, 1) \
V(LoadRootsPointer, Operator::kNoProperties, 0, 0, 1) \
V(Int32PairAdd, Operator::kNoProperties, 4, 0, 2) \
V(Int32PairSub, Operator::kNoProperties, 4, 0, 2) \
V(Int32PairMul, Operator::kNoProperties, 4, 0, 2) \

View File

@ -605,6 +605,9 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
const Operator* LoadFramePointer();
const Operator* LoadParentFramePointer();
// Access to the root register.
const Operator* LoadRootsPointer();
// atomic-load [base + index]
const Operator* Word32AtomicLoad(LoadRepresentation rep);
// atomic-store [base + index], value

View File

@ -872,6 +872,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), fp);
}
break;
case kArchRootsPointer:
__ mov(i.OutputRegister(), kRootRegister);
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),
i.InputDoubleRegister(0));

View File

@ -896,6 +896,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), fp);
}
break;
case kArchRootsPointer:
__ mov(i.OutputRegister(), kRootRegister);
break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),
i.InputDoubleRegister(0));

View File

@ -613,6 +613,7 @@
V(LoadStackPointer) \
V(LoadFramePointer) \
V(LoadParentFramePointer) \
V(LoadRootsPointer) \
V(UnalignedLoad) \
V(UnalignedStore) \
V(Int32PairAdd) \

View File

@ -1102,6 +1102,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mr(i.OutputRegister(), fp);
}
break;
case kArchRootsPointer:
__ mr(i.OutputRegister(), kRootRegister);
DCHECK_EQ(LeaveRC, i.OutputRCBit());
break;
case kArchTruncateDoubleToI:
// TODO(mbrandy): move slow call to stub out of line.
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),

View File

@ -723,6 +723,9 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
return AddNode(machine()->LoadParentFramePointer());
}
// Root pointer operations.
Node* LoadRootsPointer() { return AddNode(machine()->LoadRootsPointer()); }
// Parameters.
Node* Parameter(size_t index);

View File

@ -1325,6 +1325,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ LoadRR(i.OutputRegister(), fp);
}
break;
case kArchFramePointer:
__ LoadRR(i.OutputRegister(), kRootRegister);
break;
case kArchTruncateDoubleToI:
// TODO(mbrandy): move slow call to stub out of line.
__ TruncateDoubleToIDelayed(zone(), i.OutputRegister(),

View File

@ -1681,6 +1681,7 @@ void Verifier::Visitor::Check(Node* node, const AllNodes& all) {
case IrOpcode::kLoadStackPointer:
case IrOpcode::kLoadFramePointer:
case IrOpcode::kLoadParentFramePointer:
case IrOpcode::kLoadRootsPointer:
case IrOpcode::kUnalignedLoad:
case IrOpcode::kUnalignedStore:
case IrOpcode::kWord32AtomicLoad:

View File

@ -884,6 +884,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ movq(i.OutputRegister(), rbp);
}
break;
case kArchRootsPointer:
__ movq(i.OutputRegister(), kRootRegister);
break;
case kArchTruncateDoubleToI: {
auto result = i.OutputRegister();
auto input = i.InputDoubleRegister(0);