vm-implementation

Execution speed of references vs pointers

谁都会走 提交于 2019-12-10 01:59:18
问题 I recently read a discussion regarding whether managed languages are slower (or faster) than native languages (specifically C# vs C++). One person that contributed to the discussion said that the JIT compilers of managed languages would be able to make optimizations regarding references that simply isn't possible in languages that use pointers. What I'd like to know is what kind of optimizations that are possible on references and not on pointers? Note that the discussion was about execution

Simple Interpreted Language Design & Implementation [closed]

喜你入骨 提交于 2019-12-10 00:10:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I need some resources for implementing a simple virtual machine and interpreted language. Something that is pratical is most useful. I have read the Virtual Machine Implementation book and found that it is quite old and doesn't represent the vms I see today. Also if someone know

What is the most reliable / portable way to allocate memory at low addresses on 64-bit systems?

血红的双手。 提交于 2019-12-09 18:01:06
问题 I need to allocate large blocks of memory (to be used by my custom allocator) that fall within the first 32GB of virtual address space. I imagine that if I needed, say, 1MB blocks, I could iterate using mmap and MAP_FIXED_NOREPLACE (or VirtualAlloc) from low addresses onwards in increments of, say, 1MB, until the call succeeds. Continue from the last successful block for the next one. This sounds clumsy, but at least it will be somewhat robust against OS address space layout changes, and ASLR

Performance improvement strategies for VM / interpreter?

冷暖自知 提交于 2019-12-09 13:37:17
问题 I have written a simple VM in C, using a simple switch of instructions, without any instruction decoding whatsoever, but performance is terrible. For simple aritmetic operations the VM is about 4000 times slower than native C code for the same operations. I tested with a group of arrays of length 10 million, the first consisting of the program instructions, random + - * / operations, 2 arrays holding random integers and the third array being the operation target storage. I was expecting to

Compiling an AST to Assembly

夙愿已清 提交于 2019-12-09 13:09:21
问题 I have an abstract syntax tree that I need to convert to assembly for a virtual machine. I don't know how best to do this so I started using a chain of string templates. Pseudo-code example of what I mean, say a simplistic if-statement with one condition needs to be compiled: std::string compile_if(Node* n) { std::string str = ""; curLabel = nLabels++; str += compile_comparison(n->getChild(0)); str += ".true"+curLabel+":"; str += compile_block(n->getChild(1)); str += ".false"+curLabel+":";

Why stack-based VM? Why not queue-based VM?

╄→гoц情女王★ 提交于 2019-12-08 08:51:00
问题 As I investigated, there are 2 major ways to implement process VM: stack-based, such as JVM, CLR, etc. or register-based, such as Lua, Dalvik, etc. Register-based approach mimics the architecture of physical processors. But for the stack-based approach, there are many other data structures. I think which approach to choose mainly depends on how we want to store/fetch operands. So why choose stack? How about queue-based VM? Or other options such as linked list? 回答1: StackOverflow is really not

Optimization techniques for backtracking regex implementations

↘锁芯ラ 提交于 2019-12-06 23:33:31
问题 I'm trying to implement a regular expression matcher based on the backtracking approach sketched in Exploring Ruby’s Regular Expression Algorithm. The compiled regex is translated into an array of virtual machine commands; for the backtracking the current command and input string indices as well as capturing group information is maintained on a stack. In Regular Expression Matching: the Virtual Machine Approach Cox gives more detailed information about how to compile certain regex components

Why stack-based VM? Why not queue-based VM?

*爱你&永不变心* 提交于 2019-12-06 19:20:32
As I investigated, there are 2 major ways to implement process VM: stack-based, such as JVM, CLR, etc. or register-based, such as Lua, Dalvik, etc. Register-based approach mimics the architecture of physical processors. But for the stack-based approach, there are many other data structures. I think which approach to choose mainly depends on how we want to store/fetch operands. So why choose stack? How about queue-based VM? Or other options such as linked list? StackOverflow is really not for opinion-based surveying; it's likely to be closed. However, it's key to realise that processor-specific

How to find out what optimizations the JVM applied to my code?

落爺英雄遲暮 提交于 2019-12-04 10:34:49
问题 The JVM (especially the HotSpot VM) is famous for having a huge number of optimizations it can apply at runtime. Is there a way to look at a certain piece of code and see what the JVM has actually done to it? 回答1: One problem is that "what JVM has actually done to it" changes between invocations as the JVM is free to re-generate code. As an example I investigated some days ago what Hotspot does with final methods compared to virtual methods. Judging by microbenchmarks, my conclusions were:

PHP Request Lifecycle

牧云@^-^@ 提交于 2019-12-04 03:15:53
问题 Okay, so I'm relatively naive in my knowledge of the PHP VM and I've been wondering about something lately. In particular, what the request lifecycle looks like in PHP for a web application. I found an article here that gives a good explanation, but I feel that there has to be more to the story. From what the article explains, the script is parsed and executed each time a request is made to the server! This just seems crazy to me! I'm trying to learn PHP by writing a little micro-framework