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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (strlen(FLAG_stop_at) > 0 && | 108 if (strlen(FLAG_stop_at) > 0 && |
109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
110 __ int3(); | 110 __ int3(); |
111 } | 111 } |
112 #endif | 112 #endif |
113 | 113 |
114 // Sloppy mode functions and builtins need to replace the receiver with the | 114 // Sloppy mode functions and builtins need to replace the receiver with the |
115 // global proxy when called as functions (without an explicit receiver | 115 // global proxy when called as functions (without an explicit receiver |
116 // object). | 116 // object). |
117 if (is_sloppy(info->language_mode()) && !info->is_native() && | 117 if (is_sloppy(info->language_mode()) && !info->is_native() && |
118 info->MayUseThis() && info->scope()->has_this_declaration()) { | 118 info->MayUseThis()) { |
119 Label ok; | 119 Label ok; |
120 // +1 for return address. | 120 // +1 for return address. |
121 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); | 121 StackArgumentsAccessor args(rsp, info->scope()->num_parameters()); |
122 __ movp(rcx, args.GetReceiverOperand()); | 122 __ movp(rcx, args.GetReceiverOperand()); |
123 | 123 |
124 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); | 124 __ CompareRoot(rcx, Heap::kUndefinedValueRootIndex); |
125 __ j(not_equal, &ok, Label::kNear); | 125 __ j(not_equal, &ok, Label::kNear); |
126 | 126 |
127 __ movp(rcx, GlobalObjectOperand()); | 127 __ movp(rcx, GlobalObjectOperand()); |
128 __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset)); | 128 __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 202 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
203 } | 203 } |
204 function_in_register = false; | 204 function_in_register = false; |
205 // Context is returned in rax. It replaces the context passed to us. | 205 // Context is returned in rax. It replaces the context passed to us. |
206 // It's saved in the stack and kept live in rsi. | 206 // It's saved in the stack and kept live in rsi. |
207 __ movp(rsi, rax); | 207 __ movp(rsi, rax); |
208 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); | 208 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); |
209 | 209 |
210 // Copy any necessary parameters into the context. | 210 // Copy any necessary parameters into the context. |
211 int num_parameters = info->scope()->num_parameters(); | 211 int num_parameters = info->scope()->num_parameters(); |
212 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 212 for (int i = 0; i < num_parameters; i++) { |
213 for (int i = first_parameter; i < num_parameters; i++) { | 213 Variable* var = scope()->parameter(i); |
214 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | |
215 if (var->IsContextSlot()) { | 214 if (var->IsContextSlot()) { |
216 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 215 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
217 (num_parameters - 1 - i) * kPointerSize; | 216 (num_parameters - 1 - i) * kPointerSize; |
218 // Load parameter from stack. | 217 // Load parameter from stack. |
219 __ movp(rax, Operand(rbp, parameter_offset)); | 218 __ movp(rax, Operand(rbp, parameter_offset)); |
220 // Store it in the context. | 219 // Store it in the context. |
221 int context_offset = Context::SlotOffset(var->index()); | 220 int context_offset = Context::SlotOffset(var->index()); |
222 __ movp(Operand(rsi, context_offset), rax); | 221 __ movp(Operand(rsi, context_offset), rax); |
223 // Update the write barrier. This clobbers rax and rbx. | 222 // Update the write barrier. This clobbers rax and rbx. |
224 if (need_write_barrier) { | 223 if (need_write_barrier) { |
(...skipping 2730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 if (arg_count > 0) { | 2954 if (arg_count > 0) { |
2956 __ Push(Operand(rsp, arg_count * kPointerSize)); | 2955 __ Push(Operand(rsp, arg_count * kPointerSize)); |
2957 } else { | 2956 } else { |
2958 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2957 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2959 } | 2958 } |
2960 | 2959 |
2961 // Push the enclosing function. | 2960 // Push the enclosing function. |
2962 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 2961 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
2963 | 2962 |
2964 // Push the receiver of the enclosing function and do runtime call. | 2963 // Push the receiver of the enclosing function and do runtime call. |
2965 Variable* this_var = scope()->LookupThis(); | 2964 StackArgumentsAccessor args(rbp, info_->scope()->num_parameters()); |
2966 DCHECK_NOT_NULL(this_var); | 2965 __ Push(args.GetReceiverOperand()); |
2967 __ Push(VarOperand(this_var, rcx)); | |
2968 | 2966 |
2969 // Push the language mode. | 2967 // Push the language mode. |
2970 __ Push(Smi::FromInt(language_mode())); | 2968 __ Push(Smi::FromInt(language_mode())); |
2971 | 2969 |
2972 // Push the start position of the scope the calls resides in. | 2970 // Push the start position of the scope the calls resides in. |
2973 __ Push(Smi::FromInt(scope()->start_position())); | 2971 __ Push(Smi::FromInt(scope()->start_position())); |
2974 | 2972 |
2975 // Do the runtime call. | 2973 // Do the runtime call. |
2976 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 2974 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); |
2977 } | 2975 } |
(...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5396 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5394 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5397 Assembler::target_address_at(call_target_address, | 5395 Assembler::target_address_at(call_target_address, |
5398 unoptimized_code)); | 5396 unoptimized_code)); |
5399 return OSR_AFTER_STACK_CHECK; | 5397 return OSR_AFTER_STACK_CHECK; |
5400 } | 5398 } |
5401 | 5399 |
5402 | 5400 |
5403 } } // namespace v8::internal | 5401 } } // namespace v8::internal |
5404 | 5402 |
5405 #endif // V8_TARGET_ARCH_X64 | 5403 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |