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 2983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 2994 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
2995 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2995 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2996 __ CallStub(&stub); | 2996 __ CallStub(&stub); |
2997 RecordJSReturnSite(expr); | 2997 RecordJSReturnSite(expr); |
2998 // Restore context register. | 2998 // Restore context register. |
2999 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2999 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
3000 context()->DropAndPlug(1, eax); | 3000 context()->DropAndPlug(1, eax); |
3001 | 3001 |
3002 } else if (call_type == Call::GLOBAL_CALL) { | 3002 } else if (call_type == Call::GLOBAL_CALL) { |
3003 EmitCallWithLoadIC(expr); | 3003 EmitCallWithLoadIC(expr); |
3004 | |
3005 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 3004 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
3006 // Call to a lookup slot (dynamically introduced variable). | 3005 // Call to a lookup slot (dynamically introduced variable). |
3007 VariableProxy* proxy = callee->AsVariableProxy(); | 3006 VariableProxy* proxy = callee->AsVariableProxy(); |
3008 Label slow, done; | 3007 Label slow, done; |
3009 { PreservePositionScope scope(masm()->positions_recorder()); | 3008 { PreservePositionScope scope(masm()->positions_recorder()); |
3010 // Generate code for loading from variables potentially shadowed by | 3009 // Generate code for loading from variables potentially shadowed by |
3011 // eval-introduced variables. | 3010 // eval-introduced variables. |
3012 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | 3011 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
3013 } | 3012 } |
3014 __ bind(&slow); | 3013 __ bind(&slow); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 PreservePositionScope scope(masm()->positions_recorder()); | 3052 PreservePositionScope scope(masm()->positions_recorder()); |
3054 VisitForStackValue(property->obj()); | 3053 VisitForStackValue(property->obj()); |
3055 } | 3054 } |
3056 if (is_named_call) { | 3055 if (is_named_call) { |
3057 EmitCallWithLoadIC(expr); | 3056 EmitCallWithLoadIC(expr); |
3058 } else { | 3057 } else { |
3059 EmitKeyedCallWithLoadIC(expr, property->key()); | 3058 EmitKeyedCallWithLoadIC(expr, property->key()); |
3060 } | 3059 } |
3061 } | 3060 } |
3062 } else if (call_type == Call::SUPER_CALL) { | 3061 } else if (call_type == Call::SUPER_CALL) { |
3063 SuperReference* super_ref = callee->AsSuperReference(); | 3062 if (FLAG_experimental_classes) { |
3064 EmitLoadSuperConstructor(super_ref); | 3063 EmitSuperConstructorCall(expr); |
3065 __ push(result_register()); | 3064 } else { |
3066 VisitForStackValue(super_ref->this_var()); | 3065 SuperReference* super_ref = callee->AsSuperReference(); |
3067 EmitCall(expr, CallICState::METHOD); | 3066 EmitLoadSuperConstructor(super_ref); |
| 3067 __ push(result_register()); |
| 3068 VisitForStackValue(super_ref->this_var()); |
| 3069 EmitCall(expr, CallICState::METHOD); |
| 3070 } |
3068 } else { | 3071 } else { |
3069 DCHECK(call_type == Call::OTHER_CALL); | 3072 DCHECK(call_type == Call::OTHER_CALL); |
3070 // Call to an arbitrary expression not handled specially above. | 3073 // Call to an arbitrary expression not handled specially above. |
3071 { PreservePositionScope scope(masm()->positions_recorder()); | 3074 { PreservePositionScope scope(masm()->positions_recorder()); |
3072 VisitForStackValue(callee); | 3075 VisitForStackValue(callee); |
3073 } | 3076 } |
3074 __ push(Immediate(isolate()->factory()->undefined_value())); | 3077 __ push(Immediate(isolate()->factory()->undefined_value())); |
3075 // Emit function call. | 3078 // Emit function call. |
3076 EmitCall(expr); | 3079 EmitCall(expr); |
3077 } | 3080 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 __ LoadHeapObject(ebx, FeedbackVector()); | 3127 __ LoadHeapObject(ebx, FeedbackVector()); |
3125 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3128 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
3126 | 3129 |
3127 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3130 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
3128 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3131 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3129 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3132 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
3130 context()->Plug(eax); | 3133 context()->Plug(eax); |
3131 } | 3134 } |
3132 | 3135 |
3133 | 3136 |
| 3137 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3138 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| 3139 EmitLoadSuperConstructor(super_ref); |
| 3140 __ push(result_register()); |
| 3141 |
| 3142 // Push the arguments ("left-to-right") on the stack. |
| 3143 ZoneList<Expression*>* args = expr->arguments(); |
| 3144 int arg_count = args->length(); |
| 3145 for (int i = 0; i < arg_count; i++) { |
| 3146 VisitForStackValue(args->at(i)); |
| 3147 } |
| 3148 |
| 3149 // Call the construct call builtin that handles allocation and |
| 3150 // constructor invocation. |
| 3151 SetSourcePosition(expr->position()); |
| 3152 |
| 3153 // Load function and argument count into edi and eax. |
| 3154 __ Move(eax, Immediate(arg_count)); |
| 3155 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
| 3156 |
| 3157 // Record call targets in unoptimized code. |
| 3158 if (FLAG_pretenuring_call_new) { |
| 3159 UNREACHABLE(); |
| 3160 /* TODO[dslomov]: support pretenuring. |
| 3161 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3162 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3163 expr->CallNewFeedbackSlot().ToInt() + 1); |
| 3164 */ |
| 3165 } |
| 3166 |
| 3167 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3168 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3169 |
| 3170 // TODO(dslomov): use a different stub and propagate new.target. |
| 3171 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3172 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3173 |
| 3174 RecordJSReturnSite(expr); |
| 3175 |
| 3176 // TODO(dslomov): implement TDZ for `this`. |
| 3177 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); |
| 3178 context()->Plug(eax); |
| 3179 } |
| 3180 |
| 3181 |
3134 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3182 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3135 ZoneList<Expression*>* args = expr->arguments(); | 3183 ZoneList<Expression*>* args = expr->arguments(); |
3136 DCHECK(args->length() == 1); | 3184 DCHECK(args->length() == 1); |
3137 | 3185 |
3138 VisitForAccumulatorValue(args->at(0)); | 3186 VisitForAccumulatorValue(args->at(0)); |
3139 | 3187 |
3140 Label materialize_true, materialize_false; | 3188 Label materialize_true, materialize_false; |
3141 Label* if_true = NULL; | 3189 Label* if_true = NULL; |
3142 Label* if_false = NULL; | 3190 Label* if_false = NULL; |
3143 Label* fall_through = NULL; | 3191 Label* fall_through = NULL; |
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5234 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5282 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5235 Assembler::target_address_at(call_target_address, | 5283 Assembler::target_address_at(call_target_address, |
5236 unoptimized_code)); | 5284 unoptimized_code)); |
5237 return OSR_AFTER_STACK_CHECK; | 5285 return OSR_AFTER_STACK_CHECK; |
5238 } | 5286 } |
5239 | 5287 |
5240 | 5288 |
5241 } } // namespace v8::internal | 5289 } } // namespace v8::internal |
5242 | 5290 |
5243 #endif // V8_TARGET_ARCH_IA32 | 5291 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |