vm/document : port get/set value code from js

TODO: the set value code looks inefficient, it is a straight port;
eventually we can look to optimize these routines once we beef up our
test coverage more regarding corner cases