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

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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 792 Handle<Context> Factory::NewModuleContext(Handle<JSModule> module,
793 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { 793 Handle<JSFunction> function,
794 Handle<ScopeInfo> scope_info) {
794 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); 795 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
795 Handle<FixedArray> array = 796 Handle<FixedArray> array =
796 NewFixedArray(scope_info->ContextLength(), TENURED); 797 NewFixedArray(scope_info->ContextLength(), TENURED);
797 array->set_map_no_write_barrier(*module_context_map()); 798 array->set_map_no_write_barrier(*module_context_map());
798 // Instance link will be set later.
799 Handle<Context> context = Handle<Context>::cast(array); 799 Handle<Context> context = Handle<Context>::cast(array);
800 context->set_extension(*the_hole_value()); 800 context->set_closure(*function);
801 context->set_previous(function->context());
802 context->set_extension(*module);
803 context->set_native_context(function->native_context());
804 DCHECK(context->IsModuleContext());
801 return context; 805 return context;
802 } 806 }
803 807
804 808
805 Handle<Context> Factory::NewFunctionContext(int length, 809 Handle<Context> Factory::NewFunctionContext(int length,
806 Handle<JSFunction> function) { 810 Handle<JSFunction> function) {
807 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); 811 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
808 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); 812 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
809 Handle<FixedArray> array = NewFixedArray(length); 813 Handle<FixedArray> array = NewFixedArray(length);
810 array->set_map_no_write_barrier(*function_context_map()); 814 array->set_map_no_write_barrier(*function_context_map());
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 } 1387 }
1384 1388
1385 1389
1386 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1390 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1387 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1391 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1388 array->set_map_no_write_barrier(*scope_info_map()); 1392 array->set_map_no_write_barrier(*scope_info_map());
1389 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1393 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1390 return scope_info; 1394 return scope_info;
1391 } 1395 }
1392 1396
1397 Handle<ModuleInfoEntry> Factory::NewModuleInfoEntry() {
1398 Handle<FixedArray> array = NewFixedArray(ModuleInfoEntry::kLength, TENURED);
1399 array->set_map_no_write_barrier(*module_info_entry_map());
1400 return Handle<ModuleInfoEntry>::cast(array);
1401 }
1402
1393 Handle<ModuleInfo> Factory::NewModuleInfo() { 1403 Handle<ModuleInfo> Factory::NewModuleInfo() {
1394 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); 1404 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED);
1395 array->set_map_no_write_barrier(*module_info_map()); 1405 array->set_map_no_write_barrier(*module_info_map());
1396 Handle<ModuleInfo> module_info = Handle<ModuleInfo>::cast(array); 1406 return Handle<ModuleInfo>::cast(array);
1397 return module_info;
1398 } 1407 }
1399 1408
1400 Handle<JSObject> Factory::NewExternal(void* value) { 1409 Handle<JSObject> Factory::NewExternal(void* value) {
1401 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1410 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1402 Handle<JSObject> external = NewJSObjectFromMap(external_map()); 1411 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1403 external->SetInternalField(0, *foreign); 1412 external->SetInternalField(0, *foreign);
1404 return external; 1413 return external;
1405 } 1414 }
1406 1415
1407 1416
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 DCHECK(function->shared()->is_resumable()); 1689 DCHECK(function->shared()->is_resumable());
1681 JSFunction::EnsureHasInitialMap(function); 1690 JSFunction::EnsureHasInitialMap(function);
1682 Handle<Map> map(function->initial_map()); 1691 Handle<Map> map(function->initial_map());
1683 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); 1692 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
1684 CALL_HEAP_FUNCTION( 1693 CALL_HEAP_FUNCTION(
1685 isolate(), 1694 isolate(),
1686 isolate()->heap()->AllocateJSObjectFromMap(*map), 1695 isolate()->heap()->AllocateJSObjectFromMap(*map),
1687 JSGeneratorObject); 1696 JSGeneratorObject);
1688 } 1697 }
1689 1698
1699 Handle<JSModule> Factory::NewJSModule() {
1700 Handle<JSModule> module =
1701 Handle<JSModule>::cast(NewJSObjectFromMap(js_module_map(), TENURED));
1702 return module;
1703 }
1690 1704
1691 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, 1705 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared,
1692 PretenureFlag pretenure) { 1706 PretenureFlag pretenure) {
1693 Handle<JSFunction> array_buffer_fun( 1707 Handle<JSFunction> array_buffer_fun(
1694 shared == SharedFlag::kShared 1708 shared == SharedFlag::kShared
1695 ? isolate()->native_context()->shared_array_buffer_fun() 1709 ? isolate()->native_context()->shared_array_buffer_fun()
1696 : isolate()->native_context()->array_buffer_fun()); 1710 : isolate()->native_context()->array_buffer_fun());
1697 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( 1711 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject(
1698 *array_buffer_fun, pretenure), 1712 *array_buffer_fun, pretenure),
1699 JSArrayBuffer); 1713 JSArrayBuffer);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 Handle<AccessorInfo> prototype = 2522 Handle<AccessorInfo> prototype =
2509 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2523 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2510 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2524 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2511 prototype, attribs); 2525 prototype, attribs);
2512 map->AppendDescriptor(&d); 2526 map->AppendDescriptor(&d);
2513 } 2527 }
2514 } 2528 }
2515 2529
2516 } // namespace internal 2530 } // namespace internal
2517 } // namespace v8 2531 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698