X64: Load more values from the root array, rather than from immediate 64-bit constants.

Review URL: http://codereview.chromium.org/6676025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7150 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
whesse@chromium.org 2011-03-11 13:33:39 +00:00
parent 7b6e295021
commit 55815b5fd5
2 changed files with 29 additions and 25 deletions

View File

@ -46,8 +46,8 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
__ Ret();
__ bind(&check_heap_number);
__ Move(rbx, Factory::heap_number_map());
__ cmpq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
__ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
Heap::kHeapNumberMapRootIndex);
__ j(not_equal, &call_builtin);
__ Ret();
@ -104,7 +104,7 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
__ pop(rdx);
__ push(rsi);
__ push(rdx);
__ Push(Factory::false_value());
__ PushRoot(Heap::kFalseValueRootIndex);
__ push(rcx); // Restore return address.
__ TailCallRuntime(Runtime::kNewClosure, 3, 1);
}
@ -2493,7 +2493,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// Check that the JSArray is in fast case.
__ movq(rbx, FieldOperand(rdi, JSArray::kElementsOffset));
__ movq(rdi, FieldOperand(rbx, HeapObject::kMapOffset));
__ Cmp(rdi, Factory::fixed_array_map());
__ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset),
Heap::kFixedArrayMapRootIndex);
__ j(not_equal, &runtime);
// Check that the last match info has space for the capture registers and the
// additional information. Ensure no overflow in add.
@ -2528,8 +2529,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ testb(rbx, Immediate(kIsNotStringMask | kExternalStringTag));
__ j(not_zero, &runtime);
// String is a cons string.
__ movq(rdx, FieldOperand(rdi, ConsString::kSecondOffset));
__ Cmp(rdx, Factory::empty_string());
__ CompareRoot(FieldOperand(rdi, ConsString::kSecondOffset),
Heap::kEmptyStringRootIndex);
__ j(not_equal, &runtime);
__ movq(rdi, FieldOperand(rdi, ConsString::kFirstOffset));
__ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset));
@ -2793,8 +2794,8 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
__ movq(FieldOperand(rax, HeapObject::kMapOffset), rdx);
// Set empty properties FixedArray.
__ Move(FieldOperand(rax, JSObject::kPropertiesOffset),
Factory::empty_fixed_array());
__ LoadRoot(kScratchRegister, Heap::kEmptyFixedArrayRootIndex);
__ movq(FieldOperand(rax, JSObject::kPropertiesOffset), kScratchRegister);
// Set elements to point to FixedArray allocated right after the JSArray.
__ lea(rcx, Operand(rax, JSRegExpResult::kSize));
@ -2814,13 +2815,13 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// rbx: Number of elements in array as int32.
// Set map.
__ Move(FieldOperand(rcx, HeapObject::kMapOffset),
Factory::fixed_array_map());
__ LoadRoot(kScratchRegister, Heap::kFixedArrayMapRootIndex);
__ movq(FieldOperand(rcx, HeapObject::kMapOffset), kScratchRegister);
// Set length.
__ Integer32ToSmi(rdx, rbx);
__ movq(FieldOperand(rcx, FixedArray::kLengthOffset), rdx);
// Fill contents of fixed-array with the-hole.
__ Move(rdx, Factory::the_hole_value());
__ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
__ lea(rcx, FieldOperand(rcx, FixedArray::kHeaderSize));
// Fill fixed array elements with hole.
// rax: JSArray.
@ -4945,7 +4946,7 @@ void StringCharAtStub::Generate(MacroAssembler* masm) {
__ bind(&index_out_of_range);
// When the index is out of range, the spec requires us to return
// the empty string.
__ Move(result, Factory::empty_string());
__ LoadRoot(result, Heap::kEmptyStringRootIndex);
__ jmp(&done);
__ bind(&need_conversion);

View File

@ -1210,7 +1210,7 @@ void LCodeGen::DoBranch(LBranch* instr) {
Register reg = ToRegister(instr->InputAt(0));
HType type = instr->hydrogen()->type();
if (type.IsBoolean()) {
__ Cmp(reg, Factory::true_value());
__ CompareRoot(reg, Heap::kTrueValueRootIndex);
EmitBranch(true_block, false_block, equal);
} else if (type.IsSmi()) {
__ SmiCompare(reg, Smi::FromInt(0));
@ -1477,14 +1477,14 @@ void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) {
int true_block = chunk_->LookupDestination(instr->true_block_id());
__ Cmp(reg, Factory::null_value());
__ CompareRoot(reg, Heap::kNullValueRootIndex);
if (instr->is_strict()) {
EmitBranch(true_block, false_block, equal);
} else {
Label* true_label = chunk_->GetAssemblyLabel(true_block);
Label* false_label = chunk_->GetAssemblyLabel(false_block);
__ j(equal, true_label);
__ Cmp(reg, Factory::undefined_value());
__ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
__ j(equal, true_label);
__ JumpIfSmi(reg, false_label);
// Check for undetectable objects by looking in the bit field in
@ -2092,14 +2092,14 @@ void LCodeGen::DoLoadElements(LLoadElements* instr) {
__ movq(result, FieldOperand(input, JSObject::kElementsOffset));
if (FLAG_debug_code) {
NearLabel done;
__ Cmp(FieldOperand(result, HeapObject::kMapOffset),
Factory::fixed_array_map());
__ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
Heap::kFixedArrayMapRootIndex);
__ j(equal, &done);
__ Cmp(FieldOperand(result, HeapObject::kMapOffset),
Factory::external_pixel_array_map());
__ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
Heap::kExternalPixelArrayMapRootIndex);
__ j(equal, &done);
__ Cmp(FieldOperand(result, HeapObject::kMapOffset),
Factory::fixed_cow_array_map());
__ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
Heap::kFixedCOWArrayMapRootIndex);
__ Check(equal, "Check for fast elements failed.");
__ bind(&done);
}
@ -2146,7 +2146,7 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
FixedArray::kHeaderSize));
// Check for the hole value.
__ Cmp(result, Factory::the_hole_value());
__ CompareRoot(result, Heap::kTheHoleValueRootIndex);
DeoptimizeIf(equal, instr->environment());
}
@ -3434,7 +3434,9 @@ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
} else {
__ push(rsi);
__ Push(shared_info);
__ Push(pretenure ? Factory::true_value() : Factory::false_value());
__ PushRoot(pretenure ?
Heap::kTrueValueRootIndex :
Heap::kFalseValueRootIndex);
CallRuntime(Runtime::kNewClosure, 3, instr);
}
}
@ -3517,8 +3519,9 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label,
Condition final_branch_condition = no_condition;
if (type_name->Equals(Heap::number_symbol())) {
__ JumpIfSmi(input, true_label);
__ Cmp(FieldOperand(input, HeapObject::kMapOffset),
Factory::heap_number_map());
__ CompareRoot(FieldOperand(input, HeapObject::kMapOffset),
Heap::kHeapNumberMapRootIndex);
final_branch_condition = equal;
} else if (type_name->Equals(Heap::string_symbol())) {