gh-115999: Move specializer test from test_dis to test_opcache (gh-126498)

This commit is contained in:
Donghee Na 2024-11-07 05:23:47 +09:00 committed by GitHub
parent 9ce4fa0719
commit e56fd449fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 59 additions and 45 deletions

View file

@ -10,8 +10,7 @@ import sys
import types
import unittest
from test.support import (captured_stdout, requires_debug_ranges,
requires_specialization, requires_specialization_ft,
cpython_only)
requires_specialization, cpython_only)
from test.support.bytecode_helper import BytecodeTestCase
import opcode
@ -1261,27 +1260,6 @@ class DisTests(DisTestBase):
got = self.get_disassembly(load_test, adaptive=True)
self.do_disassembly_compare(got, dis_load_test_quickened_code)
@cpython_only
@requires_specialization_ft
def test_binary_specialize(self):
binary_op_quicken = """\
0 RESUME_CHECK 0
1 LOAD_NAME 0 (a)
LOAD_NAME 1 (b)
%s
RETURN_VALUE
"""
co_int = compile('a + b', "<int>", "eval")
self.code_quicken(lambda: exec(co_int, {}, {'a': 1, 'b': 2}))
got = self.get_disassembly(co_int, adaptive=True)
self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_INT 0 (+)")
co_unicode = compile('a + b', "<unicode>", "eval")
self.code_quicken(lambda: exec(co_unicode, {}, {'a': 'a', 'b': 'b'}))
got = self.get_disassembly(co_unicode, adaptive=True)
self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_UNICODE 0 (+)")
@cpython_only
@requires_specialization
def test_binary_subscr_specialize(self):
@ -1335,27 +1313,6 @@ class DisTests(DisTestBase):
got = self.get_disassembly(co, adaptive=True)
self.do_disassembly_compare(got, call_quicken)
@cpython_only
@requires_specialization_ft
def test_contains_specialize(self):
contains_op_quicken = """\
0 RESUME_CHECK 0
1 LOAD_NAME 0 (a)
LOAD_NAME 1 (b)
%s
RETURN_VALUE
"""
co_dict = compile('a in b', "<dict>", "eval")
self.code_quicken(lambda: exec(co_dict, {}, {'a': 1, 'b': {1: 5}}))
got = self.get_disassembly(co_dict, adaptive=True)
self.do_disassembly_compare(got, contains_op_quicken % "CONTAINS_OP_DICT 0 (in)")
co_set = compile('a in b', "<set>", "eval")
self.code_quicken(lambda: exec(co_set, {}, {'a': 1.0, 'b': {1, 2, 3}}))
got = self.get_disassembly(co_set, adaptive=True)
self.do_disassembly_compare(got, contains_op_quicken % "CONTAINS_OP_SET 0 (in)")
@cpython_only
@requires_specialization
def test_loop_quicken(self):