[arm] Port full-codegen to using UseScratchRegisterScope

Bug: v8:6553
Change-Id: Iffd023967e52aa16fdeec1deeabd3227389223a3
Reviewed-on: https://chromium-review.googlesource.com/544879
Commit-Queue: Pierre Langlois <pierre.langlois@arm.com>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46432}
This commit is contained in:
Pierre Langlois 2017-06-22 11:54:07 +01:00 committed by Commit Bot
parent 6cbeead055
commit 331c4d03b7

View File

@ -304,8 +304,7 @@ void FullCodeGenerator::Generate() {
{ {
Comment cmnt(masm_, "[ Stack check"); Comment cmnt(masm_, "[ Stack check");
Label ok; Label ok;
__ LoadRoot(ip, Heap::kStackLimitRootIndex); __ CompareRoot(sp, Heap::kStackLimitRootIndex);
__ cmp(sp, Operand(ip));
__ b(hs, &ok); __ b(hs, &ok);
Handle<Code> stack_check = isolate()->builtins()->StackCheck(); Handle<Code> stack_check = isolate()->builtins()->StackCheck();
masm_->MaybeCheckConstPool(); masm_->MaybeCheckConstPool();
@ -572,14 +571,16 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
void FullCodeGenerator::StackValueContext::Plug( void FullCodeGenerator::StackValueContext::Plug(
Label* materialize_true, Label* materialize_true,
Label* materialize_false) const { Label* materialize_false) const {
UseScratchRegisterScope temps(masm());
Register scratch = temps.Acquire();
Label done; Label done;
__ bind(materialize_true); __ bind(materialize_true);
__ LoadRoot(ip, Heap::kTrueValueRootIndex); __ LoadRoot(scratch, Heap::kTrueValueRootIndex);
__ jmp(&done); __ jmp(&done);
__ bind(materialize_false); __ bind(materialize_false);
__ LoadRoot(ip, Heap::kFalseValueRootIndex); __ LoadRoot(scratch, Heap::kFalseValueRootIndex);
__ bind(&done); __ bind(&done);
codegen()->PushOperand(ip); codegen()->PushOperand(scratch);
} }
@ -600,8 +601,10 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
void FullCodeGenerator::StackValueContext::Plug(bool flag) const { void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
Heap::RootListIndex value_root_index = Heap::RootListIndex value_root_index =
flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
__ LoadRoot(ip, value_root_index); UseScratchRegisterScope temps(masm());
codegen()->PushOperand(ip); Register scratch = temps.Acquire();
__ LoadRoot(scratch, value_root_index);
codegen()->PushOperand(scratch);
} }
@ -876,8 +879,7 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
Label skip; Label skip;
__ b(&skip); __ b(&skip);
__ LoadRoot(ip, Heap::kTrueValueRootIndex); __ CompareRoot(r0, Heap::kTrueValueRootIndex);
__ cmp(r0, ip);
__ b(ne, &next_test); __ b(ne, &next_test);
__ Drop(1); __ Drop(1);
__ jmp(clause->body_target()); __ jmp(clause->body_target());
@ -965,8 +967,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// to do a slow check. // to do a slow check.
Label fixed_array; Label fixed_array;
__ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset));
__ LoadRoot(ip, Heap::kMetaMapRootIndex); __ CompareRoot(r2, Heap::kMetaMapRootIndex);
__ cmp(r2, ip);
__ b(ne, &fixed_array); __ b(ne, &fixed_array);
// We got a map in register r0. Get the enumeration cache from it. // We got a map in register r0. Get the enumeration cache from it.
@ -1602,10 +1603,12 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
{ StackValueContext context(this); { StackValueContext context(this);
EmitVariableLoad(callee->AsVariableProxy()); EmitVariableLoad(callee->AsVariableProxy());
} }
UseScratchRegisterScope temps(masm());
Register scratch = temps.Acquire();
// Push undefined as receiver. This is patched in the method prologue if it // Push undefined as receiver. This is patched in the method prologue if it
// is a sloppy mode method. // is a sloppy mode method.
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex); __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
PushOperand(ip); PushOperand(scratch);
convert_mode = ConvertReceiverMode::kNullOrUndefined; convert_mode = ConvertReceiverMode::kNullOrUndefined;
} else { } else {
// Load the function from the receiver. // Load the function from the receiver.
@ -1613,9 +1616,13 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
DCHECK(!callee->AsProperty()->IsSuperAccess()); DCHECK(!callee->AsProperty()->IsSuperAccess());
__ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); __ ldr(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
EmitNamedPropertyLoad(callee->AsProperty()); EmitNamedPropertyLoad(callee->AsProperty());
// Push the target function under the receiver. {
__ ldr(ip, MemOperand(sp, 0)); UseScratchRegisterScope temps(masm());
PushOperand(ip); Register scratch = temps.Acquire();
// Push the target function under the receiver.
__ ldr(scratch, MemOperand(sp, 0));
PushOperand(scratch);
}
__ str(r0, MemOperand(sp, kPointerSize)); __ str(r0, MemOperand(sp, kPointerSize));
convert_mode = ConvertReceiverMode::kNotNullOrUndefined; convert_mode = ConvertReceiverMode::kNotNullOrUndefined;
} }
@ -1638,9 +1645,15 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
__ Move(LoadDescriptor::NameRegister(), r0); __ Move(LoadDescriptor::NameRegister(), r0);
EmitKeyedPropertyLoad(callee->AsProperty()); EmitKeyedPropertyLoad(callee->AsProperty());
// Push the target function under the receiver. {
__ ldr(ip, MemOperand(sp, 0)); UseScratchRegisterScope temps(masm());
PushOperand(ip); Register scratch = temps.Acquire();
// Push the target function under the receiver.
__ ldr(scratch, MemOperand(sp, 0));
PushOperand(scratch);
}
__ str(r0, MemOperand(sp, kPointerSize)); __ str(r0, MemOperand(sp, kPointerSize));
EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined);
@ -1943,8 +1956,10 @@ void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
DCHECK(expr->arguments()->length() == 0); DCHECK(expr->arguments()->length() == 0);
ExternalReference debug_is_active = ExternalReference debug_is_active =
ExternalReference::debug_is_active_address(isolate()); ExternalReference::debug_is_active_address(isolate());
__ mov(ip, Operand(debug_is_active)); UseScratchRegisterScope temps(masm());
__ ldrb(r0, MemOperand(ip)); Register scratch = temps.Acquire();
__ mov(scratch, Operand(debug_is_active));
__ ldrb(r0, MemOperand(scratch));
__ SmiTag(r0); __ SmiTag(r0);
context()->Plug(r0); context()->Plug(r0);
} }
@ -2096,8 +2111,10 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
} else { } else {
// Reserve space for result of postfix operation. // Reserve space for result of postfix operation.
if (expr->is_postfix() && !context()->IsEffect()) { if (expr->is_postfix() && !context()->IsEffect()) {
__ mov(ip, Operand(Smi::kZero)); UseScratchRegisterScope temps(masm());
PushOperand(ip); Register scratch = temps.Acquire();
__ mov(scratch, Operand(Smi::kZero));
PushOperand(scratch);
} }
switch (assign_type) { switch (assign_type) {
case NAMED_PROPERTY: { case NAMED_PROPERTY: {
@ -2237,8 +2254,7 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
if (String::Equals(check, factory->number_string())) { if (String::Equals(check, factory->number_string())) {
__ JumpIfSmi(r0, if_true); __ JumpIfSmi(r0, if_true);
__ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset));
__ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); __ CompareRoot(r0, Heap::kHeapNumberMapRootIndex);
__ cmp(r0, ip);
Split(eq, if_true, if_false, fall_through); Split(eq, if_true, if_false, fall_through);
} else if (String::Equals(check, factory->string_string())) { } else if (String::Equals(check, factory->string_string())) {
__ JumpIfSmi(r0, if_false); __ JumpIfSmi(r0, if_false);
@ -2414,22 +2430,24 @@ void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
DeclarationScope* closure_scope = scope()->GetClosureScope(); DeclarationScope* closure_scope = scope()->GetClosureScope();
UseScratchRegisterScope temps(masm());
Register scratch = temps.Acquire();
if (closure_scope->is_script_scope() || if (closure_scope->is_script_scope() ||
closure_scope->is_module_scope()) { closure_scope->is_module_scope()) {
// Contexts nested in the native context have a canonical empty function // Contexts nested in the native context have a canonical empty function
// as their closure, not the anonymous closure containing the global // as their closure, not the anonymous closure containing the global
// code. // code.
__ LoadNativeContextSlot(Context::CLOSURE_INDEX, ip); __ LoadNativeContextSlot(Context::CLOSURE_INDEX, scratch);
} else if (closure_scope->is_eval_scope()) { } else if (closure_scope->is_eval_scope()) {
// Contexts created by a call to eval have the same closure as the // Contexts created by a call to eval have the same closure as the
// context calling eval, not the anonymous closure containing the eval // context calling eval, not the anonymous closure containing the eval
// code. Fetch it from the context. // code. Fetch it from the context.
__ ldr(ip, ContextMemOperand(cp, Context::CLOSURE_INDEX)); __ ldr(scratch, ContextMemOperand(cp, Context::CLOSURE_INDEX));
} else { } else {
DCHECK(closure_scope->is_function_scope()); DCHECK(closure_scope->is_function_scope());
__ ldr(ip, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); __ ldr(scratch, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
} }
PushOperand(ip); PushOperand(scratch);
} }