Commit 7e854a76 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

MIPS[64]: Don't dereference handles in (macro-)assembler functions used by TF.

Port https://chromium-review.googlesource.com/c/561015/.

Bug: v8:6048
Change-Id: I887ad0651674fb1c503bea19660199eb5ab3e9ba
Reviewed-on: https://chromium-review.googlesource.com/565568Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46531}
parent ec8904ae
......@@ -488,13 +488,21 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
void FullCodeGenerator::AccumulatorValueContext::Plug(
Handle<Object> lit) const {
__ li(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ li(result_register(), Operand(Smi::cast(*lit)));
}
}
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
// Immediates cannot be pushed directly.
__ li(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ li(result_register(), Operand(Smi::cast(*lit)));
}
codegen()->PushOperand(result_register());
}
......@@ -519,7 +527,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ li(result_register(), Operand(lit));
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
codegen()->DoTest(this);
}
}
......
......@@ -488,13 +488,21 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
void FullCodeGenerator::AccumulatorValueContext::Plug(
Handle<Object> lit) const {
__ li(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ li(result_register(), Operand(Smi::cast(*lit)));
}
}
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
// Immediates cannot be pushed directly.
__ li(result_register(), Operand(lit));
if (lit->IsHeapObject()) {
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
} else {
__ li(result_register(), Operand(Smi::cast(*lit)));
}
codegen()->PushOperand(result_register());
}
......@@ -519,7 +527,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ li(result_register(), Operand(lit));
__ li(result_register(), Operand(Handle<HeapObject>::cast(lit)));
codegen()->DoTest(this);
}
}
......
......@@ -226,19 +226,11 @@ void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size,
// Implementation of Operand and MemOperand.
// See assembler-mips-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_ = RelocInfo::NONE32;
}
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}
Operand Operand::EmbeddedNumber(double value) {
......
......@@ -423,7 +423,7 @@ class Operand BASE_EMBEDDED {
INLINE(explicit Operand(const char* s));
INLINE(explicit Operand(Object** opp));
INLINE(explicit Operand(Context** cpp));
explicit Operand(Handle<Object> handle);
explicit Operand(Handle<HeapObject> handle);
INLINE(explicit Operand(Smi* value));
static Operand EmbeddedNumber(double number); // Smi or HeapNumber.
......
......@@ -26,7 +26,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_);
}
}
......@@ -1363,7 +1363,7 @@ void MacroAssembler::Sdc1(FPURegister fd, const MemOperand& src) {
}
}
void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) {
void MacroAssembler::li(Register dst, Handle<HeapObject> value, LiFlags mode) {
li(dst, Operand(value), mode);
}
......@@ -4073,17 +4073,24 @@ void MacroAssembler::Call(Label* target) {
BranchAndLink(target);
}
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
li(at, Operand(handle));
push(at);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
li(at, Operand(handle));
void MacroAssembler::Push(Smi* smi) {
li(at, Operand(smi));
push(at);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
if (handle->IsHeapObject()) {
Push(Handle<HeapObject>::cast(handle));
} else {
Push(Smi::cast(*handle));
}
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......@@ -5297,9 +5304,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(a0, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
......
......@@ -258,7 +258,7 @@ class MacroAssembler: public Assembler {
void Call(Label* target);
inline void Move(Register dst, Handle<Object> handle) { li(dst, handle); }
inline void Move(Register dst, Handle<HeapObject> handle) { li(dst, handle); }
inline void Move(Register dst, Smi* smi) { li(dst, Operand(smi)); }
inline void Move(Register dst, Register src) {
......@@ -673,7 +673,7 @@ class MacroAssembler: public Assembler {
inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) {
li(rd, Operand(j), mode);
}
void li(Register dst, Handle<Object> value, LiFlags mode = OPTIMIZE_SIZE);
void li(Register dst, Handle<HeapObject> value, LiFlags mode = OPTIMIZE_SIZE);
// Push multiple registers on the stack.
// Registers are saved in numerical order, with higher numbered registers
......@@ -690,9 +690,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).
......@@ -1401,7 +1400,7 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
const char* name;
};
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
......@@ -1735,7 +1734,7 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
bool has_double_zero_reg_set_;
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.
......
......@@ -206,19 +206,11 @@ void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size,
// Implementation of Operand and MemOperand.
// See assembler-mips-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_ = RelocInfo::NONE64;
}
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}
Operand Operand::EmbeddedNumber(double value) {
......
......@@ -429,7 +429,7 @@ class Operand BASE_EMBEDDED {
INLINE(explicit Operand(const char* s));
INLINE(explicit Operand(Object** opp));
INLINE(explicit Operand(Context** cpp));
explicit Operand(Handle<Object> handle);
explicit Operand(Handle<HeapObject> handle);
INLINE(explicit Operand(Smi* value));
static Operand EmbeddedNumber(double number); // Smi or HeapNumber.
......
......@@ -37,7 +37,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_);
}
}
......@@ -1597,7 +1597,7 @@ void MacroAssembler::Sdc1(FPURegister fs, const MemOperand& src) {
sdc1(fs, tmp);
}
void MacroAssembler::li(Register dst, Handle<Object> value, LiFlags mode) {
void MacroAssembler::li(Register dst, Handle<HeapObject> value, LiFlags mode) {
li(dst, Operand(value), mode);
}
......@@ -4345,14 +4345,22 @@ void MacroAssembler::Call(Label* target) {
BranchAndLink(target);
}
void MacroAssembler::Push(Smi* smi) {
li(at, Operand(smi));
push(at);
}
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
li(at, Operand(handle));
push(at);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
li(at, Operand(handle));
if (handle->IsHeapObject()) {
li(at, Operand(Handle<HeapObject>::cast(handle)));
} else {
li(at, Operand(Smi::cast(*handle)));
}
push(at);
}
......@@ -5793,9 +5801,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(a0, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
......
......@@ -285,7 +285,7 @@ class MacroAssembler: public Assembler {
void Call(Label* target);
inline void Move(Register dst, Handle<Object> handle) { li(dst, handle); }
inline void Move(Register dst, Handle<HeapObject> handle) { li(dst, handle); }
inline void Move(Register dst, Smi* smi) { li(dst, Operand(smi)); }
inline void Move(Register dst, Register src) {
......@@ -735,7 +735,7 @@ class MacroAssembler: public Assembler {
inline void li(Register rd, int64_t j, LiFlags mode = OPTIMIZE_SIZE) {
li(rd, Operand(j), mode);
}
void li(Register dst, Handle<Object> value, LiFlags mode = OPTIMIZE_SIZE);
void li(Register dst, Handle<HeapObject> value, LiFlags mode = OPTIMIZE_SIZE);
// Push multiple registers on the stack.
// Registers are saved in numerical order, with higher numbered registers
......@@ -751,10 +751,8 @@ class MacroAssembler: public Assembler {
Sd(src, MemOperand(sp, 0));
}
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).
......@@ -1520,7 +1518,7 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
const char* name;
};
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
......@@ -1883,7 +1881,7 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
bool has_double_zero_reg_set_;
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