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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 Handle<ScriptContextTable> Factory::NewScriptContextTable() { | 783 Handle<ScriptContextTable> Factory::NewScriptContextTable() { |
784 Handle<FixedArray> array = NewFixedArray(1); | 784 Handle<FixedArray> array = NewFixedArray(1); |
785 array->set_map_no_write_barrier(*script_context_table_map()); | 785 array->set_map_no_write_barrier(*script_context_table_map()); |
786 Handle<ScriptContextTable> context_table = | 786 Handle<ScriptContextTable> context_table = |
787 Handle<ScriptContextTable>::cast(array); | 787 Handle<ScriptContextTable>::cast(array); |
788 context_table->set_used(0); | 788 context_table->set_used(0); |
789 return context_table; | 789 return context_table; |
790 } | 790 } |
791 | 791 |
792 Handle<Context> Factory::NewModuleContext(Handle<JSModule> module, | 792 Handle<Context> Factory::NewModuleContext(Handle<Module> module, |
793 Handle<JSFunction> function, | 793 Handle<JSFunction> function, |
794 Handle<ScopeInfo> scope_info) { | 794 Handle<ScopeInfo> scope_info) { |
795 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); | 795 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); |
796 Handle<FixedArray> array = | 796 Handle<FixedArray> array = |
797 NewFixedArray(scope_info->ContextLength(), TENURED); | 797 NewFixedArray(scope_info->ContextLength(), TENURED); |
798 array->set_map_no_write_barrier(*module_context_map()); | 798 array->set_map_no_write_barrier(*module_context_map()); |
799 Handle<Context> context = Handle<Context>::cast(array); | 799 Handle<Context> context = Handle<Context>::cast(array); |
800 context->set_closure(*function); | 800 context->set_closure(*function); |
801 context->set_previous(function->context()); | 801 context->set_previous(function->context()); |
802 context->set_extension(*module); | 802 context->set_extension(*module); |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 DCHECK(function->shared()->is_resumable()); | 1698 DCHECK(function->shared()->is_resumable()); |
1699 JSFunction::EnsureHasInitialMap(function); | 1699 JSFunction::EnsureHasInitialMap(function); |
1700 Handle<Map> map(function->initial_map()); | 1700 Handle<Map> map(function->initial_map()); |
1701 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); | 1701 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); |
1702 CALL_HEAP_FUNCTION( | 1702 CALL_HEAP_FUNCTION( |
1703 isolate(), | 1703 isolate(), |
1704 isolate()->heap()->AllocateJSObjectFromMap(*map), | 1704 isolate()->heap()->AllocateJSObjectFromMap(*map), |
1705 JSGeneratorObject); | 1705 JSGeneratorObject); |
1706 } | 1706 } |
1707 | 1707 |
1708 Handle<JSModule> Factory::NewJSModule() { | 1708 Handle<Module> Factory::NewModule(int min_size) { |
1709 Handle<JSModule> module = | 1709 Handle<Module> module = Handle<Module>::cast(NewStruct(MODULE_TYPE)); |
1710 Handle<JSModule>::cast(NewJSObjectFromMap(js_module_map(), TENURED)); | 1710 Handle<ObjectHashTable> exports = ObjectHashTable::New(isolate(), min_size); |
| 1711 module->set_exports(*exports); |
1711 return module; | 1712 return module; |
1712 } | 1713 } |
1713 | 1714 |
1714 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, | 1715 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, |
1715 PretenureFlag pretenure) { | 1716 PretenureFlag pretenure) { |
1716 Handle<JSFunction> array_buffer_fun( | 1717 Handle<JSFunction> array_buffer_fun( |
1717 shared == SharedFlag::kShared | 1718 shared == SharedFlag::kShared |
1718 ? isolate()->native_context()->shared_array_buffer_fun() | 1719 ? isolate()->native_context()->shared_array_buffer_fun() |
1719 : isolate()->native_context()->array_buffer_fun()); | 1720 : isolate()->native_context()->array_buffer_fun()); |
1720 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( | 1721 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 Handle<AccessorInfo> prototype = | 2532 Handle<AccessorInfo> prototype = |
2532 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2533 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2533 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2534 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2534 prototype, attribs); | 2535 prototype, attribs); |
2535 map->AppendDescriptor(&d); | 2536 map->AppendDescriptor(&d); |
2536 } | 2537 } |
2537 } | 2538 } |
2538 | 2539 |
2539 } // namespace internal | 2540 } // namespace internal |
2540 } // namespace v8 | 2541 } // namespace v8 |
OLD | NEW |