OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 4016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4027 | 4027 |
4028 __ bind(&need_incremental_pop_object); | 4028 __ bind(&need_incremental_pop_object); |
4029 __ Pop(regs_.object()); | 4029 __ Pop(regs_.object()); |
4030 | 4030 |
4031 __ bind(&need_incremental); | 4031 __ bind(&need_incremental); |
4032 | 4032 |
4033 // Fall through when we need to inform the incremental marker. | 4033 // Fall through when we need to inform the incremental marker. |
4034 } | 4034 } |
4035 | 4035 |
4036 | 4036 |
4037 void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) { | |
4038 // ----------- S t a t e ------------- | |
4039 // -- rax : element value to store | |
4040 // -- rcx : element index as smi | |
4041 // -- rsp[0] : return address | |
4042 // -- rsp[8] : array literal index in function | |
4043 // -- rsp[16] : array literal | |
4044 // clobbers rbx, rdx, rdi | |
4045 // ----------------------------------- | |
4046 | |
4047 Label element_done; | |
4048 Label double_elements; | |
4049 Label smi_element; | |
4050 Label slow_elements; | |
4051 Label fast_elements; | |
4052 | |
4053 // Get array literal index, array literal and its map. | |
4054 StackArgumentsAccessor args(rsp, 2, ARGUMENTS_DONT_CONTAIN_RECEIVER); | |
4055 __ movp(rdx, args.GetArgumentOperand(1)); | |
4056 __ movp(rbx, args.GetArgumentOperand(0)); | |
4057 __ movp(rdi, FieldOperand(rbx, JSObject::kMapOffset)); | |
4058 | |
4059 __ CheckFastElements(rdi, &double_elements); | |
4060 | |
4061 // FAST_*_SMI_ELEMENTS or FAST_*_ELEMENTS | |
4062 __ JumpIfSmi(rax, &smi_element); | |
4063 __ CheckFastSmiElements(rdi, &fast_elements); | |
4064 | |
4065 // Store into the array literal requires a elements transition. Call into | |
4066 // the runtime. | |
4067 | |
4068 __ bind(&slow_elements); | |
4069 __ PopReturnAddressTo(rdi); | |
4070 __ Push(rbx); | |
4071 __ Push(rcx); | |
4072 __ Push(rax); | |
4073 __ movp(rbx, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
4074 __ Push(FieldOperand(rbx, JSFunction::kLiteralsOffset)); | |
4075 __ Push(rdx); | |
4076 __ PushReturnAddressFrom(rdi); | |
4077 __ TailCallRuntime(Runtime::kStoreArrayLiteralElement, 5, 1); | |
4078 | |
4079 // Array literal has ElementsKind of FAST_*_ELEMENTS and value is an object. | |
4080 __ bind(&fast_elements); | |
4081 __ SmiToInteger32(kScratchRegister, rcx); | |
4082 __ movp(rbx, FieldOperand(rbx, JSObject::kElementsOffset)); | |
4083 __ leap(rcx, FieldOperand(rbx, kScratchRegister, times_pointer_size, | |
4084 FixedArrayBase::kHeaderSize)); | |
4085 __ movp(Operand(rcx, 0), rax); | |
4086 // Update the write barrier for the array store. | |
4087 __ RecordWrite(rbx, rcx, rax, | |
4088 kDontSaveFPRegs, | |
4089 EMIT_REMEMBERED_SET, | |
4090 OMIT_SMI_CHECK); | |
4091 __ ret(0); | |
4092 | |
4093 // Array literal has ElementsKind of FAST_*_SMI_ELEMENTS or | |
4094 // FAST_*_ELEMENTS, and value is Smi. | |
4095 __ bind(&smi_element); | |
4096 __ SmiToInteger32(kScratchRegister, rcx); | |
4097 __ movp(rbx, FieldOperand(rbx, JSObject::kElementsOffset)); | |
4098 __ movp(FieldOperand(rbx, kScratchRegister, times_pointer_size, | |
4099 FixedArrayBase::kHeaderSize), rax); | |
4100 __ ret(0); | |
4101 | |
4102 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. | |
4103 __ bind(&double_elements); | |
4104 | |
4105 __ movp(r9, FieldOperand(rbx, JSObject::kElementsOffset)); | |
4106 __ SmiToInteger32(r11, rcx); | |
4107 __ StoreNumberToDoubleElements(rax, | |
4108 r9, | |
4109 r11, | |
4110 xmm0, | |
4111 &slow_elements); | |
4112 __ ret(0); | |
4113 } | |
4114 | |
4115 | |
4116 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { | 4037 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { |
4117 CEntryStub ces(isolate(), 1, kSaveFPRegs); | 4038 CEntryStub ces(isolate(), 1, kSaveFPRegs); |
4118 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); | 4039 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); |
4119 int parameter_count_offset = | 4040 int parameter_count_offset = |
4120 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 4041 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
4121 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); | 4042 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); |
4122 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 4043 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
4123 __ PopReturnAddressTo(rcx); | 4044 __ PopReturnAddressTo(rcx); |
4124 int additional_offset = | 4045 int additional_offset = |
4125 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; | 4046 function_mode() == JS_FUNCTION_STUB_MODE ? kPointerSize : 0; |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5476 kStackSpace, nullptr, return_value_operand, NULL); | 5397 kStackSpace, nullptr, return_value_operand, NULL); |
5477 } | 5398 } |
5478 | 5399 |
5479 | 5400 |
5480 #undef __ | 5401 #undef __ |
5481 | 5402 |
5482 } // namespace internal | 5403 } // namespace internal |
5483 } // namespace v8 | 5404 } // namespace v8 |
5484 | 5405 |
5485 #endif // V8_TARGET_ARCH_X64 | 5406 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |