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

Side by Side Diff: src/factory.cc

Issue 1478303002: Revert of [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
« no previous file with comments | « src/crankshaft/x64/lithium-codegen-x64.cc ('k') | src/full-codegen/arm/full-codegen-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
730 context->set_js_array_maps(*undefined_value()); 729 context->set_js_array_maps(*undefined_value());
731 context->set_errors_thrown(Smi::FromInt(0)); 730 context->set_errors_thrown(Smi::FromInt(0));
732 DCHECK(context->IsNativeContext()); 731 DCHECK(context->IsNativeContext());
733 return context; 732 return context;
734 } 733 }
735 734
736 735
737 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function, 736 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function,
738 Handle<ScopeInfo> scope_info) { 737 Handle<ScopeInfo> scope_info) {
739 Handle<FixedArray> array = 738 Handle<FixedArray> array =
740 NewFixedArray(scope_info->ContextLength(), TENURED); 739 NewFixedArray(scope_info->ContextLength(), TENURED);
741 array->set_map_no_write_barrier(*script_context_map()); 740 array->set_map_no_write_barrier(*script_context_map());
742 Handle<Context> context = Handle<Context>::cast(array); 741 Handle<Context> context = Handle<Context>::cast(array);
743 context->set_closure(*function); 742 context->set_closure(*function);
744 context->set_previous(function->context()); 743 context->set_previous(function->context());
745 context->set_extension(*scope_info); 744 context->set_extension(*scope_info);
746 context->set_native_context(function->native_context()); 745 context->set_global_object(function->context()->global_object());
747 DCHECK(context->IsScriptContext()); 746 DCHECK(context->IsScriptContext());
748 return context; 747 return context;
749 } 748 }
750 749
751 750
752 Handle<ScriptContextTable> Factory::NewScriptContextTable() { 751 Handle<ScriptContextTable> Factory::NewScriptContextTable() {
753 Handle<FixedArray> array = NewFixedArray(1); 752 Handle<FixedArray> array = NewFixedArray(1);
754 array->set_map_no_write_barrier(*script_context_table_map()); 753 array->set_map_no_write_barrier(*script_context_table_map());
755 Handle<ScriptContextTable> context_table = 754 Handle<ScriptContextTable> context_table =
756 Handle<ScriptContextTable>::cast(array); 755 Handle<ScriptContextTable>::cast(array);
(...skipping 15 matching lines...) Expand all
772 771
773 Handle<Context> Factory::NewFunctionContext(int length, 772 Handle<Context> Factory::NewFunctionContext(int length,
774 Handle<JSFunction> function) { 773 Handle<JSFunction> function) {
775 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); 774 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
776 Handle<FixedArray> array = NewFixedArray(length); 775 Handle<FixedArray> array = NewFixedArray(length);
777 array->set_map_no_write_barrier(*function_context_map()); 776 array->set_map_no_write_barrier(*function_context_map());
778 Handle<Context> context = Handle<Context>::cast(array); 777 Handle<Context> context = Handle<Context>::cast(array);
779 context->set_closure(*function); 778 context->set_closure(*function);
780 context->set_previous(function->context()); 779 context->set_previous(function->context());
781 context->set_extension(Smi::FromInt(0)); 780 context->set_extension(Smi::FromInt(0));
782 context->set_native_context(function->native_context()); 781 context->set_global_object(function->context()->global_object());
783 return context; 782 return context;
784 } 783 }
785 784
786 785
787 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, 786 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function,
788 Handle<Context> previous, 787 Handle<Context> previous,
789 Handle<String> name, 788 Handle<String> name,
790 Handle<Object> thrown_object) { 789 Handle<Object> thrown_object) {
791 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); 790 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX);
792 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1); 791 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 1);
793 array->set_map_no_write_barrier(*catch_context_map()); 792 array->set_map_no_write_barrier(*catch_context_map());
794 Handle<Context> context = Handle<Context>::cast(array); 793 Handle<Context> context = Handle<Context>::cast(array);
795 context->set_closure(*function); 794 context->set_closure(*function);
796 context->set_previous(*previous); 795 context->set_previous(*previous);
797 context->set_extension(*name); 796 context->set_extension(*name);
798 context->set_native_context(previous->native_context()); 797 context->set_global_object(previous->global_object());
799 context->set(Context::THROWN_OBJECT_INDEX, *thrown_object); 798 context->set(Context::THROWN_OBJECT_INDEX, *thrown_object);
800 return context; 799 return context;
801 } 800 }
802 801
803 802
804 Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, 803 Handle<Context> Factory::NewWithContext(Handle<JSFunction> function,
805 Handle<Context> previous, 804 Handle<Context> previous,
806 Handle<JSReceiver> extension) { 805 Handle<JSReceiver> extension) {
807 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS); 806 Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS);
808 array->set_map_no_write_barrier(*with_context_map()); 807 array->set_map_no_write_barrier(*with_context_map());
809 Handle<Context> context = Handle<Context>::cast(array); 808 Handle<Context> context = Handle<Context>::cast(array);
810 context->set_closure(*function); 809 context->set_closure(*function);
811 context->set_previous(*previous); 810 context->set_previous(*previous);
812 context->set_extension(*extension); 811 context->set_extension(*extension);
813 context->set_native_context(previous->native_context()); 812 context->set_global_object(previous->global_object());
814 return context; 813 return context;
815 } 814 }
816 815
817 816
818 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function, 817 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function,
819 Handle<Context> previous, 818 Handle<Context> previous,
820 Handle<ScopeInfo> scope_info) { 819 Handle<ScopeInfo> scope_info) {
821 Handle<FixedArray> array = 820 Handle<FixedArray> array =
822 NewFixedArrayWithHoles(scope_info->ContextLength()); 821 NewFixedArrayWithHoles(scope_info->ContextLength());
823 array->set_map_no_write_barrier(*block_context_map()); 822 array->set_map_no_write_barrier(*block_context_map());
824 Handle<Context> context = Handle<Context>::cast(array); 823 Handle<Context> context = Handle<Context>::cast(array);
825 context->set_closure(*function); 824 context->set_closure(*function);
826 context->set_previous(*previous); 825 context->set_previous(*previous);
827 context->set_extension(*scope_info); 826 context->set_extension(*scope_info);
828 context->set_native_context(previous->native_context()); 827 context->set_global_object(previous->global_object());
829 return context; 828 return context;
830 } 829 }
831 830
832 831
833 Handle<Struct> Factory::NewStruct(InstanceType type) { 832 Handle<Struct> Factory::NewStruct(InstanceType type) {
834 CALL_HEAP_FUNCTION( 833 CALL_HEAP_FUNCTION(
835 isolate(), 834 isolate(),
836 isolate()->heap()->AllocateStruct(type), 835 isolate()->heap()->AllocateStruct(type),
837 Struct); 836 Struct);
838 } 837 }
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 } 2326 }
2328 2327
2329 2328
2330 Handle<Object> Factory::ToBoolean(bool value) { 2329 Handle<Object> Factory::ToBoolean(bool value) {
2331 return value ? true_value() : false_value(); 2330 return value ? true_value() : false_value();
2332 } 2331 }
2333 2332
2334 2333
2335 } // namespace internal 2334 } // namespace internal
2336 } // namespace v8 2335 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/x64/lithium-codegen-x64.cc ('k') | src/full-codegen/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698