Commit fab6fe09 authored by Jaideep Bajwa's avatar Jaideep Bajwa Committed by Commit Bot

PPC/s390: Don't dereference handles in (macro-)assembler functions used by TF (reland)

Port 9b3174b2

Original Commit Message:

    Remove all IsHeapObject/IsSmi checks from assembler and also from
    the macro-assembler functions that Turbofan code generation uses.

    Note for porters: In case it's unclear which macro-assembler
    functions need to be modified, it may be best to wait until I
    split MacroAssembler in a followup-CL, which will make that clear.

R=neis@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:6048
LOG=N

Change-Id: Ic24c7145fa9c3d44d0359e93583eb5ddf0bcf5a8
Reviewed-on: https://chromium-review.googlesource.com/581796
Commit-Queue: Jaideep Bajwa <bjaideep@ca.ibm.com>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46845}
parent 4e207a42
......@@ -480,13 +480,21 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {}
void FullCodeGenerator::AccumulatorValueContext::Plug(
Handle<Object> lit) const {
__ mov(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ mov(result_register(), Operand(Smi::cast(*lit)));
}
}
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
// Immediates cannot be pushed directly.
__ mov(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ mov(result_register(), Operand(Smi::cast(*lit)));
}
codegen()->PushOperand(result_register());
}
......@@ -511,7 +519,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ mov(result_register(), Operand(lit));
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
codegen()->DoTest(this);
}
}
......
......@@ -473,12 +473,20 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {}
void FullCodeGenerator::AccumulatorValueContext::Plug(
Handle<Object> lit) const {
__ mov(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ mov(result_register(), Operand(Smi::cast(*lit)));
}
}
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
// Immediates cannot be pushed directly.
__ mov(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ mov(result_register(), Operand(Smi::cast(*lit)));
}
codegen()->PushOperand(result_register());
}
......@@ -502,7 +510,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ mov(result_register(), Operand(lit));
__ mov(result_register(), Operand(Handle<HeapObject>::cast(lit)));
codegen()->DoTest(this);
}
}
......
......@@ -199,19 +199,11 @@ void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size,
// Implementation of Operand and MemOperand
// See assembler-ppc-inl.h for inlined constructors
Operand::Operand(Handle<Object> handle) {
AllowDeferredHandleDereference using_raw_address;
Operand::Operand(Handle<HeapObject> handle) {
AllowHandleDereference using_location;
rm_ = no_reg;
// Verify all Objects referred by code are NOT in new space.
Object* obj = *handle;
if (obj->IsHeapObject()) {
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
} else {
// no relocation needed
value_.immediate = reinterpret_cast<intptr_t>(obj);
rmode_ = kRelocInfo_NONEPTR;
}
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}
Operand Operand::EmbeddedNumber(double value) {
......
......@@ -304,7 +304,7 @@ class Operand BASE_EMBEDDED {
RelocInfo::Mode rmode = kRelocInfo_NONEPTR));
INLINE(static Operand Zero()) { return Operand(static_cast<intptr_t>(0)); }
INLINE(explicit Operand(const ExternalReference& f));
explicit Operand(Handle<Object> handle);
explicit Operand(Handle<HeapObject> handle);
INLINE(explicit Operand(Smi* value));
// rm
......
......@@ -27,7 +27,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
isolate_(isolate) {
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
......@@ -71,7 +71,7 @@ void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode,
Condition cond) {
DCHECK(RelocInfo::IsCodeTarget(rmode));
// 'code' is always generated ppc code, never THUMB code
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
Jump(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
}
......@@ -140,7 +140,7 @@ void MacroAssembler::Call(Address target, RelocInfo::Mode rmode,
int MacroAssembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode,
Condition cond) {
AllowDeferredHandleDereference using_raw_address;
AllowHandleDereference using_location;
return CallSize(reinterpret_cast<Address>(code.location()), rmode, cond);
}
......@@ -159,7 +159,7 @@ void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode,
int expected_size = CallSize(code, rmode, cond);
#endif
AllowDeferredHandleDereference using_raw_address;
AllowHandleDereference using_location;
Call(reinterpret_cast<Address>(code.location()), rmode, cond);
DCHECK_EQ(expected_size, SizeOfCodeGeneratedSince(&start));
}
......@@ -178,18 +178,25 @@ void MacroAssembler::Drop(Register count, Register scratch) {
void MacroAssembler::Call(Label* target) { b(target, SetLK); }
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
mov(r0, Operand(handle));
push(r0);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
mov(r0, Operand(handle));
void MacroAssembler::Push(Smi* smi) {
mov(r0, Operand(smi));
push(r0);
}
void MacroAssembler::Move(Register dst, Handle<Object> value) {
void MacroAssembler::PushObject(Handle<Object> handle) {
if (handle->IsHeapObject()) {
Push(Handle<HeapObject>::cast(handle));
} else {
Push(Smi::cast(*handle));
}
}
void MacroAssembler::Move(Register dst, Handle<HeapObject> value) {
mov(dst, Operand(value));
}
......@@ -2235,9 +2242,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
LoadSmiLiteral(r4, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
......
......@@ -166,7 +166,7 @@ class MacroAssembler : public Assembler {
// Register move. May do nothing if the registers are identical.
void Move(Register dst, Smi* smi) { LoadSmiLiteral(dst, smi); }
void Move(Register dst, Handle<Object> value);
void Move(Register dst, Handle<HeapObject> value);
void Move(Register dst, Register src, Condition cond = al);
void Move(DoubleRegister dst, DoubleRegister src);
......@@ -275,8 +275,8 @@ class MacroAssembler : public Assembler {
void Push(Register src) { push(src); }
// Push a handle.
void Push(Handle<Object> handle);
void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void Push(Handle<HeapObject> handle);
void Push(Smi* smi);
void PushObject(Handle<Object> handle);
// Push two registers. Pushes leftmost register first (to highest address).
......@@ -948,7 +948,7 @@ class MacroAssembler : public Assembler {
void JumpToExternalReference(const ExternalReference& builtin,
bool builtin_exit_frame = false);
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
......@@ -1443,7 +1443,7 @@ class MacroAssembler : public Assembler {
bool has_frame_;
Isolate* isolate_;
// This handle will be patched with the code object on installation.
Handle<Object> code_object_;
Handle<HeapObject> code_object_;
// Needs access to SafepointRegisterStackIndex for compiled frame
// traversal.
......
......@@ -307,19 +307,11 @@ void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size,
// Implementation of Operand and MemOperand
// See assembler-s390-inl.h for inlined constructors
Operand::Operand(Handle<Object> handle) {
AllowDeferredHandleDereference using_raw_address;
Operand::Operand(Handle<HeapObject> handle) {
AllowHandleDereference using_location;
rm_ = no_reg;
// Verify all Objects referred by code are NOT in new space.
Object* obj = *handle;
if (obj->IsHeapObject()) {
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
} else {
// no relocation needed
value_.immediate = reinterpret_cast<intptr_t>(obj);
rmode_ = kRelocInfo_NONEPTR;
}
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}
Operand Operand::EmbeddedNumber(double value) {
......
......@@ -297,7 +297,7 @@ class Operand BASE_EMBEDDED {
RelocInfo::Mode rmode = kRelocInfo_NONEPTR));
INLINE(static Operand Zero()) { return Operand(static_cast<intptr_t>(0)); }
INLINE(explicit Operand(const ExternalReference& f));
explicit Operand(Handle<Object> handle);
explicit Operand(Handle<HeapObject> handle);
INLINE(explicit Operand(Smi* value));
// rm
......
......@@ -27,7 +27,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
isolate_(isolate) {
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
......@@ -164,17 +164,25 @@ void MacroAssembler::Drop(Register count, Register scratch) {
void MacroAssembler::Call(Label* target) { b(r14, target); }
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
mov(r0, Operand(handle));
push(r0);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
mov(r0, Operand(handle));
void MacroAssembler::Push(Smi* smi) {
mov(r0, Operand(smi));
push(r0);
}
void MacroAssembler::Move(Register dst, Handle<Object> value) {
void MacroAssembler::PushObject(Handle<Object> handle) {
if (handle->IsHeapObject()) {
Push(Handle<HeapObject>::cast(handle));
} else {
Push(Smi::cast(*handle));
}
}
void MacroAssembler::Move(Register dst, Handle<HeapObject> value) {
mov(dst, Operand(value));
}
......@@ -2000,9 +2008,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
LoadSmiLiteral(r3, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
......
......@@ -220,7 +220,7 @@ class MacroAssembler : public Assembler {
// Register move. May do nothing if the registers are identical.
void Move(Register dst, Smi* smi) { LoadSmiLiteral(dst, smi); }
void Move(Register dst, Handle<Object> value);
void Move(Register dst, Handle<HeapObject> value);
void Move(Register dst, Register src, Condition cond = al);
void Move(DoubleRegister dst, DoubleRegister src);
......@@ -610,8 +610,8 @@ class MacroAssembler : public Assembler {
void Push(Register src) { push(src); }
// Push a handle.
void Push(Handle<Object> handle);
void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void Push(Handle<HeapObject> handle);
void Push(Smi* smi);
void PushObject(Handle<Object> handle);
// Push two registers. Pushes leftmost register first (to highest address).
......@@ -1237,7 +1237,7 @@ class MacroAssembler : public Assembler {
void JumpToExternalReference(const ExternalReference& builtin,
bool builtin_exit_frame = false);
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
......@@ -1721,7 +1721,7 @@ class MacroAssembler : public Assembler {
bool has_frame_;
Isolate* isolate_;
// This handle will be patched with the code object on installation.
Handle<Object> code_object_;
Handle<HeapObject> code_object_;
// Needs access to SafepointRegisterStackIndex for compiled frame
// traversal.
......
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