Coder Social home page Coder Social logo

Comments (12)

amandaLi7 avatar amandaLi7 commented on June 8, 2024
C0 C0 FF EE       # magic number
00 17             # version 11, arch = 1 (64 bits)

00 00             # int pool count
# int pool

00 18             # string pool total size
# string pool
20 69 73 20 74 68 65 20 66 61 63 74 6F 72 69 61 6C 20 6F 66 20 31 35 00  # " is the factorial of 15"

00 02             # function count
# function_pool

#<main>
00                # number of arguments = 0
00                # number of local variables = 0
00 13             # code length = 19 bytes
10 0F    # bipush 15          # 15
B8 00 01 # invokestatic 1     # factorial(15)
B7 00 00 # invokenative 0     # printint(factorial(15))
57       # pop                # (ignore result)
14 00 00 # aldc 0             # s[0] = " is the factorial of 15"
B7 00 01 # invokenative 1     # println(" is the factorial of 15")
57       # pop                # (ignore result)
10 00    # bipush 0           # 0
B0       # return             # 


#<factorial>
01                # number of arguments = 1
01                # number of local variables = 1
00 1B             # code length = 27 bytes
15 00    # vload 0            # n
10 00    # bipush 0           # 0
9F 00 06 # if_cmpeq +6        # if (n == 0) goto <00:cond_true>
A7 00 08 # goto +8            # goto <01:cond_false>
# <00:cond_true>
10 01    # bipush 1           # 1
A7 00 0E # goto +14           # goto <02:cond_end>
# <01:cond_false>
15 00    # vload 0            # n
15 00    # vload 0            # n
10 01    # bipush 1           # 1
64       # isub               # (n - 1)
B8 00 01 # invokestatic 1     # factorial((n - 1))
68       # imul               # (n * factorial((n - 1)))
# <02:cond_end>
B0       # return             # 

00 02             # native count
# native pool
00 01 00 09       # printint
00 01 00 0A       # println


from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

Received! I'll dig into it tonight.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

This seems like a browser-dependent problem. I've tried to run this byte code on Firefox and Chrome and the error didn't pop out.

from c0vm-ts.

amandaLi7 avatar amandaLi7 commented on June 8, 2024

Yes, Chrome seems to work. I guess warn off testers from using Safari for now haha.
Also, very cool project, will give more feedback now that I can use it.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

That's weird... I've tried this in Safari on my MacBook, but failed to reproduce this problem.

Screen Shot 2022-08-22 at 19 32 02

Could you open the console after this error occurs and take a screen shot? The call stack will be dumped in console in debug mode.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

btw, glad to hear that you enjoy this project 😄

from c0vm-ts.

amandaLi7 avatar amandaLi7 commented on June 8, 2024

Hm, for some reason, it's empty for me. (I'm assuming you mean Console in Web Inspector).
Screen Shot 2022-08-22 at 6 46 21 PM

And just to double check, the website URL I'm using is https://markchenyutian.github.io/C0VM-ts/build/

Edit: And I also enabled Compiler Option -d for debug

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

Yes, I mean the console in inspector and the URL is correct. Sadly, this indicates that the error was caught silently.

However, after inspecting the source code & minimized JS, I suspect the error comes from

export function isNullPtr(ptr: C0Pointer): boolean {
    return ptr.getBigUint64(0) === BigInt(0);
}

in src/utility/pointer_utility.ts.

I've add a try ... catch ... on it to log the e when error occurs and update the website now, could you re-run the program and see if anything got logged in the console? (note: the version number on left corner should now be v0.2.6-alpha)

from c0vm-ts.

amandaLi7 avatar amandaLi7 commented on June 8, 2024

Great. Here's my console output. I've created a video since it gets nested. Feel free to pause whenever to get the info you want.
Screen Recording 2022-08-22 at 10.11.08 PM.mov.zip

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

Thanks for the screen recording.

Turns out this is a problem with Safari's support to bigint (a.k.a. long in C).

A similar complain is found in This issue. I'll fix this problem by changing getBigUint64(0) to getUint32(0) === 0 && getUint32(4) === 0.

from c0vm-ts.

MarkChenYutian avatar MarkChenYutian commented on June 8, 2024

Could you try again to run the program? Just to make sure the fix being applied do work.

from c0vm-ts.

amandaLi7 avatar amandaLi7 commented on June 8, 2024

Yep, looks good now!

from c0vm-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.