Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

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

Powered by Google App Engine
This is Rietveld 408576698