OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 518 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
519 Object** parameters = reinterpret_cast<Object**>(args[1]); | 519 Object** parameters = reinterpret_cast<Object**>(args[1]); |
520 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 520 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
521 return *NewStrictArguments(isolate, callee, parameters, argument_count); | 521 return *NewStrictArguments(isolate, callee, parameters, argument_count); |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 static Handle<JSArray> NewRestParam(Isolate* isolate, | 525 static Handle<JSArray> NewRestParam(Isolate* isolate, |
526 Object** parameters, | 526 Object** parameters, |
527 int num_params, | 527 int num_params, |
528 int rest_index) { | 528 int rest_index, |
| 529 LanguageMode language_mode) { |
529 parameters -= rest_index; | 530 parameters -= rest_index; |
530 int num_elements = std::max(0, num_params - rest_index); | 531 int num_elements = std::max(0, num_params - rest_index); |
531 Handle<FixedArray> elements = | 532 Handle<FixedArray> elements = |
532 isolate->factory()->NewUninitializedFixedArray(num_elements); | 533 isolate->factory()->NewUninitializedFixedArray(num_elements); |
533 for (int i = 0; i < num_elements; ++i) { | 534 for (int i = 0; i < num_elements; ++i) { |
534 elements->set(i, *--parameters); | 535 elements->set(i, *--parameters); |
535 } | 536 } |
536 return isolate->factory()->NewJSArrayWithElements(elements, FAST_ELEMENTS, | 537 return isolate->factory()->NewJSArrayWithElements(elements, FAST_ELEMENTS, |
537 num_elements); | 538 num_elements, |
| 539 strength(language_mode)); |
538 } | 540 } |
539 | 541 |
540 | 542 |
541 RUNTIME_FUNCTION(Runtime_NewRestParam) { | 543 RUNTIME_FUNCTION(Runtime_NewRestParam) { |
542 HandleScope scope(isolate); | 544 HandleScope scope(isolate); |
543 DCHECK(args.length() == 3); | 545 DCHECK(args.length() == 4); |
544 Object** parameters = reinterpret_cast<Object**>(args[0]); | 546 Object** parameters = reinterpret_cast<Object**>(args[0]); |
545 CONVERT_SMI_ARG_CHECKED(num_params, 1); | 547 CONVERT_SMI_ARG_CHECKED(num_params, 1); |
546 CONVERT_SMI_ARG_CHECKED(rest_index, 2); | 548 CONVERT_SMI_ARG_CHECKED(rest_index, 2); |
| 549 CONVERT_SMI_ARG_CHECKED(language_mode, 3); |
547 | 550 |
548 return *NewRestParam(isolate, parameters, num_params, rest_index); | 551 return *NewRestParam(isolate, parameters, num_params, rest_index, |
| 552 static_cast<LanguageMode>(language_mode)); |
549 } | 553 } |
550 | 554 |
551 | 555 |
552 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { | 556 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { |
553 HandleScope scope(isolate); | 557 HandleScope scope(isolate); |
554 DCHECK(args.length() == 1); | 558 DCHECK(args.length() == 2); |
555 CONVERT_SMI_ARG_CHECKED(rest_index, 0); | 559 CONVERT_SMI_ARG_CHECKED(rest_index, 0); |
| 560 CONVERT_SMI_ARG_CHECKED(language_mode, 1); |
556 | 561 |
557 JavaScriptFrameIterator it(isolate); | 562 JavaScriptFrameIterator it(isolate); |
558 | 563 |
559 // Find the frame that holds the actual arguments passed to the function. | 564 // Find the frame that holds the actual arguments passed to the function. |
560 it.AdvanceToArgumentsFrame(); | 565 it.AdvanceToArgumentsFrame(); |
561 JavaScriptFrame* frame = it.frame(); | 566 JavaScriptFrame* frame = it.frame(); |
562 | 567 |
563 int argument_count = frame->GetArgumentsLength(); | 568 int argument_count = frame->GetArgumentsLength(); |
564 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); | 569 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); |
565 | 570 |
566 return *NewRestParam(isolate, parameters, argument_count, rest_index); | 571 return *NewRestParam(isolate, parameters, argument_count, rest_index, |
| 572 static_cast<LanguageMode>(language_mode)); |
567 } | 573 } |
568 | 574 |
569 | 575 |
570 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 576 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
571 HandleScope scope(isolate); | 577 HandleScope scope(isolate); |
572 DCHECK(args.length() == 1); | 578 DCHECK(args.length() == 1); |
573 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 579 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
574 Handle<Context> context(isolate->context()); | 580 Handle<Context> context(isolate->context()); |
575 PretenureFlag pretenure_flag = NOT_TENURED; | 581 PretenureFlag pretenure_flag = NOT_TENURED; |
576 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 582 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 return Smi::FromInt(frame->GetArgumentsLength()); | 1136 return Smi::FromInt(frame->GetArgumentsLength()); |
1131 } | 1137 } |
1132 | 1138 |
1133 | 1139 |
1134 RUNTIME_FUNCTION(Runtime_Arguments) { | 1140 RUNTIME_FUNCTION(Runtime_Arguments) { |
1135 SealHandleScope shs(isolate); | 1141 SealHandleScope shs(isolate); |
1136 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1142 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
1137 } | 1143 } |
1138 } // namespace internal | 1144 } // namespace internal |
1139 } // namespace v8 | 1145 } // namespace v8 |
OLD | NEW |