Skip to content

Commit

Permalink
Make _Unbound special in all loaded built-in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed Mar 23, 2023
1 parent df60f02 commit ea54efe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void rewriteBytecode(Thread* thread, const Function& function) {
RawObject module = function.moduleObject();
bool is_builtin_module =
module.isModule() &&
Module::cast(module).id() == thread->runtime()->builtinsModuleId();
Module::cast(module).id() <= runtime->lastBuiltinModuleId();
for (word i = 0; i < num_opcodes;) {
BytecodeOp op = nextBytecodeOp(bytecode, &i);
word previous_index = i - 1;
Expand Down
4 changes: 4 additions & 0 deletions runtime/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,10 @@ void Runtime::initializeModules(Thread* thread) {
"failed to initialize built-in module %s",
Symbols::predefinedSymbolAt(id));
}
last_builtin_module_id_ =
Module::cast(
findModuleById(kRequiredModules[ARRAYSIZE(kRequiredModules) - 1]))
.id();
}

RawObject Runtime::initialize(Thread* thread) {
Expand Down
5 changes: 5 additions & 0 deletions runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ class Runtime {
builtins_module_id_ = builtins_module_id;
}

word lastBuiltinModuleId() { return last_builtin_module_id_; }

RawObject moduleDunderGetattribute() { return module_dunder_getattribute_; }
RawObject objectDunderClass() { return object_dunder_class_; }
RawObject objectDunderEq() { return object_dunder_eq_; }
Expand Down Expand Up @@ -954,6 +956,9 @@ class Runtime {
// The ID of builtins module.
// TODO(T64005113): Remove this once we mark individual functions.
word builtins_module_id_ = -1;
// The ID of the last built-in module initialized by the runtime. Used to
// give special properties to built-in modules.
word last_builtin_module_id_ = -1;

// Internal-only types, for which the Layout has a different described type
RawObject large_bytes_ = NoneType::object();
Expand Down

0 comments on commit ea54efe

Please sign in to comment.