Don't share function result caches between contexts.
A reference to the caches array was embedded directly into the builtin code and this allowed sharing objects between contexts. Unfortunately, clearing the cache on GC won't prevent sharing so we either have to have per-context builtin code or load the cache indirectly from the current context. This change implements the second approach. The first approach may be interesting to consider in the future for some perfomance critical functions, and the current approach can still be improved by putting the caches directly into the global context (or even global objects). Review URL: http://codereview.chromium.org/1731002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4486 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
c0f1f18f80
commit
559ba2ccf0
@ -4460,18 +4460,20 @@ void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
|
||||
frame_->EmitPush(r0);
|
||||
return;
|
||||
}
|
||||
Handle<FixedArray> cache_obj(
|
||||
FixedArray::cast(jsfunction_result_caches->get(cache_id)));
|
||||
|
||||
Load(args->at(1));
|
||||
frame_->EmitPop(r2);
|
||||
|
||||
__ ldr(r1, ContextOperand(cp, Context::GLOBAL_INDEX));
|
||||
__ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalContextOffset));
|
||||
__ ldr(r1, ContextOperand(r1, Context::JSFUNCTION_RESULT_CACHES_INDEX));
|
||||
__ ldr(r1, FieldMemOperand(r1, FixedArray::OffsetOfElementAt(cache_id)));
|
||||
|
||||
DeferredSearchCache* deferred = new DeferredSearchCache(r0, r1, r2);
|
||||
|
||||
const int kFingerOffset =
|
||||
FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex);
|
||||
ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
|
||||
__ mov(r1, Operand(cache_obj));
|
||||
__ ldr(r0, FieldMemOperand(r1, kFingerOffset));
|
||||
// r0 now holds finger offset as a smi.
|
||||
__ add(r3, r1, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
|
||||
|
@ -6553,17 +6553,23 @@ void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
|
||||
frame_->Push(Factory::undefined_value());
|
||||
return;
|
||||
}
|
||||
Handle<FixedArray> cache_obj(
|
||||
FixedArray::cast(jsfunction_result_caches->get(cache_id)));
|
||||
|
||||
Load(args->at(1));
|
||||
Result key = frame_->Pop();
|
||||
key.ToRegister();
|
||||
|
||||
Result cache = allocator()->Allocate();
|
||||
__ mov(cache.reg(), cache_obj);
|
||||
ASSERT(cache.is_valid());
|
||||
__ mov(cache.reg(), ContextOperand(esi, Context::GLOBAL_INDEX));
|
||||
__ mov(cache.reg(),
|
||||
FieldOperand(cache.reg(), GlobalObject::kGlobalContextOffset));
|
||||
__ mov(cache.reg(),
|
||||
ContextOperand(cache.reg(), Context::JSFUNCTION_RESULT_CACHES_INDEX));
|
||||
__ mov(cache.reg(),
|
||||
FieldOperand(cache.reg(), FixedArray::OffsetOfElementAt(cache_id)));
|
||||
|
||||
Result tmp = allocator()->Allocate();
|
||||
ASSERT(tmp.is_valid());
|
||||
|
||||
DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(),
|
||||
cache.reg(),
|
||||
|
@ -4305,17 +4305,23 @@ void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
|
||||
frame_->Push(Factory::undefined_value());
|
||||
return;
|
||||
}
|
||||
Handle<FixedArray> cache_obj(
|
||||
FixedArray::cast(jsfunction_result_caches->get(cache_id)));
|
||||
|
||||
Load(args->at(1));
|
||||
Result key = frame_->Pop();
|
||||
key.ToRegister();
|
||||
|
||||
Result cache = allocator()->Allocate();
|
||||
__ movq(cache.reg(), cache_obj, RelocInfo::EMBEDDED_OBJECT);
|
||||
ASSERT(cache.is_valid());
|
||||
__ movq(cache.reg(), ContextOperand(rsi, Context::GLOBAL_INDEX));
|
||||
__ movq(cache.reg(),
|
||||
FieldOperand(cache.reg(), GlobalObject::kGlobalContextOffset));
|
||||
__ movq(cache.reg(),
|
||||
ContextOperand(cache.reg(), Context::JSFUNCTION_RESULT_CACHES_INDEX));
|
||||
__ movq(cache.reg(),
|
||||
FieldOperand(cache.reg(), FixedArray::OffsetOfElementAt(cache_id)));
|
||||
|
||||
Result tmp = allocator()->Allocate();
|
||||
ASSERT(tmp.is_valid());
|
||||
|
||||
DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(),
|
||||
cache.reg(),
|
||||
|
Loading…
Reference in New Issue
Block a user