| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 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" |
| 11 #include "src/ic/ic.h" | 11 #include "src/ic/ic.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
| 17 | 17 |
| 18 | 18 |
| 19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( | 19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( |
| 20 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 20 MacroAssembler* masm, Handle<HeapType> type, Register receiver, |
| 21 Register holder, int accessor_index, int expected_arguments) { | 21 Register holder, int accessor_index, int expected_arguments, |
| 22 Register scratch) { |
| 22 { | 23 { |
| 23 FrameScope scope(masm, StackFrame::INTERNAL); | 24 FrameScope scope(masm, StackFrame::INTERNAL); |
| 24 | 25 |
| 25 if (accessor_index >= 0) { | 26 if (accessor_index >= 0) { |
| 27 DCHECK(!holder.is(scratch)); |
| 28 DCHECK(!receiver.is(scratch)); |
| 26 // Call the JavaScript getter with the receiver on the stack. | 29 // Call the JavaScript getter with the receiver on the stack. |
| 27 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 30 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
| 28 // Swap in the global receiver. | 31 // Swap in the global receiver. |
| 29 __ mov(receiver, | 32 // Do not overwrite receiver register, it can alias to holder register. |
| 33 __ mov(scratch, |
| 30 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 34 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 35 receiver = scratch; |
| 31 } | 36 } |
| 32 __ push(receiver); | 37 __ push(receiver); |
| 33 ParameterCount actual(0); | 38 ParameterCount actual(0); |
| 34 ParameterCount expected(expected_arguments); | 39 ParameterCount expected(expected_arguments); |
| 35 __ LoadAccessor(edi, holder, accessor_index, ACCESSOR_GETTER); | 40 __ LoadAccessor(edi, holder, accessor_index, ACCESSOR_GETTER); |
| 36 __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, | 41 __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, |
| 37 NullCallWrapper()); | 42 NullCallWrapper()); |
| 38 } else { | 43 } else { |
| 39 // If we generate a global code snippet for deoptimization only, remember | 44 // If we generate a global code snippet for deoptimization only, remember |
| 40 // the place to continue after deoptimization. | 45 // the place to continue after deoptimization. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 Immediate(the_hole)); | 229 Immediate(the_hole)); |
| 225 } else { | 230 } else { |
| 226 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); | 231 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); |
| 227 } | 232 } |
| 228 __ j(not_equal, miss); | 233 __ j(not_equal, miss); |
| 229 } | 234 } |
| 230 | 235 |
| 231 | 236 |
| 232 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( | 237 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( |
| 233 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | 238 MacroAssembler* masm, Handle<HeapType> type, Register receiver, |
| 234 Register holder, int accessor_index, int expected_arguments) { | 239 Register holder, int accessor_index, int expected_arguments, |
| 240 Register scratch) { |
| 235 // ----------- S t a t e ------------- | 241 // ----------- S t a t e ------------- |
| 236 // -- esp[0] : return address | 242 // -- esp[0] : return address |
| 237 // ----------------------------------- | 243 // ----------------------------------- |
| 238 { | 244 { |
| 239 FrameScope scope(masm, StackFrame::INTERNAL); | 245 FrameScope scope(masm, StackFrame::INTERNAL); |
| 240 | 246 |
| 241 // Save value register, so we can restore it later. | 247 // Save value register, so we can restore it later. |
| 242 __ push(value()); | 248 __ push(value()); |
| 243 | 249 |
| 244 if (accessor_index >= 0) { | 250 if (accessor_index >= 0) { |
| 251 DCHECK(!holder.is(scratch)); |
| 252 DCHECK(!receiver.is(scratch)); |
| 253 DCHECK(!value().is(scratch)); |
| 245 // Call the JavaScript setter with receiver and value on the stack. | 254 // Call the JavaScript setter with receiver and value on the stack. |
| 246 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | 255 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
| 247 // Swap in the global receiver. | 256 // Swap in the global receiver. |
| 248 __ mov(receiver, | 257 // Do not overwrite receiver register, it can alias to holder register. |
| 258 __ mov(scratch, |
| 249 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | 259 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); |
| 260 receiver = scratch; |
| 250 } | 261 } |
| 251 __ push(receiver); | 262 __ push(receiver); |
| 252 __ push(value()); | 263 __ push(value()); |
| 253 ParameterCount actual(1); | 264 ParameterCount actual(1); |
| 254 ParameterCount expected(expected_arguments); | 265 ParameterCount expected(expected_arguments); |
| 255 __ LoadAccessor(edi, holder, accessor_index, ACCESSOR_SETTER); | 266 __ LoadAccessor(edi, holder, accessor_index, ACCESSOR_SETTER); |
| 256 __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, | 267 __ InvokeFunction(edi, expected, actual, CALL_FUNCTION, |
| 257 NullCallWrapper()); | 268 NullCallWrapper()); |
| 258 } else { | 269 } else { |
| 259 // If we generate a global code snippet for deoptimization only, remember | 270 // If we generate a global code snippet for deoptimization only, remember |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // Return the generated code. | 767 // Return the generated code. |
| 757 return GetCode(kind(), Code::NORMAL, name); | 768 return GetCode(kind(), Code::NORMAL, name); |
| 758 } | 769 } |
| 759 | 770 |
| 760 | 771 |
| 761 #undef __ | 772 #undef __ |
| 762 } | 773 } |
| 763 } // namespace v8::internal | 774 } // namespace v8::internal |
| 764 | 775 |
| 765 #endif // V8_TARGET_ARCH_X87 | 776 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |