Skip to content

Commit 5bd535a

Browse files
committed
Revert "migrate keyword names to use a BoxedTuple of BoxedStrings"
This reverts commit 2f471db.
1 parent 2f471db commit 5bd535a

File tree

18 files changed

+131
-95
lines changed

18 files changed

+131
-95
lines changed

src/capi/typeobject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,8 @@ extern "C" void PyType_Modified(PyTypeObject* type) noexcept {
34543454

34553455
template <ExceptionStyle S>
34563456
static Box* tppProxyToTpCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2,
3457-
Box* arg3, Box** args, BoxedTuple* keyword_names) noexcept(S == CAPI) {
3457+
Box* arg3, Box** args,
3458+
const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI) {
34583459
ParamReceiveSpec paramspec(0, 0, true, true);
34593460
if (!argspec.has_kwargs && argspec.num_keywords == 0) {
34603461
paramspec.takes_kwargs = false;

src/capi/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class BoxedCApiFunction : public Box {
5454
static Box* __call__(BoxedCApiFunction* self, BoxedTuple* varargs, BoxedDict* kwargs);
5555
template <ExceptionStyle S>
5656
static Box* tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3,
57-
Box** args, BoxedTuple* keyword_names) noexcept(S == CAPI);
57+
Box** args, const std::vector<BoxedString*>* keyword_names) noexcept(S == CAPI);
5858

5959
static Box* getname(Box* b, void*) noexcept {
6060
RELEASE_ASSERT(b->cls == capifunc_cls, "");

src/codegen/ast_interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,9 @@ Value ASTInterpreter::visit_call(BST_Call* node) {
14571457
args_vars.push_back(v);
14581458
}
14591459

1460-
BoxedTuple* keyword_names = NULL;
1460+
const std::vector<BoxedString*>* keyword_names = NULL;
14611461
if (node->num_keywords)
1462-
keyword_names = (BoxedTuple*)getCodeConstants().getConstant(node->index_keyword_names);
1462+
keyword_names = getCodeConstants().getKeywordNames(node->index_keyword_names);
14631463

14641464
if (node->vreg_starargs != VREG_UNDEFINED) {
14651465
Value v = getVReg(node->vreg_starargs);

src/codegen/baseline_jit.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ RewriterVar* JitFragmentWriter::emitBinop(BST_stmt* node, RewriterVar* lhs, Rewr
245245
}
246246

247247
RewriterVar* JitFragmentWriter::emitCallattr(BST_stmt* node, RewriterVar* obj, BoxedString* attr, CallattrFlags flags,
248-
const llvm::ArrayRef<RewriterVar*> args, BoxedTuple* keyword_names) {
248+
const llvm::ArrayRef<RewriterVar*> args,
249+
const std::vector<BoxedString*>* keyword_names) {
249250
#if ENABLE_BASELINEJIT_ICS
250251
RewriterVar* attr_var = imm(attr);
251252
RewriterVar* flags_var = imm(flags.asInt());
@@ -518,7 +519,8 @@ RewriterVar* JitFragmentWriter::emitRepr(RewriterVar* v) {
518519
}
519520

520521
RewriterVar* JitFragmentWriter::emitRuntimeCall(BST_stmt* node, RewriterVar* obj, ArgPassSpec argspec,
521-
const llvm::ArrayRef<RewriterVar*> args, BoxedTuple* keyword_names) {
522+
const llvm::ArrayRef<RewriterVar*> args,
523+
const std::vector<BoxedString*>* keyword_names) {
522524
#if ENABLE_BASELINEJIT_ICS
523525
RewriterVar* argspec_var = imm(argspec.asInt());
524526
RewriterVar::SmallVector call_args;
@@ -1000,7 +1002,7 @@ void JitFragmentWriter::assertNameDefinedHelper(const char* id) {
10001002
}
10011003

10021004
Box* JitFragmentWriter::callattrHelper(Box* obj, BoxedString* attr, CallattrFlags flags, Box** args,
1003-
BoxedTuple* keyword_names) {
1005+
const std::vector<BoxedString*>* keyword_names) {
10041006
auto arg_tuple = getTupleFromArgsArray(&args[0], flags.argspec.totalPassed());
10051007
Box* r = callattr(obj, attr, flags, std::get<0>(arg_tuple), std::get<1>(arg_tuple), std::get<2>(arg_tuple),
10061008
std::get<3>(arg_tuple), keyword_names);
@@ -1058,7 +1060,8 @@ BORROWED(Box*) JitFragmentWriter::notHelper(Box* b) {
10581060
return b->nonzeroIC() ? Py_False : Py_True;
10591061
}
10601062

1061-
Box* JitFragmentWriter::runtimeCallHelper(Box* obj, ArgPassSpec argspec, Box** args, BoxedTuple* keyword_names) {
1063+
Box* JitFragmentWriter::runtimeCallHelper(Box* obj, ArgPassSpec argspec, Box** args,
1064+
const std::vector<BoxedString*>* keyword_names) {
10621065
auto arg_tuple = getTupleFromArgsArray(&args[0], argspec.totalPassed());
10631066
Box* r = runtimeCall(obj, argspec, std::get<0>(arg_tuple), std::get<1>(arg_tuple), std::get<2>(arg_tuple),
10641067
std::get<3>(arg_tuple), keyword_names);

src/codegen/baseline_jit.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class JitFragmentWriter : ICInfoManager, public Rewriter {
270270
RewriterVar* emitApplySlice(RewriterVar* target, RewriterVar* lower, RewriterVar* upper);
271271
RewriterVar* emitBinop(BST_stmt* node, RewriterVar* lhs, RewriterVar* rhs, int op_type);
272272
RewriterVar* emitCallattr(BST_stmt* node, RewriterVar* obj, BoxedString* attr, CallattrFlags flags,
273-
const llvm::ArrayRef<RewriterVar*> args, BoxedTuple* keyword_names);
273+
const llvm::ArrayRef<RewriterVar*> args, const std::vector<BoxedString*>* keyword_names);
274274
RewriterVar* emitCompare(BST_stmt* node, RewriterVar* lhs, RewriterVar* rhs, int op_type);
275275
RewriterVar* emitCreateDict();
276276
void emitDictSet(RewriterVar* dict, RewriterVar* k, RewriterVar* v);
@@ -301,7 +301,8 @@ class JitFragmentWriter : ICInfoManager, public Rewriter {
301301
RewriterVar* emitNotNonzero(RewriterVar* v);
302302
RewriterVar* emitRepr(RewriterVar* v);
303303
RewriterVar* emitRuntimeCall(BST_stmt* node, RewriterVar* obj, ArgPassSpec argspec,
304-
const llvm::ArrayRef<RewriterVar*> args, BoxedTuple* keyword_names);
304+
const llvm::ArrayRef<RewriterVar*> args,
305+
const std::vector<BoxedString*>* keyword_names);
305306
RewriterVar* emitUnaryop(RewriterVar* v, int op_type);
306307
std::vector<RewriterVar*> emitUnpackIntoArray(RewriterVar* v, uint64_t num);
307308
RewriterVar* emitYield(RewriterVar* v);
@@ -358,7 +359,8 @@ class JitFragmentWriter : ICInfoManager, public Rewriter {
358359
llvm::ArrayRef<RewriterVar*> additional_uses = {});
359360

360361
static void assertNameDefinedHelper(const char* id);
361-
static Box* callattrHelper(Box* obj, BoxedString* attr, CallattrFlags flags, Box** args, BoxedTuple* keyword_names);
362+
static Box* callattrHelper(Box* obj, BoxedString* attr, CallattrFlags flags, Box** args,
363+
const std::vector<BoxedString*>* keyword_names);
362364
static Box* createDictHelper(uint64_t num, Box** keys, Box** values);
363365
static Box* createListHelper(uint64_t num, Box** data);
364366
static Box* createSetHelper(uint64_t num, Box** data);
@@ -367,7 +369,8 @@ class JitFragmentWriter : ICInfoManager, public Rewriter {
367369
static BORROWED(Box*) hasnextHelper(Box* b);
368370
static BORROWED(Box*) nonzeroHelper(Box* b);
369371
static BORROWED(Box*) notHelper(Box* b);
370-
static Box* runtimeCallHelper(Box* obj, ArgPassSpec argspec, Box** args, BoxedTuple* keyword_names);
372+
static Box* runtimeCallHelper(Box* obj, ArgPassSpec argspec, Box** args,
373+
const std::vector<BoxedString*>* keyword_names);
371374

372375
void _emitGetLocal(RewriterVar* val_var, const char* name);
373376
void _emitJump(CFGBlock* b, RewriterVar* block_next, ExitInfo& exit_info);

src/codegen/compvars.cpp

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> {
138138

139139
CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ValuedCompilerVariable<RawInstanceMethod*>* var,
140140
ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
141-
BoxedTuple* keyword_names) override {
141+
const std::vector<BoxedString*>* keyword_names) override {
142142
std::vector<CompilerVariable*> new_args;
143143
new_args.push_back(var->getValue()->obj);
144144
new_args.insert(new_args.end(), args.begin(), args.end());
@@ -225,10 +225,11 @@ class UnknownType : public ConcreteCompilerType {
225225
CompilerVariable* getattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, BoxedString* attr,
226226
bool cls_only) override;
227227
CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, ArgPassSpec argspec,
228-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override;
228+
const std::vector<CompilerVariable*>& args,
229+
const std::vector<BoxedString*>* keyword_names) override;
229230
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, BoxedString* attr,
230231
CallattrFlags flags, const std::vector<CompilerVariable*>& args,
231-
BoxedTuple* keyword_names) override;
232+
const std::vector<BoxedString*>* keyword_names) override;
232233
ConcreteCompilerVariable* nonzero(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var) override;
233234
ConcreteCompilerVariable* unaryop(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
234235
AST_TYPE::AST_TYPE op_type) override;
@@ -592,11 +593,10 @@ CompilerVariable* UnknownType::getattr(IREmitter& emitter, const OpInfo& info, C
592593
return new ConcreteCompilerVariable(UNKNOWN, rtn_val);
593594
}
594595

595-
static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, llvm::Value* func,
596-
ExceptionStyle target_exception_style, void* func_addr,
597-
const std::vector<llvm::Value*>& other_args, ArgPassSpec argspec,
598-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names,
599-
ConcreteCompilerType* rtn_type, bool nullable_return = false) {
596+
static ConcreteCompilerVariable*
597+
_call(IREmitter& emitter, const OpInfo& info, llvm::Value* func, ExceptionStyle target_exception_style, void* func_addr,
598+
const std::vector<llvm::Value*>& other_args, ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
599+
const std::vector<BoxedString*>* keyword_names, ConcreteCompilerType* rtn_type, bool nullable_return = false) {
600600
bool pass_keyword_names = (keyword_names != nullptr);
601601
assert(pass_keyword_names == (argspec.num_keywords > 0));
602602

@@ -718,7 +718,7 @@ static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, l
718718

719719
CompilerVariable* UnknownType::call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
720720
ArgPassSpec argspec, const std::vector<CompilerVariable*>& args,
721-
BoxedTuple* keyword_names) {
721+
const std::vector<BoxedString*>* keyword_names) {
722722
bool pass_keywords = (argspec.num_keywords != 0);
723723
int npassed_args = argspec.totalPassed();
724724

@@ -750,7 +750,8 @@ CompilerVariable* UnknownType::call(IREmitter& emitter, const OpInfo& info, Conc
750750

751751
CompilerVariable* UnknownType::callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
752752
BoxedString* attr, CallattrFlags flags,
753-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) {
753+
const std::vector<CompilerVariable*>& args,
754+
const std::vector<BoxedString*>* keyword_names) {
754755
bool pass_keywords = (flags.argspec.num_keywords != 0);
755756
int npassed_args = flags.argspec.totalPassed();
756757

@@ -1162,7 +1163,8 @@ class IntType : public UnboxedType<llvm::Value*, IntType> {
11621163
}
11631164

11641165
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, BoxedString* attr, CallattrFlags flags,
1165-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
1166+
const std::vector<CompilerVariable*>& args,
1167+
const std::vector<BoxedString*>* keyword_names) override {
11661168
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_INT);
11671169
CompilerVariable* rtn = converted->callattr(emitter, info, attr, flags, args, keyword_names);
11681170
return rtn;
@@ -1449,7 +1451,8 @@ class FloatType : public UnboxedType<llvm::Value*, FloatType> {
14491451
}
14501452

14511453
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, BoxedString* attr, CallattrFlags flags,
1452-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
1454+
const std::vector<CompilerVariable*>& args,
1455+
const std::vector<BoxedString*>* keyword_names) override {
14531456
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_FLOAT);
14541457
CompilerVariable* rtn = converted->callattr(emitter, info, attr, flags, args, keyword_names);
14551458
return rtn;
@@ -1836,16 +1839,18 @@ class NormalObjectType : public ConcreteCompilerType {
18361839
}
18371840

18381841
CompilerVariable* call(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, ArgPassSpec argspec,
1839-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
1842+
const std::vector<CompilerVariable*>& args,
1843+
const std::vector<BoxedString*>* keyword_names) override {
18401844
ConcreteCompilerVariable* converted = var->makeConverted(emitter, UNKNOWN);
18411845
CompilerVariable* rtn = converted->call(emitter, info, argspec, args, keyword_names);
18421846
return rtn;
18431847
}
18441848

18451849
CompilerVariable* tryCallattrConstant(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var,
18461850
BoxedString* attr, bool clsonly, ArgPassSpec argspec,
1847-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names,
1848-
bool* no_attribute = NULL, ExceptionStyle exception_style = CXX) {
1851+
const std::vector<CompilerVariable*>& args,
1852+
const std::vector<BoxedString*>* keyword_names, bool* no_attribute = NULL,
1853+
ExceptionStyle exception_style = CXX) {
18491854
if (!canStaticallyResolveGetattrs())
18501855
return NULL;
18511856

@@ -1997,7 +2002,7 @@ class NormalObjectType : public ConcreteCompilerType {
19972002

19982003
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, BoxedString* attr,
19992004
CallattrFlags flags, const std::vector<CompilerVariable*>& args,
2000-
BoxedTuple* keyword_names) override {
2005+
const std::vector<BoxedString*>* keyword_names) override {
20012006
ExceptionStyle exception_style = info.preferredExceptionStyle();
20022007

20032008
bool no_attribute = false;
@@ -2309,7 +2314,8 @@ class StrConstantType : public ValuedCompilerType<BoxedString*> {
23092314
}
23102315

23112316
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, BoxedString* attr, CallattrFlags flags,
2312-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
2317+
const std::vector<CompilerVariable*>& args,
2318+
const std::vector<BoxedString*>* keyword_names) override {
23132319
ConcreteCompilerVariable* converted = var->makeConverted(emitter, STR);
23142320
CompilerVariable* rtn = converted->callattr(emitter, info, attr, flags, args, keyword_names);
23152321
return rtn;
@@ -2428,7 +2434,7 @@ class BoolType : public ConcreteCompilerType {
24282434

24292435
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, ConcreteCompilerVariable* var, BoxedString* attr,
24302436
CallattrFlags flags, const std::vector<CompilerVariable*>& args,
2431-
BoxedTuple* keyword_names) override {
2437+
const std::vector<BoxedString*>* keyword_names) override {
24322438
ConcreteCompilerVariable* converted = var->makeConverted(emitter, BOXED_BOOL);
24332439
CompilerVariable* rtn = converted->callattr(emitter, info, attr, flags, args, keyword_names);
24342440
return rtn;
@@ -2664,7 +2670,8 @@ class TupleType : public UnboxedType<const std::vector<CompilerVariable*>, Tuple
26642670
}
26652671

26662672
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, BoxedString* attr, CallattrFlags flags,
2667-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
2673+
const std::vector<CompilerVariable*>& args,
2674+
const std::vector<BoxedString*>* keyword_names) override {
26682675
return makeConverted(emitter, var, getConcreteType())
26692676
->callattr(emitter, info, attr, flags, args, keyword_names);
26702677
}
@@ -2805,7 +2812,8 @@ class UndefType : public ConcreteCompilerType {
28052812
}
28062813

28072814
CompilerVariable* call(IREmitter& emitter, const OpInfo& info, VAR* var, ArgPassSpec argspec,
2808-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
2815+
const std::vector<CompilerVariable*>& args,
2816+
const std::vector<BoxedString*>* keyword_names) override {
28092817
return undefVariable();
28102818
}
28112819
CompilerVariable* dup(VAR* v, DupCache& cache) override {
@@ -2826,7 +2834,8 @@ class UndefType : public ConcreteCompilerType {
28262834
}
28272835

28282836
CompilerVariable* callattr(IREmitter& emitter, const OpInfo& info, VAR* var, BoxedString* attr, CallattrFlags flags,
2829-
const std::vector<CompilerVariable*>& args, BoxedTuple* keyword_names) override {
2837+
const std::vector<CompilerVariable*>& args,
2838+
const std::vector<BoxedString*>* keyword_names) override {
28302839
return undefVariable();
28312840
}
28322841

0 commit comments

Comments
 (0)