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