| 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 // Do not overwrite receiver register, it can alias to holder register. |
| 236 __ movp(scratch, |
| 232 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 237 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 238 receiver = scratch; |
| 233 } | 239 } |
| 234 __ Push(receiver); | 240 __ Push(receiver); |
| 235 __ Push(value()); | 241 __ Push(value()); |
| 236 ParameterCount actual(1); | 242 ParameterCount actual(1); |
| 237 ParameterCount expected(expected_arguments); | 243 ParameterCount expected(expected_arguments); |
| 238 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_SETTER); | 244 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_SETTER); |
| 239 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, | 245 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, |
| 240 NullCallWrapper()); | 246 NullCallWrapper()); |
| 241 } else { | 247 } else { |
| 242 // If we generate a global code snippet for deoptimization only, remember | 248 // If we generate a global code snippet for deoptimization only, remember |
| 243 // the place to continue after deoptimization. | 249 // the place to continue after deoptimization. |
| 244 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); | 250 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); |
| 245 } | 251 } |
| 246 | 252 |
| 247 // We have to return the passed value, not the return value of the setter. | 253 // We have to return the passed value, not the return value of the setter. |
| 248 __ Pop(rax); | 254 __ Pop(rax); |
| 249 | 255 |
| 250 // Restore context register. | 256 // Restore context register. |
| 251 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 257 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 252 } | 258 } |
| 253 __ ret(0); | 259 __ ret(0); |
| 254 } | 260 } |
| 255 | 261 |
| 256 | 262 |
| 257 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( | 263 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( |
| 258 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 264 MacroAssembler* masm, Handle<HeapType> type, Register receiver, |
| 259 Register holder, int accessor_index, int expected_arguments) { | 265 Register holder, int accessor_index, int expected_arguments, |
| 266 Register scratch) { |
| 260 // ----------- S t a t e ------------- | 267 // ----------- S t a t e ------------- |
| 261 // -- rax : receiver | 268 // -- rax : receiver |
| 262 // -- rcx : name | 269 // -- rcx : name |
| 263 // -- rsp[0] : return address | 270 // -- rsp[0] : return address |
| 264 // ----------------------------------- | 271 // ----------------------------------- |
| 265 { | 272 { |
| 266 FrameScope scope(masm, StackFrame::INTERNAL); | 273 FrameScope scope(masm, StackFrame::INTERNAL); |
| 267 | 274 |
| 268 if (accessor_index >= 0) { | 275 if (accessor_index >= 0) { |
| 276 DCHECK(!holder.is(scratch)); |
| 277 DCHECK(!receiver.is(scratch)); |
| 269 // Call the JavaScript getter with the receiver on the stack. | 278 // Call the JavaScript getter with the receiver on the stack. |
| 270 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 279 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
| 271 // Swap in the global receiver. | 280 // Swap in the global receiver. |
| 272 __ movp(receiver, | 281 // Do not overwrite receiver register, it can alias to holder register. |
| 282 __ movp(scratch, |
| 273 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 283 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 284 receiver = scratch; |
| 274 } | 285 } |
| 275 __ Push(receiver); | 286 __ Push(receiver); |
| 276 ParameterCount actual(0); | 287 ParameterCount actual(0); |
| 277 ParameterCount expected(expected_arguments); | 288 ParameterCount expected(expected_arguments); |
| 278 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_GETTER); | 289 __ LoadAccessor(rdi, holder, accessor_index, ACCESSOR_GETTER); |
| 279 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, | 290 __ InvokeFunction(rdi, expected, actual, CALL_FUNCTION, |
| 280 NullCallWrapper()); | 291 NullCallWrapper()); |
| 281 } else { | 292 } else { |
| 282 // If we generate a global code snippet for deoptimization only, remember | 293 // If we generate a global code snippet for deoptimization only, remember |
| 283 // the place to continue after deoptimization. | 294 // the place to continue after deoptimization. |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 // Return the generated code. | 754 // Return the generated code. |
| 744 return GetCode(kind(), Code::NORMAL, name); | 755 return GetCode(kind(), Code::NORMAL, name); |
| 745 } | 756 } |
| 746 | 757 |
| 747 | 758 |
| 748 #undef __ | 759 #undef __ |
| 749 } | 760 } |
| 750 } // namespace v8::internal | 761 } // namespace v8::internal |
| 751 | 762 |
| 752 #endif // V8_TARGET_ARCH_X64 | 763 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |