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

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

Issue 1168513004: [es6] Super call in arrows and eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Push this_function earlier 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 Variable* home_object_var = scope()->home_object_var(); 241 Variable* home_object_var = scope()->home_object_var();
242 if (home_object_var != nullptr) { 242 if (home_object_var != nullptr) {
243 __ push(edi); 243 __ push(edi);
244 } 244 }
245 245
246 // Possibly set up a local binding to the this function which is used in
247 // derived constructors with super calls.
248 Variable* this_function_var = scope()->this_function_var();
249 if (this_function_var != nullptr) {
250 Comment cmnt(masm_, "[ This function");
251 SetVar(this_function_var, edi, ebx, edx);
252 }
253
254 Variable* new_target_var = scope()->new_target_var();
255 if (new_target_var != nullptr) {
256 Comment cmnt(masm_, "[ new.target");
257 // new.target is parameter -2.
258 int offset = 2 * kPointerSize + kFPOnStackSize + kPCOnStackSize +
259 (info_->scope()->num_parameters() - 1) * kPointerSize;
260 __ mov(eax, Operand(ebp, offset));
261 SetVar(new_target_var, eax, ebx, edx);
262 }
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
251 // Possibly allocate RestParameters 269 // Possibly allocate RestParameters
252 int rest_index; 270 int rest_index;
253 Variable* rest_param = scope()->rest_parameter(&rest_index); 271 Variable* rest_param = scope()->rest_parameter(&rest_index);
254 if (rest_param) { 272 if (rest_param) {
255 Comment cmnt(masm_, "[ Allocate rest parameter array"); 273 Comment cmnt(masm_, "[ Allocate rest parameter array");
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
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
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
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
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
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
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
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")
4576 DCHECK_EQ(1, expr->arguments()->length());
4553 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); 4577 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime();
4578
4554 ZoneList<Expression*>* args = call->arguments(); 4579 ZoneList<Expression*>* args = call->arguments();
4555 DCHECK_EQ(3, args->length()); 4580 DCHECK_EQ(3, args->length());
4556 4581
4557 SuperReference* super_reference = args->at(0)->AsSuperReference(); 4582 SuperCallReference* super_call_ref = args->at(0)->AsSuperCallReference();
4583 DCHECK_NOT_NULL(super_call_ref);
4558 4584
4559 // Load ReflectConstruct function 4585 // Load ReflectConstruct function
4560 EmitLoadJSRuntimeFunction(call); 4586 EmitLoadJSRuntimeFunction(call);
4561 4587
4562 // Push the target function under the receiver 4588 // Push the target function under the receiver
4563 __ push(Operand(esp, 0)); 4589 __ push(Operand(esp, 0));
4564 __ mov(Operand(esp, kPointerSize), eax); 4590 __ mov(Operand(esp, kPointerSize), eax);
4565 4591
4566 // Push super 4592 // Push super constructor
4567 EmitLoadSuperConstructor(); 4593 EmitLoadSuperConstructor(super_call_ref);
4568 __ Push(result_register()); 4594 __ Push(result_register());
4569 4595
4570 // Push arguments array 4596 // Push arguments array
4571 VisitForStackValue(args->at(1)); 4597 VisitForStackValue(args->at(1));
4572 4598
4573 // Push NewTarget 4599 // Push NewTarget
4574 DCHECK(args->at(2)->IsVariableProxy()); 4600 DCHECK(args->at(2)->IsVariableProxy());
4575 VisitForStackValue(args->at(2)); 4601 VisitForStackValue(args->at(2));
4576 4602
4577 EmitCallJSRuntimeFunction(call); 4603 EmitCallJSRuntimeFunction(call);
4578 4604
4579 // Restore context register. 4605 // Restore context register.
4580 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4606 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4581 context()->DropAndPlug(1, eax); 4607 context()->DropAndPlug(1, eax);
4582 4608
4583 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. 4609 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id.
4584 EmitInitializeThisAfterSuper(super_reference); 4610 EmitInitializeThisAfterSuper(super_call_ref);
4585 } 4611 }
4586 4612
4587 4613
4588 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { 4614 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
4589 // Push the builtins object as receiver. 4615 // Push the builtins object as receiver.
4590 __ mov(eax, GlobalObjectOperand()); 4616 __ mov(eax, GlobalObjectOperand());
4591 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); 4617 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
4592 4618
4593 // Load the function from the receiver. 4619 // Load the function from the receiver.
4594 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 4620 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4799 switch (assign_type) { 4825 switch (assign_type) {
4800 case NAMED_PROPERTY: { 4826 case NAMED_PROPERTY: {
4801 // Put the object both on the stack and in the register. 4827 // Put the object both on the stack and in the register.
4802 VisitForStackValue(prop->obj()); 4828 VisitForStackValue(prop->obj());
4803 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 4829 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
4804 EmitNamedPropertyLoad(prop); 4830 EmitNamedPropertyLoad(prop);
4805 break; 4831 break;
4806 } 4832 }
4807 4833
4808 case NAMED_SUPER_PROPERTY: { 4834 case NAMED_SUPER_PROPERTY: {
4809 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4835 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
4810 VisitForAccumulatorValue( 4836 VisitForAccumulatorValue(
4811 prop->obj()->AsSuperReference()->home_object_var()); 4837 prop->obj()->AsSuperPropertyReference()->home_object_var());
4812 __ push(result_register()); 4838 __ push(result_register());
4813 __ push(MemOperand(esp, kPointerSize)); 4839 __ push(MemOperand(esp, kPointerSize));
4814 __ push(result_register()); 4840 __ push(result_register());
4815 EmitNamedSuperPropertyLoad(prop); 4841 EmitNamedSuperPropertyLoad(prop);
4816 break; 4842 break;
4817 } 4843 }
4818 4844
4819 case KEYED_SUPER_PROPERTY: { 4845 case KEYED_SUPER_PROPERTY: {
4820 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4846 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
4821 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); 4847 VisitForStackValue(
4848 prop->obj()->AsSuperPropertyReference()->home_object_var());
4822 VisitForAccumulatorValue(prop->key()); 4849 VisitForAccumulatorValue(prop->key());
4823 __ push(result_register()); 4850 __ push(result_register());
4824 __ push(MemOperand(esp, 2 * kPointerSize)); 4851 __ push(MemOperand(esp, 2 * kPointerSize));
4825 __ push(MemOperand(esp, 2 * kPointerSize)); 4852 __ push(MemOperand(esp, 2 * kPointerSize));
4826 __ push(result_register()); 4853 __ push(result_register());
4827 EmitKeyedSuperPropertyLoad(prop); 4854 EmitKeyedSuperPropertyLoad(prop);
4828 break; 4855 break;
4829 } 4856 }
4830 4857
4831 case KEYED_PROPERTY: { 4858 case KEYED_PROPERTY: {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
5436 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5463 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5437 Assembler::target_address_at(call_target_address, 5464 Assembler::target_address_at(call_target_address,
5438 unoptimized_code)); 5465 unoptimized_code));
5439 return OSR_AFTER_STACK_CHECK; 5466 return OSR_AFTER_STACK_CHECK;
5440 } 5467 }
5441 5468
5442 5469
5443 } } // namespace v8::internal 5470 } } // namespace v8::internal
5444 5471
5445 #endif // V8_TARGET_ARCH_IA32 5472 #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