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_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } else if (FLAG_debug_code) { | 227 } else if (FLAG_debug_code) { |
228 Label done; | 228 Label done; |
229 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); | 229 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); |
230 __ Abort(kExpectedNewSpaceObject); | 230 __ Abort(kExpectedNewSpaceObject); |
231 __ bind(&done); | 231 __ bind(&done); |
232 } | 232 } |
233 } | 233 } |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 Variable* home_object_var = scope()->home_object_var(); | |
238 if (home_object_var != nullptr) { | |
239 __ Push(rdi); | |
240 } | |
241 | |
242 // Possibly set up a local binding to the this function which is used in | 237 // Possibly set up a local binding to the this function which is used in |
243 // derived constructors with super calls. | 238 // derived constructors with super calls. |
244 Variable* this_function_var = scope()->this_function_var(); | 239 Variable* this_function_var = scope()->this_function_var(); |
245 if (this_function_var != nullptr) { | 240 if (this_function_var != nullptr) { |
246 Comment cmnt(masm_, "[ This function"); | 241 Comment cmnt(masm_, "[ This function"); |
247 SetVar(this_function_var, rdi, rbx, rdx); | 242 SetVar(this_function_var, rdi, rbx, rdx); |
248 } | 243 } |
249 | 244 |
250 Variable* new_target_var = scope()->new_target_var(); | 245 Variable* new_target_var = scope()->new_target_var(); |
251 if (new_target_var != nullptr) { | 246 if (new_target_var != nullptr) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 313 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
319 } else { | 314 } else { |
320 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 315 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
321 } | 316 } |
322 ArgumentsAccessStub stub(isolate(), type, has_new_target); | 317 ArgumentsAccessStub stub(isolate(), type, has_new_target); |
323 __ CallStub(&stub); | 318 __ CallStub(&stub); |
324 | 319 |
325 SetVar(arguments, rax, rbx, rdx); | 320 SetVar(arguments, rax, rbx, rdx); |
326 } | 321 } |
327 | 322 |
328 // Possibly set up a local binding to the [[HomeObject]]. | |
329 if (home_object_var != nullptr) { | |
330 Comment cmnt(masm_, "[ Home object"); | |
331 __ Pop(LoadDescriptor::ReceiverRegister()); | |
332 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | |
333 __ Move(LoadDescriptor::NameRegister(), home_object_symbol); | |
334 __ Move(LoadDescriptor::SlotRegister(), | |
335 SmiFromSlot(function()->HomeObjectFeedbackSlot())); | |
336 CallLoadIC(NOT_CONTEXTUAL); | |
337 | |
338 SetVar(home_object_var, rax, rbx, rdx); | |
339 } | |
340 | |
341 if (FLAG_trace) { | 323 if (FLAG_trace) { |
342 __ CallRuntime(Runtime::kTraceEnter, 0); | 324 __ CallRuntime(Runtime::kTraceEnter, 0); |
343 } | 325 } |
344 | 326 |
345 // Visit the declarations and body unless there is an illegal | 327 // Visit the declarations and body unless there is an illegal |
346 // redeclaration. | 328 // redeclaration. |
347 if (scope()->HasIllegalRedeclaration()) { | 329 if (scope()->HasIllegalRedeclaration()) { |
348 Comment cmnt(masm_, "[ Declarations"); | 330 Comment cmnt(masm_, "[ Declarations"); |
349 scope()->VisitIllegalRedeclaration(this); | 331 scope()->VisitIllegalRedeclaration(this); |
350 | 332 |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 VisitForStackValue(property->obj()); | 1955 VisitForStackValue(property->obj()); |
1974 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 1956 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
1975 } else { | 1957 } else { |
1976 VisitForStackValue(property->obj()); | 1958 VisitForStackValue(property->obj()); |
1977 } | 1959 } |
1978 break; | 1960 break; |
1979 case NAMED_SUPER_PROPERTY: | 1961 case NAMED_SUPER_PROPERTY: |
1980 VisitForStackValue( | 1962 VisitForStackValue( |
1981 property->obj()->AsSuperPropertyReference()->this_var()); | 1963 property->obj()->AsSuperPropertyReference()->this_var()); |
1982 VisitForAccumulatorValue( | 1964 VisitForAccumulatorValue( |
1983 property->obj()->AsSuperPropertyReference()->home_object_var()); | 1965 property->obj()->AsSuperPropertyReference()->home_object()); |
1984 __ Push(result_register()); | 1966 __ Push(result_register()); |
1985 if (expr->is_compound()) { | 1967 if (expr->is_compound()) { |
1986 __ Push(MemOperand(rsp, kPointerSize)); | 1968 __ Push(MemOperand(rsp, kPointerSize)); |
1987 __ Push(result_register()); | 1969 __ Push(result_register()); |
1988 } | 1970 } |
1989 break; | 1971 break; |
1990 case KEYED_SUPER_PROPERTY: | 1972 case KEYED_SUPER_PROPERTY: |
1991 VisitForStackValue( | 1973 VisitForStackValue( |
1992 property->obj()->AsSuperPropertyReference()->this_var()); | 1974 property->obj()->AsSuperPropertyReference()->this_var()); |
1993 VisitForStackValue( | 1975 VisitForStackValue( |
1994 property->obj()->AsSuperPropertyReference()->home_object_var()); | 1976 property->obj()->AsSuperPropertyReference()->home_object()); |
1995 VisitForAccumulatorValue(property->key()); | 1977 VisitForAccumulatorValue(property->key()); |
1996 __ Push(result_register()); | 1978 __ Push(result_register()); |
1997 if (expr->is_compound()) { | 1979 if (expr->is_compound()) { |
1998 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 1980 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
1999 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 1981 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
2000 __ Push(result_register()); | 1982 __ Push(result_register()); |
2001 } | 1983 } |
2002 break; | 1984 break; |
2003 case KEYED_PROPERTY: { | 1985 case KEYED_PROPERTY: { |
2004 if (expr->is_compound()) { | 1986 if (expr->is_compound()) { |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 __ Move(StoreDescriptor::NameRegister(), | 2560 __ Move(StoreDescriptor::NameRegister(), |
2579 prop->key()->AsLiteral()->value()); | 2561 prop->key()->AsLiteral()->value()); |
2580 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2562 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2581 CallStoreIC(); | 2563 CallStoreIC(); |
2582 break; | 2564 break; |
2583 } | 2565 } |
2584 case NAMED_SUPER_PROPERTY: { | 2566 case NAMED_SUPER_PROPERTY: { |
2585 __ Push(rax); | 2567 __ Push(rax); |
2586 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); | 2568 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2587 VisitForAccumulatorValue( | 2569 VisitForAccumulatorValue( |
2588 prop->obj()->AsSuperPropertyReference()->home_object_var()); | 2570 prop->obj()->AsSuperPropertyReference()->home_object()); |
2589 // stack: value, this; rax: home_object | 2571 // stack: value, this; rax: home_object |
2590 Register scratch = rcx; | 2572 Register scratch = rcx; |
2591 Register scratch2 = rdx; | 2573 Register scratch2 = rdx; |
2592 __ Move(scratch, result_register()); // home_object | 2574 __ Move(scratch, result_register()); // home_object |
2593 __ movp(rax, MemOperand(rsp, kPointerSize)); // value | 2575 __ movp(rax, MemOperand(rsp, kPointerSize)); // value |
2594 __ movp(scratch2, MemOperand(rsp, 0)); // this | 2576 __ movp(scratch2, MemOperand(rsp, 0)); // this |
2595 __ movp(MemOperand(rsp, kPointerSize), scratch2); // this | 2577 __ movp(MemOperand(rsp, kPointerSize), scratch2); // this |
2596 __ movp(MemOperand(rsp, 0), scratch); // home_object | 2578 __ movp(MemOperand(rsp, 0), scratch); // home_object |
2597 // stack: this, home_object; rax: value | 2579 // stack: this, home_object; rax: value |
2598 EmitNamedSuperPropertyStore(prop); | 2580 EmitNamedSuperPropertyStore(prop); |
2599 break; | 2581 break; |
2600 } | 2582 } |
2601 case KEYED_SUPER_PROPERTY: { | 2583 case KEYED_SUPER_PROPERTY: { |
2602 __ Push(rax); | 2584 __ Push(rax); |
2603 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); | 2585 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
2604 VisitForStackValue( | 2586 VisitForStackValue( |
2605 prop->obj()->AsSuperPropertyReference()->home_object_var()); | 2587 prop->obj()->AsSuperPropertyReference()->home_object()); |
2606 VisitForAccumulatorValue(prop->key()); | 2588 VisitForAccumulatorValue(prop->key()); |
2607 Register scratch = rcx; | 2589 Register scratch = rcx; |
2608 Register scratch2 = rdx; | 2590 Register scratch2 = rdx; |
2609 __ movp(scratch2, MemOperand(rsp, 2 * kPointerSize)); // value | 2591 __ movp(scratch2, MemOperand(rsp, 2 * kPointerSize)); // value |
2610 // stack: value, this, home_object; rax: key, rdx: value | 2592 // stack: value, this, home_object; rax: key, rdx: value |
2611 __ movp(scratch, MemOperand(rsp, kPointerSize)); // this | 2593 __ movp(scratch, MemOperand(rsp, kPointerSize)); // this |
2612 __ movp(MemOperand(rsp, 2 * kPointerSize), scratch); | 2594 __ movp(MemOperand(rsp, 2 * kPointerSize), scratch); |
2613 __ movp(scratch, MemOperand(rsp, 0)); // home_object | 2595 __ movp(scratch, MemOperand(rsp, 0)); // home_object |
2614 __ movp(MemOperand(rsp, kPointerSize), scratch); | 2596 __ movp(MemOperand(rsp, kPointerSize), scratch); |
2615 __ movp(MemOperand(rsp, 0), rax); | 2597 __ movp(MemOperand(rsp, 0), rax); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2816 | 2798 |
2817 if (key->IsPropertyName()) { | 2799 if (key->IsPropertyName()) { |
2818 if (!expr->IsSuperAccess()) { | 2800 if (!expr->IsSuperAccess()) { |
2819 VisitForAccumulatorValue(expr->obj()); | 2801 VisitForAccumulatorValue(expr->obj()); |
2820 DCHECK(!rax.is(LoadDescriptor::ReceiverRegister())); | 2802 DCHECK(!rax.is(LoadDescriptor::ReceiverRegister())); |
2821 __ movp(LoadDescriptor::ReceiverRegister(), rax); | 2803 __ movp(LoadDescriptor::ReceiverRegister(), rax); |
2822 EmitNamedPropertyLoad(expr); | 2804 EmitNamedPropertyLoad(expr); |
2823 } else { | 2805 } else { |
2824 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); | 2806 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2825 VisitForStackValue( | 2807 VisitForStackValue( |
2826 expr->obj()->AsSuperPropertyReference()->home_object_var()); | 2808 expr->obj()->AsSuperPropertyReference()->home_object()); |
2827 EmitNamedSuperPropertyLoad(expr); | 2809 EmitNamedSuperPropertyLoad(expr); |
2828 } | 2810 } |
2829 } else { | 2811 } else { |
2830 if (!expr->IsSuperAccess()) { | 2812 if (!expr->IsSuperAccess()) { |
2831 VisitForStackValue(expr->obj()); | 2813 VisitForStackValue(expr->obj()); |
2832 VisitForAccumulatorValue(expr->key()); | 2814 VisitForAccumulatorValue(expr->key()); |
2833 __ Move(LoadDescriptor::NameRegister(), rax); | 2815 __ Move(LoadDescriptor::NameRegister(), rax); |
2834 __ Pop(LoadDescriptor::ReceiverRegister()); | 2816 __ Pop(LoadDescriptor::ReceiverRegister()); |
2835 EmitKeyedPropertyLoad(expr); | 2817 EmitKeyedPropertyLoad(expr); |
2836 } else { | 2818 } else { |
2837 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); | 2819 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
2838 VisitForStackValue( | 2820 VisitForStackValue( |
2839 expr->obj()->AsSuperPropertyReference()->home_object_var()); | 2821 expr->obj()->AsSuperPropertyReference()->home_object()); |
2840 VisitForStackValue(expr->key()); | 2822 VisitForStackValue(expr->key()); |
2841 EmitKeyedSuperPropertyLoad(expr); | 2823 EmitKeyedSuperPropertyLoad(expr); |
2842 } | 2824 } |
2843 } | 2825 } |
2844 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2826 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
2845 context()->Plug(rax); | 2827 context()->Plug(rax); |
2846 } | 2828 } |
2847 | 2829 |
2848 | 2830 |
2849 void FullCodeGenerator::CallIC(Handle<Code> code, | 2831 void FullCodeGenerator::CallIC(Handle<Code> code, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 Expression* callee = expr->expression(); | 2870 Expression* callee = expr->expression(); |
2889 DCHECK(callee->IsProperty()); | 2871 DCHECK(callee->IsProperty()); |
2890 Property* prop = callee->AsProperty(); | 2872 Property* prop = callee->AsProperty(); |
2891 DCHECK(prop->IsSuperAccess()); | 2873 DCHECK(prop->IsSuperAccess()); |
2892 | 2874 |
2893 SetSourcePosition(prop->position()); | 2875 SetSourcePosition(prop->position()); |
2894 Literal* key = prop->key()->AsLiteral(); | 2876 Literal* key = prop->key()->AsLiteral(); |
2895 DCHECK(!key->value()->IsSmi()); | 2877 DCHECK(!key->value()->IsSmi()); |
2896 // Load the function from the receiver. | 2878 // Load the function from the receiver. |
2897 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); | 2879 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2898 VisitForStackValue(super_ref->home_object_var()); | 2880 VisitForStackValue(super_ref->home_object()); |
2899 VisitForAccumulatorValue(super_ref->this_var()); | 2881 VisitForAccumulatorValue(super_ref->this_var()); |
2900 __ Push(rax); | 2882 __ Push(rax); |
2901 __ Push(rax); | 2883 __ Push(rax); |
2902 __ Push(Operand(rsp, kPointerSize * 2)); | 2884 __ Push(Operand(rsp, kPointerSize * 2)); |
2903 __ Push(key->value()); | 2885 __ Push(key->value()); |
2904 | 2886 |
2905 // Stack here: | 2887 // Stack here: |
2906 // - home_object | 2888 // - home_object |
2907 // - this (receiver) | 2889 // - this (receiver) |
2908 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2890 // - this (receiver) <-- LoadFromSuper will pop here and below. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2945 | 2927 |
2946 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2928 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
2947 Expression* callee = expr->expression(); | 2929 Expression* callee = expr->expression(); |
2948 DCHECK(callee->IsProperty()); | 2930 DCHECK(callee->IsProperty()); |
2949 Property* prop = callee->AsProperty(); | 2931 Property* prop = callee->AsProperty(); |
2950 DCHECK(prop->IsSuperAccess()); | 2932 DCHECK(prop->IsSuperAccess()); |
2951 | 2933 |
2952 SetSourcePosition(prop->position()); | 2934 SetSourcePosition(prop->position()); |
2953 // Load the function from the receiver. | 2935 // Load the function from the receiver. |
2954 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); | 2936 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
2955 VisitForStackValue(super_ref->home_object_var()); | 2937 VisitForStackValue(super_ref->home_object()); |
2956 VisitForAccumulatorValue(super_ref->this_var()); | 2938 VisitForAccumulatorValue(super_ref->this_var()); |
2957 __ Push(rax); | 2939 __ Push(rax); |
2958 __ Push(rax); | 2940 __ Push(rax); |
2959 __ Push(Operand(rsp, kPointerSize * 2)); | 2941 __ Push(Operand(rsp, kPointerSize * 2)); |
2960 VisitForStackValue(prop->key()); | 2942 VisitForStackValue(prop->key()); |
2961 | 2943 |
2962 // Stack here: | 2944 // Stack here: |
2963 // - home_object | 2945 // - home_object |
2964 // - this (receiver) | 2946 // - this (receiver) |
2965 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 2947 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4865 case NAMED_PROPERTY: { | 4847 case NAMED_PROPERTY: { |
4866 VisitForStackValue(prop->obj()); | 4848 VisitForStackValue(prop->obj()); |
4867 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4849 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4868 EmitNamedPropertyLoad(prop); | 4850 EmitNamedPropertyLoad(prop); |
4869 break; | 4851 break; |
4870 } | 4852 } |
4871 | 4853 |
4872 case NAMED_SUPER_PROPERTY: { | 4854 case NAMED_SUPER_PROPERTY: { |
4873 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); | 4855 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4874 VisitForAccumulatorValue( | 4856 VisitForAccumulatorValue( |
4875 prop->obj()->AsSuperPropertyReference()->home_object_var()); | 4857 prop->obj()->AsSuperPropertyReference()->home_object()); |
4876 __ Push(result_register()); | 4858 __ Push(result_register()); |
4877 __ Push(MemOperand(rsp, kPointerSize)); | 4859 __ Push(MemOperand(rsp, kPointerSize)); |
4878 __ Push(result_register()); | 4860 __ Push(result_register()); |
4879 EmitNamedSuperPropertyLoad(prop); | 4861 EmitNamedSuperPropertyLoad(prop); |
4880 break; | 4862 break; |
4881 } | 4863 } |
4882 | 4864 |
4883 case KEYED_SUPER_PROPERTY: { | 4865 case KEYED_SUPER_PROPERTY: { |
4884 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); | 4866 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
4885 VisitForStackValue( | 4867 VisitForStackValue( |
4886 prop->obj()->AsSuperPropertyReference()->home_object_var()); | 4868 prop->obj()->AsSuperPropertyReference()->home_object()); |
4887 VisitForAccumulatorValue(prop->key()); | 4869 VisitForAccumulatorValue(prop->key()); |
4888 __ Push(result_register()); | 4870 __ Push(result_register()); |
4889 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 4871 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
4890 __ Push(MemOperand(rsp, 2 * kPointerSize)); | 4872 __ Push(MemOperand(rsp, 2 * kPointerSize)); |
4891 __ Push(result_register()); | 4873 __ Push(result_register()); |
4892 EmitKeyedSuperPropertyLoad(prop); | 4874 EmitKeyedSuperPropertyLoad(prop); |
4893 break; | 4875 break; |
4894 } | 4876 } |
4895 | 4877 |
4896 case KEYED_PROPERTY: { | 4878 case KEYED_PROPERTY: { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5499 Assembler::target_address_at(call_target_address, | 5481 Assembler::target_address_at(call_target_address, |
5500 unoptimized_code)); | 5482 unoptimized_code)); |
5501 return OSR_AFTER_STACK_CHECK; | 5483 return OSR_AFTER_STACK_CHECK; |
5502 } | 5484 } |
5503 | 5485 |
5504 | 5486 |
5505 } // namespace internal | 5487 } // namespace internal |
5506 } // namespace v8 | 5488 } // namespace v8 |
5507 | 5489 |
5508 #endif // V8_TARGET_ARCH_X64 | 5490 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |