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

Side by Side Diff: src/factory.cc

Issue 2395233003: [modules] Give Module an internal [hash] field (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | src/heap/heap.cc » ('j') | src/objects.h » ('J')
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 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) { 1751 Handle<Module> Factory::NewModule(Handle<SharedFunctionInfo> code) {
1752 Handle<ModuleInfo> module_info(code->scope_info()->ModuleDescriptorInfo(), 1752 Handle<ModuleInfo> module_info(code->scope_info()->ModuleDescriptorInfo(),
1753 isolate()); 1753 isolate());
1754 Handle<ObjectHashTable> exports = 1754 Handle<ObjectHashTable> exports =
1755 ObjectHashTable::New(isolate(), module_info->regular_exports()->length()); 1755 ObjectHashTable::New(isolate(), module_info->regular_exports()->length());
1756 int requested_modules_length = module_info->module_requests()->length(); 1756 int requested_modules_length = module_info->module_requests()->length();
1757 Handle<FixedArray> requested_modules = 1757 Handle<FixedArray> requested_modules =
1758 requested_modules_length > 0 ? NewFixedArray(requested_modules_length) 1758 requested_modules_length > 0 ? NewFixedArray(requested_modules_length)
1759 : empty_fixed_array(); 1759 : empty_fixed_array();
1760 1760
1761 // To make it easy to hash Modules, we set a new symbol as the name of
1762 // SharedFunctionInfo representing this Module.
1763 Handle<Symbol> name_symbol = NewSymbol();
1764 code->set_name(*name_symbol);
1765
1766 Handle<Module> module = Handle<Module>::cast(NewStruct(MODULE_TYPE)); 1761 Handle<Module> module = Handle<Module>::cast(NewStruct(MODULE_TYPE));
1767 module->set_code(*code); 1762 module->set_code(*code);
1768 module->set_exports(*exports); 1763 module->set_exports(*exports);
1769 module->set_requested_modules(*requested_modules); 1764 module->set_requested_modules(*requested_modules);
1770 module->set_flags(0); 1765 module->set_flags(0);
1771 module->set_embedder_data(isolate()->heap()->undefined_value()); 1766 module->set_embedder_data(isolate()->heap()->undefined_value());
1767 module->set_hash(isolate()->GenerateIdentityHash(Smi::kMaxValue));
1772 return module; 1768 return module;
1773 } 1769 }
1774 1770
1775 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared, 1771 Handle<JSArrayBuffer> Factory::NewJSArrayBuffer(SharedFlag shared,
1776 PretenureFlag pretenure) { 1772 PretenureFlag pretenure) {
1777 Handle<JSFunction> array_buffer_fun( 1773 Handle<JSFunction> array_buffer_fun(
1778 shared == SharedFlag::kShared 1774 shared == SharedFlag::kShared
1779 ? isolate()->native_context()->shared_array_buffer_fun() 1775 ? isolate()->native_context()->shared_array_buffer_fun()
1780 : isolate()->native_context()->array_buffer_fun()); 1776 : isolate()->native_context()->array_buffer_fun());
1781 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject( 1777 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateJSObject(
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 Handle<AccessorInfo> prototype = 2599 Handle<AccessorInfo> prototype =
2604 Accessors::FunctionPrototypeInfo(isolate(), attribs); 2600 Accessors::FunctionPrototypeInfo(isolate(), attribs);
2605 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), 2601 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())),
2606 prototype, attribs); 2602 prototype, attribs);
2607 map->AppendDescriptor(&d); 2603 map->AppendDescriptor(&d);
2608 } 2604 }
2609 } 2605 }
2610 2606
2611 } // namespace internal 2607 } // namespace internal
2612 } // namespace v8 2608 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698