OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 case kArchCallAddress: | 114 case kArchCallAddress: |
115 if (HasImmediateInput(instr, 0)) { | 115 if (HasImmediateInput(instr, 0)) { |
116 // TODO(dcarney): wire up EXTERNAL_REFERENCE instead of RUNTIME_ENTRY. | 116 // TODO(dcarney): wire up EXTERNAL_REFERENCE instead of RUNTIME_ENTRY. |
117 __ call(reinterpret_cast<byte*>(i.InputInt32(0)), | 117 __ call(reinterpret_cast<byte*>(i.InputInt32(0)), |
118 RelocInfo::RUNTIME_ENTRY); | 118 RelocInfo::RUNTIME_ENTRY); |
119 } else { | 119 } else { |
120 __ call(i.InputRegister(0)); | 120 __ call(i.InputRegister(0)); |
121 } | 121 } |
122 break; | 122 break; |
123 case kArchCallCodeObject: { | 123 case kArchCallCodeObject: { |
| 124 EnsureSpaceForLazyDeopt(); |
124 if (HasImmediateInput(instr, 0)) { | 125 if (HasImmediateInput(instr, 0)) { |
125 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 126 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
126 __ call(code, RelocInfo::CODE_TARGET); | 127 __ call(code, RelocInfo::CODE_TARGET); |
127 } else { | 128 } else { |
128 Register reg = i.InputRegister(0); | 129 Register reg = i.InputRegister(0); |
129 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); | 130 __ call(Operand(reg, Code::kHeaderSize - kHeapObjectTag)); |
130 } | 131 } |
131 AddSafepointAndDeopt(instr); | 132 AddSafepointAndDeopt(instr); |
132 break; | 133 break; |
133 } | 134 } |
134 case kArchCallJSFunction: { | 135 case kArchCallJSFunction: { |
| 136 EnsureSpaceForLazyDeopt(); |
135 Register func = i.InputRegister(0); | 137 Register func = i.InputRegister(0); |
136 if (FLAG_debug_code) { | 138 if (FLAG_debug_code) { |
137 // Check the function's context matches the context argument. | 139 // Check the function's context matches the context argument. |
138 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 140 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
139 __ Assert(equal, kWrongFunctionContext); | 141 __ Assert(equal, kWrongFunctionContext); |
140 } | 142 } |
141 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 143 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
142 AddSafepointAndDeopt(instr); | 144 AddSafepointAndDeopt(instr); |
143 break; | 145 break; |
144 } | 146 } |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 __ movsd(src0, xmm0); | 942 __ movsd(src0, xmm0); |
941 } else { | 943 } else { |
942 // No other combinations are possible. | 944 // No other combinations are possible. |
943 UNREACHABLE(); | 945 UNREACHABLE(); |
944 } | 946 } |
945 } | 947 } |
946 | 948 |
947 | 949 |
948 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } | 950 void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |
949 | 951 |
| 952 |
| 953 void CodeGenerator::EnsureSpaceForLazyDeopt() { |
| 954 int space_needed = Deoptimizer::patch_size(); |
| 955 if (!linkage()->info()->IsStub()) { |
| 956 // Ensure that we have enough space after the previous lazy-bailout |
| 957 // instruction for patching the code here. |
| 958 int current_pc = masm()->pc_offset(); |
| 959 if (current_pc < last_lazy_deopt_pc_ + space_needed) { |
| 960 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 961 __ Nop(padding_size); |
| 962 } |
| 963 } |
| 964 MarkLazyDeoptSite(); |
| 965 } |
| 966 |
950 #undef __ | 967 #undef __ |
951 | 968 |
952 } // namespace compiler | 969 } // namespace compiler |
953 } // namespace internal | 970 } // namespace internal |
954 } // namespace v8 | 971 } // namespace v8 |
OLD | NEW |