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

Unified Diff: src/objects.cc

Issue 2839623003: [modules] Factor out cell load into helper function. (Closed)
Patch Set: Assign cell in unreachable path. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 5636d826064c44024bbdef0bc7eaeb81177c6457..ae7eb7b89a745e44f8bcdc0aad154147b1c16c1f 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -20147,33 +20147,34 @@ void Module::CreateExport(Handle<Module> module, int cell_index,
module->set_exports(*exports);
}
-Handle<Object> Module::LoadVariable(Handle<Module> module, int cell_index) {
- Isolate* isolate = module->GetIsolate();
- Handle<Object> object;
+Cell* Module::GetCell(int cell_index) {
+ DisallowHeapAllocation no_gc;
+ Object* cell;
switch (ModuleDescriptor::GetCellIndexKind(cell_index)) {
case ModuleDescriptor::kImport:
- object = handle(module->regular_imports()->get(ImportIndex(cell_index)),
- isolate);
+ cell = regular_imports()->get(ImportIndex(cell_index));
break;
case ModuleDescriptor::kExport:
- object = handle(module->regular_exports()->get(ExportIndex(cell_index)),
- isolate);
+ cell = regular_exports()->get(ExportIndex(cell_index));
break;
case ModuleDescriptor::kInvalid:
UNREACHABLE();
+ cell = nullptr;
break;
}
- return handle(Handle<Cell>::cast(object)->value(), isolate);
+ return Cell::cast(cell);
+}
+
+Handle<Object> Module::LoadVariable(Handle<Module> module, int cell_index) {
+ Isolate* isolate = module->GetIsolate();
+ return handle(module->GetCell(cell_index)->value(), isolate);
}
void Module::StoreVariable(Handle<Module> module, int cell_index,
Handle<Object> value) {
- Isolate* isolate = module->GetIsolate();
DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index),
ModuleDescriptor::kExport);
- Handle<Object> object(module->regular_exports()->get(ExportIndex(cell_index)),
- isolate);
- Handle<Cell>::cast(object)->set_value(*value);
+ module->GetCell(cell_index)->set_value(*value);
}
MaybeHandle<Cell> Module::ResolveImport(Handle<Module> module,
« 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