Don't dereference handles in (macro-)assembler functions used by TF.

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.

Bug: v8:6048
Change-Id: Ife0735cc6f48713c9ec493faf2dac5e553d1c06b
Reviewed-on: https://chromium-review.googlesource.com/561015
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46436}
This commit is contained in:
Georg Neis 2017-07-06 11:13:09 +02:00 committed by Commit Bot
parent 239e53e727
commit 9b3174b295
32 changed files with 203 additions and 223 deletions

View File

@ -373,19 +373,11 @@ void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size,
// Implementation of Operand and MemOperand
// See assembler-arm-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;
}

View File

@ -502,7 +502,7 @@ class Operand BASE_EMBEDDED {
RelocInfo::Mode rmode = RelocInfo::NONE32));
INLINE(static Operand Zero());
INLINE(explicit Operand(const ExternalReference& f));
explicit Operand(Handle<Object> handle);
explicit Operand(Handle<HeapObject> handle);
INLINE(explicit Operand(Smi* value));
// rm

View File

@ -35,7 +35,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
}
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
@ -63,7 +63,7 @@ void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode,
Condition cond) {
DCHECK(RelocInfo::IsCodeTarget(rmode));
// 'code' is always generated ARM code, never THUMB code
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
Jump(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
}
@ -143,7 +143,7 @@ void MacroAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond,
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);
}
@ -152,7 +152,7 @@ void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode,
bool check_constant_pool) {
DCHECK(RelocInfo::IsCodeTarget(rmode));
// 'code' is always generated ARM code, never THUMB code
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
Call(reinterpret_cast<Address>(code.location()), rmode, cond, mode);
}
@ -235,19 +235,31 @@ void MacroAssembler::Call(Label* target) {
bl(target);
}
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
mov(scratch, Operand(handle));
push(scratch);
}
void MacroAssembler::Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void MacroAssembler::Push(Smi* smi) {
UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire();
mov(scratch, Operand(smi));
push(scratch);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
if (handle->IsHeapObject()) {
Push(Handle<HeapObject>::cast(handle));
} else {
Push(Smi::cast(*handle));
}
}
void MacroAssembler::Move(Register dst, Smi* smi) { mov(dst, Operand(smi)); }
void MacroAssembler::Move(Register dst, Handle<Object> value) {
void MacroAssembler::Move(Register dst, Handle<HeapObject> value) {
mov(dst, Operand(value));
}
@ -2582,9 +2594,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(r1, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.

View File

@ -175,7 +175,7 @@ class MacroAssembler: public Assembler {
// Register move. May do nothing if the registers are identical.
void Move(Register dst, Smi* 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, const Operand& src, SBit sbit = LeaveCC,
Condition cond = al) {
@ -330,9 +330,9 @@ class MacroAssembler: public Assembler {
PointersToHereCheck pointers_to_here_check_for_value =
kPointersToHereMaybeInteresting);
// Push a handle.
void Push(Handle<Object> handle);
void Push(Handle<HeapObject> handle);
void Push(Smi* smi);
void PushObject(Handle<Object> handle);
// Push two registers. Pushes leftmost register first (to highest address).
void Push(Register src1, Register src2, Condition cond = al) {
@ -1087,7 +1087,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_;
}
@ -1370,7 +1370,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_;
int jit_cookie_;
// Needs access to SafepointRegisterStackIndex for compiled frame

View File

@ -308,19 +308,10 @@ bool AreConsecutive(const VRegister& reg1, const VRegister& reg2,
return true;
}
void Immediate::InitializeHandle(Handle<Object> handle) {
AllowDeferredHandleDereference using_raw_address;
// Verify all Objects referred by code are NOT in new space.
Object* obj = *handle;
if (obj->IsHeapObject()) {
value_ = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
} else {
STATIC_ASSERT(sizeof(intptr_t) == sizeof(int64_t));
value_ = reinterpret_cast<intptr_t>(obj);
rmode_ = RelocInfo::NONE64;
}
void Immediate::InitializeHandle(Handle<HeapObject> handle) {
AllowHandleDereference using_location;
value_ = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}

View File

@ -658,7 +658,7 @@ class Immediate {
RelocInfo::Mode rmode() const { return rmode_; }
private:
void InitializeHandle(Handle<Object> value);
void InitializeHandle(Handle<HeapObject> value);
int64_t value_;
RelocInfo::Mode rmode_;

View File

@ -1379,15 +1379,27 @@ void MacroAssembler::IsObjectJSStringType(Register object,
}
}
void MacroAssembler::Push(Handle<Object> handle) {
void MacroAssembler::Push(Handle<HeapObject> handle) {
UseScratchRegisterScope temps(this);
Register tmp = temps.AcquireX();
Mov(tmp, Operand(handle));
Push(tmp);
}
void MacroAssembler::Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void MacroAssembler::Push(Smi* smi) {
UseScratchRegisterScope temps(this);
Register tmp = temps.AcquireX();
Mov(tmp, Operand(smi));
Push(tmp);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
if (handle->IsHeapObject()) {
Push(Handle<HeapObject>::cast(handle));
} else {
Push(Smi::cast(*handle));
}
}
void MacroAssembler::Claim(int64_t count, uint64_t unit_size) {
DCHECK(count >= 0);

View File

@ -39,7 +39,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, byte* buffer,
fptmp_list_(DefaultFPTmpList()) {
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
@ -1618,25 +1618,17 @@ void MacroAssembler::LoadTrueFalseRoots(Register true_root,
}
void MacroAssembler::LoadHeapObject(Register result,
Handle<HeapObject> object) {
Mov(result, Operand(object));
}
void MacroAssembler::LoadObject(Register result, Handle<Object> object) {
AllowDeferredHandleDereference heap_object_check;
if (object->IsHeapObject()) {
LoadHeapObject(result, Handle<HeapObject>::cast(object));
Move(result, Handle<HeapObject>::cast(object));
} else {
DCHECK(object->IsSmi());
Mov(result, Operand(object));
Mov(result, Operand(Smi::cast(*object)));
}
}
void MacroAssembler::Move(Register dst, Register src) { Mov(dst, src); }
void MacroAssembler::Move(Register dst, Handle<Object> x) {
LoadObject(dst, x);
}
void MacroAssembler::Move(Register dst, Handle<HeapObject> x) { Mov(dst, x); }
void MacroAssembler::Move(Register dst, Smi* src) { Mov(dst, src); }
void MacroAssembler::LoadInstanceDescriptors(Register map,
@ -2130,7 +2122,7 @@ void MacroAssembler::Jump(Address target, RelocInfo::Mode rmode,
void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode,
Condition cond) {
DCHECK(RelocInfo::IsCodeTarget(rmode));
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
Jump(reinterpret_cast<intptr_t>(code.location()), rmode, cond);
}
@ -2203,7 +2195,7 @@ void MacroAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode) {
Bind(&start_call);
#endif
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
Call(reinterpret_cast<Address>(code.location()), rmode);
#ifdef DEBUG
@ -4257,9 +4249,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
// Avoid infinite recursion; Push contains some assertions that use Abort.
NoUseRealAbortsScope no_real_aborts(this);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(x1, Smi::FromInt(static_cast<int>(reason)));
if (!has_frame_) {

View File

@ -184,7 +184,7 @@ class MacroAssembler : public Assembler {
Isolate* isolate() const { return isolate_; }
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
@ -1266,9 +1266,9 @@ class MacroAssembler : public Assembler {
void PushMultipleTimes(CPURegister src, Register count);
void PushMultipleTimes(CPURegister src, int count);
// This is a convenience method for pushing a single Handle<Object>.
inline void Push(Handle<Object> handle);
inline void Push(Handle<HeapObject> handle);
inline void Push(Smi* smi);
inline void PushObject(Handle<Object> handle);
// Aliases of Push and Pop, required for V8 compatibility.
inline void push(Register src) {
@ -1517,7 +1517,7 @@ class MacroAssembler : public Assembler {
// This is required for compatibility with architecture independant code.
// Remove if not needed.
void Move(Register dst, Register src);
void Move(Register dst, Handle<Object> x);
void Move(Register dst, Handle<HeapObject> x);
void Move(Register dst, Smi* src);
void LoadInstanceDescriptors(Register map,
@ -2520,7 +2520,7 @@ class MacroAssembler : public Assembler {
bool use_real_aborts_;
// This handle will be patched with the code object on installation.
Handle<Object> code_object_;
Handle<HeapObject> code_object_;
// The register to use as a stack pointer for stack operations.
Register sp_;

View File

@ -1247,8 +1247,7 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
Smi* interpreter_entry_return_pc_offset(
masm->isolate()->heap()->interpreter_entry_return_pc_offset());
DCHECK_NE(interpreter_entry_return_pc_offset, Smi::kZero);
__ LoadHeapObject(ebx,
masm->isolate()->builtins()->InterpreterEntryTrampoline());
__ Move(ebx, masm->isolate()->builtins()->InterpreterEntryTrampoline());
__ add(ebx, Immediate(interpreter_entry_return_pc_offset->value() +
Code::kHeaderSize - kHeapObjectTag));
__ push(ebx);

View File

@ -2611,7 +2611,7 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
Handle<HeapObject> src = src_constant.ToHeapObject();
if (destination->IsRegister()) {
Register dst = g.ToRegister(destination);
__ LoadHeapObject(dst, src);
__ Move(dst, src);
} else {
DCHECK(destination->IsStackSlot());
Operand dst = g.ToOperand(destination);

View File

@ -503,13 +503,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());
}
@ -534,7 +542,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);
}
}

View File

@ -493,13 +493,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());
}
@ -524,7 +532,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);
}
}

View File

@ -180,7 +180,7 @@ void FullCodeGenerator::CallIC(Handle<Code> code) {
void FullCodeGenerator::CallLoadIC(FeedbackSlot slot, Handle<Object> name) {
DCHECK(name->IsName());
__ Move(LoadDescriptor::NameRegister(), name);
__ Move(LoadDescriptor::NameRegister(), Handle<Name>::cast(name));
EmitLoadSlot(LoadDescriptor::SlotRegister(), slot);
@ -192,7 +192,7 @@ void FullCodeGenerator::CallLoadIC(FeedbackSlot slot, Handle<Object> name) {
void FullCodeGenerator::CallStoreIC(FeedbackSlot slot, Handle<Object> name,
StoreICKind store_ic_kind) {
DCHECK(name->IsName());
__ Move(StoreDescriptor::NameRegister(), name);
__ Move(StoreDescriptor::NameRegister(), Handle<Name>::cast(name));
STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack ||
StoreDescriptor::kStackArgumentsCount == 2);
@ -462,7 +462,7 @@ int FullCodeGenerator::DeclareGlobalsFlags() {
void FullCodeGenerator::PushOperand(Handle<Object> handle) {
OperandStackDepthIncrement(1);
__ Push(handle);
__ PushObject(handle);
}
void FullCodeGenerator::PushOperand(Smi* smi) {

View File

@ -442,9 +442,9 @@ void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
void FullCodeGenerator::AccumulatorValueContext::Plug(
Handle<Object> lit) const {
if (lit->IsSmi()) {
__ SafeMove(result_register(), Immediate(lit));
__ SafeMove(result_register(), Immediate(Smi::cast(*lit)));
} else {
__ Move(result_register(), Immediate(lit));
__ Move(result_register(), Immediate(Handle<HeapObject>::cast(lit)));
}
}
@ -452,9 +452,9 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
codegen()->OperandStackDepthIncrement(1);
if (lit->IsSmi()) {
__ SafePush(Immediate(lit));
__ SafePush(Immediate(Smi::cast(*lit)));
} else {
__ push(Immediate(lit));
__ push(Immediate(Handle<HeapObject>::cast(lit)));
}
}
@ -479,7 +479,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ mov(result_register(), lit);
__ mov(result_register(), Handle<HeapObject>::cast(lit));
codegen()->DoTest(this);
}
}
@ -535,18 +535,16 @@ void FullCodeGenerator::TestContext::Plug(Label* materialize_true,
void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
Handle<Object> value = flag
? isolate()->factory()->true_value()
: isolate()->factory()->false_value();
Handle<HeapObject> value = flag ? isolate()->factory()->true_value()
: isolate()->factory()->false_value();
__ mov(result_register(), value);
}
void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
codegen()->OperandStackDepthIncrement(1);
Handle<Object> value = flag
? isolate()->factory()->true_value()
: isolate()->factory()->false_value();
Handle<HeapObject> value = flag ? isolate()->factory()->true_value()
: isolate()->factory()->false_value();
__ push(Immediate(value));
}
@ -2291,9 +2289,9 @@ void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr,
VisitForAccumulatorValue(sub_expr);
Handle<Object> nil_value = nil == kNullValue
? isolate()->factory()->null_value()
: isolate()->factory()->undefined_value();
Handle<HeapObject> nil_value = nil == kNullValue
? isolate()->factory()->null_value()
: isolate()->factory()->undefined_value();
if (expr->op() == Token::EQ_STRICT) {
__ cmp(eax, nil_value);
Split(equal, if_true, if_false, fall_through);

View File

@ -457,7 +457,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
if (lit->IsSmi()) {
__ SafeMove(result_register(), Smi::cast(*lit));
} else {
__ Move(result_register(), lit);
__ Move(result_register(), Handle<HeapObject>::cast(lit));
}
}
@ -467,7 +467,7 @@ void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
if (lit->IsSmi()) {
__ SafePush(Smi::cast(*lit));
} else {
__ Push(lit);
__ Push(Handle<HeapObject>::cast(lit));
}
}
@ -492,7 +492,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
}
} else {
// For simplicity we always test the accumulator register.
__ Move(result_register(), lit);
__ Move(result_register(), Handle<HeapObject>::cast(lit));
codegen()->DoTest(this);
}
}

View File

@ -315,19 +315,10 @@ Immediate::Immediate(Label* internal_offset) {
rmode_ = RelocInfo::INTERNAL_REFERENCE;
}
Immediate::Immediate(Handle<Object> handle) {
AllowDeferredHandleDereference using_raw_address;
// 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;
}
Immediate::Immediate(Handle<HeapObject> handle) {
AllowHandleDereference using_location;
value_.immediate = reinterpret_cast<intptr_t>(handle.location());
rmode_ = RelocInfo::EMBEDDED_OBJECT;
}
@ -354,18 +345,10 @@ void Assembler::emit_q(uint64_t x) {
pc_ += sizeof(uint64_t);
}
void Assembler::emit(Handle<Object> handle) {
AllowDeferredHandleDereference heap_object_check;
// Verify all Objects referred by code are NOT in new space.
Object* obj = *handle;
if (obj->IsHeapObject()) {
emit(reinterpret_cast<intptr_t>(handle.location()),
RelocInfo::EMBEDDED_OBJECT);
} else {
// no relocation needed
emit(reinterpret_cast<intptr_t>(obj));
}
void Assembler::emit(Handle<HeapObject> handle) {
AllowHandleDereference using_location;
emit(reinterpret_cast<intptr_t>(handle.location()),
RelocInfo::EMBEDDED_OBJECT);
}
void Assembler::emit(uint32_t x, RelocInfo::Mode rmode) {
@ -376,7 +359,7 @@ void Assembler::emit(uint32_t x, RelocInfo::Mode rmode) {
}
void Assembler::emit(Handle<Code> code, RelocInfo::Mode rmode) {
AllowDeferredHandleDereference embedding_raw_address;
AllowHandleDereference using_location;
emit(reinterpret_cast<intptr_t>(code.location()), rmode);
}

View File

@ -615,8 +615,7 @@ void Assembler::mov(Register dst, const Immediate& x) {
emit(x);
}
void Assembler::mov(Register dst, Handle<Object> handle) {
void Assembler::mov(Register dst, Handle<HeapObject> handle) {
EnsureSpace ensure_space(this);
EMIT(0xB8 | dst.code());
emit(handle);
@ -644,8 +643,7 @@ void Assembler::mov(const Operand& dst, const Immediate& x) {
emit(x);
}
void Assembler::mov(const Operand& dst, Handle<Object> handle) {
void Assembler::mov(const Operand& dst, Handle<HeapObject> handle) {
EnsureSpace ensure_space(this);
EMIT(0xC7);
emit_operand(eax, dst);
@ -907,8 +905,7 @@ void Assembler::cmp(Register reg, int32_t imm32) {
emit_arith(7, Operand(reg), Immediate(imm32));
}
void Assembler::cmp(Register reg, Handle<Object> handle) {
void Assembler::cmp(Register reg, Handle<HeapObject> handle) {
EnsureSpace ensure_space(this);
emit_arith(7, Operand(reg), Immediate(handle));
}
@ -931,8 +928,7 @@ void Assembler::cmp(const Operand& op, const Immediate& imm) {
emit_arith(7, op, imm);
}
void Assembler::cmp(const Operand& op, Handle<Object> handle) {
void Assembler::cmp(const Operand& op, Handle<HeapObject> handle) {
EnsureSpace ensure_space(this);
emit_arith(7, op, Immediate(handle));
}

View File

@ -269,7 +269,7 @@ class Immediate BASE_EMBEDDED {
public:
inline explicit Immediate(int x);
inline explicit Immediate(const ExternalReference& ext);
inline explicit Immediate(Handle<Object> handle);
inline explicit Immediate(Handle<HeapObject> handle);
inline explicit Immediate(Smi* value);
inline explicit Immediate(Address addr);
inline explicit Immediate(Address x, RelocInfo::Mode rmode);
@ -641,11 +641,11 @@ class Assembler : public AssemblerBase {
void mov(Register dst, int32_t imm32);
void mov(Register dst, const Immediate& x);
void mov(Register dst, Handle<Object> handle);
void mov(Register dst, Handle<HeapObject> handle);
void mov(Register dst, const Operand& src);
void mov(Register dst, Register src);
void mov(const Operand& dst, const Immediate& x);
void mov(const Operand& dst, Handle<Object> handle);
void mov(const Operand& dst, Handle<HeapObject> handle);
void mov(const Operand& dst, Register src);
void movsx_b(Register dst, Register src) { movsx_b(dst, Operand(src)); }
@ -718,13 +718,13 @@ class Assembler : public AssemblerBase {
void cmpw(Register dst, Register src) { cmpw(Operand(dst), src); }
void cmpw(const Operand& dst, Register src);
void cmp(Register reg, int32_t imm32);
void cmp(Register reg, Handle<Object> handle);
void cmp(Register reg, Handle<HeapObject> handle);
void cmp(Register reg0, Register reg1) { cmp(reg0, Operand(reg1)); }
void cmp(Register reg, const Operand& op);
void cmp(Register reg, const Immediate& imm) { cmp(Operand(reg), imm); }
void cmp(const Operand& op, Register reg);
void cmp(const Operand& op, const Immediate& imm);
void cmp(const Operand& op, Handle<Object> handle);
void cmp(const Operand& op, Handle<HeapObject> handle);
void dec_b(Register dst);
void dec_b(const Operand& dst);
@ -1741,7 +1741,7 @@ class Assembler : public AssemblerBase {
// code emission
void GrowBuffer();
inline void emit(uint32_t x);
inline void emit(Handle<Object> handle);
inline void emit(Handle<HeapObject> handle);
inline void emit(uint32_t x, RelocInfo::Mode rmode);
inline void emit(Handle<Code> code, RelocInfo::Mode rmode);
inline void emit(const Immediate& x);

View File

@ -1867,7 +1867,7 @@ void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm,
NameDictionaryLookupStub stub(masm->isolate(), properties, r0, r0,
NEGATIVE_LOOKUP);
__ push(Immediate(Handle<Object>(name)));
__ push(Immediate(name));
__ push(Immediate(name->Hash()));
__ CallStub(&stub);
__ test(r0, r0);

View File

@ -32,7 +32,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
}
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
@ -72,7 +72,12 @@ void MacroAssembler::Store(Register src, const Operand& dst, Representation r) {
void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) {
if (isolate()->heap()->RootCanBeTreatedAsConstant(index)) {
mov(destination, isolate()->heap()->root_handle(index));
Handle<Object> object = isolate()->heap()->root_handle(index);
if (object->IsHeapObject()) {
mov(destination, Handle<HeapObject>::cast(object));
} else {
mov(destination, Immediate(Smi::cast(*object)));
}
return;
}
ExternalReference roots_array_start =
@ -110,20 +115,30 @@ void MacroAssembler::CompareRoot(Register with,
void MacroAssembler::CompareRoot(Register with, Heap::RootListIndex index) {
DCHECK(isolate()->heap()->RootCanBeTreatedAsConstant(index));
cmp(with, isolate()->heap()->root_handle(index));
Handle<Object> object = isolate()->heap()->root_handle(index);
if (object->IsHeapObject()) {
cmp(with, Handle<HeapObject>::cast(object));
} else {
cmp(with, Immediate(Smi::cast(*object)));
}
}
void MacroAssembler::CompareRoot(const Operand& with,
Heap::RootListIndex index) {
DCHECK(isolate()->heap()->RootCanBeTreatedAsConstant(index));
cmp(with, isolate()->heap()->root_handle(index));
Handle<Object> object = isolate()->heap()->root_handle(index);
if (object->IsHeapObject()) {
cmp(with, Handle<HeapObject>::cast(object));
} else {
cmp(with, Immediate(Smi::cast(*object)));
}
}
void MacroAssembler::PushRoot(Heap::RootListIndex index) {
DCHECK(isolate()->heap()->RootCanBeTreatedAsConstant(index));
Push(isolate()->heap()->root_handle(index));
PushObject(isolate()->heap()->root_handle(index));
}
#define REG(Name) \
@ -1864,7 +1879,7 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper) {
LoadHeapObject(edi, function);
Move(edi, function);
InvokeFunction(edi, expected, actual, flag, call_wrapper);
}
@ -1954,17 +1969,17 @@ int MacroAssembler::SafepointRegisterStackIndex(int reg_code) {
}
void MacroAssembler::LoadHeapObject(Register result,
Handle<HeapObject> object) {
mov(result, object);
}
void MacroAssembler::CmpHeapObject(Register reg, Handle<HeapObject> object) {
cmp(reg, object);
}
void MacroAssembler::PushHeapObject(Handle<HeapObject> object) { Push(object); }
void MacroAssembler::PushObject(Handle<Object> object) {
if (object->IsHeapObject()) {
Push(Handle<HeapObject>::cast(object));
} else {
Push(Smi::cast(*object));
}
}
void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) {
mov(value, cell);
@ -2024,6 +2039,9 @@ void MacroAssembler::Move(const Operand& dst, const Immediate& x) {
mov(dst, x);
}
void MacroAssembler::Move(Register dst, Handle<HeapObject> object) {
mov(dst, object);
}
void MacroAssembler::Move(XMMRegister dst, uint32_t src) {
if (src == 0) {

View File

@ -281,25 +281,15 @@ class MacroAssembler: public Assembler {
// 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);
void LoadObject(Register result, Handle<Object> object) {
AllowDeferredHandleDereference heap_object_check;
if (object->IsHeapObject()) {
LoadHeapObject(result, Handle<HeapObject>::cast(object));
} else {
Move(result, Immediate(object));
}
}
void PushObject(Handle<Object> object);
void CmpObject(Register reg, Handle<Object> object) {
AllowDeferredHandleDereference heap_object_check;
if (object->IsHeapObject()) {
CmpHeapObject(reg, Handle<HeapObject>::cast(object));
} else {
cmp(reg, Immediate(object));
cmp(reg, Immediate(Smi::cast(*object)));
}
}
@ -771,14 +761,14 @@ class MacroAssembler: public Assembler {
void Move(XMMRegister dst, float src) { Move(dst, bit_cast<uint32_t>(src)); }
void Move(XMMRegister dst, double src) { Move(dst, bit_cast<uint64_t>(src)); }
void Move(Register dst, Handle<Object> handle) { LoadObject(dst, handle); }
void Move(Register dst, Handle<HeapObject> handle);
void Move(Register dst, Smi* source) { Move(dst, Immediate(source)); }
// Push a handle value.
void Push(Handle<Object> handle) { push(Immediate(handle)); }
void Push(Handle<HeapObject> handle) { push(Immediate(handle)); }
void Push(Smi* smi) { Push(Immediate(smi)); }
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
@ -870,7 +860,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_;
int jit_cookie_;
// Helper functions for generating invokes.

View File

@ -4068,6 +4068,11 @@ void MacroAssembler::Push(Handle<Object> handle) {
push(at);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
li(at, Operand(handle));
push(at);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =

View File

@ -693,6 +693,7 @@ class MacroAssembler: public Assembler {
// Push a handle.
void Push(Handle<Object> handle);
void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void PushObject(Handle<Object> handle);
// Push two registers. Pushes leftmost register first (to highest address).
void Push(Register src1, Register src2) {

View File

@ -4340,6 +4340,10 @@ void MacroAssembler::Push(Handle<Object> handle) {
push(at);
}
void MacroAssembler::PushObject(Handle<Object> handle) {
li(at, Operand(handle));
push(at);
}
void MacroAssembler::PushRegisterAsTwoSmis(Register src, Register scratch) {
DCHECK(!src.is(scratch));

View File

@ -755,6 +755,7 @@ class MacroAssembler: public Assembler {
// Push a handle.
void Push(Handle<Object> handle);
void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
void PushObject(Handle<Object> handle);
// Push two registers. Pushes leftmost register first (to highest address).
void Push(Register src1, Register src2) {

View File

@ -1800,7 +1800,7 @@ void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm,
__ j(equal, done);
// Stop if found the property.
__ Cmp(entity_name, Handle<Name>(name));
__ Cmp(entity_name, name);
__ j(equal, miss);
Label good;
@ -1817,7 +1817,7 @@ void NameDictionaryLookupStub::GenerateNegativeLookup(MacroAssembler* masm,
NameDictionaryLookupStub stub(masm->isolate(), properties, r0, r0,
NEGATIVE_LOOKUP);
__ Push(Handle<Object>(name));
__ Push(name);
__ Push(Immediate(name->Hash()));
__ CallStub(&stub);
__ testp(r0, r0);

View File

@ -33,7 +33,7 @@ MacroAssembler::MacroAssembler(Isolate* isolate, void* buffer, int size,
}
if (create_code_object == CodeObjectRequired::kYes) {
code_object_ =
Handle<Object>::New(isolate_->heap()->undefined_value(), isolate_);
Handle<HeapObject>::New(isolate_->heap()->undefined_value(), isolate_);
}
}
@ -579,9 +579,6 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(rdx, Smi::FromInt(static_cast<int>(reason)));
if (!has_frame_) {
@ -2525,27 +2522,6 @@ void MacroAssembler::MoveNumber(Register dst, double value) {
}
}
void MacroAssembler::Move(Register dst, Handle<Object> source) {
AllowDeferredHandleDereference smi_check;
if (source->IsSmi()) {
Move(dst, Smi::cast(*source));
} else {
MoveHeapObject(dst, source);
}
}
void MacroAssembler::Move(const Operand& dst, Handle<Object> source) {
AllowDeferredHandleDereference smi_check;
if (source->IsSmi()) {
Move(dst, Smi::cast(*source));
} else {
MoveHeapObject(kScratchRegister, source);
movp(dst, kScratchRegister);
}
}
void MacroAssembler::Move(XMMRegister dst, uint32_t src) {
if (src == 0) {
Xorpd(dst, dst);
@ -2890,7 +2866,7 @@ void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
if (source->IsSmi()) {
Cmp(dst, Smi::cast(*source));
} else {
MoveHeapObject(kScratchRegister, source);
Move(kScratchRegister, Handle<HeapObject>::cast(source));
cmpp(dst, kScratchRegister);
}
}
@ -2901,27 +2877,35 @@ void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) {
if (source->IsSmi()) {
Cmp(dst, Smi::cast(*source));
} else {
MoveHeapObject(kScratchRegister, source);
Move(kScratchRegister, Handle<HeapObject>::cast(source));
cmpp(dst, kScratchRegister);
}
}
void MacroAssembler::Push(Handle<Object> source) {
void MacroAssembler::PushObject(Handle<Object> source) {
AllowDeferredHandleDereference smi_check;
if (source->IsSmi()) {
Push(Smi::cast(*source));
} else {
MoveHeapObject(kScratchRegister, source);
Push(kScratchRegister);
Push(Handle<HeapObject>::cast(source));
}
}
void MacroAssembler::Push(Handle<HeapObject> source) {
Move(kScratchRegister, source);
Push(kScratchRegister);
}
void MacroAssembler::MoveHeapObject(Register result,
Handle<Object> object) {
DCHECK(object->IsHeapObject());
Move(result, object, RelocInfo::EMBEDDED_OBJECT);
void MacroAssembler::Move(Register result, Handle<HeapObject> object,
RelocInfo::Mode rmode) {
AllowHandleDereference using_location;
movp(result, reinterpret_cast<void*>(object.location()), rmode);
}
void MacroAssembler::Move(const Operand& dst, Handle<HeapObject> object,
RelocInfo::Mode rmode) {
Move(kScratchRegister, object, rmode);
movp(dst, kScratchRegister);
}

View File

@ -818,21 +818,20 @@ class MacroAssembler: public Assembler {
void Move(Register target, Register source);
// Handle support
void Move(Register dst, Handle<Object> source);
void Move(const Operand& dst, Handle<Object> source);
void Move(Register dst, Handle<HeapObject> source,
RelocInfo::Mode rmode = RelocInfo::EMBEDDED_OBJECT);
void Move(const Operand& dst, Handle<HeapObject> source,
RelocInfo::Mode rmode = RelocInfo::EMBEDDED_OBJECT);
void Cmp(Register dst, Handle<Object> source);
void Cmp(const Operand& dst, Handle<Object> source);
void Cmp(Register dst, Smi* src);
void Cmp(const Operand& dst, Smi* src);
void Push(Handle<Object> source);
void Push(Handle<HeapObject> source);
void PushObject(Handle<Object> source);
// Move a Smi or HeapNumber.
void MoveNumber(Register dst, double value);
// Load a heap object and handle the case of new-space objects by
// indirecting via a global cell.
void MoveHeapObject(Register result, Handle<Object> object);
void GetWeakValue(Register value, Handle<WeakCell> cell);
// Load the value of the weak cell in the value register. Branch to the given
@ -884,13 +883,6 @@ class MacroAssembler: public Assembler {
movp(dst, ptr, rmode);
}
void Move(Register dst, Handle<Object> value, RelocInfo::Mode rmode) {
AllowDeferredHandleDereference using_raw_address;
DCHECK(!RelocInfo::IsNone(rmode));
DCHECK(value->IsHeapObject());
movp(dst, reinterpret_cast<void*>(value.location()), rmode);
}
void Move(XMMRegister dst, uint32_t src);
void Move(XMMRegister dst, uint64_t src);
void Move(XMMRegister dst, float src) { Move(dst, bit_cast<uint32_t>(src)); }
@ -1334,7 +1326,7 @@ class MacroAssembler: public Assembler {
// may be bigger than 2^16 - 1. Requires a scratch register.
void Ret(int bytes_dropped, Register scratch);
Handle<Object> CodeObject() {
Handle<HeapObject> CodeObject() {
DCHECK(!code_object_.is_null());
return code_object_;
}
@ -1429,7 +1421,7 @@ class MacroAssembler: public Assembler {
void LoadSmiConstant(Register dst, Smi* value);
// This handle will be patched with the code object on installation.
Handle<Object> code_object_;
Handle<HeapObject> code_object_;
// Helper functions for generating invokes.
void InvokePrologue(const ParameterCount& expected,

View File

@ -184,7 +184,7 @@ HEAP_TEST(TestNewSpaceRefsInCopiedCode) {
Heap* heap = isolate->heap();
HandleScope sc(isolate);
Handle<Object> value = factory->NewNumber(1.000123);
Handle<HeapNumber> value = factory->NewHeapNumber(1.000123);
CHECK(heap->InNewSpace(*value));
i::byte buffer[i::Assembler::kMinimalBufferSize];

View File

@ -2821,7 +2821,7 @@ TEST(code_relative_offset) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
// Initialize a code object that will contain the code.
Handle<Object> code_object(isolate->heap()->undefined_value(), isolate);
Handle<HeapObject> code_object(isolate->heap()->undefined_value(), isolate);
Assembler assm(isolate, NULL, 0);

View File

@ -1920,7 +1920,7 @@ TEST(CodeSerializerEmbeddedObject) {
MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size),
v8::internal::CodeObjectRequired::kYes);
assembler.enable_serializer();
Handle<Object> number = isolate->factory()->NewHeapNumber(0.3);
Handle<HeapNumber> number = isolate->factory()->NewHeapNumber(0.3);
CHECK(isolate->heap()->InNewSpace(*number));
Handle<Code> code;
{