OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 } | 2806 } |
2807 | 2807 |
2808 | 2808 |
2809 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { | 2809 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) { |
2810 class DeferredInstanceOfKnownGlobal final : public LDeferredCode { | 2810 class DeferredInstanceOfKnownGlobal final : public LDeferredCode { |
2811 public: | 2811 public: |
2812 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, | 2812 DeferredInstanceOfKnownGlobal(LCodeGen* codegen, |
2813 LInstanceOfKnownGlobal* instr) | 2813 LInstanceOfKnownGlobal* instr) |
2814 : LDeferredCode(codegen), instr_(instr) {} | 2814 : LDeferredCode(codegen), instr_(instr) {} |
2815 void Generate() override { | 2815 void Generate() override { |
2816 codegen()->DoDeferredInstanceOfKnownGlobal(instr_, &map_check_); | 2816 codegen()->DoDeferredInstanceOfKnownGlobal(instr_, &map_check_, |
| 2817 &load_bool_); |
2817 } | 2818 } |
2818 LInstruction* instr() override { return instr_; } | 2819 LInstruction* instr() override { return instr_; } |
2819 Label* map_check() { return &map_check_; } | 2820 Label* map_check() { return &map_check_; } |
| 2821 Label* load_bool() { return &load_bool_; } |
2820 | 2822 |
2821 private: | 2823 private: |
2822 LInstanceOfKnownGlobal* instr_; | 2824 LInstanceOfKnownGlobal* instr_; |
2823 Label map_check_; | 2825 Label map_check_; |
| 2826 Label load_bool_; |
2824 }; | 2827 }; |
2825 | 2828 |
2826 DeferredInstanceOfKnownGlobal* deferred; | 2829 DeferredInstanceOfKnownGlobal* deferred; |
2827 deferred = new (zone()) DeferredInstanceOfKnownGlobal(this, instr); | 2830 deferred = new (zone()) DeferredInstanceOfKnownGlobal(this, instr); |
2828 | 2831 |
2829 Label done, false_result; | 2832 Label done, false_result; |
2830 Register object = ToRegister(instr->value()); | 2833 Register object = ToRegister(instr->value()); |
2831 Register temp = ToRegister(instr->temp()); | 2834 Register temp = ToRegister(instr->temp()); |
2832 Register result = ToRegister(instr->result()); | 2835 Register result = ToRegister(instr->result()); |
2833 | 2836 |
(...skipping 12 matching lines...) Expand all Loading... |
2846 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); | 2849 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
2847 __ bind(deferred->map_check()); // Label for calculating code patching. | 2850 __ bind(deferred->map_check()); // Label for calculating code patching. |
2848 // We use Factory::the_hole_value() on purpose instead of loading from the | 2851 // We use Factory::the_hole_value() on purpose instead of loading from the |
2849 // root array to force relocation to be able to later patch with | 2852 // root array to force relocation to be able to later patch with |
2850 // the cached map. | 2853 // the cached map. |
2851 Handle<Cell> cell = factory()->NewCell(factory()->the_hole_value()); | 2854 Handle<Cell> cell = factory()->NewCell(factory()->the_hole_value()); |
2852 __ mov(ip, Operand(cell)); | 2855 __ mov(ip, Operand(cell)); |
2853 __ LoadP(ip, FieldMemOperand(ip, Cell::kValueOffset)); | 2856 __ LoadP(ip, FieldMemOperand(ip, Cell::kValueOffset)); |
2854 __ cmp(map, ip); | 2857 __ cmp(map, ip); |
2855 __ bc_short(ne, &cache_miss); | 2858 __ bc_short(ne, &cache_miss); |
| 2859 __ bind(deferred->load_bool()); // Label for calculating code patching. |
2856 // We use Factory::the_hole_value() on purpose instead of loading from the | 2860 // We use Factory::the_hole_value() on purpose instead of loading from the |
2857 // root array to force relocation to be able to later patch | 2861 // root array to force relocation to be able to later patch |
2858 // with true or false. | 2862 // with true or false. |
2859 __ mov(result, Operand(factory()->the_hole_value())); | 2863 __ mov(result, Operand(factory()->the_hole_value())); |
2860 } | 2864 } |
2861 __ b(&done); | 2865 __ b(&done); |
2862 | 2866 |
2863 // The inlined call site cache did not match. Check null and string before | 2867 // The inlined call site cache did not match. Check null and string before |
2864 // calling the deferred code. | 2868 // calling the deferred code. |
2865 __ bind(&cache_miss); | 2869 __ bind(&cache_miss); |
(...skipping 13 matching lines...) Expand all Loading... |
2879 __ LoadRoot(result, Heap::kFalseValueRootIndex); | 2883 __ LoadRoot(result, Heap::kFalseValueRootIndex); |
2880 | 2884 |
2881 // Here result has either true or false. Deferred code also produces true or | 2885 // Here result has either true or false. Deferred code also produces true or |
2882 // false object. | 2886 // false object. |
2883 __ bind(deferred->exit()); | 2887 __ bind(deferred->exit()); |
2884 __ bind(&done); | 2888 __ bind(&done); |
2885 } | 2889 } |
2886 | 2890 |
2887 | 2891 |
2888 void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, | 2892 void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr, |
2889 Label* map_check) { | 2893 Label* map_check, |
| 2894 Label* bool_load) { |
2890 InstanceofStub::Flags flags = InstanceofStub::kNoFlags; | 2895 InstanceofStub::Flags flags = InstanceofStub::kNoFlags; |
2891 flags = static_cast<InstanceofStub::Flags>(flags | | 2896 flags = static_cast<InstanceofStub::Flags>(flags | |
2892 InstanceofStub::kArgsInRegisters); | 2897 InstanceofStub::kArgsInRegisters); |
2893 flags = static_cast<InstanceofStub::Flags>( | 2898 flags = static_cast<InstanceofStub::Flags>( |
2894 flags | InstanceofStub::kCallSiteInlineCheck); | 2899 flags | InstanceofStub::kCallSiteInlineCheck); |
2895 flags = static_cast<InstanceofStub::Flags>( | 2900 flags = static_cast<InstanceofStub::Flags>( |
2896 flags | InstanceofStub::kReturnTrueFalseObject); | 2901 flags | InstanceofStub::kReturnTrueFalseObject); |
2897 InstanceofStub stub(isolate(), flags); | 2902 InstanceofStub stub(isolate(), flags); |
2898 | 2903 |
2899 PushSafepointRegistersScope scope(this); | 2904 PushSafepointRegistersScope scope(this); |
2900 LoadContextFromDeferred(instr->context()); | 2905 LoadContextFromDeferred(instr->context()); |
2901 | 2906 |
2902 __ Move(InstanceofStub::right(), instr->function()); | 2907 __ Move(InstanceofStub::right(), instr->function()); |
2903 { | 2908 { |
2904 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); | 2909 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
2905 Handle<Code> code = stub.GetCode(); | 2910 Handle<Code> code = stub.GetCode(); |
2906 // Include instructions below in delta: bitwise_mov32 + call | 2911 // Include instructions below in delta: bitwise_mov32 + li + call |
2907 int delta = (masm_->InstructionsGeneratedSince(map_check) + 2) * | 2912 int additional_delta = 3 * Instruction::kInstrSize + masm_->CallSize(code); |
2908 Instruction::kInstrSize + | 2913 // The labels must be already bound since the code has predictabel size up |
2909 masm_->CallSize(code); | 2914 // to the call instruction. |
2910 // r8 is used to communicate the offset to the location of the map check. | 2915 DCHECK(map_check->is_bound()); |
2911 if (is_int16(delta)) { | 2916 DCHECK(bool_load->is_bound()); |
2912 delta -= Instruction::kInstrSize; | 2917 int map_check_delta = |
2913 __ li(r8, Operand(delta)); | 2918 masm_->InstructionsGeneratedSince(map_check) * Instruction::kInstrSize; |
2914 } else { | 2919 int bool_load_delta = |
2915 __ bitwise_mov32(r8, delta); | 2920 masm_->InstructionsGeneratedSince(bool_load) * Instruction::kInstrSize; |
2916 } | 2921 // r8 is the delta from our callee's lr to the location of the map check. |
| 2922 __ bitwise_mov32(r8, map_check_delta + additional_delta); |
| 2923 // r9 is the delta from map check to bool load. |
| 2924 __ li(r9, Operand(map_check_delta - bool_load_delta)); |
2917 CallCodeGeneric(code, RelocInfo::CODE_TARGET, instr, | 2925 CallCodeGeneric(code, RelocInfo::CODE_TARGET, instr, |
2918 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2926 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
2919 DCHECK(delta / Instruction::kInstrSize == | 2927 DCHECK_EQ((map_check_delta + additional_delta) / Instruction::kInstrSize, |
2920 masm_->InstructionsGeneratedSince(map_check)); | 2928 masm_->InstructionsGeneratedSince(map_check)); |
2921 } | 2929 } |
2922 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); | 2930 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); |
2923 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 2931 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
2924 // Put the result value (r3) into the result register slot and | 2932 // Put the result value (r3) into the result register slot and |
2925 // restore all registers. | 2933 // restore all registers. |
2926 __ StoreToSafepointRegisterSlot(r3, ToRegister(instr->result())); | 2934 __ StoreToSafepointRegisterSlot(r3, ToRegister(instr->result())); |
2927 } | 2935 } |
2928 | 2936 |
2929 | 2937 |
2930 void LCodeGen::DoCmpT(LCmpT* instr) { | 2938 void LCodeGen::DoCmpT(LCmpT* instr) { |
(...skipping 3325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6256 __ Push(scope_info); | 6264 __ Push(scope_info); |
6257 __ push(ToRegister(instr->function())); | 6265 __ push(ToRegister(instr->function())); |
6258 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6266 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6259 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6267 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6260 } | 6268 } |
6261 | 6269 |
6262 | 6270 |
6263 #undef __ | 6271 #undef __ |
6264 } // namespace internal | 6272 } // namespace internal |
6265 } // namespace v8 | 6273 } // namespace v8 |
OLD | NEW |