News for hackers. Stuff that matters.
Re:Adding a new Bytecode instruction to the .NET runtime by krallja on Friday May 19, 2017 @08:01PM (#14380218)
Every time I see a post by matthewwarren I know I'm about to learn something seriously fun.
Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Saturday May 20, 2017 @04:06AM (#14381486)
That's good!

I always learn something when I write my posts, but it nice to know I'm not the only one

Re:Adding a new Bytecode instruction to the .NET runtime by thaiphanvevo on Friday May 19, 2017 @11:32PM (#14380898)
This Matt Warren character is pretty hardcore. His passion for .NET is pretty inspirational!
Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Saturday May 20, 2017 @04:07AM (#14381490)
Well it's a pretty interesting platform/runtime!

And now that it's open-source it's easy to look under the hood and have a play around

Re:Adding a new Bytecode instruction to the .NET runtime by erikig on Friday May 19, 2017 @09:17PM (#14380492)
This resource for Matt's attributions footer is a boon for CLI hackers: http://www.newardassociates.com/files/SSCLI2.pdf
Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Saturday May 20, 2017 @04:03AM (#14381473)
Yeah there's lots of good stuff in there.

Even though it's written about the Shared Source code (.Net 2.0), lots of the info in the book still applies

Re:Adding a new Bytecode instruction to the .NET runtime by pinum on Sunday May 21, 2017 @10:05AM (#14387354)
I noticed you added your instruction by replacing one of the "unused" entries. Would things have been more complicated if there weren't any of those left?

Or is there a strict limit to the number of instructions, with existing "unused" entries for all of the free ones?

Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Monday May 22, 2017 @05:14AM (#14392089)
Someone else asked that questions over on /r/programming, see https://www.reddit.com/r/programming/comments/6c3qsh/adding_... for the discussion
Re:Adding a new Bytecode instruction to the .NET runtime by taspeotis on Friday May 19, 2017 @09:21PM (#14380511)
How does one generate those "Assembly listing for method" listings?
Re:Adding a new Bytecode instruction to the .NET runtime by schrodinger on Friday May 19, 2017 @10:24PM (#14380727)
You can use a tool called ildasm (Intermediate language disassembler) provided by Microsoft [1], or a more polished tool like ILSpy [2].

1: https://msdn.microsoft.com/en-us/library/f7dy01k1(v=vs.110)....

2: http://ilspy.net/

Re:Adding a new Bytecode instruction to the .NET runtime by taspeotis on Friday May 19, 2017 @11:16PM (#14380866)
Thanks for the answer. Won't that get me the IL and not the ASM?
Re:Adding a new Bytecode instruction to the .NET runtime by mandaleeka on Friday May 19, 2017 @11:38PM (#14380916)
Correct. To view the JIT-emitted code, you can either use a debugger or set a special environment variable (COMPlus_JitDisasm='NameOfMyMethod') that tells the JIT to emit some logging about the code it generates for that method (it appears this is what the author of the blog post did).
Re:Adding a new Bytecode instruction to the .NET runtime by taspeotis on Saturday May 20, 2017 @12:29AM (#14381040)
COMPlus_JitDisasm lead me to this [1]. Thanks!

[1] https://github.com/dotnet/coreclr/blob/master/Documentation/...

Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Saturday May 20, 2017 @04:05AM (#14381481)
Yeah that's how I did it, I guess I should include the 'COMPlus_JitDisasm' info in the post, when I get a chance I'll update it
Re:Adding a new Bytecode instruction to the .NET runtime by pjmlp on Saturday May 20, 2017 @05:23AM (#14381602)
Another easier way is just to run it under Visual Studio debugging session, put breakpoint on the code one wants to see and select "Show Disassembly" view.
Re:Adding a new Bytecode instruction to the .NET runtime by taspeotis on Saturday May 20, 2017 @06:13AM (#14381694)
I'm aware of this method but I've found it difficult in practice, you want to be running in Release mode for the JIT optimisatinos. Then due to method inlining your breakpoint might get inlined somewhere that "just my code" thinks is not your code. You rarely want "just my code" off in practice, so it becomes cumbersome to toggle off/on.
Re:Adding a new Bytecode instruction to the .NET runtime by pjmlp on Saturday May 20, 2017 @06:35AM (#14381752)
Yeah I agree it isn't the best way, just one that I find comfortable to use since I am always on Studio.

What about using Windbg with the sos.dll extensions?

Re:Adding a new Bytecode instruction to the .NET runtime by hdhzy on Sunday May 21, 2017 @03:32AM (#14386153)
Excellent post. The blog [0] is an incredible boon for anyone interested in CLR internals.

I wonder if the author considered writing a book, kind of modern Shared Source CLI Essentials (that I read years ago and hold in high regard)?

[0]: http://mattwarren.org/

Re:Adding a new Bytecode instruction to the .NET runtime by matthewwarren on Monday May 22, 2017 @05:17AM (#14392098)
> I wonder if the author considered writing a book..

Now there's an idea :-)

BTW I've been bugging/asking the author of the SSCLI book if he has any plans to update it, see http://mattwarren.org/2017/05/19/Adding-a-new-Bytecode-Instr...

Re:Adding a new Bytecode instruction to the .NET runtime by 0xffffff77a81g9 on Saturday May 20, 2017 @07:20AM (#14381885)
> It contains just a cmp, a jg and a couple of mov instructions

Using cmov you can improve performance a bit.

Re:Adding a new Bytecode instruction to the .NET runtime by WaxProlix on Friday May 19, 2017 @08:29PM (#14380319)
That tl;dr wasn't very good.
Re:Adding a new Bytecode instruction to the .NET runtime by DiabloD3 on Friday May 19, 2017 @09:11PM (#14380475)
I think if you tried to publish an article where you tried to add an opcode to an existing JVM... Oracle would nastygram you even if you never released the source code or even if you didn't do it to a JVM based on theirs.

Something is seriously wrong with some companies.

Edit: To those downvoting, remember, if you disagree, post a reply.

Re:Adding a new Bytecode instruction to the .NET runtime by kogir on Saturday May 20, 2017 @12:09AM (#14380988)
The downvotes are probably because Oracle is off topic, and you can add an opcode to OpenJDK and even blog about it if you so desire.
Re:Adding a new Bytecode instruction to the .NET runtime by pjmlp on Saturday May 20, 2017 @05:28AM (#14381611)
Oracle gets a bit around bad reputation on HN circles, but lot of us on the enterprise world actually do like their software.

As for Java, they were already selling Java based products around 2000 and former Sun employees like James Gosling, were not happy with Google actions but Sun had run out of money for any kind of lawsuits.

Also it is easy to write angry posts about Oracle's decisions, but if Google, Red-Hat or IBM actually cared that much about Java's future they would have given work to those driving the future of the language, instead of ignoring them.

Re:Adding a new Bytecode instruction to the .NET runtime by douche on Saturday May 20, 2017 @10:29AM (#14382524)
Java is just... disappointing. I learned Java 5 (1.5) a decade ago in high school, for the AP test, and it's just made very little real progress since, particularly in comparison to the rest of the field.

I look at all of the innovations and convenience features that C#(an unashamed Java clone at the start) has introduced in the meantime, and it makes me wonder what is so broken with Java.

Re:Adding a new Bytecode instruction to the .NET runtime by pjmlp on Saturday May 20, 2017 @11:16AM (#14382737)
I deslike C a lot, however it still is probably the only programming language with more market share than Java.

C design is driven by committee with deep respect for backwards compatibility, despite the inherent security flaws, the language differences between C11 and C89 are superficial.

Likewise, in spite of having Oracle at the helm, Java's design is driven by the JEP working group.

When the majority of the world depends on Java, cannot add language features just because they look cool.

C# moves fast because it mostly only Microsoft calling the shot, even if they are now taking input via Github.

We just saw Java politics recently with IBM and Red-Hat vetting jigsaw because it isn't a copy of OSGi.

Re:Adding a new Bytecode instruction to the .NET runtime by benaadams on Saturday May 20, 2017 @01:07PM (#14383289)
> C# moves fast because it mostly only Microsoft calling the shot, even if they are now taking input via Github.

Is Microsoft, RedHat, JetBrains, Unity, Samsung and Google (Also Mono and Xamarin - though they are now part of Microsoft) - as well as the wider community via GitHub etc

https://dotnetfoundation.org/about/tsg

Re:Adding a new Bytecode instruction to the .NET runtime by pjmlp on Saturday May 20, 2017 @01:40PM (#14383446)
.NET Foundation was created when .NET went open source, about two years ago.

Still very new and so far Microsoft has been driving most of it, as one can see from the Github architecture meetings.

It is bit different from JCP which goes all the way back to 1998.

Just having the logos on the .NET Foundation web site doesn't mean those companies are driving language decisions.