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

Side by Side Diff: src/factory.cc

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: . Created 4 years, 3 months 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
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/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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 785
786 Handle<ScriptContextTable> Factory::NewScriptContextTable() { 786 Handle<ScriptContextTable> Factory::NewScriptContextTable() {
787 Handle<FixedArray> array = NewFixedArray(1); 787 Handle<FixedArray> array = NewFixedArray(1);
788 array->set_map_no_write_barrier(*script_context_table_map()); 788 array->set_map_no_write_barrier(*script_context_table_map());
789 Handle<ScriptContextTable> context_table = 789 Handle<ScriptContextTable> context_table =
790 Handle<ScriptContextTable>::cast(array); 790 Handle<ScriptContextTable>::cast(array);
791 context_table->set_used(0); 791 context_table->set_used(0);
792 return context_table; 792 return context_table;
793 } 793 }
794 794
795 795 Handle<Context> Factory::NewModuleContext(Handle<JSModule> module,
796 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { 796 Handle<JSFunction> function,
797 Handle<ScopeInfo> scope_info) {
797 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); 798 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
798 Handle<FixedArray> array = 799 Handle<FixedArray> array =
799 NewFixedArray(scope_info->ContextLength(), TENURED); 800 NewFixedArray(scope_info->ContextLength(), TENURED);
800 array->set_map_no_write_barrier(*module_context_map()); 801 array->set_map_no_write_barrier(*module_context_map());
801 // Instance link will be set later.
802 Handle<Context> context = Handle<Context>::cast(array); 802 Handle<Context> context = Handle<Context>::cast(array);
803 context->set_extension(*the_hole_value()); 803 context->set_closure(*function);
804 context->set_previous(function->context());
805 context->set_extension(*module);
806 context->set_native_context(function->native_context());
807 DCHECK(context->IsModuleContext());
804 return context; 808 return context;
805 } 809 }
806 810
807 811
808 Handle<Context> Factory::NewFunctionContext(int length, 812 Handle<Context> Factory::NewFunctionContext(int length,
809 Handle<JSFunction> function) { 813 Handle<JSFunction> function) {
810 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); 814 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
811 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); 815 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
812 Handle<FixedArray> array = NewFixedArray(length); 816 Handle<FixedArray> array = NewFixedArray(length);
813 array->set_map_no_write_barrier(*function_context_map()); 817 array->set_map_no_write_barrier(*function_context_map());
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 } 1390 }
1387 1391
1388 1392
1389 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1393 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1390 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1394 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1391 array->set_map_no_write_barrier(*scope_info_map()); 1395 array->set_map_no_write_barrier(*scope_info_map());
1392 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1396 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1393 return scope_info; 1397 return scope_info;
1394 } 1398 }
1395 1399
1400 Handle<ModuleInfoEntry> Factory::NewModuleInfoEntry() {
1401 Handle<FixedArray> array = NewFixedArray(ModuleInfoEntry::kLength, TENURED);
1402 array->set_map_no_write_barrier(*module_info_entry_map());
1403 return Handle<ModuleInfoEntry>::cast(array);
1404 }
1405
1396 Handle<ModuleInfo> Factory::NewModuleInfo() { 1406 Handle<ModuleInfo> Factory::NewModuleInfo() {
1397 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); 1407 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED);
1398 array->set_map_no_write_barrier(*module_info_map()); 1408 array->set_map_no_write_barrier(*module_info_map());
1399 Handle<ModuleInfo> module_info = Handle<ModuleInfo>::cast(array); 1409 return Handle<ModuleInfo>::cast(array);
1400 return module_info;
1401 } 1410 }
1402 1411
1403 Handle<JSObject> Factory::NewExternal(void* value) { 1412 Handle<JSObject> Factory::NewExternal(void* value) {
1404 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1413 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1405 Handle<JSObject> external = NewJSObjectFromMap(external_map()); 1414 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1406 external->SetInternalField(0, *foreign); 1415 external->SetInternalField(0, *foreign);
1407 return external; 1416 return external;
1408 } 1417 }
1409 1418
1410 1419
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 DCHECK(function->shared()->is_resumable()); 1692 DCHECK(function->shared()->is_resumable());
1684 JSFunction::EnsureHasInitialMap(function); 1693 JSFunction::EnsureHasInitialMap(function);
1685 Handle<Map> map(function->initial_map()); 1694 Handle<Map> map(function->initial_map());
1686 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); 1695 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
1687 CALL_HEAP_FUNCTION( 1696 CALL_HEAP_FUNCTION(
1688 isolate(), 1697 isolate(),
1689 isolate()->heap()->AllocateJSObjectFromMap(*map), 1698 isolate()->heap()->AllocateJSObjectFromMap(*map),
1690 JSGeneratorObject); 1699 JSGeneratorObject);
1691 } 1700 }
1692 1701
1702 // XXX
1703 Handle<JSModule> Factory::NewJSModule() {
1704 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize);
adamk 2016/09/01 23:13:34 As discussed offline, the module map should in the
neis 2016/09/02 11:32:58 Done. But I can't claim I really understand what I
1705 // Allocate the object based on the map.
1706 Handle<JSModule> module =
1707 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED));
1708 return module;
1709 }
1693 1710
1694 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, 1711 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared,
1695 PretenureFlag pretenure) { 1712 PretenureFlag pretenure) {
1696 Handle<JSFunction> array_buffer_fun( 1713 Handle<JSFunction> array_buffer_fun(
1697 shared == SharedFlag::kShared 1714 shared == SharedFlag::kShared
1698 ? isolate()->native_context()->shared_array_buffer_fun() 1715 ? isolate()->native_context()->shared_array_buffer_fun()
1699 : isolate()->native_context()->array_buffer_fun()); 1716 : isolate()->native_context()->array_buffer_fun());
1700 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( 1717 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject(
1701 *array_buffer_fun, pretenure), 1718 *array_buffer_fun, pretenure),
1702 JSArrayBuffer); 1719 JSArrayBuffer);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 Handle<AccessorInfo> prototype = 2528 Handle<AccessorInfo> prototype =
2512 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2529 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2513 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2530 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2514 prototype, attribs); 2531 prototype, attribs);
2515 map->AppendDescriptor(&d); 2532 map->AppendDescriptor(&d);
2516 } 2533 }
2517 } 2534 }
2518 2535
2519 } // namespace internal 2536 } // namespace internal
2520 } // namespace v8 2537 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698