Use shorter encoding for mov REG, IMM. Use Set() in two places to generate smaller code when the immediate is 0.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@728 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
deanm@chromium.org 2008-11-11 06:10:07 +00:00
parent 3ccdce6d83
commit 8bea254650
7 changed files with 45 additions and 27 deletions

View File

@ -597,6 +597,14 @@ void Assembler::mov(Register dst, int32_t imm32) {
}
void Assembler::mov(Register dst, const Immediate& x) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
EMIT(0xB8 | dst.code());
emit(x);
}
void Assembler::mov(Register dst, Handle<Object> handle) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
@ -613,6 +621,14 @@ void Assembler::mov(Register dst, const Operand& src) {
}
void Assembler::mov(Register dst, Register src) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
EMIT(0x89);
EMIT(0xC0 | src.code() << 3 | dst.code());
}
void Assembler::mov(const Operand& dst, const Immediate& x) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;

View File

@ -453,8 +453,10 @@ class Assembler : public Malloced {
void mov_w(const Operand& dst, Register src);
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, 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, Register src);

View File

@ -129,7 +129,7 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
// ebx: JSObject
// edi: start of next object
__ mov(Operand(ebx, JSObject::kMapOffset), eax);
__ mov(Operand(ecx), Factory::empty_fixed_array());
__ mov(ecx, Factory::empty_fixed_array());
__ mov(Operand(ebx, JSObject::kPropertiesOffset), ecx);
__ mov(Operand(ebx, JSObject::kElementsOffset), ecx);
// Set extra fields in the newly allocated object.
@ -137,7 +137,7 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
// ebx: JSObject
// edi: start of next object
{ Label loop, entry;
__ mov(Operand(edx), Factory::undefined_value());
__ mov(edx, Factory::undefined_value());
__ lea(ecx, Operand(ebx, JSObject::kHeaderSize));
__ jmp(&entry);
__ bind(&loop);
@ -198,7 +198,7 @@ void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
// edi: FixedArray
// ecx: start of next object
{ Label loop, entry;
__ mov(Operand(edx), Factory::undefined_value());
__ mov(edx, Factory::undefined_value());
__ lea(eax, Operand(edi, FixedArray::kHeaderSize));
__ jmp(&entry);
__ bind(&loop);
@ -440,7 +440,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
__ push(edi); // save edi across the call
__ push(ebx);
__ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
__ mov(Operand(ebx), eax);
__ mov(ebx, eax);
__ pop(edi); // restore edi after the call
// Get the arguments count and untag it.
@ -778,7 +778,7 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
__ RecordComment("// Calling from debug break to runtime - come in - over");
#endif
__ Set(eax, Immediate(0)); // no arguments
__ mov(Operand(ebx), Immediate(ExternalReference::debug_break()));
__ mov(ebx, Immediate(ExternalReference::debug_break()));
CEntryDebugBreakStub ceb;
__ CallStub(&ceb);

View File

@ -1041,7 +1041,7 @@ void CodeGenerator::SmiOperation(Token::Value op,
} else {
deferred = new DeferredInlinedSmiSubReversed(this, edx, overwrite_mode);
__ mov(edx, Operand(eax));
__ mov(Operand(eax), Immediate(value));
__ mov(eax, Immediate(value));
__ sub(eax, Operand(edx));
}
__ j(overflow, deferred->enter(), not_taken);
@ -1265,7 +1265,7 @@ void SmiComparisonDeferred::Generate() {
CompareStub stub(cc_, strict_);
// Setup parameters and call stub.
__ mov(edx, Operand(eax));
__ mov(Operand(eax), Immediate(Smi::FromInt(value_)));
__ Set(eax, Immediate(Smi::FromInt(value_)));
__ CallStub(&stub);
__ cmp(eax, 0);
// "result" is returned in the flags
@ -4984,7 +4984,7 @@ void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
// running with --gc-greedy set.
if (FLAG_gc_greedy) {
Failure* failure = Failure::RetryAfterGC(0);
__ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(failure)));
__ mov(eax, Immediate(reinterpret_cast<int32_t>(failure)));
}
GenerateCore(masm, &throw_normal_exception,
&throw_out_of_memory_exception,
@ -5002,7 +5002,7 @@ void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) {
// Do full GC and retry runtime call one final time.
Failure* failure = Failure::InternalError();
__ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(failure)));
__ mov(eax, Immediate(reinterpret_cast<int32_t>(failure)));
GenerateCore(masm,
&throw_normal_exception,
&throw_out_of_memory_exception,
@ -5068,10 +5068,10 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
// stub, because the builtin stubs may not have been generated yet.
if (is_construct) {
ExternalReference construct_entry(Builtins::JSConstructEntryTrampoline);
__ mov(Operand(edx), Immediate(construct_entry));
__ mov(edx, Immediate(construct_entry));
} else {
ExternalReference entry(Builtins::JSEntryTrampoline);
__ mov(Operand(edx), Immediate(entry));
__ mov(edx, Immediate(entry));
}
__ mov(edx, Operand(edx, 0)); // deref address
__ lea(edx, FieldOperand(edx, Code::kHeaderSize));

View File

@ -543,12 +543,12 @@ void CallIC::Generate(MacroAssembler* masm,
// Call the entry.
CEntryStub stub;
__ mov(Operand(eax), Immediate(2));
__ mov(Operand(ebx), Immediate(f));
__ mov(eax, Immediate(2));
__ mov(ebx, Immediate(f));
__ CallStub(&stub);
// Move result to edi and exit the internal frame.
__ mov(Operand(edi), eax);
__ mov(edi, eax);
__ LeaveInternalFrame();
// Check if the receiver is a global object of some sort.

View File

@ -293,7 +293,7 @@ void MacroAssembler::Set(Register dst, const Immediate& x) {
if (x.is_zero()) {
xor_(dst, Operand(dst)); // shorter than mov
} else {
mov(Operand(dst), x);
mov(dst, x);
}
}
@ -695,7 +695,7 @@ void MacroAssembler::IllegalOperation(int num_arguments) {
if (num_arguments > 0) {
add(Operand(esp), Immediate(num_arguments * kPointerSize));
}
mov(Operand(eax), Immediate(Factory::undefined_value()));
mov(eax, Immediate(Factory::undefined_value()));
}
@ -726,14 +726,14 @@ void MacroAssembler::TailCallRuntime(const ExternalReference& ext,
// arguments passed in because it is constant. At some point we
// should remove this need and make the runtime routine entry code
// smarter.
mov(Operand(eax), Immediate(num_arguments));
Set(eax, Immediate(num_arguments));
JumpToBuiltin(ext);
}
void MacroAssembler::JumpToBuiltin(const ExternalReference& ext) {
// Set the entry point and jump to the C entry runtime stub.
mov(Operand(ebx), Immediate(ext));
mov(ebx, Immediate(ext));
CEntryStub ces;
jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
}
@ -787,7 +787,7 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
Handle<Code> adaptor =
Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline));
if (!code_constant.is_null()) {
mov(Operand(edx), Immediate(code_constant));
mov(edx, Immediate(code_constant));
add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag));
} else if (!code_operand.is_reg(edx)) {
mov(edx, code_operand);

View File

@ -395,7 +395,7 @@ void StubCompiler::GenerateStoreField(MacroAssembler* masm,
if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) {
// The properties must be extended before we can store the value.
// We jump to a runtime call that extends the propeties array.
__ mov(Operand(ecx), Immediate(Handle<Map>(transition)));
__ mov(ecx, Immediate(Handle<Map>(transition)));
Handle<Code> ic(Builtins::builtin(storage_extend));
__ jmp(ic, RelocInfo::CODE_TARGET);
return;
@ -628,7 +628,7 @@ Object* CallStubCompiler::CompileCallConstant(Object* object,
}
// Get the function and setup the context.
__ mov(Operand(edi), Immediate(Handle<JSFunction>(function)));
__ mov(edi, Immediate(Handle<JSFunction>(function)));
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// Jump to the cached code (tail call).
@ -681,14 +681,14 @@ Object* CallStubCompiler::CompileCallInterceptor(Object* object,
// Perform call.
ExternalReference load_interceptor =
ExternalReference(IC_Utility(IC::kLoadInterceptorProperty));
__ mov(Operand(eax), Immediate(3));
__ mov(Operand(ebx), Immediate(load_interceptor));
__ mov(eax, Immediate(3));
__ mov(ebx, Immediate(load_interceptor));
CEntryStub stub;
__ CallStub(&stub);
// Move result to edi and restore receiver.
__ mov(Operand(edi), eax);
__ mov(edi, eax);
__ mov(edx, Operand(ebp, (argc + 2) * kPointerSize)); // receiver
// Exit frame.
@ -750,7 +750,7 @@ Object* StoreStubCompiler::CompileStoreField(JSObject* object,
// Handle store cache miss.
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
__ mov(ecx, Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
__ jmp(ic, RelocInfo::CODE_TARGET);
@ -807,7 +807,7 @@ Object* StoreStubCompiler::CompileStoreCallback(JSObject* object,
// Handle store cache miss.
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
__ mov(ecx, Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
__ jmp(ic, RelocInfo::CODE_TARGET);
@ -862,7 +862,7 @@ Object* StoreStubCompiler::CompileStoreInterceptor(JSObject* receiver,
// Handle store cache miss.
__ bind(&miss);
__ mov(Operand(ecx), Immediate(Handle<String>(name))); // restore name
__ mov(ecx, Immediate(Handle<String>(name))); // restore name
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
__ jmp(ic, RelocInfo::CODE_TARGET);