Skip to content

Conversation

@dgryski
Copy link
Member

@dgryski dgryski commented Feb 20, 2023

No description provided.

@dgryski
Copy link
Member Author

dgryski commented Feb 20, 2023

This is in no way its final form; I'll pick and choose and construct better PRs, but this is my current WIP branch.

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very reasonable. Some early comments and suggestions below.

@dgryski dgryski force-pushed the dgryski/reflect-refactor-3 branch 2 times, most recently from 2513ac8 to 23bc045 Compare February 20, 2023 23:17
@dgryski dgryski force-pushed the dgryski/reflect-refactor-3 branch 2 times, most recently from 807771c to a0ff5c1 Compare February 21, 2023 01:14
@dgryski dgryski marked this pull request as ready for review February 21, 2023 21:54
@soypat soypat added the reflection Needs further work on reflection label Feb 22, 2023
@dgryski dgryski force-pushed the dgryski/reflect-refactor-3 branch from 65c31b6 to 41addd2 Compare February 22, 2023 20:21
@dgryski
Copy link
Member Author

dgryski commented Feb 22, 2023

Bumping the cortex-m-qemu stack size to 4096 causes it to pass. Not sure if that's something we can do in general .

@dgryski dgryski force-pushed the dgryski/reflect-refactor-3 branch from 41addd2 to 305abe8 Compare February 23, 2023 00:08
@dgryski dgryski force-pushed the dgryski/reflect-refactor-3 branch from 32d1713 to 5c22c9d Compare February 23, 2023 01:12
Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed most of the PR, but didn't review value.go completely. But figured it would be useful to send review feedback already.

Assuming this gets more of encoding/json to work, can you also add some tests to testdata/json.go? Just a few lines to prove the new features work (the testdata/* files are run on more platforms than the reflect package tests so might catch more bugs).

c.getTypeCode(types.NewPointer(typ)), // ptrTo
c.getTypeCode(typ.Underlying()), // underlying
llvm.ConstInt(c.uintptrType, uint64(len(name)), false), // length
llvm.ConstArray(c.ctx.Int8Type(), buf),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this has the same effect and may be a bit faster or more readable:

Suggested change
llvm.ConstArray(c.ctx.Int8Type(), buf),
llvm.ConstString(name, false),

Comment on lines 112 to 117
typeFieldTypes = append(typeFieldTypes,
types.NewVar(token.NoPos, nil, "ptrTo", types.Typ[types.UnsafePointer]),
types.NewVar(token.NoPos, nil, "underlying", types.Typ[types.UnsafePointer]),
types.NewVar(token.NoPos, nil, "len", types.Typ[types.Uintptr]),
types.NewVar(token.NoPos, nil, "name", types.NewArray(types.Typ[types.Int8], int64(len(typ.Obj().Name())))),
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the corresponding update to the comment at the top of src/reflect/type.go.

"libc": "picolibc",
"automatic-stack-size": true,
"default-stack-size": 2048,
"default-stack-size": 4096,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for tests this is probably more appropriate.

return Value{
typecode: pointerTo(v.typecode),
value: unsafe.Pointer(&v.value),
flags: v.flags,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the bug you mentioned on Slack? Because I think you need to clear the indirect flag here:

Suggested change
flags: v.flags,
flags: v.flags &^ valueFlagIndirect,

@dgryski
Copy link
Member Author

dgryski commented Feb 25, 2023

Closing in favour of #3486 (and others)

@dgryski dgryski closed this Feb 25, 2023
@dgryski dgryski deleted the dgryski/reflect-refactor-3 branch March 31, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reflection Needs further work on reflection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants