mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
Don't check for strings and primitives in idmap.
It appears that `Ref::WeakValueMap` is not 100% correct. There are cases where entries are temporarily corrupted; probably while attached finalizers run. This is a slight decrease in flexibility in that strings and primitives cannot maintain referential integrity when passed by reference to v8, but the default is to pass them by value anyway, and it greatly reduces the number of object_ids that the idmap sees and therefore reduces the chances of a recycled object id causing a bad lookup. While this is not a perfect fix, it does make a collision very unlikely, and it prevents the crashes being seen in #169 If this pops up again, we'll have to look at getting a perfectly reliable weakmap implementation.
This commit is contained in:
parent
2da238aa94
commit
77804fce1c
2 changed files with 1 additions and 5 deletions
|
@ -39,11 +39,6 @@ if MODE==:object
|
|||
end
|
||||
elsif MODE==:function
|
||||
def get(i)
|
||||
test = @cxt['test']
|
||||
unless test
|
||||
$stderr.puts "wtf? #{test.inspect} -> #{@cxt.eval('test')}"
|
||||
$stderr.puts "wff2? #{test.inspect} -> #{@cxt['test']}"
|
||||
end
|
||||
@cxt["test"].getObject(i)
|
||||
end
|
||||
elsif MODE==:eval
|
||||
|
|
|
@ -11,6 +11,7 @@ class V8::Conversion
|
|||
end
|
||||
|
||||
def to_v8(ruby_object)
|
||||
return super(ruby_object) if ruby_object.is_a?(String) || ruby_object.is_a?(Primitive)
|
||||
rb_idmap[ruby_object.object_id] || super(ruby_object)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue