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

Side by Side Diff: src/objects.cc

Issue 2839623003: [modules] Factor out cell load into helper function. (Closed)
Patch Set: Make GetCell a method. Created 3 years, 8 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/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 20129 matching lines...) Expand 10 before | Expand all | Expand 10 after
20140 20140
20141 Handle<ObjectHashTable> exports(module->exports(), isolate); 20141 Handle<ObjectHashTable> exports(module->exports(), isolate);
20142 for (int i = 0, n = names->length(); i < n; ++i) { 20142 for (int i = 0, n = names->length(); i < n; ++i) {
20143 Handle<String> name(String::cast(names->get(i)), isolate); 20143 Handle<String> name(String::cast(names->get(i)), isolate);
20144 DCHECK(exports->Lookup(name)->IsTheHole(isolate)); 20144 DCHECK(exports->Lookup(name)->IsTheHole(isolate));
20145 exports = ObjectHashTable::Put(exports, name, cell); 20145 exports = ObjectHashTable::Put(exports, name, cell);
20146 } 20146 }
20147 module->set_exports(*exports); 20147 module->set_exports(*exports);
20148 } 20148 }
20149 20149
20150 Handle<Object> Module::LoadVariable(Handle<Module> module, int cell_index) { 20150 Cell* Module::GetCell(int cell_index) {
20151 Isolate* isolate = module->GetIsolate(); 20151 DisallowHeapAllocation no_gc;
20152 Handle<Object> object; 20152 Object* cell;
Michael Starzinger 2017/05/03 17:08:02 nit: I have the sneaking suspicion that some compi
20153 switch (ModuleDescriptor::GetCellIndexKind(cell_index)) { 20153 switch (ModuleDescriptor::GetCellIndexKind(cell_index)) {
20154 case ModuleDescriptor::kImport: 20154 case ModuleDescriptor::kImport:
20155 object = handle(module->regular_imports()->get(ImportIndex(cell_index)), 20155 cell = regular_imports()->get(ImportIndex(cell_index));
20156 isolate);
20157 break; 20156 break;
20158 case ModuleDescriptor::kExport: 20157 case ModuleDescriptor::kExport:
20159 object = handle(module->regular_exports()->get(ExportIndex(cell_index)), 20158 cell = regular_exports()->get(ExportIndex(cell_index));
20160 isolate);
20161 break; 20159 break;
20162 case ModuleDescriptor::kInvalid: 20160 case ModuleDescriptor::kInvalid:
20163 UNREACHABLE(); 20161 UNREACHABLE();
20164 break; 20162 break;
20165 } 20163 }
20166 return handle(Handle<Cell>::cast(object)->value(), isolate); 20164 return Cell::cast(cell);
20165 }
20166
20167 Handle<Object> Module::LoadVariable(Handle<Module> module, int cell_index) {
20168 Isolate* isolate = module->GetIsolate();
20169 return handle(module->GetCell(cell_index)->value(), isolate);
20167 } 20170 }
20168 20171
20169 void Module::StoreVariable(Handle<Module> module, int cell_index, 20172 void Module::StoreVariable(Handle<Module> module, int cell_index,
20170 Handle<Object> value) { 20173 Handle<Object> value) {
20171 Isolate* isolate = module->GetIsolate();
20172 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), 20174 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index),
20173 ModuleDescriptor::kExport); 20175 ModuleDescriptor::kExport);
20174 Handle<Object> object(module->regular_exports()->get(ExportIndex(cell_index)), 20176 module->GetCell(cell_index)->set_value(*value);
20175 isolate);
20176 Handle<Cell>::cast(object)->set_value(*value);
20177 } 20177 }
20178 20178
20179 MaybeHandle<Cell> Module::ResolveImport(Handle<Module> module, 20179 MaybeHandle<Cell> Module::ResolveImport(Handle<Module> module,
20180 Handle<String> name, int module_request, 20180 Handle<String> name, int module_request,
20181 MessageLocation loc, bool must_resolve, 20181 MessageLocation loc, bool must_resolve,
20182 Module::ResolveSet* resolve_set) { 20182 Module::ResolveSet* resolve_set) {
20183 Isolate* isolate = module->GetIsolate(); 20183 Isolate* isolate = module->GetIsolate();
20184 Handle<Module> requested_module( 20184 Handle<Module> requested_module(
20185 Module::cast(module->requested_modules()->get(module_request)), isolate); 20185 Module::cast(module->requested_modules()->get(module_request)), isolate);
20186 return Module::ResolveExport(requested_module, name, loc, must_resolve, 20186 return Module::ResolveExport(requested_module, name, loc, must_resolve,
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
20670 // depend on this. 20670 // depend on this.
20671 return DICTIONARY_ELEMENTS; 20671 return DICTIONARY_ELEMENTS;
20672 } 20672 }
20673 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20673 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20674 return kind; 20674 return kind;
20675 } 20675 }
20676 } 20676 }
20677 20677
20678 } // namespace internal 20678 } // namespace internal
20679 } // namespace v8 20679 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698