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

Side by Side Diff: src/factory.cc

Issue 2328283002: Revert of [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
« no previous file with comments | « src/factory.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Handle<Context> Factory::NewModuleContext(Handle<JSModule> module, 792
793 Handle<JSFunction> function, 793 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
794 Handle<ScopeInfo> scope_info) {
795 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); 794 DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
796 Handle<FixedArray> array = 795 Handle<FixedArray> array =
797 NewFixedArray(scope_info->ContextLength(), TENURED); 796 NewFixedArray(scope_info->ContextLength(), TENURED);
798 array->set_map_no_write_barrier(*module_context_map()); 797 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_closure(*function); 800 context->set_extension(*the_hole_value());
801 context->set_previous(function->context());
802 context->set_extension(*module);
803 context->set_native_context(function->native_context());
804 DCHECK(context->IsModuleContext());
805 return context; 801 return context;
806 } 802 }
807 803
808 804
809 Handle<Context> Factory::NewFunctionContext(int length, 805 Handle<Context> Factory::NewFunctionContext(int length,
810 Handle<JSFunction> function) { 806 Handle<JSFunction> function) {
811 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE); 807 DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
812 DCHECK(length >= Context::MIN_CONTEXT_SLOTS); 808 DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
813 Handle<FixedArray> array = NewFixedArray(length); 809 Handle<FixedArray> array = NewFixedArray(length);
814 array->set_map_no_write_barrier(*function_context_map()); 810 array->set_map_no_write_barrier(*function_context_map());
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1391 }
1396 1392
1397 1393
1398 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1394 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1399 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1395 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1400 array->set_map_no_write_barrier(*scope_info_map()); 1396 array->set_map_no_write_barrier(*scope_info_map());
1401 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1397 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1402 return scope_info; 1398 return scope_info;
1403 } 1399 }
1404 1400
1405 Handle<ModuleInfoEntry> Factory::NewModuleInfoEntry() {
1406 Handle<FixedArray> array = NewFixedArray(ModuleInfoEntry::kLength, TENURED);
1407 array->set_map_no_write_barrier(*module_info_entry_map());
1408 return Handle<ModuleInfoEntry>::cast(array);
1409 }
1410
1411 Handle<ModuleInfo> Factory::NewModuleInfo() { 1401 Handle<ModuleInfo> Factory::NewModuleInfo() {
1412 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); 1402 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED);
1413 array->set_map_no_write_barrier(*module_info_map()); 1403 array->set_map_no_write_barrier(*module_info_map());
1414 return Handle<ModuleInfo>::cast(array); 1404 Handle<ModuleInfo> module_info = Handle<ModuleInfo>::cast(array);
1405 return module_info;
1415 } 1406 }
1416 1407
1417 Handle<JSObject> Factory::NewExternal(void* value) { 1408 Handle<JSObject> Factory::NewExternal(void* value) {
1418 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1409 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1419 Handle<JSObject> external = NewJSObjectFromMap(external_map()); 1410 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1420 external->SetInternalField(0, *foreign); 1411 external->SetInternalField(0, *foreign);
1421 return external; 1412 return external;
1422 } 1413 }
1423 1414
1424 1415
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 DCHECK(function->shared()->is_resumable()); 1688 DCHECK(function->shared()->is_resumable());
1698 JSFunction::EnsureHasInitialMap(function); 1689 JSFunction::EnsureHasInitialMap(function);
1699 Handle<Map> map(function->initial_map()); 1690 Handle<Map> map(function->initial_map());
1700 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); 1691 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
1701 CALL_HEAP_FUNCTION( 1692 CALL_HEAP_FUNCTION(
1702 isolate(), 1693 isolate(),
1703 isolate()->heap()->AllocateJSObjectFromMap(*map), 1694 isolate()->heap()->AllocateJSObjectFromMap(*map),
1704 JSGeneratorObject); 1695 JSGeneratorObject);
1705 } 1696 }
1706 1697
1707 Handle<JSModule> Factory::NewJSModule() {
1708 Handle<JSModule> module =
1709 Handle<JSModule>::cast(NewJSObjectFromMap(js_module_map(), TENURED));
1710 return module;
1711 }
1712 1698
1713 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, 1699 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared,
1714 PretenureFlag pretenure) { 1700 PretenureFlag pretenure) {
1715 Handle<JSFunction> array_buffer_fun( 1701 Handle<JSFunction> array_buffer_fun(
1716 shared == SharedFlag::kShared 1702 shared == SharedFlag::kShared
1717 ? isolate()->native_context()->shared_array_buffer_fun() 1703 ? isolate()->native_context()->shared_array_buffer_fun()
1718 : isolate()->native_context()->array_buffer_fun()); 1704 : isolate()->native_context()->array_buffer_fun());
1719 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( 1705 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject(
1720 *array_buffer_fun, pretenure), 1706 *array_buffer_fun, pretenure),
1721 JSArrayBuffer); 1707 JSArrayBuffer);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 Handle<AccessorInfo> prototype = 2516 Handle<AccessorInfo> prototype =
2531 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2517 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2532 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2518 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2533 prototype, attribs); 2519 prototype, attribs);
2534 map->AppendDescriptor(&d); 2520 map->AppendDescriptor(&d);
2535 } 2521 }
2536 } 2522 }
2537 2523
2538 } // namespace internal 2524 } // namespace internal
2539 } // namespace v8 2525 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698