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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 DisallowHeapAllocation no_gc; | 604 DisallowHeapAllocation no_gc; |
605 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | 605 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
606 for (int index = 0; index < length; ++index) { | 606 for (int index = 0; index < length; ++index) { |
607 result->set(index, frame[offset - index], mode); | 607 result->set(index, frame[offset - index], mode); |
608 } | 608 } |
609 return *result; | 609 return *result; |
610 } | 610 } |
611 | 611 |
612 RUNTIME_FUNCTION(Runtime_NewClosure) { | 612 RUNTIME_FUNCTION(Runtime_NewClosure) { |
613 HandleScope scope(isolate); | 613 HandleScope scope(isolate); |
614 DCHECK_EQ(1, args.length()); | 614 DCHECK_EQ(3, args.length()); |
615 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 615 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 616 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
| 617 CONVERT_SMI_ARG_CHECKED(index, 2); |
616 Handle<Context> context(isolate->context(), isolate); | 618 Handle<Context> context(isolate->context(), isolate); |
617 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 619 FeedbackVectorSlot slot = TypeFeedbackVector::ToSlot(index); |
618 NOT_TENURED); | 620 Handle<LiteralsArray> literals(LiteralsArray::cast(vector->Get(slot)), |
| 621 isolate); |
| 622 Handle<JSFunction> function = |
| 623 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 624 shared, context, literals, NOT_TENURED); |
| 625 return *function; |
619 } | 626 } |
620 | 627 |
621 | 628 |
622 RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) { | 629 RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) { |
623 HandleScope scope(isolate); | 630 HandleScope scope(isolate); |
624 DCHECK_EQ(1, args.length()); | 631 DCHECK_EQ(3, args.length()); |
625 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 632 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 633 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
| 634 CONVERT_SMI_ARG_CHECKED(index, 2); |
626 Handle<Context> context(isolate->context(), isolate); | 635 Handle<Context> context(isolate->context(), isolate); |
| 636 FeedbackVectorSlot slot = TypeFeedbackVector::ToSlot(index); |
| 637 Handle<LiteralsArray> literals(LiteralsArray::cast(vector->Get(slot)), |
| 638 isolate); |
627 // The caller ensures that we pretenure closures that are assigned | 639 // The caller ensures that we pretenure closures that are assigned |
628 // directly to properties. | 640 // directly to properties. |
629 return *isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 641 Handle<JSFunction> function = |
630 TENURED); | 642 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
| 643 literals, TENURED); |
| 644 return *function; |
631 } | 645 } |
632 | 646 |
633 static Object* FindNameClash(Handle<ScopeInfo> scope_info, | 647 static Object* FindNameClash(Handle<ScopeInfo> scope_info, |
634 Handle<JSGlobalObject> global_object, | 648 Handle<JSGlobalObject> global_object, |
635 Handle<ScriptContextTable> script_context) { | 649 Handle<ScriptContextTable> script_context) { |
636 Isolate* isolate = scope_info->GetIsolate(); | 650 Isolate* isolate = scope_info->GetIsolate(); |
637 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { | 651 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { |
638 Handle<String> name(scope_info->ContextLocalName(var)); | 652 Handle<String> name(scope_info->ContextLocalName(var)); |
639 VariableMode mode = scope_info->ContextLocalMode(var); | 653 VariableMode mode = scope_info->ContextLocalMode(var); |
640 ScriptContextTable::LookupResult lookup; | 654 ScriptContextTable::LookupResult lookup; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { | 989 RUNTIME_FUNCTION(Runtime_StoreLookupSlot_Strict) { |
976 HandleScope scope(isolate); | 990 HandleScope scope(isolate); |
977 DCHECK_EQ(2, args.length()); | 991 DCHECK_EQ(2, args.length()); |
978 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 992 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
979 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 993 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
980 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); | 994 RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT)); |
981 } | 995 } |
982 | 996 |
983 } // namespace internal | 997 } // namespace internal |
984 } // namespace v8 | 998 } // namespace v8 |
OLD | NEW |