Commit cddf5bbd authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[ia32,root] Initialize kRootRegister and verify through IsolateData

With this CL we finally actually set the root register to the correct
value.  Verification is still preserved by keeping a magic number in
IsolateData.

Bug: v8:6666
Change-Id: I89cb7cb36f977ac677ec33a814a2798baab4cec4
Reviewed-on: https://chromium-review.googlesource.com/c/1278277Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56627}
parent 4bc1517f
......@@ -31,23 +31,27 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
ProfileEntryHookStub::MaybeCallEntryHook(masm);
// Set up frame.
__ push(ebp);
__ mov(ebp, esp);
// Push marker in two places.
StackFrame::Type marker = type();
__ push(Immediate(StackFrame::TypeToMarker(marker))); // marker
ExternalReference context_address =
ExternalReference::Create(IsolateAddressId::kContextAddress, isolate());
__ push(__ StaticVariable(context_address)); // context
// Save callee-saved registers (C calling conventions).
__ push(edi);
__ push(esi);
Assembler::AllowExplicitEbxAccessScope spill_register(masm);
__ push(ebx);
__ InitializeRootRegister();
{ // NOLINT. Scope block confuses linter.
NoRootArrayScope uninitialized_root_register(masm);
Assembler::AllowExplicitEbxAccessScope spill_register(masm);
// Set up frame.
__ push(ebp);
__ mov(ebp, esp);
// Push marker in two places.
StackFrame::Type marker = type();
__ push(Immediate(StackFrame::TypeToMarker(marker))); // marker
ExternalReference context_address =
ExternalReference::Create(IsolateAddressId::kContextAddress, isolate());
__ push(__ StaticVariable(context_address)); // context
// Save callee-saved registers (C calling conventions).
__ push(edi);
__ push(esi);
__ push(ebx);
__ InitializeRootRegister();
}
Assembler::SupportsRootRegisterScope supports_root_register(masm);
// Save copies of the top frame descriptor on the stack.
......
......@@ -15,10 +15,6 @@ namespace internal {
// currently no root register is present.
constexpr int kRootRegisterBias = 0;
// Used temporarily to track clobbering of the root register.
// TODO(v8:6666): Remove this once use the root register.
constexpr size_t kRootRegisterSentinel = 0xcafeca11;
// TODO(sigurds): Change this value once we use relative jumps.
constexpr size_t kMaxPCRelativeCodeRangeInMB = 0;
} // namespace internal
......
......@@ -41,14 +41,33 @@ MacroAssembler::MacroAssembler(Isolate* isolate,
code_object_ = Handle<HeapObject>::New(
*isolate->factory()->NewSelfReferenceMarker(), isolate);
}
}
void TurboAssembler::InitializeRootRegister() {
// TODO(v8:6666): Initialize unconditionally once poisoning support has been
// removed.
if (!FLAG_embedded_builtins) return;
#ifdef V8_EMBEDDED_BUILTINS
// Fake it as long as we use indirections through an embedded external
// reference. This will let us implement indirections without a real
// root register.
// TODO(jgruber, v8:6666): Remove once a real root register exists.
if (FLAG_embedded_builtins) set_root_array_available(true);
#endif // V8_EMBEDDED_BUILTINS
Assembler::AllowExplicitEbxAccessScope setup(this);
ExternalReference roots_array_start =
ExternalReference::roots_array_start(isolate());
Move(kRootRegister, Immediate(roots_array_start));
add(kRootRegister, Immediate(kRootRegisterBias));
}
void TurboAssembler::VerifyRootRegister() {
if (!FLAG_ia32_verify_root_register) return;
DCHECK(FLAG_embedded_builtins);
Assembler::AllowExplicitEbxAccessScope read_only_access(this);
Label root_register_ok;
cmp(Operand(kRootRegister,
IsolateData::kMagicNumberOffset - kRootRegisterBias),
Immediate(IsolateData::kRootRegisterSentinel));
j(equal, &root_register_ok);
int3();
bind(&root_register_ok);
}
void TurboAssembler::LoadRoot(Register destination, RootIndex index) {
......
......@@ -110,26 +110,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Check that the stack is aligned.
void CheckStackAlignment();
void InitializeRootRegister() {
Assembler::AllowExplicitEbxAccessScope setup(this);
// For now, only check sentinel value for root register.
// TODO(jgruber,v8:6666): Implement root register.
if (FLAG_ia32_verify_root_register && FLAG_embedded_builtins) {
mov(kRootRegister, kRootRegisterSentinel);
}
}
void VerifyRootRegister() {
if (FLAG_ia32_verify_root_register && FLAG_embedded_builtins) {
Assembler::AllowExplicitEbxAccessScope read_only_access(this);
Label root_register_ok;
cmp(kRootRegister, kRootRegisterSentinel);
j(equal, &root_register_ok);
int3();
bind(&root_register_ok);
}
}
// Move a constant into a destination using the most efficient encoding.
void Move(Register dst, const Immediate& src);
void Move(Register dst, Smi* src) { Move(dst, Immediate(src)); }
......@@ -244,6 +224,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Ret();
// Root register utility functions.
void InitializeRootRegister();
void VerifyRootRegister();
void LoadRoot(Register destination, RootIndex index) override;
// Indirect root-relative loads.
......
......@@ -37,6 +37,9 @@ class IsolateData final {
/* builtins_ */ \
V(kBuiltinsTableOffset, Builtins::builtin_count* kPointerSize) \
V(kBuiltinsTableEndOffset, 0) \
/* magic_number_ */ \
V(kMagicNumberOffset, kIntptrSize) \
V(kMagicNumberEndOffset, 0) \
/* Total size. */ \
V(kSize, 0)
......@@ -61,6 +64,10 @@ class IsolateData final {
Object** builtins() { return &builtins_[0]; }
// For root register verification.
// TODO(v8:6666): Remove once the root register is fully supported on ia32.
static constexpr intptr_t kRootRegisterSentinel = 0xcafeca11;
private:
RootsTable roots_;
......@@ -68,6 +75,10 @@ class IsolateData final {
Object* builtins_[Builtins::builtin_count];
// For root register verification.
// TODO(v8:6666): Remove once the root register is fully supported on ia32.
const intptr_t magic_number_ = kRootRegisterSentinel;
V8_INLINE static void AssertPredictableLayout();
friend class Isolate;
......
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