OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 __ Push(Smi::FromInt(StackFrame::STUB)); | 156 __ Push(Smi::FromInt(StackFrame::STUB)); |
157 } else { | 157 } else { |
158 __ push(rdi); // Callee's JS function. | 158 __ push(rdi); // Callee's JS function. |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 // Reserve space for the stack slots needed by the code. | 162 // Reserve space for the stack slots needed by the code. |
163 int slots = GetStackSlotCount(); | 163 int slots = GetStackSlotCount(); |
164 if (slots > 0) { | 164 if (slots > 0) { |
165 if (FLAG_debug_code) { | 165 if (FLAG_debug_code) { |
| 166 __ subq(rsp, Immediate(slots * kPointerSize)); |
| 167 __ push(rax); |
166 __ Set(rax, slots); | 168 __ Set(rax, slots); |
167 __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE64); | 169 __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE64); |
168 Label loop; | 170 Label loop; |
169 __ bind(&loop); | 171 __ bind(&loop); |
170 __ push(kScratchRegister); | 172 __ movq(MemOperand(rsp, rax, times_pointer_size, 0), |
| 173 kScratchRegister); |
171 __ decl(rax); | 174 __ decl(rax); |
172 __ j(not_zero, &loop); | 175 __ j(not_zero, &loop); |
| 176 __ pop(rax); |
173 } else { | 177 } else { |
174 __ subq(rsp, Immediate(slots * kPointerSize)); | 178 __ subq(rsp, Immediate(slots * kPointerSize)); |
175 #ifdef _MSC_VER | 179 #ifdef _MSC_VER |
176 // On windows, you may not access the stack more than one page below | 180 // On windows, you may not access the stack more than one page below |
177 // the most recently mapped page. To make the allocated area randomly | 181 // the most recently mapped page. To make the allocated area randomly |
178 // accessible, we write to each page in turn (the value is irrelevant). | 182 // accessible, we write to each page in turn (the value is irrelevant). |
179 const int kPageSize = 4 * KB; | 183 const int kPageSize = 4 * KB; |
180 for (int offset = slots * kPointerSize - kPageSize; | 184 for (int offset = slots * kPointerSize - kPageSize; |
181 offset > 0; | 185 offset > 0; |
182 offset -= kPageSize) { | 186 offset -= kPageSize) { |
183 __ movq(Operand(rsp, offset), rax); | 187 __ movq(Operand(rsp, offset), rax); |
184 } | 188 } |
185 #endif | 189 #endif |
186 } | 190 } |
| 191 |
| 192 if (info()->saves_caller_doubles()) { |
| 193 Comment(";;; Save clobbered callee double registers"); |
| 194 int count = 0; |
| 195 BitVector* doubles = chunk()->allocated_double_registers(); |
| 196 BitVector::Iterator save_iterator(doubles); |
| 197 while (!save_iterator.Done()) { |
| 198 __ movsd(MemOperand(rsp, count * kDoubleSize), |
| 199 XMMRegister::FromAllocationIndex(save_iterator.Current())); |
| 200 save_iterator.Advance(); |
| 201 count++; |
| 202 } |
| 203 } |
187 } | 204 } |
188 | 205 |
189 // Possibly allocate a local context. | 206 // Possibly allocate a local context. |
190 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 207 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
191 if (heap_slots > 0) { | 208 if (heap_slots > 0) { |
192 Comment(";;; Allocate local context"); | 209 Comment(";;; Allocate local context"); |
193 // Argument to NewContext is the function, which is still in rdi. | 210 // Argument to NewContext is the function, which is still in rdi. |
194 __ push(rdi); | 211 __ push(rdi); |
195 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 212 if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
196 FastNewContextStub stub(heap_slots); | 213 FastNewContextStub stub(heap_slots); |
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2458 } | 2475 } |
2459 | 2476 |
2460 | 2477 |
2461 void LCodeGen::DoReturn(LReturn* instr) { | 2478 void LCodeGen::DoReturn(LReturn* instr) { |
2462 if (FLAG_trace && info()->IsOptimizing()) { | 2479 if (FLAG_trace && info()->IsOptimizing()) { |
2463 // Preserve the return value on the stack and rely on the runtime | 2480 // Preserve the return value on the stack and rely on the runtime |
2464 // call to return the value in the same register. | 2481 // call to return the value in the same register. |
2465 __ push(rax); | 2482 __ push(rax); |
2466 __ CallRuntime(Runtime::kTraceExit, 1); | 2483 __ CallRuntime(Runtime::kTraceExit, 1); |
2467 } | 2484 } |
| 2485 if (info()->saves_caller_doubles()) { |
| 2486 ASSERT(NeedsEagerFrame()); |
| 2487 BitVector* doubles = chunk()->allocated_double_registers(); |
| 2488 BitVector::Iterator save_iterator(doubles); |
| 2489 int count = 0; |
| 2490 while (!save_iterator.Done()) { |
| 2491 __ movsd(XMMRegister::FromAllocationIndex(save_iterator.Current()), |
| 2492 MemOperand(rsp, count * kDoubleSize)); |
| 2493 save_iterator.Advance(); |
| 2494 count++; |
| 2495 } |
| 2496 } |
2468 if (NeedsEagerFrame()) { | 2497 if (NeedsEagerFrame()) { |
2469 __ movq(rsp, rbp); | 2498 __ movq(rsp, rbp); |
2470 __ pop(rbp); | 2499 __ pop(rbp); |
2471 } | 2500 } |
2472 if (info()->IsStub()) { | 2501 if (info()->IsStub()) { |
2473 __ Ret(0, r10); | 2502 __ Ret(0, r10); |
2474 } else { | 2503 } else { |
2475 __ Ret((GetParameterCount() + 1) * kPointerSize, rcx); | 2504 __ Ret((GetParameterCount() + 1) * kPointerSize, rcx); |
2476 } | 2505 } |
2477 } | 2506 } |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4128 | 4157 |
4129 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) | 4158 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) |
4130 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 4159 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() |
4131 : isolate()->builtins()->KeyedStoreIC_Initialize(); | 4160 : isolate()->builtins()->KeyedStoreIC_Initialize(); |
4132 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 4161 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
4133 } | 4162 } |
4134 | 4163 |
4135 | 4164 |
4136 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { | 4165 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { |
4137 Register object_reg = ToRegister(instr->object()); | 4166 Register object_reg = ToRegister(instr->object()); |
4138 Register new_map_reg = ToRegister(instr->new_map_temp()); | |
4139 | 4167 |
4140 Handle<Map> from_map = instr->original_map(); | 4168 Handle<Map> from_map = instr->original_map(); |
4141 Handle<Map> to_map = instr->transitioned_map(); | 4169 Handle<Map> to_map = instr->transitioned_map(); |
4142 ElementsKind from_kind = instr->from_kind(); | 4170 ElementsKind from_kind = instr->from_kind(); |
4143 ElementsKind to_kind = instr->to_kind(); | 4171 ElementsKind to_kind = instr->to_kind(); |
4144 | 4172 |
4145 Label not_applicable; | 4173 Label not_applicable; |
4146 __ Cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map); | 4174 __ Cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map); |
4147 __ j(not_equal, ¬_applicable); | 4175 __ j(not_equal, ¬_applicable); |
4148 __ movq(new_map_reg, to_map, RelocInfo::EMBEDDED_OBJECT); | |
4149 if (IsSimpleMapChangeTransition(from_kind, to_kind)) { | 4176 if (IsSimpleMapChangeTransition(from_kind, to_kind)) { |
| 4177 Register new_map_reg = ToRegister(instr->new_map_temp()); |
| 4178 __ movq(new_map_reg, to_map, RelocInfo::EMBEDDED_OBJECT); |
4150 __ movq(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg); | 4179 __ movq(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg); |
4151 // Write barrier. | 4180 // Write barrier. |
4152 ASSERT_NE(instr->temp(), NULL); | 4181 ASSERT_NE(instr->temp(), NULL); |
4153 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, | 4182 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, |
4154 ToRegister(instr->temp()), kDontSaveFPRegs); | 4183 ToRegister(instr->temp()), kDontSaveFPRegs); |
4155 } else if (IsFastSmiElementsKind(from_kind) && | |
4156 IsFastDoubleElementsKind(to_kind)) { | |
4157 Register fixed_object_reg = ToRegister(instr->temp()); | |
4158 ASSERT(fixed_object_reg.is(rdx)); | |
4159 ASSERT(new_map_reg.is(rbx)); | |
4160 __ movq(fixed_object_reg, object_reg); | |
4161 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(), | |
4162 RelocInfo::CODE_TARGET, instr); | |
4163 } else if (IsFastDoubleElementsKind(from_kind) && | |
4164 IsFastObjectElementsKind(to_kind)) { | |
4165 Register fixed_object_reg = ToRegister(instr->temp()); | |
4166 ASSERT(fixed_object_reg.is(rdx)); | |
4167 ASSERT(new_map_reg.is(rbx)); | |
4168 __ movq(fixed_object_reg, object_reg); | |
4169 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(), | |
4170 RelocInfo::CODE_TARGET, instr); | |
4171 } else { | 4184 } else { |
4172 UNREACHABLE(); | 4185 PushSafepointRegistersScope scope(this); |
| 4186 if (!object_reg.is(rax)) { |
| 4187 __ movq(rax, object_reg); |
| 4188 } |
| 4189 __ Move(rbx, to_map); |
| 4190 TransitionElementsKindStub stub(from_kind, to_kind); |
| 4191 __ CallStub(&stub); |
| 4192 RecordSafepointWithRegisters( |
| 4193 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
4173 } | 4194 } |
4174 __ bind(¬_applicable); | 4195 __ bind(¬_applicable); |
4175 } | 4196 } |
4176 | 4197 |
4177 | 4198 |
| 4199 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { |
| 4200 Register object = ToRegister(instr->object()); |
| 4201 Register temp = ToRegister(instr->temp()); |
| 4202 __ TestJSArrayForAllocationSiteInfo(object, temp); |
| 4203 DeoptimizeIf(equal, instr->environment()); |
| 4204 } |
| 4205 |
| 4206 |
4178 void LCodeGen::DoStringAdd(LStringAdd* instr) { | 4207 void LCodeGen::DoStringAdd(LStringAdd* instr) { |
4179 EmitPushTaggedOperand(instr->left()); | 4208 EmitPushTaggedOperand(instr->left()); |
4180 EmitPushTaggedOperand(instr->right()); | 4209 EmitPushTaggedOperand(instr->right()); |
4181 StringAddStub stub(NO_STRING_CHECK_IN_STUB); | 4210 StringAddStub stub(NO_STRING_CHECK_IN_STUB); |
4182 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4211 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4183 } | 4212 } |
4184 | 4213 |
4185 | 4214 |
4186 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { | 4215 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { |
4187 class DeferredStringCharCodeAt: public LDeferredCode { | 4216 class DeferredStringCharCodeAt: public LDeferredCode { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4394 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } | 4423 virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); } |
4395 virtual LInstruction* instr() { return instr_; } | 4424 virtual LInstruction* instr() { return instr_; } |
4396 private: | 4425 private: |
4397 LNumberTagD* instr_; | 4426 LNumberTagD* instr_; |
4398 }; | 4427 }; |
4399 | 4428 |
4400 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 4429 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
4401 Register reg = ToRegister(instr->result()); | 4430 Register reg = ToRegister(instr->result()); |
4402 Register tmp = ToRegister(instr->temp()); | 4431 Register tmp = ToRegister(instr->temp()); |
4403 | 4432 |
| 4433 bool convert_hole = false; |
| 4434 HValue* change_input = instr->hydrogen()->value(); |
| 4435 if (change_input->IsLoadKeyed()) { |
| 4436 HLoadKeyed* load = HLoadKeyed::cast(change_input); |
| 4437 convert_hole = load->CanReturnHole(); |
| 4438 } |
| 4439 |
| 4440 Label no_special_nan_handling; |
| 4441 Label done; |
| 4442 if (convert_hole) { |
| 4443 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
| 4444 __ ucomisd(input_reg, input_reg); |
| 4445 __ j(parity_odd, &no_special_nan_handling); |
| 4446 __ subq(rsp, Immediate(kDoubleSize)); |
| 4447 __ movsd(MemOperand(rsp, 0), input_reg); |
| 4448 __ cmpl(MemOperand(rsp, sizeof(kHoleNanLower32)), |
| 4449 Immediate(kHoleNanUpper32)); |
| 4450 Label canonicalize; |
| 4451 __ j(not_equal, &canonicalize); |
| 4452 __ addq(rsp, Immediate(kDoubleSize)); |
| 4453 __ Move(reg, factory()->the_hole_value()); |
| 4454 __ jmp(&done); |
| 4455 __ bind(&canonicalize); |
| 4456 __ addq(rsp, Immediate(kDoubleSize)); |
| 4457 __ Set(kScratchRegister, BitCast<uint64_t>( |
| 4458 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); |
| 4459 __ movq(input_reg, kScratchRegister); |
| 4460 } |
| 4461 |
| 4462 __ bind(&no_special_nan_handling); |
4404 DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr); | 4463 DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr); |
4405 if (FLAG_inline_new) { | 4464 if (FLAG_inline_new) { |
4406 __ AllocateHeapNumber(reg, tmp, deferred->entry()); | 4465 __ AllocateHeapNumber(reg, tmp, deferred->entry()); |
4407 } else { | 4466 } else { |
4408 __ jmp(deferred->entry()); | 4467 __ jmp(deferred->entry()); |
4409 } | 4468 } |
4410 __ bind(deferred->exit()); | 4469 __ bind(deferred->exit()); |
4411 __ movsd(FieldOperand(reg, HeapNumber::kValueOffset), input_reg); | 4470 __ movsd(FieldOperand(reg, HeapNumber::kValueOffset), input_reg); |
| 4471 |
| 4472 __ bind(&done); |
4412 } | 4473 } |
4413 | 4474 |
4414 | 4475 |
4415 void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) { | 4476 void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) { |
4416 // TODO(3095996): Get rid of this. For now, we need to make the | 4477 // TODO(3095996): Get rid of this. For now, we need to make the |
4417 // result register contain a valid pointer because it is already | 4478 // result register contain a valid pointer because it is already |
4418 // contained in the register pointer map. | 4479 // contained in the register pointer map. |
4419 Register reg = ToRegister(instr->result()); | 4480 Register reg = ToRegister(instr->result()); |
4420 __ Move(reg, Smi::FromInt(0)); | 4481 __ Move(reg, Smi::FromInt(0)); |
4421 | 4482 |
(...skipping 25 matching lines...) Expand all Loading... |
4447 __ AssertSmi(input); | 4508 __ AssertSmi(input); |
4448 } | 4509 } |
4449 __ SmiToInteger32(input, input); | 4510 __ SmiToInteger32(input, input); |
4450 } | 4511 } |
4451 | 4512 |
4452 | 4513 |
4453 void LCodeGen::EmitNumberUntagD(Register input_reg, | 4514 void LCodeGen::EmitNumberUntagD(Register input_reg, |
4454 XMMRegister result_reg, | 4515 XMMRegister result_reg, |
4455 bool deoptimize_on_undefined, | 4516 bool deoptimize_on_undefined, |
4456 bool deoptimize_on_minus_zero, | 4517 bool deoptimize_on_minus_zero, |
4457 LEnvironment* env) { | 4518 LEnvironment* env, |
| 4519 NumberUntagDMode mode) { |
4458 Label load_smi, done; | 4520 Label load_smi, done; |
4459 | 4521 |
4460 // Smi check. | 4522 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
4461 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 4523 // Smi check. |
| 4524 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
4462 | 4525 |
4463 // Heap number map check. | 4526 // Heap number map check. |
4464 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 4527 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
4465 Heap::kHeapNumberMapRootIndex); | 4528 Heap::kHeapNumberMapRootIndex); |
4466 if (deoptimize_on_undefined) { | 4529 if (deoptimize_on_undefined) { |
4467 DeoptimizeIf(not_equal, env); | 4530 DeoptimizeIf(not_equal, env); |
| 4531 } else { |
| 4532 Label heap_number; |
| 4533 __ j(equal, &heap_number, Label::kNear); |
| 4534 |
| 4535 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
| 4536 DeoptimizeIf(not_equal, env); |
| 4537 |
| 4538 // Convert undefined to NaN. Compute NaN as 0/0. |
| 4539 __ xorps(result_reg, result_reg); |
| 4540 __ divsd(result_reg, result_reg); |
| 4541 __ jmp(&done, Label::kNear); |
| 4542 |
| 4543 __ bind(&heap_number); |
| 4544 } |
| 4545 // Heap number to XMM conversion. |
| 4546 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 4547 if (deoptimize_on_minus_zero) { |
| 4548 XMMRegister xmm_scratch = xmm0; |
| 4549 __ xorps(xmm_scratch, xmm_scratch); |
| 4550 __ ucomisd(xmm_scratch, result_reg); |
| 4551 __ j(not_equal, &done, Label::kNear); |
| 4552 __ movmskpd(kScratchRegister, result_reg); |
| 4553 __ testq(kScratchRegister, Immediate(1)); |
| 4554 DeoptimizeIf(not_zero, env); |
| 4555 } |
| 4556 __ jmp(&done, Label::kNear); |
| 4557 } else if (mode == NUMBER_CANDIDATE_IS_SMI_OR_HOLE) { |
| 4558 __ testq(input_reg, Immediate(kSmiTagMask)); |
| 4559 DeoptimizeIf(not_equal, env); |
| 4560 } else if (mode == NUMBER_CANDIDATE_IS_SMI_CONVERT_HOLE) { |
| 4561 __ testq(input_reg, Immediate(kSmiTagMask)); |
| 4562 __ j(zero, &load_smi); |
| 4563 __ Set(kScratchRegister, BitCast<uint64_t>( |
| 4564 FixedDoubleArray::hole_nan_as_double())); |
| 4565 __ movq(result_reg, kScratchRegister); |
| 4566 __ jmp(&done, Label::kNear); |
4468 } else { | 4567 } else { |
4469 Label heap_number; | 4568 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
4470 __ j(equal, &heap_number, Label::kNear); | |
4471 | |
4472 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | |
4473 DeoptimizeIf(not_equal, env); | |
4474 | |
4475 // Convert undefined to NaN. Compute NaN as 0/0. | |
4476 __ xorps(result_reg, result_reg); | |
4477 __ divsd(result_reg, result_reg); | |
4478 __ jmp(&done, Label::kNear); | |
4479 | |
4480 __ bind(&heap_number); | |
4481 } | 4569 } |
4482 // Heap number to XMM conversion. | |
4483 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
4484 if (deoptimize_on_minus_zero) { | |
4485 XMMRegister xmm_scratch = xmm0; | |
4486 __ xorps(xmm_scratch, xmm_scratch); | |
4487 __ ucomisd(xmm_scratch, result_reg); | |
4488 __ j(not_equal, &done, Label::kNear); | |
4489 __ movmskpd(kScratchRegister, result_reg); | |
4490 __ testq(kScratchRegister, Immediate(1)); | |
4491 DeoptimizeIf(not_zero, env); | |
4492 } | |
4493 __ jmp(&done, Label::kNear); | |
4494 | 4570 |
4495 // Smi to XMM conversion | 4571 // Smi to XMM conversion |
4496 __ bind(&load_smi); | 4572 __ bind(&load_smi); |
4497 __ SmiToInteger32(kScratchRegister, input_reg); | 4573 __ SmiToInteger32(kScratchRegister, input_reg); |
4498 __ cvtlsi2sd(result_reg, kScratchRegister); | 4574 __ cvtlsi2sd(result_reg, kScratchRegister); |
4499 __ bind(&done); | 4575 __ bind(&done); |
4500 } | 4576 } |
4501 | 4577 |
4502 | 4578 |
4503 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 4579 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4572 | 4648 |
4573 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 4649 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
4574 LOperand* input = instr->value(); | 4650 LOperand* input = instr->value(); |
4575 ASSERT(input->IsRegister()); | 4651 ASSERT(input->IsRegister()); |
4576 LOperand* result = instr->result(); | 4652 LOperand* result = instr->result(); |
4577 ASSERT(result->IsDoubleRegister()); | 4653 ASSERT(result->IsDoubleRegister()); |
4578 | 4654 |
4579 Register input_reg = ToRegister(input); | 4655 Register input_reg = ToRegister(input); |
4580 XMMRegister result_reg = ToDoubleRegister(result); | 4656 XMMRegister result_reg = ToDoubleRegister(result); |
4581 | 4657 |
| 4658 NumberUntagDMode mode = NUMBER_CANDIDATE_IS_ANY_TAGGED; |
| 4659 HValue* value = instr->hydrogen()->value(); |
| 4660 if (value->type().IsSmi()) { |
| 4661 if (value->IsLoadKeyed()) { |
| 4662 HLoadKeyed* load = HLoadKeyed::cast(value); |
| 4663 if (load->CanReturnHole()) { |
| 4664 if (load->hole_mode() == ALLOW_RETURN_HOLE) { |
| 4665 mode = NUMBER_CANDIDATE_IS_SMI_CONVERT_HOLE; |
| 4666 } else { |
| 4667 mode = NUMBER_CANDIDATE_IS_SMI_OR_HOLE; |
| 4668 } |
| 4669 } else { |
| 4670 mode = NUMBER_CANDIDATE_IS_SMI; |
| 4671 } |
| 4672 } |
| 4673 } |
| 4674 |
4582 EmitNumberUntagD(input_reg, result_reg, | 4675 EmitNumberUntagD(input_reg, result_reg, |
4583 instr->hydrogen()->deoptimize_on_undefined(), | 4676 instr->hydrogen()->deoptimize_on_undefined(), |
4584 instr->hydrogen()->deoptimize_on_minus_zero(), | 4677 instr->hydrogen()->deoptimize_on_minus_zero(), |
4585 instr->environment()); | 4678 instr->environment(), |
| 4679 mode); |
4586 } | 4680 } |
4587 | 4681 |
4588 | 4682 |
4589 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 4683 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
4590 LOperand* input = instr->value(); | 4684 LOperand* input = instr->value(); |
4591 ASSERT(input->IsDoubleRegister()); | 4685 ASSERT(input->IsDoubleRegister()); |
4592 LOperand* result = instr->result(); | 4686 LOperand* result = instr->result(); |
4593 ASSERT(result->IsRegister()); | 4687 ASSERT(result->IsRegister()); |
4594 | 4688 |
4595 XMMRegister input_reg = ToDoubleRegister(input); | 4689 XMMRegister input_reg = ToDoubleRegister(input); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4887 // contained in the register pointer map. | 4981 // contained in the register pointer map. |
4888 __ Set(result, 0); | 4982 __ Set(result, 0); |
4889 | 4983 |
4890 PushSafepointRegistersScope scope(this); | 4984 PushSafepointRegistersScope scope(this); |
4891 __ Push(Smi::FromInt(instance_size)); | 4985 __ Push(Smi::FromInt(instance_size)); |
4892 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); | 4986 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
4893 __ StoreToSafepointRegisterSlot(result, rax); | 4987 __ StoreToSafepointRegisterSlot(result, rax); |
4894 } | 4988 } |
4895 | 4989 |
4896 | 4990 |
| 4991 void LCodeGen::DoAllocate(LAllocate* instr) { |
| 4992 class DeferredAllocate: public LDeferredCode { |
| 4993 public: |
| 4994 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) |
| 4995 : LDeferredCode(codegen), instr_(instr) { } |
| 4996 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } |
| 4997 virtual LInstruction* instr() { return instr_; } |
| 4998 private: |
| 4999 LAllocate* instr_; |
| 5000 }; |
| 5001 |
| 5002 DeferredAllocate* deferred = |
| 5003 new(zone()) DeferredAllocate(this, instr); |
| 5004 |
| 5005 Register size = ToRegister(instr->size()); |
| 5006 Register result = ToRegister(instr->result()); |
| 5007 Register temp = ToRegister(instr->temp()); |
| 5008 |
| 5009 HAllocate* original_instr = instr->hydrogen(); |
| 5010 if (original_instr->size()->IsConstant()) { |
| 5011 UNREACHABLE(); |
| 5012 } else { |
| 5013 // Allocate memory for the object. |
| 5014 AllocationFlags flags = TAG_OBJECT; |
| 5015 if (original_instr->MustAllocateDoubleAligned()) { |
| 5016 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
| 5017 } |
| 5018 __ AllocateInNewSpace(size, result, temp, no_reg, |
| 5019 deferred->entry(), flags); |
| 5020 } |
| 5021 |
| 5022 __ bind(deferred->exit()); |
| 5023 } |
| 5024 |
| 5025 |
| 5026 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
| 5027 Register size = ToRegister(instr->size()); |
| 5028 Register result = ToRegister(instr->result()); |
| 5029 |
| 5030 // TODO(3095996): Get rid of this. For now, we need to make the |
| 5031 // result register contain a valid pointer because it is already |
| 5032 // contained in the register pointer map. |
| 5033 __ Set(result, 0); |
| 5034 |
| 5035 PushSafepointRegistersScope scope(this); |
| 5036 __ Integer32ToSmi(size, size); |
| 5037 __ push(size); |
| 5038 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
| 5039 __ StoreToSafepointRegisterSlot(result, rax); |
| 5040 } |
| 5041 |
| 5042 |
4897 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 5043 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4898 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 5044 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
4899 ElementsKind boilerplate_elements_kind = | 5045 ElementsKind boilerplate_elements_kind = |
4900 instr->hydrogen()->boilerplate_elements_kind(); | 5046 instr->hydrogen()->boilerplate_elements_kind(); |
4901 AllocationSiteMode allocation_site_mode = | 5047 AllocationSiteMode allocation_site_mode = |
4902 instr->hydrogen()->allocation_site_mode(); | 5048 instr->hydrogen()->allocation_site_mode(); |
4903 | 5049 |
4904 // Deopt if the array literal boilerplate ElementsKind is of a type different | 5050 // Deopt if the array literal boilerplate ElementsKind is of a type different |
4905 // than the expected one. The check isn't necessary if the boilerplate has | 5051 // than the expected one. The check isn't necessary if the boilerplate has |
4906 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 5052 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5574 FixedArray::kHeaderSize - kPointerSize)); | 5720 FixedArray::kHeaderSize - kPointerSize)); |
5575 __ bind(&done); | 5721 __ bind(&done); |
5576 } | 5722 } |
5577 | 5723 |
5578 | 5724 |
5579 #undef __ | 5725 #undef __ |
5580 | 5726 |
5581 } } // namespace v8::internal | 5727 } } // namespace v8::internal |
5582 | 5728 |
5583 #endif // V8_TARGET_ARCH_X64 | 5729 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |