OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/ic/call-optimization.h" | 9 #include "src/ic/call-optimization.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 DCHECK(cell->value()->IsTheHole()); | 207 DCHECK(cell->value()->IsTheHole()); |
208 __ Move(scratch, cell); | 208 __ Move(scratch, cell); |
209 __ Cmp(FieldOperand(scratch, Cell::kValueOffset), | 209 __ Cmp(FieldOperand(scratch, Cell::kValueOffset), |
210 masm->isolate()->factory()->the_hole_value()); | 210 masm->isolate()->factory()->the_hole_value()); |
211 __ j(not_equal, miss); | 211 __ j(not_equal, miss); |
212 } | 212 } |
213 | 213 |
214 | 214 |
215 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( | 215 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( |
216 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 216 MacroAssembler* masm, Handle<HeapType> type, Register receiver, |
217 Register holder, int accessor_index, int expected_arguments) { | 217 Register holder, int accessor_index, int expected_arguments, |
| 218 Register scratch) { |
218 // ----------- S t a t e ------------- | 219 // ----------- S t a t e ------------- |
219 // -- rsp[0] : return address | 220 // -- rsp[0] : return address |
220 // ----------------------------------- | 221 // ----------------------------------- |
221 { | 222 { |
222 FrameScope scope(masm, StackFrame::INTERNAL); | 223 FrameScope scope(masm, StackFrame::INTERNAL); |
223 | 224 |
224 // Save value register, so we can restore it later. | 225 // Save value register, so we can restore it later. |
225 __ Push(value()); | 226 __ Push(value()); |
226 | 227 |
227 if (accessor_index >= 0) { | 228 if (accessor_index >= 0) { |
| 229 DCHECK(!holder.is(scratch)); |
| 230 DCHECK(!receiver.is(scratch)); |
| 231 DCHECK(!value().is(scratch)); |
228 // Call the JavaScript setter with receiver and value on the stack. | 232 // Call the JavaScript setter with receiver and value on the stack. |
229 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 233 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
230 // Swap in the global receiver. | 234 // Swap in the global receiver. |
231 __ movp(receiver, | 235 __ movp(scratch, |
232 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 236 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 237 receiver = scratch; |
233 } | 238 } |
234 __ Push(receiver); | 239 __ Push(receiver); |
235 __ Push(value()); | 240 __ Push(value()); |
236 ParameterCount actual(1); | 241 ParameterCount actual(1); |
237 ParameterCount expected(expected_arguments); | 242 ParameterCount expected(expected_arguments); |
238 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_SETTER); | 243 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_SETTER); |
239 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, | 244 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, |
240 NullCallWrapper()); | 245 NullCallWrapper()); |
241 } else { | 246 } else { |
242 // If we generate a global code snippet for deoptimization only, remember | 247 // If we generate a global code snippet for deoptimization only, remember |
243 // the place to continue after deoptimization. | 248 // the place to continue after deoptimization. |
244 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); | 249 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); |
245 } | 250 } |
246 | 251 |
247 // We have to return the passed value, not the return value of the setter. | 252 // We have to return the passed value, not the return value of the setter. |
248 __ Pop(rax); | 253 __ Pop(rax); |
249 | 254 |
250 // Restore context register. | 255 // Restore context register. |
251 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 256 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
252 } | 257 } |
253 __ ret(0); | 258 __ ret(0); |
254 } | 259 } |
255 | 260 |
256 | 261 |
257 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( | 262 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( |
258 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 263 MacroAssembler* masm, Handle<HeapType> type, Register receiver, |
259 Register holder, int accessor_index, int expected_arguments) { | 264 Register holder, int accessor_index, int expected_arguments, |
| 265 Register scratch) { |
260 // ----------- S t a t e ------------- | 266 // ----------- S t a t e ------------- |
261 // -- rax : receiver | 267 // -- rax : receiver |
262 // -- rcx : name | 268 // -- rcx : name |
263 // -- rsp[0] : return address | 269 // -- rsp[0] : return address |
264 // ----------------------------------- | 270 // ----------------------------------- |
265 { | 271 { |
266 FrameScope scope(masm, StackFrame::INTERNAL); | 272 FrameScope scope(masm, StackFrame::INTERNAL); |
267 | 273 |
268 if (accessor_index >= 0) { | 274 if (accessor_index >= 0) { |
| 275 DCHECK(!holder.is(scratch)); |
| 276 DCHECK(!receiver.is(scratch)); |
269 // Call the JavaScript getter with the receiver on the stack. | 277 // Call the JavaScript getter with the receiver on the stack. |
270 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 278 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
271 // Swap in the global receiver. | 279 // Swap in the global receiver. |
272 __ movp(receiver, | 280 __ movp(scratch, |
273 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 281 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 282 receiver = scratch; |
274 } | 283 } |
275 __ Push(receiver); | 284 __ Push(receiver); |
276 ParameterCount actual(0); | 285 ParameterCount actual(0); |
277 ParameterCount expected(expected_arguments); | 286 ParameterCount expected(expected_arguments); |
278 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_GETTER); | 287 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_GETTER); |
279 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, | 288 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, |
280 NullCallWrapper()); | 289 NullCallWrapper()); |
281 } else { | 290 } else { |
282 // If we generate a global code snippet for deoptimization only, remember | 291 // If we generate a global code snippet for deoptimization only, remember |
283 // the place to continue after deoptimization. | 292 // the place to continue after deoptimization. |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // Return the generated code. | 752 // Return the generated code. |
744 return GetCode(kind(), Code::NORMAL, name); | 753 return GetCode(kind(), Code::NORMAL, name); |
745 } | 754 } |
746 | 755 |
747 | 756 |
748 #undef __ | 757 #undef __ |
749 } | 758 } |
750 } // namespace v8::internal | 759 } // namespace v8::internal |
751 | 760 |
752 #endif // V8_TARGET_ARCH_X64 | 761 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |