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 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) { | 1755 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) { |
1756 Handle<ModuleInfo> module_info(code->scope_info()->ModuleDescriptorInfo(), | 1756 Handle<ModuleInfo> module_info(code->scope_info()->ModuleDescriptorInfo(), |
1757 isolate()); | 1757 isolate()); |
1758 Handle<ObjectHashTable> exports = | 1758 Handle<ObjectHashTable> exports = |
1759 ObjectHashTable::New(isolate(), module_info->regular_exports()->length()); | 1759 ObjectHashTable::New(isolate(), module_info->regular_exports()->length()); |
1760 int requested_modules_length = module_info->module_requests()->length(); | 1760 int requested_modules_length = module_info->module_requests()->length(); |
1761 Handle<FixedArray> requested_modules = | 1761 Handle<FixedArray> requested_modules = |
1762 requested_modules_length > 0 ? NewFixedArray(requested_modules_length) | 1762 requested_modules_length > 0 ? NewFixedArray(requested_modules_length) |
1763 : empty_fixed_array(); | 1763 : empty_fixed_array(); |
1764 | 1764 |
1765 // To make it easy to hash Modules, we set a new symbol as the name of | |
1766 // SharedFunctionInfo representing this Module. | |
1767 Handle<Symbol> name_symbol = NewSymbol(); | |
1768 code->set_name(*name_symbol); | |
1769 | |
1770 Handle<Module> module = Handle<Module>::cast(NewStruct(MODULE_TYPE)); | 1765 Handle<Module> module = Handle<Module>::cast(NewStruct(MODULE_TYPE)); |
1771 module->set_code(*code); | 1766 module->set_code(*code); |
1772 module->set_embedder_data(isolate()->heap()->undefined_value()); | 1767 module->set_embedder_data(isolate()->heap()->undefined_value()); |
1773 module->set_exports(*exports); | 1768 module->set_exports(*exports); |
1774 module->set_flags(0); | 1769 module->set_flags(0); |
1775 module->set_module_namespace(isolate()->heap()->undefined_value()); | 1770 module->set_module_namespace(isolate()->heap()->undefined_value()); |
1776 module->set_requested_modules(*requested_modules); | 1771 module->set_requested_modules(*requested_modules); |
| 1772 module->set_embedder_data(isolate()->heap()->undefined_value()); |
| 1773 module->set_hash(isolate()->GenerateIdentityHash(Smi::kMaxValue)); |
1777 return module; | 1774 return module; |
1778 } | 1775 } |
1779 | 1776 |
1780 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, | 1777 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, |
1781 PretenureFlag pretenure) { | 1778 PretenureFlag pretenure) { |
1782 Handle<JSFunction> array_buffer_fun( | 1779 Handle<JSFunction> array_buffer_fun( |
1783 shared == SharedFlag::kShared | 1780 shared == SharedFlag::kShared |
1784 ? isolate()->native_context()->shared_array_buffer_fun() | 1781 ? isolate()->native_context()->shared_array_buffer_fun() |
1785 : isolate()->native_context()->array_buffer_fun()); | 1782 : isolate()->native_context()->array_buffer_fun()); |
1786 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( | 1783 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 Handle<AccessorInfo> prototype = | 2605 Handle<AccessorInfo> prototype = |
2609 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2606 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2610 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2607 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2611 prototype, attribs); | 2608 prototype, attribs); |
2612 map->AppendDescriptor(&d); | 2609 map->AppendDescriptor(&d); |
2613 } | 2610 } |
2614 } | 2611 } |
2615 | 2612 |
2616 } // namespace internal | 2613 } // namespace internal |
2617 } // namespace v8 | 2614 } // namespace v8 |
OLD | NEW |