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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { | 519 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
520 HandleScope scope(isolate); | 520 HandleScope scope(isolate); |
521 DCHECK(args.length() == 3); | 521 DCHECK(args.length() == 3); |
522 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 522 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
523 Object** parameters = reinterpret_cast<Object**>(args[1]); | 523 Object** parameters = reinterpret_cast<Object**>(args[1]); |
524 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 524 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
525 return *NewStrictArguments(isolate, callee, parameters, argument_count); | 525 return *NewStrictArguments(isolate, callee, parameters, argument_count); |
526 } | 526 } |
527 | 527 |
528 | 528 |
529 static Handle<JSArray> NewRestParam(Isolate* isolate, Object** parameters, | |
530 int num_params, int rest_index, | |
531 LanguageMode language_mode) { | |
532 parameters -= rest_index; | |
533 int num_elements = std::max(0, num_params - rest_index); | |
534 Handle<FixedArray> elements = | |
535 isolate->factory()->NewUninitializedFixedArray(num_elements); | |
536 for (int i = 0; i < num_elements; ++i) { | |
537 elements->set(i, *--parameters); | |
538 } | |
539 return isolate->factory()->NewJSArrayWithElements( | |
540 elements, FAST_ELEMENTS, num_elements, strength(language_mode)); | |
541 } | |
542 | |
543 | |
544 RUNTIME_FUNCTION(Runtime_NewRestParam) { | |
545 HandleScope scope(isolate); | |
546 DCHECK(args.length() == 4); | |
547 Object** parameters = reinterpret_cast<Object**>(args[0]); | |
548 CONVERT_SMI_ARG_CHECKED(num_params, 1); | |
549 CONVERT_SMI_ARG_CHECKED(rest_index, 2); | |
550 CONVERT_SMI_ARG_CHECKED(language_mode, 3); | |
551 | |
552 return *NewRestParam(isolate, parameters, num_params, rest_index, | |
553 static_cast<LanguageMode>(language_mode)); | |
554 } | |
555 | |
556 | |
557 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { | |
558 HandleScope scope(isolate); | |
559 DCHECK(args.length() == 2); | |
560 CONVERT_SMI_ARG_CHECKED(rest_index, 0); | |
561 CONVERT_SMI_ARG_CHECKED(language_mode, 1); | |
562 | |
563 JavaScriptFrameIterator it(isolate); | |
564 | |
565 // Find the frame that holds the actual arguments passed to the function. | |
566 it.AdvanceToArgumentsFrame(); | |
567 JavaScriptFrame* frame = it.frame(); | |
568 | |
569 int argument_count = frame->GetArgumentsLength(); | |
570 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); | |
571 | |
572 return *NewRestParam(isolate, parameters, argument_count, rest_index, | |
573 static_cast<LanguageMode>(language_mode)); | |
574 } | |
575 | |
576 | |
577 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 529 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
578 HandleScope scope(isolate); | 530 HandleScope scope(isolate); |
579 DCHECK(args.length() == 1); | 531 DCHECK(args.length() == 1); |
580 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 532 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
581 Handle<Context> context(isolate->context()); | 533 Handle<Context> context(isolate->context()); |
582 PretenureFlag pretenure_flag = NOT_TENURED; | 534 PretenureFlag pretenure_flag = NOT_TENURED; |
583 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 535 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
584 pretenure_flag); | 536 pretenure_flag); |
585 } | 537 } |
586 | 538 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 return Smi::FromInt(frame->GetArgumentsLength()); | 1102 return Smi::FromInt(frame->GetArgumentsLength()); |
1151 } | 1103 } |
1152 | 1104 |
1153 | 1105 |
1154 RUNTIME_FUNCTION(Runtime_Arguments) { | 1106 RUNTIME_FUNCTION(Runtime_Arguments) { |
1155 SealHandleScope shs(isolate); | 1107 SealHandleScope shs(isolate); |
1156 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1108 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
1157 } | 1109 } |
1158 } // namespace internal | 1110 } // namespace internal |
1159 } // namespace v8 | 1111 } // namespace v8 |
OLD | NEW |