Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: src/factory.cc

Issue 1480003002: [runtime] Replace global object link with native context link in all contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 symbol->set_is_private(true); 719 symbol->set_is_private(true);
720 return symbol; 720 return symbol;
721 } 721 }
722 722
723 723
724 Handle<Context> Factory::NewNativeContext() { 724 Handle<Context> Factory::NewNativeContext() {
725 Handle<FixedArray> array = 725 Handle<FixedArray> array =
726 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED); 726 NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED);
727 array->set_map_no_write_barrier(*native_context_map()); 727 array->set_map_no_write_barrier(*native_context_map());
728 Handle<Context> context = Handle<Context>::cast(array); 728 Handle<Context> context = Handle<Context>::cast(array);
729 context->set_native_context(*context);
729 context->set_js_array_maps(*undefined_value()); 730 context->set_js_array_maps(*undefined_value());
730 context->set_errors_thrown(Smi::FromInt(0)); 731 context->set_errors_thrown(Smi::FromInt(0));
731 DCHECK(context->IsNativeContext()); 732 DCHECK(context->IsNativeContext());
732 return context; 733 return context;
733 } 734 }
734 735
735 736
736 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function, 737 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function,
737 Handle<ScopeInfo> scope_info) { 738 Handle<ScopeInfo> scope_info) {
738 Handle<FixedArray> array = 739 Handle<FixedArray> array =
739 NewFixedArray(scope_info->ContextLength(), TENURED); 740 NewFixedArray(scope_info->ContextLength(), TENURED);
740 array->set_map_no_write_barrier(*script_context_map()); 741 array->set_map_no_write_barrier(*script_context_map());
741 Handle<Context> context = Handle<Context>::cast(array); 742 Handle<Context> context = Handle<Context>::cast(array);
742 context->set_closure(*function); 743 context->set_closure(*function);
743 context->set_previous(function->context()); 744 context->set_previous(function->context());
744 context->set_extension(*scope_info); 745 context->set_extension(*scope_info);
745 context->set_global_object(function->context()->global_object()); 746 context->set_native_context(function->native_context());
746 DCHECK(context->IsScriptContext()); 747 DCHECK(context->IsScriptContext());
747 return context; 748 return context;
748 } 749 }
749 750
750 751
751 Handle<ScriptContextTable> Factory::NewScriptContextTable() { 752 Handle<ScriptContextTable> Factory::NewScriptContextTable() {
752 Handle<FixedArray> array = NewFixedArray(1); 753 Handle<FixedArray> array = NewFixedArray(1);
753 array->set_map_no_write_barrier(*script_context_table_map()); 754 array->set_map_no_write_barrier(*script_context_table_map());
754 Handle<ScriptContextTable> context_table = 755 Handle<ScriptContextTable> context_table =
755 Handle<ScriptContextTable>::cast(array); 756 Handle<ScriptContextTable>::cast(array);
(...skipping 15 matching lines...) Expand all
771 772
772 Handle<Context> Factory::NewFunctionContext(int length, 773 Handle<Context> Factory::NewFunctionContext(int length,
773 Handle<JSFunction> function) { 774 Handle<JSFunction> function) {
774 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); 775 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
775 Handle<FixedArray> array = NewFixedArray(length); 776 Handle<FixedArray> array = NewFixedArray(length);
776 array->set_map_no_write_barrier(*function_context_map()); 777 array->set_map_no_write_barrier(*function_context_map());
777 Handle<Context> context = Handle<Context>::cast(array); 778 Handle<Context> context = Handle<Context>::cast(array);
778 context->set_closure(*function); 779 context->set_closure(*function);
779 context->set_previous(function->context()); 780 context->set_previous(function->context());
780 context->set_extension(Smi::FromInt(0)); 781 context->set_extension(Smi::FromInt(0));
781 context->set_global_object(function->context()->global_object()); 782 context->set_native_context(function->native_context());
782 return context; 783 return context;
783 } 784 }
784 785
785 786
786 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, 787 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function,
787 Handle<Context> previous, 788 Handle<Context> previous,
788 Handle<String> name, 789 Handle<String> name,
789 Handle<Object> thrown_object) { 790 Handle<Object> thrown_object) {
790 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); 791 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX);
791 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1); 792 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1);
792 array->set_map_no_write_barrier(*catch_context_map()); 793 array->set_map_no_write_barrier(*catch_context_map());
793 Handle<Context> context = Handle<Context>::cast(array); 794 Handle<Context> context = Handle<Context>::cast(array);
794 context->set_closure(*function); 795 context->set_closure(*function);
795 context->set_previous(*previous); 796 context->set_previous(*previous);
796 context->set_extension(*name); 797 context->set_extension(*name);
797 context->set_global_object(previous->global_object()); 798 context->set_native_context(previous->native_context());
798 context->set(Context::THROWN_OBJECT_INDEX, *thrown_object); 799 context->set(Context::THROWN_OBJECT_INDEX, *thrown_object);
799 return context; 800 return context;
800 } 801 }
801 802
802 803
803 Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, 804 Handle<Context> Factory::NewWithContext(Handle<JSFunction> function,
804 Handle<Context> previous, 805 Handle<Context> previous,
805 Handle<JSReceiver> extension) { 806 Handle<JSReceiver> extension) {
806 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS); 807 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS);
807 array->set_map_no_write_barrier(*with_context_map()); 808 array->set_map_no_write_barrier(*with_context_map());
808 Handle<Context> context = Handle<Context>::cast(array); 809 Handle<Context> context = Handle<Context>::cast(array);
809 context->set_closure(*function); 810 context->set_closure(*function);
810 context->set_previous(*previous); 811 context->set_previous(*previous);
811 context->set_extension(*extension); 812 context->set_extension(*extension);
812 context->set_global_object(previous->global_object()); 813 context->set_native_context(previous->native_context());
813 return context; 814 return context;
814 } 815 }
815 816
816 817
817 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function, 818 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function,
818 Handle<Context> previous, 819 Handle<Context> previous,
819 Handle<ScopeInfo> scope_info) { 820 Handle<ScopeInfo> scope_info) {
820 Handle<FixedArray> array = 821 Handle<FixedArray> array =
821 NewFixedArrayWithHoles(scope_info->ContextLength()); 822 NewFixedArrayWithHoles(scope_info->ContextLength());
822 array->set_map_no_write_barrier(*block_context_map()); 823 array->set_map_no_write_barrier(*block_context_map());
823 Handle<Context> context = Handle<Context>::cast(array); 824 Handle<Context> context = Handle<Context>::cast(array);
824 context->set_closure(*function); 825 context->set_closure(*function);
825 context->set_previous(*previous); 826 context->set_previous(*previous);
826 context->set_extension(*scope_info); 827 context->set_extension(*scope_info);
827 context->set_global_object(previous->global_object()); 828 context->set_native_context(previous->native_context());
828 return context; 829 return context;
829 } 830 }
830 831
831 832
832 Handle<Struct> Factory::NewStruct(InstanceType type) { 833 Handle<Struct> Factory::NewStruct(InstanceType type) {
833 CALL_HEAP_FUNCTION( 834 CALL_HEAP_FUNCTION(
834 isolate(), 835 isolate(),
835 isolate()->heap()->AllocateStruct(type), 836 isolate()->heap()->AllocateStruct(type),
836 Struct); 837 Struct);
837 } 838 }
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 } 2327 }
2327 2328
2328 2329
2329 Handle<Object> Factory::ToBoolean(bool value) { 2330 Handle<Object> Factory::ToBoolean(bool value) {
2330 return value ? true_value() : false_value(); 2331 return value ? true_value() : false_value();
2331 } 2332 }
2332 2333
2333 2334
2334 } // namespace internal 2335 } // namespace internal
2335 } // namespace v8 2336 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698