| 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/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 array->set_map_no_write_barrier(*module_context_map()); | 883 array->set_map_no_write_barrier(*module_context_map()); |
| 884 Handle<Context> context = Handle<Context>::cast(array); | 884 Handle<Context> context = Handle<Context>::cast(array); |
| 885 context->set_closure(*function); | 885 context->set_closure(*function); |
| 886 context->set_previous(function->context()); | 886 context->set_previous(function->context()); |
| 887 context->set_extension(*module); | 887 context->set_extension(*module); |
| 888 context->set_native_context(function->native_context()); | 888 context->set_native_context(function->native_context()); |
| 889 DCHECK(context->IsModuleContext()); | 889 DCHECK(context->IsModuleContext()); |
| 890 return context; | 890 return context; |
| 891 } | 891 } |
| 892 | 892 |
| 893 | |
| 894 Handle<Context> Factory::NewFunctionContext(int length, | 893 Handle<Context> Factory::NewFunctionContext(int length, |
| 895 Handle<JSFunction> function) { | 894 Handle<JSFunction> function, |
| 896 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | 895 ScopeType scope_type) { |
| 896 DCHECK(function->shared()->scope_info()->scope_type() == scope_type); |
| 897 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | 897 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); |
| 898 Handle<FixedArray> array = NewFixedArray(length); | 898 Handle<FixedArray> array = NewFixedArray(length); |
| 899 array->set_map_no_write_barrier(*function_context_map()); | 899 Handle<Map> map; |
| 900 switch (scope_type) { |
| 901 case EVAL_SCOPE: |
| 902 map = eval_context_map(); |
| 903 break; |
| 904 case FUNCTION_SCOPE: |
| 905 map = function_context_map(); |
| 906 break; |
| 907 default: |
| 908 UNREACHABLE(); |
| 909 } |
| 910 array->set_map_no_write_barrier(*map); |
| 900 Handle<Context> context = Handle<Context>::cast(array); | 911 Handle<Context> context = Handle<Context>::cast(array); |
| 901 context->set_closure(*function); | 912 context->set_closure(*function); |
| 902 context->set_previous(function->context()); | 913 context->set_previous(function->context()); |
| 903 context->set_extension(*the_hole_value()); | 914 context->set_extension(*the_hole_value()); |
| 904 context->set_native_context(function->native_context()); | 915 context->set_native_context(function->native_context()); |
| 905 return context; | 916 return context; |
| 906 } | 917 } |
| 907 | 918 |
| 908 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, | 919 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, |
| 909 Handle<Context> previous, | 920 Handle<Context> previous, |
| (...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2780 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); | 2791 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
| 2781 iterator->set_initial_next(*next); | 2792 iterator->set_initial_next(*next); |
| 2782 iterator->set_array(*array); | 2793 iterator->set_array(*array); |
| 2783 iterator->set_index(0); | 2794 iterator->set_index(0); |
| 2784 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); | 2795 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
| 2785 return iterator; | 2796 return iterator; |
| 2786 } | 2797 } |
| 2787 | 2798 |
| 2788 } // namespace internal | 2799 } // namespace internal |
| 2789 } // namespace v8 | 2800 } // namespace v8 |
| OLD | NEW |