Chromium Code Reviews| 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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } else if (FLAG_debug_code) { | 231 } else if (FLAG_debug_code) { |
| 232 Label done; | 232 Label done; |
| 233 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); | 233 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); |
| 234 __ Abort(kExpectedNewSpaceObject); | 234 __ Abort(kExpectedNewSpaceObject); |
| 235 __ bind(&done); | 235 __ bind(&done); |
| 236 } | 236 } |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Possibly set up a local binding to the this function which is used in | |
| 242 // derived constructors with super calls. | |
| 243 Variable* this_function_var = scope()->this_function_var(); | |
| 244 if (this_function_var != nullptr) { | |
| 245 Comment cmnt(masm_, "[ This function"); | |
| 246 SetVar(this_function_var, edi, ebx, edx); | |
| 247 } | |
| 248 | |
| 249 Variable* new_target_var = scope()->new_target_var(); | |
| 250 if (new_target_var != nullptr) { | |
| 251 Comment cmnt(masm_, "[ new.target"); | |
| 252 // new.target is parameter -2. | |
| 253 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize + | |
| 254 (info_->scope()->num_parameters() - 1) * kPointerSize; | |
| 255 __ mov(eax, Operand(ebp, offset)); | |
| 256 SetVar(new_target_var, eax, ebx, edx); | |
| 257 } | |
| 258 | |
| 241 Variable* home_object_var = scope()->home_object_var(); | 259 Variable* home_object_var = scope()->home_object_var(); |
| 242 if (home_object_var != nullptr) { | 260 if (home_object_var != nullptr) { |
| 243 __ push(edi); | 261 __ push(edi); |
| 244 } | 262 } |
| 245 | 263 |
| 246 ArgumentsAccessStub::HasNewTarget has_new_target = | 264 ArgumentsAccessStub::HasNewTarget has_new_target = |
| 247 IsSubclassConstructor(info->function()->kind()) | 265 IsSubclassConstructor(info->function()->kind()) |
| 248 ? ArgumentsAccessStub::HAS_NEW_TARGET | 266 ? ArgumentsAccessStub::HAS_NEW_TARGET |
| 249 : ArgumentsAccessStub::NO_NEW_TARGET; | 267 : ArgumentsAccessStub::NO_NEW_TARGET; |
| 250 | 268 |
| (...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1913 | 1931 |
| 1914 Property* property = expr->target()->AsProperty(); | 1932 Property* property = expr->target()->AsProperty(); |
| 1915 LhsKind assign_type = Property::GetAssignType(property); | 1933 LhsKind assign_type = Property::GetAssignType(property); |
| 1916 | 1934 |
| 1917 // Evaluate LHS expression. | 1935 // Evaluate LHS expression. |
| 1918 switch (assign_type) { | 1936 switch (assign_type) { |
| 1919 case VARIABLE: | 1937 case VARIABLE: |
| 1920 // Nothing to do here. | 1938 // Nothing to do here. |
| 1921 break; | 1939 break; |
| 1922 case NAMED_SUPER_PROPERTY: | 1940 case NAMED_SUPER_PROPERTY: |
| 1923 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | 1941 VisitForStackValue( |
| 1942 property->obj()->AsSuperPropertyReference()->this_var()); | |
| 1924 VisitForAccumulatorValue( | 1943 VisitForAccumulatorValue( |
| 1925 property->obj()->AsSuperReference()->home_object_var()); | 1944 property->obj()->AsSuperPropertyReference()->home_object_var()); |
| 1926 __ push(result_register()); | 1945 __ push(result_register()); |
| 1927 if (expr->is_compound()) { | 1946 if (expr->is_compound()) { |
| 1928 __ push(MemOperand(esp, kPointerSize)); | 1947 __ push(MemOperand(esp, kPointerSize)); |
| 1929 __ push(result_register()); | 1948 __ push(result_register()); |
| 1930 } | 1949 } |
| 1931 break; | 1950 break; |
| 1932 case NAMED_PROPERTY: | 1951 case NAMED_PROPERTY: |
| 1933 if (expr->is_compound()) { | 1952 if (expr->is_compound()) { |
| 1934 // We need the receiver both on the stack and in the register. | 1953 // We need the receiver both on the stack and in the register. |
| 1935 VisitForStackValue(property->obj()); | 1954 VisitForStackValue(property->obj()); |
| 1936 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 1955 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
| 1937 } else { | 1956 } else { |
| 1938 VisitForStackValue(property->obj()); | 1957 VisitForStackValue(property->obj()); |
| 1939 } | 1958 } |
| 1940 break; | 1959 break; |
| 1941 case KEYED_SUPER_PROPERTY: | 1960 case KEYED_SUPER_PROPERTY: |
| 1942 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); | |
| 1943 VisitForStackValue( | 1961 VisitForStackValue( |
| 1944 property->obj()->AsSuperReference()->home_object_var()); | 1962 property->obj()->AsSuperPropertyReference()->this_var()); |
| 1963 VisitForStackValue( | |
| 1964 property->obj()->AsSuperPropertyReference()->home_object_var()); | |
| 1945 VisitForAccumulatorValue(property->key()); | 1965 VisitForAccumulatorValue(property->key()); |
| 1946 __ Push(result_register()); | 1966 __ Push(result_register()); |
| 1947 if (expr->is_compound()) { | 1967 if (expr->is_compound()) { |
| 1948 __ push(MemOperand(esp, 2 * kPointerSize)); | 1968 __ push(MemOperand(esp, 2 * kPointerSize)); |
| 1949 __ push(MemOperand(esp, 2 * kPointerSize)); | 1969 __ push(MemOperand(esp, 2 * kPointerSize)); |
| 1950 __ push(result_register()); | 1970 __ push(result_register()); |
| 1951 } | 1971 } |
| 1952 break; | 1972 break; |
| 1953 case KEYED_PROPERTY: { | 1973 case KEYED_PROPERTY: { |
| 1954 if (expr->is_compound()) { | 1974 if (expr->is_compound()) { |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2558 __ Move(StoreDescriptor::ReceiverRegister(), eax); | 2578 __ Move(StoreDescriptor::ReceiverRegister(), eax); |
| 2559 __ pop(StoreDescriptor::ValueRegister()); // Restore value. | 2579 __ pop(StoreDescriptor::ValueRegister()); // Restore value. |
| 2560 __ mov(StoreDescriptor::NameRegister(), | 2580 __ mov(StoreDescriptor::NameRegister(), |
| 2561 prop->key()->AsLiteral()->value()); | 2581 prop->key()->AsLiteral()->value()); |
| 2562 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2582 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
| 2563 CallStoreIC(); | 2583 CallStoreIC(); |
| 2564 break; | 2584 break; |
| 2565 } | 2585 } |
| 2566 case NAMED_SUPER_PROPERTY: { | 2586 case NAMED_SUPER_PROPERTY: { |
| 2567 __ push(eax); | 2587 __ push(eax); |
| 2568 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2588 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
| 2569 VisitForAccumulatorValue( | 2589 VisitForAccumulatorValue( |
| 2570 prop->obj()->AsSuperReference()->home_object_var()); | 2590 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
| 2571 // stack: value, this; eax: home_object | 2591 // stack: value, this; eax: home_object |
| 2572 Register scratch = ecx; | 2592 Register scratch = ecx; |
| 2573 Register scratch2 = edx; | 2593 Register scratch2 = edx; |
| 2574 __ mov(scratch, result_register()); // home_object | 2594 __ mov(scratch, result_register()); // home_object |
| 2575 __ mov(eax, MemOperand(esp, kPointerSize)); // value | 2595 __ mov(eax, MemOperand(esp, kPointerSize)); // value |
| 2576 __ mov(scratch2, MemOperand(esp, 0)); // this | 2596 __ mov(scratch2, MemOperand(esp, 0)); // this |
| 2577 __ mov(MemOperand(esp, kPointerSize), scratch2); // this | 2597 __ mov(MemOperand(esp, kPointerSize), scratch2); // this |
| 2578 __ mov(MemOperand(esp, 0), scratch); // home_object | 2598 __ mov(MemOperand(esp, 0), scratch); // home_object |
| 2579 // stack: this, home_object. eax: value | 2599 // stack: this, home_object. eax: value |
| 2580 EmitNamedSuperPropertyStore(prop); | 2600 EmitNamedSuperPropertyStore(prop); |
| 2581 break; | 2601 break; |
| 2582 } | 2602 } |
| 2583 case KEYED_SUPER_PROPERTY: { | 2603 case KEYED_SUPER_PROPERTY: { |
| 2584 __ push(eax); | 2604 __ push(eax); |
| 2585 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 2605 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
| 2586 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); | 2606 VisitForStackValue( |
| 2607 prop->obj()->AsSuperPropertyReference()->home_object_var()); | |
| 2587 VisitForAccumulatorValue(prop->key()); | 2608 VisitForAccumulatorValue(prop->key()); |
| 2588 Register scratch = ecx; | 2609 Register scratch = ecx; |
| 2589 Register scratch2 = edx; | 2610 Register scratch2 = edx; |
| 2590 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value | 2611 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value |
| 2591 // stack: value, this, home_object; eax: key, edx: value | 2612 // stack: value, this, home_object; eax: key, edx: value |
| 2592 __ mov(scratch, MemOperand(esp, kPointerSize)); // this | 2613 __ mov(scratch, MemOperand(esp, kPointerSize)); // this |
| 2593 __ mov(MemOperand(esp, 2 * kPointerSize), scratch); | 2614 __ mov(MemOperand(esp, 2 * kPointerSize), scratch); |
| 2594 __ mov(scratch, MemOperand(esp, 0)); // home_object | 2615 __ mov(scratch, MemOperand(esp, 0)); // home_object |
| 2595 __ mov(MemOperand(esp, kPointerSize), scratch); | 2616 __ mov(MemOperand(esp, kPointerSize), scratch); |
| 2596 __ mov(MemOperand(esp, 0), eax); | 2617 __ mov(MemOperand(esp, 0), eax); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2798 void FullCodeGenerator::VisitProperty(Property* expr) { | 2819 void FullCodeGenerator::VisitProperty(Property* expr) { |
| 2799 Comment cmnt(masm_, "[ Property"); | 2820 Comment cmnt(masm_, "[ Property"); |
| 2800 Expression* key = expr->key(); | 2821 Expression* key = expr->key(); |
| 2801 | 2822 |
| 2802 if (key->IsPropertyName()) { | 2823 if (key->IsPropertyName()) { |
| 2803 if (!expr->IsSuperAccess()) { | 2824 if (!expr->IsSuperAccess()) { |
| 2804 VisitForAccumulatorValue(expr->obj()); | 2825 VisitForAccumulatorValue(expr->obj()); |
| 2805 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); | 2826 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); |
| 2806 EmitNamedPropertyLoad(expr); | 2827 EmitNamedPropertyLoad(expr); |
| 2807 } else { | 2828 } else { |
| 2808 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2829 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
| 2809 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2830 VisitForStackValue( |
| 2831 expr->obj()->AsSuperPropertyReference()->home_object_var()); | |
| 2810 EmitNamedSuperPropertyLoad(expr); | 2832 EmitNamedSuperPropertyLoad(expr); |
| 2811 } | 2833 } |
| 2812 } else { | 2834 } else { |
| 2813 if (!expr->IsSuperAccess()) { | 2835 if (!expr->IsSuperAccess()) { |
| 2814 VisitForStackValue(expr->obj()); | 2836 VisitForStackValue(expr->obj()); |
| 2815 VisitForAccumulatorValue(expr->key()); | 2837 VisitForAccumulatorValue(expr->key()); |
| 2816 __ pop(LoadDescriptor::ReceiverRegister()); // Object. | 2838 __ pop(LoadDescriptor::ReceiverRegister()); // Object. |
| 2817 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. | 2839 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. |
| 2818 EmitKeyedPropertyLoad(expr); | 2840 EmitKeyedPropertyLoad(expr); |
| 2819 } else { | 2841 } else { |
| 2820 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); | 2842 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
| 2821 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); | 2843 VisitForStackValue( |
| 2844 expr->obj()->AsSuperPropertyReference()->home_object_var()); | |
| 2822 VisitForStackValue(expr->key()); | 2845 VisitForStackValue(expr->key()); |
| 2823 EmitKeyedSuperPropertyLoad(expr); | 2846 EmitKeyedSuperPropertyLoad(expr); |
| 2824 } | 2847 } |
| 2825 } | 2848 } |
| 2826 PrepareForBailoutForId(expr->LoadId(), TOS_REG); | 2849 PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
| 2827 context()->Plug(eax); | 2850 context()->Plug(eax); |
| 2828 } | 2851 } |
| 2829 | 2852 |
| 2830 | 2853 |
| 2831 void FullCodeGenerator::CallIC(Handle<Code> code, | 2854 void FullCodeGenerator::CallIC(Handle<Code> code, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2869 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { | 2892 void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
| 2870 Expression* callee = expr->expression(); | 2893 Expression* callee = expr->expression(); |
| 2871 DCHECK(callee->IsProperty()); | 2894 DCHECK(callee->IsProperty()); |
| 2872 Property* prop = callee->AsProperty(); | 2895 Property* prop = callee->AsProperty(); |
| 2873 DCHECK(prop->IsSuperAccess()); | 2896 DCHECK(prop->IsSuperAccess()); |
| 2874 | 2897 |
| 2875 SetSourcePosition(prop->position()); | 2898 SetSourcePosition(prop->position()); |
| 2876 Literal* key = prop->key()->AsLiteral(); | 2899 Literal* key = prop->key()->AsLiteral(); |
| 2877 DCHECK(!key->value()->IsSmi()); | 2900 DCHECK(!key->value()->IsSmi()); |
| 2878 // Load the function from the receiver. | 2901 // Load the function from the receiver. |
| 2879 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); | 2902 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
| 2880 VisitForStackValue(super_ref->home_object_var()); | 2903 VisitForStackValue(super_ref->home_object_var()); |
| 2881 VisitForAccumulatorValue(super_ref->this_var()); | 2904 VisitForAccumulatorValue(super_ref->this_var()); |
| 2882 __ push(eax); | 2905 __ push(eax); |
| 2883 __ push(eax); | 2906 __ push(eax); |
| 2884 __ push(Operand(esp, kPointerSize * 2)); | 2907 __ push(Operand(esp, kPointerSize * 2)); |
| 2885 __ push(Immediate(key->value())); | 2908 __ push(Immediate(key->value())); |
| 2886 // Stack here: | 2909 // Stack here: |
| 2887 // - home_object | 2910 // - home_object |
| 2888 // - this (receiver) | 2911 // - this (receiver) |
| 2889 // - this (receiver) <-- LoadFromSuper will pop here and below. | 2912 // - this (receiver) <-- LoadFromSuper will pop here and below. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 | 2948 |
| 2926 | 2949 |
| 2927 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { | 2950 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
| 2928 Expression* callee = expr->expression(); | 2951 Expression* callee = expr->expression(); |
| 2929 DCHECK(callee->IsProperty()); | 2952 DCHECK(callee->IsProperty()); |
| 2930 Property* prop = callee->AsProperty(); | 2953 Property* prop = callee->AsProperty(); |
| 2931 DCHECK(prop->IsSuperAccess()); | 2954 DCHECK(prop->IsSuperAccess()); |
| 2932 | 2955 |
| 2933 SetSourcePosition(prop->position()); | 2956 SetSourcePosition(prop->position()); |
| 2934 // Load the function from the receiver. | 2957 // Load the function from the receiver. |
| 2935 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); | 2958 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
| 2936 VisitForStackValue(super_ref->home_object_var()); | 2959 VisitForStackValue(super_ref->home_object_var()); |
| 2937 VisitForAccumulatorValue(super_ref->this_var()); | 2960 VisitForAccumulatorValue(super_ref->this_var()); |
| 2938 __ push(eax); | 2961 __ push(eax); |
| 2939 __ push(eax); | 2962 __ push(eax); |
| 2940 __ push(Operand(esp, kPointerSize * 2)); | 2963 __ push(Operand(esp, kPointerSize * 2)); |
| 2941 VisitForStackValue(prop->key()); | 2964 VisitForStackValue(prop->key()); |
| 2942 // Stack here: | 2965 // Stack here: |
| 2943 // - home_object | 2966 // - home_object |
| 2944 // - this (receiver) | 2967 // - this (receiver) |
| 2945 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. | 2968 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3003 __ push(Immediate(Smi::FromInt(language_mode()))); | 3026 __ push(Immediate(Smi::FromInt(language_mode()))); |
| 3004 | 3027 |
| 3005 // Push the start position of the scope the calls resides in. | 3028 // Push the start position of the scope the calls resides in. |
| 3006 __ push(Immediate(Smi::FromInt(scope()->start_position()))); | 3029 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
| 3007 | 3030 |
| 3008 // Do the runtime call. | 3031 // Do the runtime call. |
| 3009 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3032 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
| 3010 } | 3033 } |
| 3011 | 3034 |
| 3012 | 3035 |
| 3013 void FullCodeGenerator::EmitLoadSuperConstructor() { | |
| 3014 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
| 3015 __ CallRuntime(Runtime::kGetPrototype, 1); | |
| 3016 } | |
| 3017 | |
| 3018 | |
| 3019 void FullCodeGenerator::EmitInitializeThisAfterSuper( | 3036 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
| 3020 SuperReference* super_ref, FeedbackVectorICSlot slot) { | 3037 SuperCallReference* super_call_ref, FeedbackVectorICSlot slot) { |
| 3021 Variable* this_var = super_ref->this_var()->var(); | 3038 Variable* this_var = super_call_ref->this_var()->var(); |
| 3022 GetVar(ecx, this_var); | 3039 GetVar(ecx, this_var); |
| 3023 __ cmp(ecx, isolate()->factory()->the_hole_value()); | 3040 __ cmp(ecx, isolate()->factory()->the_hole_value()); |
| 3024 Label uninitialized_this; | 3041 Label uninitialized_this; |
| 3025 __ j(equal, &uninitialized_this); | 3042 __ j(equal, &uninitialized_this); |
| 3026 __ push(Immediate(this_var->name())); | 3043 __ push(Immediate(this_var->name())); |
| 3027 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 3044 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3028 __ bind(&uninitialized_this); | 3045 __ bind(&uninitialized_this); |
| 3029 | 3046 |
| 3030 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); | 3047 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); |
| 3031 } | 3048 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3160 | 3177 |
| 3161 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3178 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| 3162 Comment cmnt(masm_, "[ CallNew"); | 3179 Comment cmnt(masm_, "[ CallNew"); |
| 3163 // According to ECMA-262, section 11.2.2, page 44, the function | 3180 // According to ECMA-262, section 11.2.2, page 44, the function |
| 3164 // expression in new calls must be evaluated before the | 3181 // expression in new calls must be evaluated before the |
| 3165 // arguments. | 3182 // arguments. |
| 3166 | 3183 |
| 3167 // Push constructor on the stack. If it's not a function it's used as | 3184 // Push constructor on the stack. If it's not a function it's used as |
| 3168 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3185 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
| 3169 // ignored. | 3186 // ignored. |
| 3170 DCHECK(!expr->expression()->IsSuperReference()); | 3187 DCHECK(!expr->expression()->IsSuperPropertyReference()); |
| 3171 VisitForStackValue(expr->expression()); | 3188 VisitForStackValue(expr->expression()); |
| 3172 | 3189 |
| 3173 // Push the arguments ("left-to-right") on the stack. | 3190 // Push the arguments ("left-to-right") on the stack. |
| 3174 ZoneList<Expression*>* args = expr->arguments(); | 3191 ZoneList<Expression*>* args = expr->arguments(); |
| 3175 int arg_count = args->length(); | 3192 int arg_count = args->length(); |
| 3176 for (int i = 0; i < arg_count; i++) { | 3193 for (int i = 0; i < arg_count; i++) { |
| 3177 VisitForStackValue(args->at(i)); | 3194 VisitForStackValue(args->at(i)); |
| 3178 } | 3195 } |
| 3179 | 3196 |
| 3180 // Call the construct call builtin that handles allocation and | 3197 // Call the construct call builtin that handles allocation and |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 3196 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3213 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
| 3197 | 3214 |
| 3198 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3215 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3199 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3216 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3200 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3217 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 3201 context()->Plug(eax); | 3218 context()->Plug(eax); |
| 3202 } | 3219 } |
| 3203 | 3220 |
| 3204 | 3221 |
| 3205 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { | 3222 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3206 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 3223 SuperCallReference* super_call_ref = |
| 3207 GetVar(eax, new_target_var); | 3224 expr->expression()->AsSuperCallReference(); |
| 3208 __ push(eax); | 3225 DCHECK_NOT_NULL(super_call_ref); |
| 3209 | 3226 |
| 3210 EmitLoadSuperConstructor(); | 3227 VariableProxy* new_target_proxy = super_call_ref->new_target_var(); |
| 3228 VisitForStackValue(new_target_proxy); | |
| 3229 | |
| 3230 EmitLoadSuperConstructor(super_call_ref); | |
| 3211 __ push(result_register()); | 3231 __ push(result_register()); |
| 3212 | 3232 |
| 3213 // Push the arguments ("left-to-right") on the stack. | 3233 // Push the arguments ("left-to-right") on the stack. |
| 3214 ZoneList<Expression*>* args = expr->arguments(); | 3234 ZoneList<Expression*>* args = expr->arguments(); |
| 3215 int arg_count = args->length(); | 3235 int arg_count = args->length(); |
| 3216 for (int i = 0; i < arg_count; i++) { | 3236 for (int i = 0; i < arg_count; i++) { |
| 3217 VisitForStackValue(args->at(i)); | 3237 VisitForStackValue(args->at(i)); |
| 3218 } | 3238 } |
| 3219 | 3239 |
| 3220 // Call the construct call builtin that handles allocation and | 3240 // Call the construct call builtin that handles allocation and |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3238 __ LoadHeapObject(ebx, FeedbackVector()); | 3258 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3239 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); | 3259 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3240 | 3260 |
| 3241 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3261 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
| 3242 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3262 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3243 | 3263 |
| 3244 __ Drop(1); | 3264 __ Drop(1); |
| 3245 | 3265 |
| 3246 RecordJSReturnSite(expr); | 3266 RecordJSReturnSite(expr); |
| 3247 | 3267 |
| 3248 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference(), | 3268 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); |
| 3249 expr->CallFeedbackICSlot()); | |
| 3250 context()->Plug(eax); | 3269 context()->Plug(eax); |
| 3251 } | 3270 } |
| 3252 | 3271 |
| 3253 | 3272 |
| 3254 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3273 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 3255 ZoneList<Expression*>* args = expr->arguments(); | 3274 ZoneList<Expression*>* args = expr->arguments(); |
| 3256 DCHECK(args->length() == 1); | 3275 DCHECK(args->length() == 1); |
| 3257 | 3276 |
| 3258 VisitForAccumulatorValue(args->at(0)); | 3277 VisitForAccumulatorValue(args->at(0)); |
| 3259 | 3278 |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4116 __ bind(&runtime); | 4135 __ bind(&runtime); |
| 4117 __ push(eax); | 4136 __ push(eax); |
| 4118 __ CallRuntime(Runtime::kCall, args->length()); | 4137 __ CallRuntime(Runtime::kCall, args->length()); |
| 4119 __ bind(&done); | 4138 __ bind(&done); |
| 4120 | 4139 |
| 4121 context()->Plug(eax); | 4140 context()->Plug(eax); |
| 4122 } | 4141 } |
| 4123 | 4142 |
| 4124 | 4143 |
| 4125 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { | 4144 void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) { |
| 4126 Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); | 4145 ZoneList<Expression*>* args = expr->arguments(); |
| 4127 GetVar(eax, new_target_var); | 4146 DCHECK(args->length() == 2); |
| 4128 __ push(eax); | |
| 4129 | 4147 |
| 4130 EmitLoadSuperConstructor(); | 4148 // new.target |
| 4149 VisitForStackValue(args->at(0)); | |
| 4150 | |
| 4151 // .this_function | |
| 4152 VisitForStackValue(args->at(1)); | |
| 4153 __ CallRuntime(Runtime::kGetPrototype, 1); | |
| 4131 __ push(result_register()); | 4154 __ push(result_register()); |
| 4132 | 4155 |
| 4133 // Check if the calling frame is an arguments adaptor frame. | 4156 // Check if the calling frame is an arguments adaptor frame. |
| 4134 Label adaptor_frame, args_set_up, runtime; | 4157 Label adaptor_frame, args_set_up, runtime; |
| 4135 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 4158 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
| 4136 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); | 4159 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); |
| 4137 __ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 4160 __ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 4138 __ j(equal, &adaptor_frame); | 4161 __ j(equal, &adaptor_frame); |
| 4139 // default constructor has no arguments, so no adaptor frame means no args. | 4162 // default constructor has no arguments, so no adaptor frame means no args. |
| 4140 __ mov(eax, Immediate(0)); | 4163 __ mov(eax, Immediate(0)); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4543 ExternalReference debug_is_active = | 4566 ExternalReference debug_is_active = |
| 4544 ExternalReference::debug_is_active_address(isolate()); | 4567 ExternalReference::debug_is_active_address(isolate()); |
| 4545 __ movzx_b(eax, Operand::StaticVariable(debug_is_active)); | 4568 __ movzx_b(eax, Operand::StaticVariable(debug_is_active)); |
| 4546 __ SmiTag(eax); | 4569 __ SmiTag(eax); |
| 4547 context()->Plug(eax); | 4570 context()->Plug(eax); |
| 4548 } | 4571 } |
| 4549 | 4572 |
| 4550 | 4573 |
| 4551 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { | 4574 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
| 4552 // Assert: expr == CallRuntime("ReflectConstruct") | 4575 // Assert: expr == CallRuntime("ReflectConstruct") |
| 4553 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); | 4576 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
|
adamk
2015/05/29 19:14:45
Can you add an ASSERT for the length of expr->argu
| |
| 4554 ZoneList<Expression*>* args = call->arguments(); | 4577 ZoneList<Expression*>* args = call->arguments(); |
| 4555 DCHECK_EQ(3, args->length()); | 4578 DCHECK_EQ(3, args->length()); |
| 4556 | 4579 |
| 4557 SuperReference* super_reference = args->at(0)->AsSuperReference(); | 4580 SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference(); |
| 4581 DCHECK_NOT_NULL(super_call_ref); | |
| 4558 | 4582 |
| 4559 // Load ReflectConstruct function | 4583 // Load ReflectConstruct function |
| 4560 EmitLoadJSRuntimeFunction(call); | 4584 EmitLoadJSRuntimeFunction(call); |
| 4561 | 4585 |
| 4562 // Push the target function under the receiver | 4586 // Push the target function under the receiver |
| 4563 __ push(Operand(esp, 0)); | 4587 __ push(Operand(esp, 0)); |
| 4564 __ mov(Operand(esp, kPointerSize), eax); | 4588 __ mov(Operand(esp, kPointerSize), eax); |
| 4565 | 4589 |
| 4566 // Push super | 4590 // Push super constructor |
| 4567 EmitLoadSuperConstructor(); | 4591 EmitLoadSuperConstructor(super_call_ref); |
| 4568 __ Push(result_register()); | 4592 __ Push(result_register()); |
| 4569 | 4593 |
| 4570 // Push arguments array | 4594 // Push arguments array |
| 4571 VisitForStackValue(args->at(1)); | 4595 VisitForStackValue(args->at(1)); |
| 4572 | 4596 |
| 4573 // Push NewTarget | 4597 // Push NewTarget |
| 4574 DCHECK(args->at(2)->IsVariableProxy()); | 4598 DCHECK(args->at(2)->IsVariableProxy()); |
| 4575 VisitForStackValue(args->at(2)); | 4599 VisitForStackValue(args->at(2)); |
| 4576 | 4600 |
| 4577 EmitCallJSRuntimeFunction(call); | 4601 EmitCallJSRuntimeFunction(call); |
| 4578 | 4602 |
| 4579 // Restore context register. | 4603 // Restore context register. |
| 4580 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4604 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 4581 context()->DropAndPlug(1, eax); | 4605 context()->DropAndPlug(1, eax); |
| 4582 | 4606 |
| 4583 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. | 4607 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. |
| 4584 EmitInitializeThisAfterSuper(super_reference); | 4608 EmitInitializeThisAfterSuper(super_call_ref); |
| 4585 } | 4609 } |
| 4586 | 4610 |
| 4587 | 4611 |
| 4588 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4612 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
| 4589 // Push the builtins object as receiver. | 4613 // Push the builtins object as receiver. |
| 4590 __ mov(eax, GlobalObjectOperand()); | 4614 __ mov(eax, GlobalObjectOperand()); |
| 4591 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4615 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
| 4592 | 4616 |
| 4593 // Load the function from the receiver. | 4617 // Load the function from the receiver. |
| 4594 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4618 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4799 switch (assign_type) { | 4823 switch (assign_type) { |
| 4800 case NAMED_PROPERTY: { | 4824 case NAMED_PROPERTY: { |
| 4801 // Put the object both on the stack and in the register. | 4825 // Put the object both on the stack and in the register. |
| 4802 VisitForStackValue(prop->obj()); | 4826 VisitForStackValue(prop->obj()); |
| 4803 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4827 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
| 4804 EmitNamedPropertyLoad(prop); | 4828 EmitNamedPropertyLoad(prop); |
| 4805 break; | 4829 break; |
| 4806 } | 4830 } |
| 4807 | 4831 |
| 4808 case NAMED_SUPER_PROPERTY: { | 4832 case NAMED_SUPER_PROPERTY: { |
| 4809 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4833 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
| 4810 VisitForAccumulatorValue( | 4834 VisitForAccumulatorValue( |
| 4811 prop->obj()->AsSuperReference()->home_object_var()); | 4835 prop->obj()->AsSuperPropertyReference()->home_object_var()); |
| 4812 __ push(result_register()); | 4836 __ push(result_register()); |
| 4813 __ push(MemOperand(esp, kPointerSize)); | 4837 __ push(MemOperand(esp, kPointerSize)); |
| 4814 __ push(result_register()); | 4838 __ push(result_register()); |
| 4815 EmitNamedSuperPropertyLoad(prop); | 4839 EmitNamedSuperPropertyLoad(prop); |
| 4816 break; | 4840 break; |
| 4817 } | 4841 } |
| 4818 | 4842 |
| 4819 case KEYED_SUPER_PROPERTY: { | 4843 case KEYED_SUPER_PROPERTY: { |
| 4820 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); | 4844 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
| 4821 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); | 4845 VisitForStackValue( |
| 4846 prop->obj()->AsSuperPropertyReference()->home_object_var()); | |
| 4822 VisitForAccumulatorValue(prop->key()); | 4847 VisitForAccumulatorValue(prop->key()); |
| 4823 __ push(result_register()); | 4848 __ push(result_register()); |
| 4824 __ push(MemOperand(esp, 2 * kPointerSize)); | 4849 __ push(MemOperand(esp, 2 * kPointerSize)); |
| 4825 __ push(MemOperand(esp, 2 * kPointerSize)); | 4850 __ push(MemOperand(esp, 2 * kPointerSize)); |
| 4826 __ push(result_register()); | 4851 __ push(result_register()); |
| 4827 EmitKeyedSuperPropertyLoad(prop); | 4852 EmitKeyedSuperPropertyLoad(prop); |
| 4828 break; | 4853 break; |
| 4829 } | 4854 } |
| 4830 | 4855 |
| 4831 case KEYED_PROPERTY: { | 4856 case KEYED_PROPERTY: { |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5436 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5461 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5437 Assembler::target_address_at(call_target_address, | 5462 Assembler::target_address_at(call_target_address, |
| 5438 unoptimized_code)); | 5463 unoptimized_code)); |
| 5439 return OSR_AFTER_STACK_CHECK; | 5464 return OSR_AFTER_STACK_CHECK; |
| 5440 } | 5465 } |
| 5441 | 5466 |
| 5442 | 5467 |
| 5443 } } // namespace v8::internal | 5468 } } // namespace v8::internal |
| 5444 | 5469 |
| 5445 #endif // V8_TARGET_ARCH_IA32 | 5470 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |