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_X64 | 7 #if V8_TARGET_ARCH_X64 |
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(Smi::FromInt(strict_mode())); | 2860 __ Push(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(Smi::FromInt(scope()->start_position())); | 2863 __ Push(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(rbp, 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 VisitForStackValue(property->obj()); | 2976 VisitForStackValue(property->obj()); |
2970 } | 2977 } |
2971 if (is_named_call) { | 2978 if (is_named_call) { |
2972 EmitCallWithLoadIC(expr); | 2979 EmitCallWithLoadIC(expr); |
2973 } else { | 2980 } else { |
2974 EmitKeyedCallWithLoadIC(expr, property->key()); | 2981 EmitKeyedCallWithLoadIC(expr, property->key()); |
2975 } | 2982 } |
2976 } | 2983 } |
2977 } else if (call_type == Call::SUPER_CALL) { | 2984 } else if (call_type == Call::SUPER_CALL) { |
2978 SuperReference* super_ref = callee->AsSuperReference(); | 2985 SuperReference* super_ref = callee->AsSuperReference(); |
2979 DCHECK(super_ref != NULL); | 2986 EmitLoadSuperConstructor(super_ref); |
2980 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
2981 __ CallRuntime(Runtime::kGetPrototype, 1); | |
2982 __ Push(result_register()); | 2987 __ Push(result_register()); |
2983 VisitForStackValue(super_ref->this_var()); | 2988 VisitForStackValue(super_ref->this_var()); |
2984 EmitCall(expr, CallICState::METHOD); | 2989 EmitCall(expr, CallICState::METHOD); |
2985 } else { | 2990 } else { |
2986 DCHECK(call_type == Call::OTHER_CALL); | 2991 DCHECK(call_type == Call::OTHER_CALL); |
2987 // Call to an arbitrary expression not handled specially above. | 2992 // Call to an arbitrary expression not handled specially above. |
2988 { PreservePositionScope scope(masm()->positions_recorder()); | 2993 { PreservePositionScope scope(masm()->positions_recorder()); |
2989 VisitForStackValue(callee); | 2994 VisitForStackValue(callee); |
2990 } | 2995 } |
2991 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2996 __ PushRoot(Heap::kUndefinedValueRootIndex); |
(...skipping 10 matching lines...) Expand all Loading... |
3002 | 3007 |
3003 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 3008 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
3004 Comment cmnt(masm_, "[ CallNew"); | 3009 Comment cmnt(masm_, "[ CallNew"); |
3005 // According to ECMA-262, section 11.2.2, page 44, the function | 3010 // According to ECMA-262, section 11.2.2, page 44, the function |
3006 // expression in new calls must be evaluated before the | 3011 // expression in new calls must be evaluated before the |
3007 // arguments. | 3012 // arguments. |
3008 | 3013 |
3009 // Push constructor on the stack. If it's not a function it's used as | 3014 // Push constructor on the stack. If it's not a function it's used as |
3010 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is | 3015 // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
3011 // ignored. | 3016 // ignored. |
3012 VisitForStackValue(expr->expression()); | 3017 if (expr->expression()->IsSuperReference()) { |
| 3018 EmitLoadSuperConstructor(expr->expression()->AsSuperReference()); |
| 3019 __ Push(result_register()); |
| 3020 } else { |
| 3021 VisitForStackValue(expr->expression()); |
| 3022 } |
3013 | 3023 |
3014 // Push the arguments ("left-to-right") on the stack. | 3024 // Push the arguments ("left-to-right") on the stack. |
3015 ZoneList<Expression*>* args = expr->arguments(); | 3025 ZoneList<Expression*>* args = expr->arguments(); |
3016 int arg_count = args->length(); | 3026 int arg_count = args->length(); |
3017 for (int i = 0; i < arg_count; i++) { | 3027 for (int i = 0; i < arg_count; i++) { |
3018 VisitForStackValue(args->at(i)); | 3028 VisitForStackValue(args->at(i)); |
3019 } | 3029 } |
3020 | 3030 |
3021 // Call the construct call builtin that handles allocation and | 3031 // Call the construct call builtin that handles allocation and |
3022 // constructor invocation. | 3032 // constructor invocation. |
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5161 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5171 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5162 Assembler::target_address_at(call_target_address, | 5172 Assembler::target_address_at(call_target_address, |
5163 unoptimized_code)); | 5173 unoptimized_code)); |
5164 return OSR_AFTER_STACK_CHECK; | 5174 return OSR_AFTER_STACK_CHECK; |
5165 } | 5175 } |
5166 | 5176 |
5167 | 5177 |
5168 } } // namespace v8::internal | 5178 } } // namespace v8::internal |
5169 | 5179 |
5170 #endif // V8_TARGET_ARCH_X64 | 5180 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |