Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)
Patch Set: Last round :) Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/macros.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 6610 matching lines...) Expand 10 before | Expand all | Expand 10 after
6621 __ bind(&slowcase); 6621 __ bind(&slowcase);
6622 __ CallRuntime(Runtime::kRegExpConstructResult, 3); 6622 __ CallRuntime(Runtime::kRegExpConstructResult, 3);
6623 6623
6624 __ bind(&done); 6624 __ bind(&done);
6625 } 6625 }
6626 frame_->Forget(3); 6626 frame_->Forget(3);
6627 frame_->Push(eax); 6627 frame_->Push(eax);
6628 } 6628 }
6629 6629
6630 6630
6631 class DeferredSearchCache: public DeferredCode {
6632 public:
6633 DeferredSearchCache(Register dst, Register cache, Register key)
6634 : dst_(dst), cache_(cache), key_(key) {
6635 set_comment("[ DeferredSearchCache");
6636 }
6637
6638 virtual void Generate();
6639
6640 private:
6641 Register dst_, cache_, key_;
6642 };
6643
6644
6645 void DeferredSearchCache::Generate() {
6646 __ push(cache_);
6647 __ push(key_);
6648 __ CallRuntime(Runtime::kGetFromCache, 2);
6649 if (!dst_.is(eax)) {
6650 __ mov(dst_, eax);
6651 }
6652 }
6653
6654
6655 void CodeGenerator::GenerateGetFromCache(ZoneList<Expression*>* args) {
6656 ASSERT_EQ(2, args->length());
6657
6658 ASSERT_NE(NULL, args->at(0)->AsLiteral());
6659 int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
6660
6661 Handle<FixedArray> jsfunction_result_caches(
6662 Top::global_context()->jsfunction_result_caches());
6663 if (jsfunction_result_caches->length() <= cache_id) {
6664 __ Abort("Attempt to use undefined cache.");
6665 frame_->Push(Factory::undefined_value());
6666 return;
6667 }
6668 Handle<FixedArray> cache_obj(
6669 FixedArray::cast(jsfunction_result_caches->get(cache_id)));
6670
6671 Load(args->at(1));
6672 Result key = frame_->Pop();
6673 key.ToRegister();
6674
6675 Result cache = allocator()->Allocate();
6676 __ mov(cache.reg(), cache_obj);
6677
6678 Result tmp = allocator()->Allocate();
6679
6680 DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(),
6681 cache.reg(),
6682 key.reg());
6683
6684 const int kFingerOffset =
6685 FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex);
6686 // tmp.reg() now holds finger offset as a smi.
6687 ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
6688 __ mov(tmp.reg(), FieldOperand(cache.reg(), kFingerOffset));
6689 __ cmp(key.reg(), FieldOperand(cache.reg(),
6690 tmp.reg(), // as smi
6691 times_half_pointer_size,
6692 FixedArray::kHeaderSize));
6693 deferred->Branch(not_equal);
6694
6695 __ mov(tmp.reg(), FieldOperand(cache.reg(),
6696 tmp.reg(), // as smi
6697 times_half_pointer_size,
6698 kPointerSize + FixedArray::kHeaderSize));
6699
6700 deferred->BindExit();
6701 frame_->Push(&tmp);
6702 }
6703
6704
6631 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { 6705 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) {
6632 ASSERT_EQ(args->length(), 1); 6706 ASSERT_EQ(args->length(), 1);
6633 6707
6634 // Load the argument on the stack and call the stub. 6708 // Load the argument on the stack and call the stub.
6635 Load(args->at(0)); 6709 Load(args->at(0));
6636 NumberToStringStub stub; 6710 NumberToStringStub stub;
6637 Result result = frame_->CallStub(&stub, 1); 6711 Result result = frame_->CallStub(&stub, 1);
6638 frame_->Push(&result); 6712 frame_->Push(&result);
6639 } 6713 }
6640 6714
(...skipping 6160 matching lines...) Expand 10 before | Expand all | Expand 10 after
12801 12875
12802 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12876 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12803 // tagged as a small integer. 12877 // tagged as a small integer.
12804 __ bind(&runtime); 12878 __ bind(&runtime);
12805 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12879 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12806 } 12880 }
12807 12881
12808 #undef __ 12882 #undef __
12809 12883
12810 } } // namespace v8::internal 12884 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698