Commit a17bd3f3 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Initialize the root register for WASM tests.

The root register is needed (at least on x64) to access
ExternalReferences.

R=titzer@chromium.org

Review URL: https://codereview.chromium.org/1641153003

Cr-Commit-Position: refs/heads/master@{#33631}
parent 587ad6fc
......@@ -133,7 +133,7 @@ LinkageLocation regloc(Register reg) {
// General code uses the above configuration data.
CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Zone* zone, const MachineSignature* msig) {
Zone* zone, const MachineSignature* msig, bool set_initialize_root_flag) {
LocationSignature::Builder locations(zone, msig->return_count(),
msig->parameter_count());
#if 0 // TODO(titzer): instruction selector tests break here.
......@@ -220,7 +220,9 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(
Operator::kNoProperties, // properties
kCalleeSaveRegisters, // callee-saved registers
kCalleeSaveFPRegisters, // callee-saved fp regs
CallDescriptor::kNoFlags, // flags
set_initialize_root_flag ? // flags
CallDescriptor::kInitializeRootRegister
: CallDescriptor::kNoFlags,
"c-call");
}
......
......@@ -78,10 +78,12 @@ Handle<Code> CodeGenerator::GenerateCode() {
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
ProfileEntryHookStub::MaybeCallEntryHook(masm());
}
// Architecture-specific, linkage-specific prologue.
info->set_prologue_offset(masm()->pc_offset());
AssemblePrologue();
if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) {
masm()->InitializeRootRegister();
}
// Define deoptimization literals for all inlined functions.
DCHECK_EQ(0u, deoptimization_literals_.size());
......
......@@ -157,6 +157,8 @@ class CallDescriptor final : public ZoneObject {
kUseNativeStack = 1u << 7,
// (arm64 only) call instruction has to restore JSSP.
kRestoreJSSP = 1u << 8,
// Causes the code generator to initialize the root register.
kInitializeRootRegister = 1u << 9,
kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
};
typedef base::Flags<Flag> Flags;
......@@ -223,6 +225,9 @@ class CallDescriptor final : public ZoneObject {
bool NeedsFrameState() const { return flags() & kNeedsFrameState; }
bool SupportsTailCalls() const { return flags() & kSupportsTailCalls; }
bool UseNativeStack() const { return flags() & kUseNativeStack; }
bool InitializeRootRegister() const {
return flags() & kInitializeRootRegister;
}
LinkageLocation GetReturnLocation(size_t index) const {
return location_sig_->GetReturn(index);
......@@ -327,8 +332,9 @@ class Linkage : public ZoneObject {
// for the host platform. This simplified calling convention only supports
// integers and pointers of one word size each, i.e. no floating point,
// structs, pointers to members, etc.
static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone,
const MachineSignature* sig);
static CallDescriptor* GetSimplifiedCDescriptor(
Zone* zone, const MachineSignature* sig,
bool set_initialize_root_flag = false);
// Creates a call descriptor for interpreter handler code stubs. These are not
// intended to be called directly but are instead dispatched to by the
......
......@@ -271,6 +271,9 @@ class MacroAssembler: public Assembler {
void StoreToSafepointRegisterSlot(Register dst, Immediate src);
void LoadFromSafepointRegisterSlot(Register dst, Register src);
// Nop, because ia32 does not have a root register.
void InitializeRootRegister() {}
void LoadHeapObject(Register result, Handle<HeapObject> object);
void CmpHeapObject(Register reg, Handle<HeapObject> object);
void PushHeapObject(Handle<HeapObject> object);
......
......@@ -271,6 +271,9 @@ class MacroAssembler: public Assembler {
void StoreToSafepointRegisterSlot(Register dst, Immediate src);
void LoadFromSafepointRegisterSlot(Register dst, Register src);
// Nop, because x87 does not have a root register.
void InitializeRootRegister() {}
void LoadHeapObject(Register result, Handle<HeapObject> object);
void CmpHeapObject(Register reg, Handle<HeapObject> object);
void PushHeapObject(Handle<HeapObject> object);
......
......@@ -35,7 +35,8 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
Linkage::GetSimplifiedCDescriptor(
main_zone(),
CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p0,
p1, p2, p3, p4)),
p1, p2, p3, p4),
true),
MachineType::PointerRepresentation(),
InstructionSelector::SupportedMachineOperatorFlags()) {}
......
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