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

Side by Side Diff: src/factory.cc

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: Disable module tests for deopt fuzzer. 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 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1395 }
1392 1396
1393 1397
1394 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1398 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1395 Handle<FixedArray> array = NewFixedArray(length, TENURED); 1399 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1396 array->set_map_no_write_barrier(*scope_info_map()); 1400 array->set_map_no_write_barrier(*scope_info_map());
1397 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); 1401 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1398 return scope_info; 1402 return scope_info;
1399 } 1403 }
1400 1404
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
1401 Handle<ModuleInfo> Factory::NewModuleInfo() { 1411 Handle<ModuleInfo> Factory::NewModuleInfo() {
1402 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED); 1412 Handle<FixedArray> array = NewFixedArray(ModuleInfo::kLength, TENURED);
1403 array->set_map_no_write_barrier(*module_info_map()); 1413 array->set_map_no_write_barrier(*module_info_map());
1404 Handle<ModuleInfo> module_info = Handle<ModuleInfo>::cast(array); 1414 return Handle<ModuleInfo>::cast(array);
1405 return module_info;
1406 } 1415 }
1407 1416
1408 Handle<JSObject> Factory::NewExternal(void* value) { 1417 Handle<JSObject> Factory::NewExternal(void* value) {
1409 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value)); 1418 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1410 Handle<JSObject> external = NewJSObjectFromMap(external_map()); 1419 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1411 external->SetInternalField(0, *foreign); 1420 external->SetInternalField(0, *foreign);
1412 return external; 1421 return external;
1413 } 1422 }
1414 1423
1415 1424
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 DCHECK(function->shared()->is_resumable()); 1697 DCHECK(function->shared()->is_resumable());
1689 JSFunction::EnsureHasInitialMap(function); 1698 JSFunction::EnsureHasInitialMap(function);
1690 Handle<Map> map(function->initial_map()); 1699 Handle<Map> map(function->initial_map());
1691 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type()); 1700 DCHECK_EQ(JS_GENERATOR_OBJECT_TYPE, map->instance_type());
1692 CALL_HEAP_FUNCTION( 1701 CALL_HEAP_FUNCTION(
1693 isolate(), 1702 isolate(),
1694 isolate()->heap()->AllocateJSObjectFromMap(*map), 1703 isolate()->heap()->AllocateJSObjectFromMap(*map),
1695 JSGeneratorObject); 1704 JSGeneratorObject);
1696 } 1705 }
1697 1706
1707 Handle<JSModule> Factory::NewJSModule() {
1708 Handle<JSModule> module =
1709 Handle<JSModule>::cast(NewJSObjectFromMap(js_module_map(), TENURED));
1710 return module;
1711 }
1698 1712
1699 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, 1713 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared,
1700 PretenureFlag pretenure) { 1714 PretenureFlag pretenure) {
1701 Handle<JSFunction> array_buffer_fun( 1715 Handle<JSFunction> array_buffer_fun(
1702 shared == SharedFlag::kShared 1716 shared == SharedFlag::kShared
1703 ? isolate()->native_context()->shared_array_buffer_fun() 1717 ? isolate()->native_context()->shared_array_buffer_fun()
1704 : isolate()->native_context()->array_buffer_fun()); 1718 : isolate()->native_context()->array_buffer_fun());
1705 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( 1719 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject(
1706 *array_buffer_fun, pretenure), 1720 *array_buffer_fun, pretenure),
1707 JSArrayBuffer); 1721 JSArrayBuffer);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 Handle<AccessorInfo> prototype = 2530 Handle<AccessorInfo> prototype =
2517 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2531 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2518 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2532 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2519 prototype, attribs); 2533 prototype, attribs);
2520 map->AppendDescriptor(&d); 2534 map->AppendDescriptor(&d);
2521 } 2535 }
2522 } 2536 }
2523 2537
2524 } // namespace internal 2538 } // namespace internal
2525 } // namespace v8 2539 } // 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