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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // This runtime function does not materialize the correct arguments when the | 598 // This runtime function does not materialize the correct arguments when the |
599 // caller has been inlined, better make sure we are not hitting that case. | 599 // caller has been inlined, better make sure we are not hitting that case. |
600 JavaScriptFrameIterator it(isolate); | 600 JavaScriptFrameIterator it(isolate); |
601 DCHECK(!it.frame()->HasInlinedFrames()); | 601 DCHECK(!it.frame()->HasInlinedFrames()); |
602 #endif // DEBUG | 602 #endif // DEBUG |
603 ParameterArguments argument_getter(parameters); | 603 ParameterArguments argument_getter(parameters); |
604 return *NewStrictArguments(isolate, callee, argument_getter, argument_count); | 604 return *NewStrictArguments(isolate, callee, argument_getter, argument_count); |
605 } | 605 } |
606 | 606 |
607 | 607 |
| 608 static Handle<JSArray> NewRestParam(Isolate* isolate, Object** parameters, |
| 609 int num_params, int rest_index, |
| 610 LanguageMode language_mode) { |
| 611 parameters -= rest_index; |
| 612 int num_elements = std::max(0, num_params - rest_index); |
| 613 Handle<FixedArray> elements = |
| 614 isolate->factory()->NewUninitializedFixedArray(num_elements); |
| 615 for (int i = 0; i < num_elements; ++i) { |
| 616 elements->set(i, *--parameters); |
| 617 } |
| 618 return isolate->factory()->NewJSArrayWithElements( |
| 619 elements, FAST_ELEMENTS, num_elements, strength(language_mode)); |
| 620 } |
| 621 |
| 622 |
| 623 RUNTIME_FUNCTION(Runtime_NewRestParam) { |
| 624 HandleScope scope(isolate); |
| 625 DCHECK(args.length() == 4); |
| 626 Object** parameters = reinterpret_cast<Object**>(args[0]); |
| 627 CONVERT_SMI_ARG_CHECKED(num_params, 1); |
| 628 CONVERT_SMI_ARG_CHECKED(rest_index, 2); |
| 629 CONVERT_SMI_ARG_CHECKED(language_mode, 3); |
| 630 |
| 631 return *NewRestParam(isolate, parameters, num_params, rest_index, |
| 632 static_cast<LanguageMode>(language_mode)); |
| 633 } |
| 634 |
| 635 |
| 636 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { |
| 637 HandleScope scope(isolate); |
| 638 DCHECK(args.length() == 2); |
| 639 CONVERT_SMI_ARG_CHECKED(rest_index, 0); |
| 640 CONVERT_SMI_ARG_CHECKED(language_mode, 1); |
| 641 |
| 642 JavaScriptFrameIterator it(isolate); |
| 643 |
| 644 // Find the frame that holds the actual arguments passed to the function. |
| 645 it.AdvanceToArgumentsFrame(); |
| 646 JavaScriptFrame* frame = it.frame(); |
| 647 |
| 648 int argument_count = frame->GetArgumentsLength(); |
| 649 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); |
| 650 |
| 651 return *NewRestParam(isolate, parameters, argument_count, rest_index, |
| 652 static_cast<LanguageMode>(language_mode)); |
| 653 } |
| 654 |
| 655 |
608 RUNTIME_FUNCTION(Runtime_NewClosure) { | 656 RUNTIME_FUNCTION(Runtime_NewClosure) { |
609 HandleScope scope(isolate); | 657 HandleScope scope(isolate); |
610 DCHECK_EQ(1, args.length()); | 658 DCHECK_EQ(1, args.length()); |
611 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 659 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
612 Handle<Context> context(isolate->context(), isolate); | 660 Handle<Context> context(isolate->context(), isolate); |
613 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 661 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
614 NOT_TENURED); | 662 NOT_TENURED); |
615 } | 663 } |
616 | 664 |
617 | 665 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 | 1178 |
1131 // Lookup in the initial Object.prototype object. | 1179 // Lookup in the initial Object.prototype object. |
1132 Handle<Object> result; | 1180 Handle<Object> result; |
1133 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1181 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1134 isolate, result, | 1182 isolate, result, |
1135 Object::GetProperty(isolate->initial_object_prototype(), key)); | 1183 Object::GetProperty(isolate->initial_object_prototype(), key)); |
1136 return *result; | 1184 return *result; |
1137 } | 1185 } |
1138 } // namespace internal | 1186 } // namespace internal |
1139 } // namespace v8 | 1187 } // namespace v8 |
OLD | NEW |