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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 6621071: X64 Crankshaft: Add inline one-element cache for Instanceof. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 } 1827 }
1828 1828
1829 1829
1830 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { 1830 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
1831 class DeferredInstanceOfKnownGlobal: public LDeferredCode { 1831 class DeferredInstanceOfKnownGlobal: public LDeferredCode {
1832 public: 1832 public:
1833 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, 1833 DeferredInstanceOfKnownGlobal(LCodeGen* codegen,
1834 LInstanceOfKnownGlobal* instr) 1834 LInstanceOfKnownGlobal* instr)
1835 : LDeferredCode(codegen), instr_(instr) { } 1835 : LDeferredCode(codegen), instr_(instr) { }
1836 virtual void Generate() { 1836 virtual void Generate() {
1837 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_); 1837 codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_);
1838 } 1838 }
1839 1839
1840 Label* map_check() { return &map_check_; }
1841
1840 private: 1842 private:
1841 LInstanceOfKnownGlobal* instr_; 1843 LInstanceOfKnownGlobal* instr_;
1844 Label map_check_;
1842 }; 1845 };
1843 1846
1844 1847
1845 DeferredInstanceOfKnownGlobal* deferred; 1848 DeferredInstanceOfKnownGlobal* deferred;
1846 deferred = new DeferredInstanceOfKnownGlobal(this, instr); 1849 deferred = new DeferredInstanceOfKnownGlobal(this, instr);
1847 1850
1848 Label false_result; 1851 Label done, false_result;
1849 Register object = ToRegister(instr->InputAt(0)); 1852 Register object = ToRegister(instr->InputAt(0));
1850 1853
1851 // A Smi is not an instance of anything. 1854 // A Smi is not an instance of anything.
1852 __ JumpIfSmi(object, &false_result); 1855 __ JumpIfSmi(object, &false_result);
1853 1856
1854 // Null is not an instance of anything. 1857 // This is the inlined call site instanceof cache. The two occurences of the
1858 // hole value will be patched to the last map/result pair generated by the
1859 // instanceof stub.
1860 NearLabel cache_miss;
1861 // Use a temp register to avoid memory operands with variable lengths.
1862 Register map = ToRegister(instr->TempAt(0));
1863 __ movq(map, FieldOperand(object, HeapObject::kMapOffset));
1864 __ bind(deferred->map_check()); // Label for calculating code patching.
1865 __ Move(kScratchRegister, Factory::the_hole_value());
1866 __ cmpq(map, kScratchRegister); // Patched to cached map.
1867 __ j(not_equal, &cache_miss);
1868 // Patched to load either true or false.
1869 __ LoadRoot(ToRegister(instr->result()), Heap::kTheHoleValueRootIndex);
1870 #ifdef DEBUG
1871 // Check that the code size between patch label and patch sites is invariant.
1872 Label end_of_patched_code;
1873 __ bind(&end_of_patched_code);
1874 ASSERT(true);
1875 #endif
1876 __ jmp(&done);
1877
1878 // The inlined call site cache did not match. Check for null and string
1879 // before calling the deferred code.
1880 __ bind(&cache_miss); // Null is not an instance of anything.
1855 __ CompareRoot(object, Heap::kNullValueRootIndex); 1881 __ CompareRoot(object, Heap::kNullValueRootIndex);
1856 __ j(equal, &false_result); 1882 __ j(equal, &false_result);
1857 1883
1858 // String values are not instances of anything. 1884 // String values are not instances of anything.
1859 __ JumpIfNotString(object, kScratchRegister, deferred->entry()); 1885 __ JumpIfNotString(object, kScratchRegister, deferred->entry());
1860 1886
1861 __ bind(&false_result); 1887 __ bind(&false_result);
1862 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex); 1888 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1863 1889
1864 __ bind(deferred->exit()); 1890 __ bind(deferred->exit());
1891 __ bind(&done);
1865 } 1892 }
1866 1893
1867 1894
1868 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { 1895 void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
1896 Label* map_check) {
1869 __ PushSafepointRegisters(); 1897 __ PushSafepointRegisters();
1870 1898 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>(
1871 InstanceofStub stub(InstanceofStub::kNoFlags); 1899 InstanceofStub::kNoFlags | InstanceofStub::kCallSiteInlineCheck);
1900 InstanceofStub stub(flags);
1872 1901
1873 __ push(ToRegister(instr->InputAt(0))); 1902 __ push(ToRegister(instr->InputAt(0)));
1874 __ Push(instr->function()); 1903 __ Push(instr->function());
1875 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 1904 Register temp = ToRegister(instr->TempAt(0));
1905 ASSERT(temp.is(rdi));
1906 static const int kAdditionalDelta = 16;
1907 int delta =
1908 masm_->SizeOfCodeGeneratedSince(map_check) + kAdditionalDelta;
1909 __ movq(temp, Immediate(delta));
1910 __ push(temp);
1876 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 1911 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1877 __ movq(kScratchRegister, rax); 1912 __ movq(kScratchRegister, rax);
1878 __ PopSafepointRegisters(); 1913 __ PopSafepointRegisters();
1879 __ testq(kScratchRegister, kScratchRegister); 1914 __ testq(kScratchRegister, kScratchRegister);
1880 Label load_false; 1915 Label load_false;
1881 Label done; 1916 Label done;
1882 __ j(not_zero, &load_false); 1917 __ j(not_zero, &load_false);
1883 __ LoadRoot(rax, Heap::kTrueValueRootIndex); 1918 __ LoadRoot(rax, Heap::kTrueValueRootIndex);
1884 __ jmp(&done); 1919 __ jmp(&done);
1885 __ bind(&load_false); 1920 __ bind(&load_false);
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
3664 RegisterEnvironmentForDeoptimization(environment); 3699 RegisterEnvironmentForDeoptimization(environment);
3665 ASSERT(osr_pc_offset_ == -1); 3700 ASSERT(osr_pc_offset_ == -1);
3666 osr_pc_offset_ = masm()->pc_offset(); 3701 osr_pc_offset_ = masm()->pc_offset();
3667 } 3702 }
3668 3703
3669 #undef __ 3704 #undef __
3670 3705
3671 } } // namespace v8::internal 3706 } } // namespace v8::internal
3672 3707
3673 #endif // V8_TARGET_ARCH_X64 3708 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698