| 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 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 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2984 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 2984 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 2985 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2985 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
| 2986 __ CallStub(&stub); | 2986 __ CallStub(&stub); |
| 2987 RecordJSReturnSite(expr); | 2987 RecordJSReturnSite(expr); |
| 2988 // Restore context register. | 2988 // Restore context register. |
| 2989 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2989 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2990 context()->DropAndPlug(1, eax); | 2990 context()->DropAndPlug(1, eax); |
| 2991 | 2991 |
| 2992 } else if (call_type == Call::GLOBAL_CALL) { | 2992 } else if (call_type == Call::GLOBAL_CALL) { |
| 2993 EmitCallWithLoadIC(expr); | 2993 EmitCallWithLoadIC(expr); |
| 2994 | |
| 2995 } else if (call_type == Call::LOOKUP_SLOT_CALL) { | 2994 } else if (call_type == Call::LOOKUP_SLOT_CALL) { |
| 2996 // Call to a lookup slot (dynamically introduced variable). | 2995 // Call to a lookup slot (dynamically introduced variable). |
| 2997 VariableProxy* proxy = callee->AsVariableProxy(); | 2996 VariableProxy* proxy = callee->AsVariableProxy(); |
| 2998 Label slow, done; | 2997 Label slow, done; |
| 2999 { PreservePositionScope scope(masm()->positions_recorder()); | 2998 { PreservePositionScope scope(masm()->positions_recorder()); |
| 3000 // Generate code for loading from variables potentially shadowed by | 2999 // Generate code for loading from variables potentially shadowed by |
| 3001 // eval-introduced variables. | 3000 // eval-introduced variables. |
| 3002 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); | 3001 EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
| 3003 } | 3002 } |
| 3004 __ bind(&slow); | 3003 __ bind(&slow); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 PreservePositionScope scope(masm()->positions_recorder()); | 3042 PreservePositionScope scope(masm()->positions_recorder()); |
| 3044 VisitForStackValue(property->obj()); | 3043 VisitForStackValue(property->obj()); |
| 3045 } | 3044 } |
| 3046 if (is_named_call) { | 3045 if (is_named_call) { |
| 3047 EmitCallWithLoadIC(expr); | 3046 EmitCallWithLoadIC(expr); |
| 3048 } else { | 3047 } else { |
| 3049 EmitKeyedCallWithLoadIC(expr, property->key()); | 3048 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 3050 } | 3049 } |
| 3051 } | 3050 } |
| 3052 } else if (call_type == Call::SUPER_CALL) { | 3051 } else if (call_type == Call::SUPER_CALL) { |
| 3053 SuperReference* super_ref = callee->AsSuperReference(); | 3052 if (FLAG_experimental_classes) { |
| 3054 EmitLoadSuperConstructor(super_ref); | 3053 EmitSuperConstructorCall(expr); |
| 3055 __ push(result_register()); | 3054 } else { |
| 3056 VisitForStackValue(super_ref->this_var()); | 3055 SuperReference* super_ref = callee->AsSuperReference(); |
| 3057 EmitCall(expr, CallICState::METHOD); | 3056 EmitLoadSuperConstructor(super_ref); |
| 3057 __ push(result_register()); |
| 3058 VisitForStackValue(super_ref->this_var()); |
| 3059 EmitCall(expr, CallICState::METHOD); |
| 3060 } |
| 3058 } else { | 3061 } else { |
| 3059 DCHECK(call_type == Call::OTHER_CALL); | 3062 DCHECK(call_type == Call::OTHER_CALL); |
| 3060 // Call to an arbitrary expression not handled specially above. | 3063 // Call to an arbitrary expression not handled specially above. |
| 3061 { PreservePositionScope scope(masm()->positions_recorder()); | 3064 { PreservePositionScope scope(masm()->positions_recorder()); |
| 3062 VisitForStackValue(callee); | 3065 VisitForStackValue(callee); |
| 3063 } | 3066 } |
| 3064 __ push(Immediate(isolate()->factory()->undefined_value())); | 3067 __ push(Immediate(isolate()->factory()->undefined_value())); |
| 3065 // Emit function call. | 3068 // Emit function call. |
| 3066 EmitCall(expr); | 3069 EmitCall(expr); |
| 3067 } | 3070 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3114 __ LoadHeapObject(ebx, FeedbackVector()); | 3117 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3115 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); | 3118 __ mov(edx, Immediate(SmiFromSlot(expr->CallNewFeedbackSlot()))); |
| 3116 | 3119 |
| 3117 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); | 3120 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3118 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3121 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3119 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 3122 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 3120 context()->Plug(eax); | 3123 context()->Plug(eax); |
| 3121 } | 3124 } |
| 3122 | 3125 |
| 3123 | 3126 |
| 3127 void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
| 3128 SuperReference* super_ref = expr->expression()->AsSuperReference(); |
| 3129 EmitLoadSuperConstructor(super_ref); |
| 3130 __ push(result_register()); |
| 3131 |
| 3132 // Push the arguments ("left-to-right") on the stack. |
| 3133 ZoneList<Expression*>* args = expr->arguments(); |
| 3134 int arg_count = args->length(); |
| 3135 for (int i = 0; i < arg_count; i++) { |
| 3136 VisitForStackValue(args->at(i)); |
| 3137 } |
| 3138 |
| 3139 // Call the construct call builtin that handles allocation and |
| 3140 // constructor invocation. |
| 3141 SetSourcePosition(expr->position()); |
| 3142 |
| 3143 // Load function and argument count into edi and eax. |
| 3144 __ Move(eax, Immediate(arg_count)); |
| 3145 __ mov(edi, Operand(esp, arg_count * kPointerSize)); |
| 3146 |
| 3147 // Record call targets in unoptimized code. |
| 3148 if (FLAG_pretenuring_call_new) { |
| 3149 UNREACHABLE(); |
| 3150 /* TODO(dslomov): support pretenuring. |
| 3151 EnsureSlotContainsAllocationSite(expr->AllocationSiteFeedbackSlot()); |
| 3152 DCHECK(expr->AllocationSiteFeedbackSlot().ToInt() == |
| 3153 expr->CallNewFeedbackSlot().ToInt() + 1); |
| 3154 */ |
| 3155 } |
| 3156 |
| 3157 __ LoadHeapObject(ebx, FeedbackVector()); |
| 3158 __ mov(edx, Immediate(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3159 |
| 3160 // TODO(dslomov): use a different stub and propagate new.target. |
| 3161 CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); |
| 3162 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3163 |
| 3164 RecordJSReturnSite(expr); |
| 3165 |
| 3166 // TODO(dslomov): implement TDZ for `this`. |
| 3167 EmitVariableAssignment(super_ref->this_var()->var(), Token::ASSIGN); |
| 3168 context()->Plug(eax); |
| 3169 } |
| 3170 |
| 3171 |
| 3124 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3172 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 3125 ZoneList<Expression*>* args = expr->arguments(); | 3173 ZoneList<Expression*>* args = expr->arguments(); |
| 3126 DCHECK(args->length() == 1); | 3174 DCHECK(args->length() == 1); |
| 3127 | 3175 |
| 3128 VisitForAccumulatorValue(args->at(0)); | 3176 VisitForAccumulatorValue(args->at(0)); |
| 3129 | 3177 |
| 3130 Label materialize_true, materialize_false; | 3178 Label materialize_true, materialize_false; |
| 3131 Label* if_true = NULL; | 3179 Label* if_true = NULL; |
| 3132 Label* if_false = NULL; | 3180 Label* if_false = NULL; |
| 3133 Label* fall_through = NULL; | 3181 Label* fall_through = NULL; |
| (...skipping 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5223 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5271 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5224 Assembler::target_address_at(call_target_address, | 5272 Assembler::target_address_at(call_target_address, |
| 5225 unoptimized_code)); | 5273 unoptimized_code)); |
| 5226 return OSR_AFTER_STACK_CHECK; | 5274 return OSR_AFTER_STACK_CHECK; |
| 5227 } | 5275 } |
| 5228 | 5276 |
| 5229 | 5277 |
| 5230 } } // namespace v8::internal | 5278 } } // namespace v8::internal |
| 5231 | 5279 |
| 5232 #endif // V8_TARGET_ARCH_X87 | 5280 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |