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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } else if (FLAG_debug_code) { | 225 } else if (FLAG_debug_code) { |
226 Label done; | 226 Label done; |
227 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); | 227 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); |
228 __ Abort(kExpectedNewSpaceObject); | 228 __ Abort(kExpectedNewSpaceObject); |
229 __ bind(&done); | 229 __ bind(&done); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
| 235 // Possibly allocate RestParameters |
| 236 int rest_index; |
| 237 Variable* rest_param = scope()->rest_parameter(&rest_index); |
| 238 if (rest_param) { |
| 239 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
| 240 |
| 241 int num_parameters = info->scope()->num_parameters(); |
| 242 int offset = num_parameters * kPointerSize; |
| 243 __ leap(rdx, |
| 244 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); |
| 245 __ Push(rdx); |
| 246 __ Push(Smi::FromInt(num_parameters)); |
| 247 __ Push(Smi::FromInt(rest_index)); |
| 248 |
| 249 RestParamAccessStub stub(isolate()); |
| 250 __ CallStub(&stub); |
| 251 |
| 252 SetVar(rest_param, rax, rbx, rdx); |
| 253 } |
| 254 |
235 // Possibly allocate an arguments object. | 255 // Possibly allocate an arguments object. |
236 Variable* arguments = scope()->arguments(); | 256 Variable* arguments = scope()->arguments(); |
237 if (arguments != NULL) { | 257 if (arguments != NULL) { |
238 // Arguments object must be allocated after the context object, in | 258 // Arguments object must be allocated after the context object, in |
239 // case the "arguments" or ".arguments" variables are in the context. | 259 // case the "arguments" or ".arguments" variables are in the context. |
240 Comment cmnt(masm_, "[ Allocate arguments object"); | 260 Comment cmnt(masm_, "[ Allocate arguments object"); |
241 if (function_in_register) { | 261 if (function_in_register) { |
242 __ Push(rdi); | 262 __ Push(rdi); |
243 } else { | 263 } else { |
244 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 264 __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
245 } | 265 } |
246 // The receiver is just before the parameters on the caller's stack. | 266 // The receiver is just before the parameters on the caller's stack. |
247 int num_parameters = info->scope()->num_parameters(); | 267 int num_parameters = info->scope()->num_parameters(); |
248 int offset = num_parameters * kPointerSize; | 268 int offset = num_parameters * kPointerSize; |
249 __ leap(rdx, | 269 __ leap(rdx, |
250 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); | 270 Operand(rbp, StandardFrameConstants::kCallerSPOffset + offset)); |
251 __ Push(rdx); | 271 __ Push(rdx); |
252 __ Push(Smi::FromInt(num_parameters)); | 272 __ Push(Smi::FromInt(num_parameters)); |
253 // Arguments to ArgumentsAccessStub: | 273 // Arguments to ArgumentsAccessStub: |
254 // function, receiver address, parameter count. | 274 // function, receiver address, parameter count. |
255 // The stub will rewrite receiver and parameter count if the previous | 275 // The stub will rewrite receiver and parameter count if the previous |
256 // stack frame was an arguments adapter frame. | 276 // stack frame was an arguments adapter frame. |
257 | 277 |
258 ArgumentsAccessStub::HasNewTarget has_new_target = | 278 ArgumentsAccessStub::HasNewTarget has_new_target = |
259 IsSubclassConstructor(info->function()->kind()) | 279 IsSubclassConstructor(info->function()->kind()) |
260 ? ArgumentsAccessStub::HAS_NEW_TARGET | 280 ? ArgumentsAccessStub::HAS_NEW_TARGET |
261 : ArgumentsAccessStub::NO_NEW_TARGET; | 281 : ArgumentsAccessStub::NO_NEW_TARGET; |
262 ArgumentsAccessStub::Type type; | 282 ArgumentsAccessStub::Type type; |
263 if (is_strict(language_mode())) { | 283 if (is_strict(language_mode()) || !is_simple_parameter_list()) { |
264 type = ArgumentsAccessStub::NEW_STRICT; | 284 type = ArgumentsAccessStub::NEW_STRICT; |
265 } else if (function()->has_duplicate_parameters()) { | 285 } else if (function()->has_duplicate_parameters()) { |
266 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; | 286 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
267 } else { | 287 } else { |
268 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; | 288 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; |
269 } | 289 } |
270 ArgumentsAccessStub stub(isolate(), type, has_new_target); | 290 ArgumentsAccessStub stub(isolate(), type, has_new_target); |
271 __ CallStub(&stub); | 291 __ CallStub(&stub); |
272 | 292 |
273 SetVar(arguments, rax, rbx, rdx); | 293 SetVar(arguments, rax, rbx, rdx); |
(...skipping 5092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5366 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5386 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5367 Assembler::target_address_at(call_target_address, | 5387 Assembler::target_address_at(call_target_address, |
5368 unoptimized_code)); | 5388 unoptimized_code)); |
5369 return OSR_AFTER_STACK_CHECK; | 5389 return OSR_AFTER_STACK_CHECK; |
5370 } | 5390 } |
5371 | 5391 |
5372 | 5392 |
5373 } } // namespace v8::internal | 5393 } } // namespace v8::internal |
5374 | 5394 |
5375 #endif // V8_TARGET_ARCH_X64 | 5395 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |