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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 array->set_map_no_write_barrier(*module_context_map()); | 831 array->set_map_no_write_barrier(*module_context_map()); |
832 Handle<Context> context = Handle<Context>::cast(array); | 832 Handle<Context> context = Handle<Context>::cast(array); |
833 context->set_closure(*function); | 833 context->set_closure(*function); |
834 context->set_previous(function->context()); | 834 context->set_previous(function->context()); |
835 context->set_extension(*module); | 835 context->set_extension(*module); |
836 context->set_native_context(function->native_context()); | 836 context->set_native_context(function->native_context()); |
837 DCHECK(context->IsModuleContext()); | 837 DCHECK(context->IsModuleContext()); |
838 return context; | 838 return context; |
839 } | 839 } |
840 | 840 |
| 841 Handle<Context> Factory::NewEvalContext(Handle<Module> module, |
| 842 Handle<JSFunction> function, |
| 843 Handle<ScopeInfo> scope_info) { |
| 844 DCHECK_EQ(scope_info->scope_type(), EVAL_SCOPE); |
| 845 Handle<FixedArray> array = |
| 846 NewFixedArray(scope_info->ContextLength(), TENURED); |
| 847 array->set_map_no_write_barrier(*module_context_map()); |
| 848 Handle<Context> context = Handle<Context>::cast(array); |
| 849 context->set_closure(*function); |
| 850 context->set_previous(function->context()); |
| 851 context->set_extension(*module); |
| 852 context->set_native_context(function->native_context()); |
| 853 DCHECK(context->IsModuleContext()); |
| 854 return context; |
| 855 } |
841 | 856 |
842 Handle<Context> Factory::NewFunctionContext(int length, | 857 Handle<Context> Factory::NewFunctionContext(int length, |
843 Handle<JSFunction> function) { | 858 Handle<JSFunction> function) { |
844 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); | 859 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); |
845 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); | 860 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); |
846 Handle<FixedArray> array = NewFixedArray(length); | 861 Handle<FixedArray> array = NewFixedArray(length); |
847 array->set_map_no_write_barrier(*function_context_map()); | 862 array->set_map_no_write_barrier(*function_context_map()); |
848 Handle<Context> context = Handle<Context>::cast(array); | 863 Handle<Context> context = Handle<Context>::cast(array); |
849 context->set_closure(*function); | 864 context->set_closure(*function); |
850 context->set_previous(function->context()); | 865 context->set_previous(function->context()); |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); | 2685 Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map)); |
2671 iterator->set_initial_next(*next); | 2686 iterator->set_initial_next(*next); |
2672 iterator->set_array(*array); | 2687 iterator->set_array(*array); |
2673 iterator->set_index(0); | 2688 iterator->set_index(0); |
2674 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); | 2689 iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next); |
2675 return iterator; | 2690 return iterator; |
2676 } | 2691 } |
2677 | 2692 |
2678 } // namespace internal | 2693 } // namespace internal |
2679 } // namespace v8 | 2694 } // namespace v8 |
OLD | NEW |