blob: a9e30de44d66aa75c2cd6427a659f8935648d214 [file] [log] [blame]
Steve Block44f0eee2011-05-26 01:26:41 +01001// Copyright 2011 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Block44f0eee2011-05-26 01:26:41 +01004
Ben Murdochb8a8cc12014-11-26 15:28:44 +00005#include "src/codegen.h"
6#include "src/deoptimizer.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00007#include "src/full-codegen/full-codegen.h"
8#include "src/register-configuration.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +00009#include "src/safepoint-table.h"
Steve Block44f0eee2011-05-26 01:26:41 +010010
Steve Block44f0eee2011-05-26 01:26:41 +010011namespace v8 {
12namespace internal {
13
14
Steve Block44f0eee2011-05-26 01:26:41 +010015int Deoptimizer::patch_size() {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010016 const int kCallInstructionSizeInWords = 4;
Steve Block44f0eee2011-05-26 01:26:41 +010017 return kCallInstructionSizeInWords * Assembler::kInstrSize;
18}
19
20
Emily Bernierd0a1eb72015-03-24 16:35:39 -040021void Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(Handle<Code> code) {
22 // Empty because there is no need for relocation information for the code
23 // patching in Deoptimizer::PatchCodeForDeoptimization below.
24}
25
26
Ben Murdochb8a8cc12014-11-26 15:28:44 +000027void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010028 Address code_start_address = code->instruction_start();
Ben Murdoch3ef787d2012-04-12 10:51:47 +010029 // Invalidate the relocation information, as it will become invalid by the
30 // code patching below, and is not needed any more.
31 code->InvalidateRelocation();
32
Ben Murdochb8a8cc12014-11-26 15:28:44 +000033 if (FLAG_zap_code_space) {
34 // Fail hard and early if we enter this code object again.
35 byte* pointer = code->FindCodeAgeSequence();
36 if (pointer != NULL) {
37 pointer += kNoCodeAgeSequenceLength;
38 } else {
39 pointer = code->instruction_start();
40 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000041 CodePatcher patcher(isolate, pointer, 1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 patcher.masm()->break_(0xCC);
43
44 DeoptimizationInputData* data =
45 DeoptimizationInputData::cast(code->deoptimization_data());
46 int osr_offset = data->OsrPcOffset()->value();
47 if (osr_offset > 0) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000048 CodePatcher osr_patcher(isolate, code->instruction_start() + osr_offset,
49 1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050 osr_patcher.masm()->break_(0xCC);
51 }
52 }
53
Ben Murdoch3ef787d2012-04-12 10:51:47 +010054 DeoptimizationInputData* deopt_data =
55 DeoptimizationInputData::cast(code->deoptimization_data());
56#ifdef DEBUG
57 Address prev_call_address = NULL;
58#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +000059 // For each LLazyBailout instruction insert a call to the corresponding
60 // deoptimization entry.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010061 for (int i = 0; i < deopt_data->DeoptCount(); i++) {
62 if (deopt_data->Pc(i)->value() == -1) continue;
63 Address call_address = code_start_address + deopt_data->Pc(i)->value();
Ben Murdochb8a8cc12014-11-26 15:28:44 +000064 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010065 int call_size_in_bytes = MacroAssembler::CallSize(deopt_entry,
Ben Murdochb8a8cc12014-11-26 15:28:44 +000066 RelocInfo::NONE32);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010067 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000068 DCHECK(call_size_in_bytes % Assembler::kInstrSize == 0);
69 DCHECK(call_size_in_bytes <= patch_size());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000070 CodePatcher patcher(isolate, call_address, call_size_in_words);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000071 patcher.masm()->Call(deopt_entry, RelocInfo::NONE32);
72 DCHECK(prev_call_address == NULL ||
Ben Murdoch3ef787d2012-04-12 10:51:47 +010073 call_address >= prev_call_address + patch_size());
Ben Murdochb8a8cc12014-11-26 15:28:44 +000074 DCHECK(call_address + patch_size() <= code->instruction_end());
Ben Murdoch3ef787d2012-04-12 10:51:47 +010075
76#ifdef DEBUG
77 prev_call_address = call_address;
78#endif
79 }
Steve Block44f0eee2011-05-26 01:26:41 +010080}
81
82
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000083void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010084 // Set the register values. The values are not important as there are no
85 // callee saved registers in JavaScript frames, so all registers are
86 // spilled. Registers fp and sp are set to the correct values though.
87
88 for (int i = 0; i < Register::kNumRegisters; i++) {
89 input_->SetRegister(i, i * 4);
90 }
91 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp()));
92 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp()));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000093 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; i++) {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010094 input_->SetDoubleRegister(i, 0.0);
95 }
96
97 // Fill the frame content from the actual data on the frame.
98 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) {
99 input_->SetFrameSlot(i, Memory::uint32_at(tos + i));
100 }
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000101}
102
103
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000104void Deoptimizer::SetPlatformCompiledStubRegisters(
105 FrameDescription* output_frame, CodeStubDescriptor* descriptor) {
106 ApiFunction function(descriptor->deoptimization_handler());
107 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_);
108 intptr_t handler = reinterpret_cast<intptr_t>(xref.address());
109 int params = descriptor->GetHandlerParameterCount();
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400110 output_frame->SetRegister(a0.code(), params);
111 output_frame->SetRegister(a1.code(), handler);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000112}
113
114
115void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
116 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) {
117 double double_value = input_->GetDoubleRegister(i);
118 output_frame->SetDoubleRegister(i, double_value);
119 }
120}
121
122
123bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
124 // There is no dynamic alignment padding on MIPS in the input frame.
125 return false;
126}
127
128
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100129#define __ masm()->
130
131
132// This code tries to be close to ia32 code so that any changes can be
133// easily ported.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000134void Deoptimizer::TableEntryGenerator::Generate() {
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100135 GeneratePrologue();
136
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100137 // Unlike on ARM we don't save all the registers, just the useful ones.
138 // For the rest, there are gaps on the stack, so the offsets remain the same.
139 const int kNumberOfRegisters = Register::kNumRegisters;
140
141 RegList restored_regs = kJSCallerSaved | kCalleeSaved;
142 RegList saved_regs = restored_regs | sp.bit() | ra.bit();
143
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000144 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kMaxNumRegisters;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100145
146 // Save all FPU registers before messing with them.
147 __ Subu(sp, sp, Operand(kDoubleRegsSize));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000148 const RegisterConfiguration* config =
149 RegisterConfiguration::ArchDefault(RegisterConfiguration::CRANKSHAFT);
150 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) {
151 int code = config->GetAllocatableDoubleCode(i);
152 const DoubleRegister fpu_reg = DoubleRegister::from_code(code);
153 int offset = code * kDoubleSize;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100154 __ sdc1(fpu_reg, MemOperand(sp, offset));
155 }
156
157 // Push saved_regs (needed to populate FrameDescription::registers_).
158 // Leave gaps for other registers.
159 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize);
160 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) {
161 if ((saved_regs & (1 << i)) != 0) {
162 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i));
163 }
164 }
165
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000166 __ li(a2, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
167 __ sw(fp, MemOperand(a2));
168
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100169 const int kSavedRegistersAreaSize =
170 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize;
171
172 // Get the bailout id from the stack.
173 __ lw(a2, MemOperand(sp, kSavedRegistersAreaSize));
174
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000175 // Get the address of the location in the code object (a3) (return
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100176 // address for lazy deoptimization) and compute the fp-to-sp delta in
177 // register t0.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000178 __ mov(a3, ra);
179 // Correct one word for bailout id.
180 __ Addu(t0, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize)));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100181
182 __ Subu(t0, fp, t0);
183
184 // Allocate a new deoptimizer object.
185 // Pass four arguments in a0 to a3 and fifth & sixth arguments on stack.
186 __ PrepareCallCFunction(6, t1);
187 __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
188 __ li(a1, Operand(type())); // bailout type,
189 // a2: bailout id already loaded.
190 // a3: code address or 0 already loaded.
191 __ sw(t0, CFunctionArgumentOperand(5)); // Fp-to-sp delta.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000192 __ li(t1, Operand(ExternalReference::isolate_address(isolate())));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100193 __ sw(t1, CFunctionArgumentOperand(6)); // Isolate.
194 // Call Deoptimizer::New().
195 {
196 AllowExternalCallThatCantCauseGC scope(masm());
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000197 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100198 }
199
200 // Preserve "deoptimizer" object in register v0 and get the input
201 // frame descriptor pointer to a1 (deoptimizer->input_);
202 // Move deopt-obj to a0 for call to Deoptimizer::ComputeOutputFrames() below.
203 __ mov(a0, v0);
204 __ lw(a1, MemOperand(v0, Deoptimizer::input_offset()));
205
206 // Copy core registers into FrameDescription::registers_[kNumRegisters].
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000207 DCHECK(Register::kNumRegisters == kNumberOfRegisters);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100208 for (int i = 0; i < kNumberOfRegisters; i++) {
209 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
210 if ((saved_regs & (1 << i)) != 0) {
211 __ lw(a2, MemOperand(sp, i * kPointerSize));
212 __ sw(a2, MemOperand(a1, offset));
213 } else if (FLAG_debug_code) {
214 __ li(a2, kDebugZapValue);
215 __ sw(a2, MemOperand(a1, offset));
216 }
217 }
218
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000219 int double_regs_offset = FrameDescription::double_registers_offset();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100220 // Copy FPU registers to
221 // double_registers_[DoubleRegister::kNumAllocatableRegisters]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000222 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) {
223 int code = config->GetAllocatableDoubleCode(i);
224 int dst_offset = code * kDoubleSize + double_regs_offset;
225 int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100226 __ ldc1(f0, MemOperand(sp, src_offset));
227 __ sdc1(f0, MemOperand(a1, dst_offset));
228 }
229
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000230 // Remove the bailout id and the saved registers from the stack.
231 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize)));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100232
233 // Compute a pointer to the unwinding limit in register a2; that is
234 // the first stack slot not part of the input frame.
235 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset()));
236 __ Addu(a2, a2, sp);
237
238 // Unwind the stack down to - but not including - the unwinding
239 // limit and copy the contents of the activation frame to the input
240 // frame description.
241 __ Addu(a3, a1, Operand(FrameDescription::frame_content_offset()));
242 Label pop_loop;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000243 Label pop_loop_header;
244 __ BranchShort(&pop_loop_header);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100245 __ bind(&pop_loop);
246 __ pop(t0);
247 __ sw(t0, MemOperand(a3, 0));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000248 __ addiu(a3, a3, sizeof(uint32_t));
249 __ bind(&pop_loop_header);
250 __ BranchShort(&pop_loop, ne, a2, Operand(sp));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100251
252 // Compute the output frame in the deoptimizer.
253 __ push(a0); // Preserve deoptimizer object across call.
254 // a0: deoptimizer object; a1: scratch.
255 __ PrepareCallCFunction(1, a1);
256 // Call Deoptimizer::ComputeOutputFrames().
257 {
258 AllowExternalCallThatCantCauseGC scope(masm());
259 __ CallCFunction(
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000260 ExternalReference::compute_output_frames_function(isolate()), 1);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100261 }
262 __ pop(a0); // Restore deoptimizer object (class Deoptimizer).
263
264 // Replace the current (input) frame with the output frames.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000265 Label outer_push_loop, inner_push_loop,
266 outer_loop_header, inner_loop_header;
267 // Outer loop state: t0 = current "FrameDescription** output_",
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100268 // a1 = one past the last FrameDescription**.
269 __ lw(a1, MemOperand(a0, Deoptimizer::output_count_offset()));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000270 __ lw(t0, MemOperand(a0, Deoptimizer::output_offset())); // t0 is output_.
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100271 __ sll(a1, a1, kPointerSizeLog2); // Count to offset.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000272 __ addu(a1, t0, a1); // a1 = one past the last FrameDescription**.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000273 __ BranchShort(&outer_loop_header);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100274 __ bind(&outer_push_loop);
275 // Inner loop state: a2 = current FrameDescription*, a3 = loop index.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000276 __ lw(a2, MemOperand(t0, 0)); // output_[ix]
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100277 __ lw(a3, MemOperand(a2, FrameDescription::frame_size_offset()));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000278 __ BranchShort(&inner_loop_header);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100279 __ bind(&inner_push_loop);
280 __ Subu(a3, a3, Operand(sizeof(uint32_t)));
281 __ Addu(t2, a2, Operand(a3));
282 __ lw(t3, MemOperand(t2, FrameDescription::frame_content_offset()));
283 __ push(t3);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000284 __ bind(&inner_loop_header);
285 __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100286
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000287 __ Addu(t0, t0, Operand(kPointerSize));
288 __ bind(&outer_loop_header);
289 __ BranchShort(&outer_push_loop, lt, t0, Operand(a1));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100290
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000291 __ lw(a1, MemOperand(a0, Deoptimizer::input_offset()));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000292 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) {
293 int code = config->GetAllocatableDoubleCode(i);
294 const DoubleRegister fpu_reg = DoubleRegister::from_code(code);
295 int src_offset = code * kDoubleSize + double_regs_offset;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000296 __ ldc1(fpu_reg, MemOperand(a1, src_offset));
297 }
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100298
299 // Push state, pc, and continuation from the last output frame.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000300 __ lw(t2, MemOperand(a2, FrameDescription::state_offset()));
301 __ push(t2);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100302
303 __ lw(t2, MemOperand(a2, FrameDescription::pc_offset()));
304 __ push(t2);
305 __ lw(t2, MemOperand(a2, FrameDescription::continuation_offset()));
306 __ push(t2);
307
308
309 // Technically restoring 'at' should work unless zero_reg is also restored
310 // but it's safer to check for this.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000311 DCHECK(!(at.bit() & restored_regs));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100312 // Restore the registers from the last output frame.
313 __ mov(at, a2);
314 for (int i = kNumberOfRegisters - 1; i >= 0; i--) {
315 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
316 if ((restored_regs & (1 << i)) != 0) {
317 __ lw(ToRegister(i), MemOperand(at, offset));
318 }
319 }
320
321 __ InitializeRootRegister();
322
323 __ pop(at); // Get continuation, leave pc on stack.
324 __ pop(ra);
325 __ Jump(at);
326 __ stop("Unreachable.");
Steve Block44f0eee2011-05-26 01:26:41 +0100327}
328
329
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100330// Maximum size of a table entry generated below.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000331const int Deoptimizer::table_entry_size_ = 2 * Assembler::kInstrSize;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100332
Steve Block44f0eee2011-05-26 01:26:41 +0100333void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100334 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm());
335
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000336 // Create a sequence of deoptimization entries.
337 // Note that registers are still live when jumping to an entry.
338 Label table_start, done, done_special, trampoline_jump;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100339 __ bind(&table_start);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000340 int kMaxEntriesBranchReach = (1 << (kImm16Bits - 2))/
341 (table_entry_size_ / Assembler::kInstrSize);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100342
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000343 if (count() <= kMaxEntriesBranchReach) {
344 // Common case.
345 for (int i = 0; i < count(); i++) {
346 Label start;
347 __ bind(&start);
348 DCHECK(is_int16(i));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000349 __ BranchShort(USE_DELAY_SLOT, &done); // Expose delay slot.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000350 __ li(at, i); // In the delay slot.
351
352 DCHECK_EQ(table_entry_size_, masm()->SizeOfCodeGeneratedSince(&start));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100353 }
354
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000355 DCHECK_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
356 count() * table_entry_size_);
357 __ bind(&done);
358 __ Push(at);
359 } else {
360 // Uncommon case, the branch cannot reach.
361 // Create mini trampoline and adjust id constants to get proper value at
362 // the end of table.
363 for (int i = kMaxEntriesBranchReach; i > 1; i--) {
364 Label start;
365 __ bind(&start);
366 DCHECK(is_int16(i));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000367 __ BranchShort(USE_DELAY_SLOT, &trampoline_jump); // Expose delay slot.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000368 __ li(at, - i); // In the delay slot.
369 DCHECK_EQ(table_entry_size_, masm()->SizeOfCodeGeneratedSince(&start));
370 }
371 // Entry with id == kMaxEntriesBranchReach - 1.
372 __ bind(&trampoline_jump);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000373 __ BranchShort(USE_DELAY_SLOT, &done_special);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000374 __ li(at, -1);
375
376 for (int i = kMaxEntriesBranchReach ; i < count(); i++) {
377 Label start;
378 __ bind(&start);
379 DCHECK(is_int16(i));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000380 __ BranchShort(USE_DELAY_SLOT, &done); // Expose delay slot.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000381 __ li(at, i); // In the delay slot.
382 }
383
384 DCHECK_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
385 count() * table_entry_size_);
386 __ bind(&done_special);
387 __ addiu(at, at, kMaxEntriesBranchReach);
388 __ bind(&done);
389 __ Push(at);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100390 }
Steve Block44f0eee2011-05-26 01:26:41 +0100391}
392
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000393
394void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) {
395 SetFrameSlot(offset, value);
396}
397
398
399void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) {
400 SetFrameSlot(offset, value);
401}
402
403
404void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000405 // No embedded constant pool support.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000406 UNREACHABLE();
407}
408
409
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100410#undef __
411
Steve Block44f0eee2011-05-26 01:26:41 +0100412
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000413} // namespace internal
414} // namespace v8