Chromium Code Reviews| 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/factory.h" | 5 #include "src/factory.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 context->set_errors_thrown(Smi::FromInt(0)); | 753 context->set_errors_thrown(Smi::FromInt(0)); |
| 754 Handle<WeakCell> weak_cell = NewWeakCell(context); | 754 Handle<WeakCell> weak_cell = NewWeakCell(context); |
| 755 context->set_self_weak_cell(*weak_cell); | 755 context->set_self_weak_cell(*weak_cell); |
| 756 DCHECK(context->IsNativeContext()); | 756 DCHECK(context->IsNativeContext()); |
| 757 return context; | 757 return context; |
| 758 } | 758 } |
| 759 | 759 |
| 760 | 760 |
| 761 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function, | 761 Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function, |
| 762 Handle<ScopeInfo> scope_info) { | 762 Handle<ScopeInfo> scope_info) { |
| 763 DCHECK(scope_info->scope_type() == SCRIPT_SCOPE); | |
|
Toon Verwaest
2016/08/19 12:48:52
_EQ
| |
| 763 Handle<FixedArray> array = | 764 Handle<FixedArray> array = |
| 764 NewFixedArray(scope_info->ContextLength(), TENURED); | 765 NewFixedArray(scope_info->ContextLength(), TENURED); |
| 765 array->set_map_no_write_barrier(*script_context_map()); | 766 array->set_map_no_write_barrier(*script_context_map()); |
| 766 Handle<Context> context = Handle<Context>::cast(array); | 767 Handle<Context> context = Handle<Context>::cast(array); |
| 767 context->set_closure(*function); | 768 context->set_closure(*function); |
| 768 context->set_previous(function->context()); | 769 context->set_previous(function->context()); |
| 769 context->set_extension(*scope_info); | 770 context->set_extension(*scope_info); |
| 770 context->set_native_context(function->native_context()); | 771 context->set_native_context(function->native_context()); |
| 771 DCHECK(context->IsScriptContext()); | 772 DCHECK(context->IsScriptContext()); |
| 772 return context; | 773 return context; |
| 773 } | 774 } |
| 774 | 775 |
| 775 | 776 |
| 776 Handle<ScriptContextTable> Factory::NewScriptContextTable() { | 777 Handle<ScriptContextTable> Factory::NewScriptContextTable() { |
| 777 Handle<FixedArray> array = NewFixedArray(1); | 778 Handle<FixedArray> array = NewFixedArray(1); |
| 778 array->set_map_no_write_barrier(*script_context_table_map()); | 779 array->set_map_no_write_barrier(*script_context_table_map()); |
| 779 Handle<ScriptContextTable> context_table = | 780 Handle<ScriptContextTable> context_table = |
| 780 Handle<ScriptContextTable>::cast(array); | 781 Handle<ScriptContextTable>::cast(array); |
| 781 context_table->set_used(0); | 782 context_table->set_used(0); |
| 782 return context_table; | 783 return context_table; |
| 783 } | 784 } |
| 784 | 785 |
| 785 | 786 |
| 786 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { | 787 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { |
| 788 DCHECK(scope_info->scope_type() == MODULE_SCOPE); | |
|
Toon Verwaest
2016/08/19 12:48:53
_EQ
| |
| 787 Handle<FixedArray> array = | 789 Handle<FixedArray> array = |
| 788 NewFixedArray(scope_info->ContextLength(), TENURED); | 790 NewFixedArray(scope_info->ContextLength(), TENURED); |
| 789 array->set_map_no_write_barrier(*module_context_map()); | 791 array->set_map_no_write_barrier(*module_context_map()); |
| 790 // Instance link will be set later. | 792 // Instance link will be set later. |
| 791 Handle<Context> context = Handle<Context>::cast(array); | 793 Handle<Context> context = Handle<Context>::cast(array); |
| 792 context->set_extension(*the_hole_value()); | 794 context->set_extension(*the_hole_value()); |
| 793 return context; | 795 return context; |
| 794 } | 796 } |
| 795 | 797 |
| 796 | 798 |
| 797 Handle<Context> Factory::NewFunctionContext(int length, | 799 Handle<Context> Factory::NewFunctionContext(int length, |
| 798 Handle<JSFunction> function) { | 800 Handle<JSFunction> function) { |
| 801 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | |
|
Toon Verwaest
2016/08/19 12:48:52
_EQ
| |
| 799 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | 802 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); |
| 800 Handle<FixedArray> array = NewFixedArray(length); | 803 Handle<FixedArray> array = NewFixedArray(length); |
| 801 array->set_map_no_write_barrier(*function_context_map()); | 804 array->set_map_no_write_barrier(*function_context_map()); |
| 802 Handle<Context> context = Handle<Context>::cast(array); | 805 Handle<Context> context = Handle<Context>::cast(array); |
| 803 context->set_closure(*function); | 806 context->set_closure(*function); |
| 804 context->set_previous(function->context()); | 807 context->set_previous(function->context()); |
| 805 context->set_extension(*the_hole_value()); | 808 context->set_extension(*the_hole_value()); |
| 806 context->set_native_context(function->native_context()); | 809 context->set_native_context(function->native_context()); |
| 807 return context; | 810 return context; |
| 808 } | 811 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 context->set_previous(*previous); | 854 context->set_previous(*previous); |
| 852 context->set_extension(*extension); | 855 context->set_extension(*extension); |
| 853 context->set_native_context(previous->native_context()); | 856 context->set_native_context(previous->native_context()); |
| 854 return context; | 857 return context; |
| 855 } | 858 } |
| 856 | 859 |
| 857 | 860 |
| 858 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function, | 861 Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function, |
| 859 Handle<Context> previous, | 862 Handle<Context> previous, |
| 860 Handle<ScopeInfo> scope_info) { | 863 Handle<ScopeInfo> scope_info) { |
| 864 DCHECK(scope_info->scope_type() == BLOCK_SCOPE); | |
|
Toon Verwaest
2016/08/19 12:48:52
_EQ
| |
| 861 Handle<FixedArray> array = NewFixedArray(scope_info->ContextLength()); | 865 Handle<FixedArray> array = NewFixedArray(scope_info->ContextLength()); |
| 862 array->set_map_no_write_barrier(*block_context_map()); | 866 array->set_map_no_write_barrier(*block_context_map()); |
| 863 Handle<Context> context = Handle<Context>::cast(array); | 867 Handle<Context> context = Handle<Context>::cast(array); |
| 864 context->set_closure(*function); | 868 context->set_closure(*function); |
| 865 context->set_previous(*previous); | 869 context->set_previous(*previous); |
| 866 context->set_extension(*scope_info); | 870 context->set_extension(*scope_info); |
| 867 context->set_native_context(previous->native_context()); | 871 context->set_native_context(previous->native_context()); |
| 868 return context; | 872 return context; |
| 869 } | 873 } |
| 870 | 874 |
| (...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2492 Handle<AccessorInfo> prototype = | 2496 Handle<AccessorInfo> prototype = |
| 2493 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2497 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
| 2494 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2498 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
| 2495 prototype, attribs); | 2499 prototype, attribs); |
| 2496 map->AppendDescriptor(&d); | 2500 map->AppendDescriptor(&d); |
| 2497 } | 2501 } |
| 2498 } | 2502 } |
| 2499 | 2503 |
| 2500 } // namespace internal | 2504 } // namespace internal |
| 2501 } // namespace v8 | 2505 } // namespace v8 |
| OLD | NEW |