| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { | 537 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
| 538 HandleScope scope(isolate); | 538 HandleScope scope(isolate); |
| 539 DCHECK(args.length() == 3); | 539 DCHECK(args.length() == 3); |
| 540 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 540 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
| 541 Object** parameters = reinterpret_cast<Object**>(args[1]); | 541 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 542 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 542 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
| 543 return *NewStrictArguments(isolate, callee, parameters, argument_count); | 543 return *NewStrictArguments(isolate, callee, parameters, argument_count); |
| 544 } | 544 } |
| 545 | 545 |
| 546 | 546 |
| 547 static Handle<JSArray> NewRestParam(Isolate* isolate, Object** parameters, | |
| 548 int num_params, int rest_index, | |
| 549 LanguageMode language_mode) { | |
| 550 parameters -= rest_index; | |
| 551 int num_elements = std::max(0, num_params - rest_index); | |
| 552 Handle<FixedArray> elements = | |
| 553 isolate->factory()->NewUninitializedFixedArray(num_elements); | |
| 554 for (int i = 0; i < num_elements; ++i) { | |
| 555 elements->set(i, *--parameters); | |
| 556 } | |
| 557 return isolate->factory()->NewJSArrayWithElements( | |
| 558 elements, FAST_ELEMENTS, num_elements, strength(language_mode)); | |
| 559 } | |
| 560 | |
| 561 | |
| 562 RUNTIME_FUNCTION(Runtime_NewRestParam) { | |
| 563 HandleScope scope(isolate); | |
| 564 DCHECK(args.length() == 4); | |
| 565 Object** parameters = reinterpret_cast<Object**>(args[0]); | |
| 566 CONVERT_SMI_ARG_CHECKED(num_params, 1); | |
| 567 CONVERT_SMI_ARG_CHECKED(rest_index, 2); | |
| 568 CONVERT_SMI_ARG_CHECKED(language_mode, 3); | |
| 569 | |
| 570 return *NewRestParam(isolate, parameters, num_params, rest_index, | |
| 571 static_cast<LanguageMode>(language_mode)); | |
| 572 } | |
| 573 | |
| 574 | |
| 575 RUNTIME_FUNCTION(Runtime_NewRestParamSlow) { | |
| 576 HandleScope scope(isolate); | |
| 577 DCHECK(args.length() == 2); | |
| 578 CONVERT_SMI_ARG_CHECKED(rest_index, 0); | |
| 579 CONVERT_SMI_ARG_CHECKED(language_mode, 1); | |
| 580 | |
| 581 JavaScriptFrameIterator it(isolate); | |
| 582 | |
| 583 // Find the frame that holds the actual arguments passed to the function. | |
| 584 it.AdvanceToArgumentsFrame(); | |
| 585 JavaScriptFrame* frame = it.frame(); | |
| 586 | |
| 587 int argument_count = frame->GetArgumentsLength(); | |
| 588 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); | |
| 589 | |
| 590 return *NewRestParam(isolate, parameters, argument_count, rest_index, | |
| 591 static_cast<LanguageMode>(language_mode)); | |
| 592 } | |
| 593 | |
| 594 | |
| 595 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 547 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
| 596 HandleScope scope(isolate); | 548 HandleScope scope(isolate); |
| 597 DCHECK(args.length() == 1); | 549 DCHECK(args.length() == 1); |
| 598 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 550 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 599 Handle<Context> context(isolate->context()); | 551 Handle<Context> context(isolate->context()); |
| 600 PretenureFlag pretenure_flag = NOT_TENURED; | 552 PretenureFlag pretenure_flag = NOT_TENURED; |
| 601 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 553 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
| 602 pretenure_flag); | 554 pretenure_flag); |
| 603 } | 555 } |
| 604 | 556 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 | 1113 |
| 1162 // Lookup in the initial Object.prototype object. | 1114 // Lookup in the initial Object.prototype object. |
| 1163 Handle<Object> result; | 1115 Handle<Object> result; |
| 1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1116 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1165 isolate, result, | 1117 isolate, result, |
| 1166 Object::GetProperty(isolate->initial_object_prototype(), key)); | 1118 Object::GetProperty(isolate->initial_object_prototype(), key)); |
| 1167 return *result; | 1119 return *result; |
| 1168 } | 1120 } |
| 1169 } // namespace internal | 1121 } // namespace internal |
| 1170 } // namespace v8 | 1122 } // namespace v8 |
| OLD | NEW |