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 2849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 __ push(Immediate(Smi::FromInt(strict_mode()))); | 2860 __ push(Immediate(Smi::FromInt(strict_mode()))); |
2861 | 2861 |
2862 // Push the start position of the scope the calls resides in. | 2862 // Push the start position of the scope the calls resides in. |
2863 __ push(Immediate(Smi::FromInt(scope()->start_position()))); | 2863 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
2864 | 2864 |
2865 // Do the runtime call. | 2865 // Do the runtime call. |
2866 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); | 2866 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); |
2867 } | 2867 } |
2868 | 2868 |
2869 | 2869 |
2870 void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* expr) { | |
2871 DCHECK(super_ref != NULL); | |
2872 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | |
2873 __ CallRuntime(Runtime::kGetPrototype, 1); | |
2874 } | |
2875 | |
2876 | |
2877 void FullCodeGenerator::VisitCall(Call* expr) { | 2870 void FullCodeGenerator::VisitCall(Call* expr) { |
2878 #ifdef DEBUG | 2871 #ifdef DEBUG |
2879 // We want to verify that RecordJSReturnSite gets called on all paths | 2872 // We want to verify that RecordJSReturnSite gets called on all paths |
2880 // through this function. Avoid early returns. | 2873 // through this function. Avoid early returns. |
2881 expr->return_is_recorded_ = false; | 2874 expr->return_is_recorded_ = false; |
2882 #endif | 2875 #endif |
2883 | 2876 |
2884 Comment cmnt(masm_, "[ Call"); | 2877 Comment cmnt(masm_, "[ Call"); |
2885 Expression* callee = expr->expression(); | 2878 Expression* callee = expr->expression(); |
2886 Call::CallType call_type = expr->GetCallType(isolate()); | 2879 Call::CallType call_type = expr->GetCallType(isolate()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2977 VisitForStackValue(property->obj()); | 2970 VisitForStackValue(property->obj()); |
2978 } | 2971 } |
2979 if (is_named_call) { | 2972 if (is_named_call) { |
2980 EmitCallWithLoadIC(expr); | 2973 EmitCallWithLoadIC(expr); |
2981 } else { | 2974 } else { |
2982 EmitKeyedCallWithLoadIC(expr, property->key()); | 2975 EmitKeyedCallWithLoadIC(expr, property->key()); |
2983 } | 2976 } |
2984 } | 2977 } |
2985 } else if (call_type == Call::SUPER_CALL) { | 2978 } else if (call_type == Call::SUPER_CALL) { |
2986 SuperReference* super_ref = callee->AsSuperReference(); | 2979 SuperReference* super_ref = callee->AsSuperReference(); |
2987 EmitLoadSuperConstructor(super_ref); | 2980 DCHECK(super_ref != NULL); |
| 2981 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2982 __ CallRuntime(Runtime::kGetPrototype, 1); |
2988 __ push(result_register()); | 2983 __ push(result_register()); |
2989 VisitForStackValue(super_ref->this_var()); | 2984 VisitForStackValue(super_ref->this_var()); |
2990 EmitCall(expr, CallICState::METHOD); | 2985 EmitCall(expr, CallICState::METHOD); |
2991 } else { | 2986 } else { |
2992 DCHECK(call_type == Call::OTHER_CALL); | 2987 DCHECK(call_type == Call::OTHER_CALL); |
2993 // Call to an arbitrary expression not handled specially above. | 2988 // Call to an arbitrary expression not handled specially above. |
2994 { PreservePositionScope scope(masm()->positions_recorder()); | 2989 { PreservePositionScope scope(masm()->positions_recorder()); |
2995 VisitForStackValue(callee); | 2990 VisitForStackValue(callee); |
2996 } | 2991 } |
2997 __ push(Immediate(isolate()->factory()->undefined_value())); | 2992 __ push(Immediate(isolate()->factory()->undefined_value())); |
(...skipping 10 matching lines...) Expand all Loading... |
3008 | 3003 |
3009 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3004 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3010 Comment cmnt(masm_, "[ CallNew"); | 3005 Comment cmnt(masm_, "[ CallNew"); |
3011 // According to ECMA-262, section 11.2.2, page 44, the function | 3006 // According to ECMA-262, section 11.2.2, page 44, the function |
3012 // expression in new calls must be evaluated before the | 3007 // expression in new calls must be evaluated before the |
3013 // arguments. | 3008 // arguments. |
3014 | 3009 |
3015 // Push constructor on the stack. If it's not a function it's used as | 3010 // Push constructor on the stack. If it's not a function it's used as |
3016 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3011 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
3017 // ignored. | 3012 // ignored. |
3018 if (expr->expression()->IsSuperReference()) { | 3013 VisitForStackValue(expr->expression()); |
3019 EmitLoadSuperConstructor(expr->expression()->AsSuperReference()); | |
3020 __ push(result_register()); | |
3021 } else { | |
3022 VisitForStackValue(expr->expression()); | |
3023 } | |
3024 | 3014 |
3025 // Push the arguments ("left-to-right") on the stack. | 3015 // Push the arguments ("left-to-right") on the stack. |
3026 ZoneList<Expression*>* args = expr->arguments(); | 3016 ZoneList<Expression*>* args = expr->arguments(); |
3027 int arg_count = args->length(); | 3017 int arg_count = args->length(); |
3028 for (int i = 0; i < arg_count; i++) { | 3018 for (int i = 0; i < arg_count; i++) { |
3029 VisitForStackValue(args->at(i)); | 3019 VisitForStackValue(args->at(i)); |
3030 } | 3020 } |
3031 | 3021 |
3032 // Call the construct call builtin that handles allocation and | 3022 // Call the construct call builtin that handles allocation and |
3033 // constructor invocation. | 3023 // constructor invocation. |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5156 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5146 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5157 Assembler::target_address_at(call_target_address, | 5147 Assembler::target_address_at(call_target_address, |
5158 unoptimized_code)); | 5148 unoptimized_code)); |
5159 return OSR_AFTER_STACK_CHECK; | 5149 return OSR_AFTER_STACK_CHECK; |
5160 } | 5150 } |
5161 | 5151 |
5162 | 5152 |
5163 } } // namespace v8::internal | 5153 } } // namespace v8::internal |
5164 | 5154 |
5165 #endif // V8_TARGET_ARCH_IA32 | 5155 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |