Index: src/ia32/codegen-ia32.cc |
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc |
index e2d68e8563272094a2b3cb67cf05a9e6c46164f0..45b75d17033c04bfa2ab3f0ea3b735a1b10cb791 100644 |
--- a/src/ia32/codegen-ia32.cc |
+++ b/src/ia32/codegen-ia32.cc |
@@ -6628,6 +6628,80 @@ void CodeGenerator::GenerateRegExpConstructResult(ZoneList<Expression*>* args) { |
} |
+class DeferredSearchCache: public DeferredCode { |
+ public: |
+ DeferredSearchCache(Register dst, Register cache, Register key) |
+ : dst_(dst), cache_(cache), key_(key) { |
+ set_comment("[ DeferredSearchCache"); |
+ } |
+ |
+ virtual void Generate(); |
+ |
+ private: |
+ Register dst_, cache_, key_; |
+}; |
+ |
+ |
+void DeferredSearchCache::Generate() { |
+ __ push(cache_); |
+ __ push(key_); |
+ __ CallRuntime(Runtime::kGetFromCache, 2); |
+ if (!dst_.is(eax)) { |
+ __ mov(dst_, eax); |
+ } |
+} |
+ |
+ |
+void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) { |
+ ASSERT_EQ(2, args->length()); |
+ |
+ ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
+ int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); |
+ |
+ Handle<FixedArray> jsfunction_result_caches( |
+ Top::global_context()->jsfunction_result_caches()); |
+ if (jsfunction_result_caches->length() <= cache_id) { |
+ __ Abort("Attempt to use undefined cache."); |
+ 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); |
+ |
+ Result tmp = allocator()->Allocate(); |
+ |
+ DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(), |
+ cache.reg(), |
+ key.reg()); |
+ |
+ const int kFingerOffset = |
+ FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex); |
+ // tmp.reg() now holds finger offset as a smi. |
+ ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
+ __ mov(tmp.reg(), FieldOperand(cache.reg(), kFingerOffset)); |
+ __ cmp(key.reg(), FieldOperand(cache.reg(), |
+ tmp.reg(), // as smi |
+ times_half_pointer_size, |
+ FixedArray::kHeaderSize)); |
+ deferred->Branch(not_equal); |
+ |
+ __ mov(tmp.reg(), FieldOperand(cache.reg(), |
+ tmp.reg(), // as smi |
+ times_half_pointer_size, |
+ kPointerSize + FixedArray::kHeaderSize)); |
+ |
+ deferred->BindExit(); |
+ frame_->Push(&tmp); |
+} |
+ |
+ |
void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { |
ASSERT_EQ(args->length(), 1); |