| 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { | 515 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
| 516 HandleScope scope(isolate); | 516 HandleScope scope(isolate); |
| 517 DCHECK(args.length() == 3); | 517 DCHECK(args.length() == 3); |
| 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, Object** parameters, |
| 526 Object** parameters, | 526 int num_params, int rest_index, |
| 527 int num_params, | 527 LanguageMode language_mode) { |
| 528 int rest_index) { | |
| 529 parameters -= rest_index; | 528 parameters -= rest_index; |
| 530 int num_elements = std::max(0, num_params - rest_index); | 529 int num_elements = std::max(0, num_params - rest_index); |
| 531 Handle<FixedArray> elements = | 530 Handle<FixedArray> elements = |
| 532 isolate->factory()->NewUninitializedFixedArray(num_elements); | 531 isolate->factory()->NewUninitializedFixedArray(num_elements); |
| 533 for (int i = 0; i < num_elements; ++i) { | 532 for (int i = 0; i < num_elements; ++i) { |
| 534 elements->set(i, *--parameters); | 533 elements->set(i, *--parameters); |
| 535 } | 534 } |
| 536 return isolate->factory()->NewJSArrayWithElements(elements, FAST_ELEMENTS, | 535 return isolate->factory()->NewJSArrayWithElements( |
| 537 num_elements); | 536 elements, FAST_ELEMENTS, num_elements, strength(language_mode)); |
| 538 } | 537 } |
| 539 | 538 |
| 540 | 539 |
| 541 RUNTIME_FUNCTION(Runtime_NewRestParam) { | 540 RUNTIME_FUNCTION(Runtime_NewRestParam) { |
| 542 HandleScope scope(isolate); | 541 HandleScope scope(isolate); |
| 543 DCHECK(args.length() == 3); | 542 DCHECK(args.length() == 4); |
| 544 Object** parameters = reinterpret_cast<Object**>(args[0]); | 543 Object** parameters = reinterpret_cast<Object**>(args[0]); |
| 545 CONVERT_SMI_ARG_CHECKED(num_params, 1); | 544 CONVERT_SMI_ARG_CHECKED(num_params, 1); |
| 546 CONVERT_SMI_ARG_CHECKED(rest_index, 2); | 545 CONVERT_SMI_ARG_CHECKED(rest_index, 2); |
| 546 CONVERT_SMI_ARG_CHECKED(language_mode, 3); |
| 547 | 547 |
| 548 return *NewRestParam(isolate, parameters, num_params, rest_index); | 548 return *NewRestParam(isolate, parameters, num_params, rest_index, |
| 549 static_cast<LanguageMode>(language_mode)); |
| 549 } | 550 } |
| 550 | 551 |
| 551 | 552 |
| 552 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { | 553 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { |
| 553 HandleScope scope(isolate); | 554 HandleScope scope(isolate); |
| 554 DCHECK(args.length() == 1); | 555 DCHECK(args.length() == 2); |
| 555 CONVERT_SMI_ARG_CHECKED(rest_index, 0); | 556 CONVERT_SMI_ARG_CHECKED(rest_index, 0); |
| 557 CONVERT_SMI_ARG_CHECKED(language_mode, 1); |
| 556 | 558 |
| 557 JavaScriptFrameIterator it(isolate); | 559 JavaScriptFrameIterator it(isolate); |
| 558 | 560 |
| 559 // Find the frame that holds the actual arguments passed to the function. | 561 // Find the frame that holds the actual arguments passed to the function. |
| 560 it.AdvanceToArgumentsFrame(); | 562 it.AdvanceToArgumentsFrame(); |
| 561 JavaScriptFrame* frame = it.frame(); | 563 JavaScriptFrame* frame = it.frame(); |
| 562 | 564 |
| 563 int argument_count = frame->GetArgumentsLength(); | 565 int argument_count = frame->GetArgumentsLength(); |
| 564 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); | 566 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); |
| 565 | 567 |
| 566 return *NewRestParam(isolate, parameters, argument_count, rest_index); | 568 return *NewRestParam(isolate, parameters, argument_count, rest_index, |
| 569 static_cast<LanguageMode>(language_mode)); |
| 567 } | 570 } |
| 568 | 571 |
| 569 | 572 |
| 570 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 573 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
| 571 HandleScope scope(isolate); | 574 HandleScope scope(isolate); |
| 572 DCHECK(args.length() == 1); | 575 DCHECK(args.length() == 1); |
| 573 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 576 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 574 Handle<Context> context(isolate->context()); | 577 Handle<Context> context(isolate->context()); |
| 575 PretenureFlag pretenure_flag = NOT_TENURED; | 578 PretenureFlag pretenure_flag = NOT_TENURED; |
| 576 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 579 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()); | 1133 return Smi::FromInt(frame->GetArgumentsLength()); |
| 1131 } | 1134 } |
| 1132 | 1135 |
| 1133 | 1136 |
| 1134 RUNTIME_FUNCTION(Runtime_Arguments) { | 1137 RUNTIME_FUNCTION(Runtime_Arguments) { |
| 1135 SealHandleScope shs(isolate); | 1138 SealHandleScope shs(isolate); |
| 1136 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 1139 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
| 1137 } | 1140 } |
| 1138 } // namespace internal | 1141 } // namespace internal |
| 1139 } // namespace v8 | 1142 } // namespace v8 |
| OLD | NEW |