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