8000 gh-115999: Add free-threaded specialization for ``TO_BOOL`` by corona10 · Pull Request #126616 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115999: Add free-threaded specialization for TO_BOOL #126616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make set cache as atomic operation
  • Loading branch information
corona10 committed Nov 9, 2024
commit 67983665ded9c9395d6f78a87e7331f7a99c004b
26 changes: 25 additions & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,21 @@
#endif
}

static inline int
set_cache_verison(uint16_t *old_version, uint32_t new_version)
{
#ifdef Py_GIL_DISABLED
uint32_t old_version_val = read_u32(old_version);
if (!_Py_atomic_compare_exchange_uint32((uint32_t *)old_version, &old_version_val, new_version)) {
return 0;
}
return 1;
#else
write_u32(cache, new_version);

Check failure on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'cache': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'function': 'uint16_t *' differs in levels of indirection from 'int' [D:\ 8000 a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'write_u32': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

'cache': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

'function': 'uint16_t *' differs in levels of indirection from 'int' [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check warning on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

'write_u32': different types for formal and actual parameter 1 [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

Check failure on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘cache’ undeclared (first use in this function)

Check failure on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04)

‘cache’ undeclared (first use in this function)

Check failure on line 702 in Python/specialize.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-24.04)

‘cache’ undeclared (first use in this function)
return 1;
#endif
}

static inline void
set_counter(_Py_BackoffCounter *counter, _Py_BackoffCounter value)
{
Expand Down Expand Up @@ -2742,8 +2757,17 @@
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
return;
}
#ifdef Py_GIL_DISABLED
if (read_u32(cache->version) > version) {
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
return;
}
#endif
if (!set_cache_verison(cache->version, version)) {
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
return;
}
specialize(instr, TO_BOOL_ALWAYS_TRUE);
write_u32(cache->version, version);
assert(version);
return;
}
Expand Down
Loading
0