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/osr.h" | 10 #include "src/compiler/osr.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 __ j(above_equal, &done, Label::kNear); \ | 319 __ j(above_equal, &done, Label::kNear); \ |
320 if (instr->InputAt(2)->IsRegister()) { \ | 320 if (instr->InputAt(2)->IsRegister()) { \ |
321 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ | 321 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ |
322 } else { \ | 322 } else { \ |
323 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ | 323 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ |
324 } \ | 324 } \ |
325 __ bind(&done); \ | 325 __ bind(&done); \ |
326 } while (false) | 326 } while (false) |
327 | 327 |
328 | 328 |
329 void CodeGenerator::AssembleDeconstructActivationRecord() { | 329 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
330 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 330 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
331 int stack_slots = frame()->GetSpillSlotCount(); | 331 int stack_slots = frame()->GetSpillSlotCount(); |
332 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 332 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { |
333 __ mov(esp, ebp); | 333 __ mov(esp, ebp); |
334 __ pop(ebp); | 334 __ pop(ebp); |
335 } | 335 } |
| 336 if (stack_param_delta < 0) { |
| 337 int offset = -(stack_param_delta + 1) * kPointerSize; |
| 338 __ pop(Operand(esp, offset)); |
| 339 if (offset != 0) { |
| 340 __ add(esp, Immediate(offset)); |
| 341 } |
| 342 } |
336 } | 343 } |
337 | 344 |
338 | 345 |
339 // Assembles an instruction after register allocation, producing machine code. | 346 // Assembles an instruction after register allocation, producing machine code. |
340 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 347 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
341 IA32OperandConverter i(this, instr); | 348 IA32OperandConverter i(this, instr); |
342 | 349 |
343 switch (ArchOpcodeField::decode(instr->opcode())) { | 350 switch (ArchOpcodeField::decode(instr->opcode())) { |
344 case kArchCallCodeObject: { | 351 case kArchCallCodeObject: { |
345 EnsureSpaceForLazyDeopt(); | 352 EnsureSpaceForLazyDeopt(); |
346 if (HasImmediateInput(instr, 0)) { | 353 if (HasImmediateInput(instr, 0)) { |
347 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 354 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
348 __ call(code, RelocInfo::CODE_TARGET); | 355 __ call(code, RelocInfo::CODE_TARGET); |
349 } else { | 356 } else { |
350 Register reg = i.InputRegister(0); | 357 Register reg = i.InputRegister(0); |
351 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 358 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
352 __ call(reg); | 359 __ call(reg); |
353 } | 360 } |
354 RecordCallPosition(instr); | 361 RecordCallPosition(instr); |
355 break; | 362 break; |
356 } | 363 } |
357 case kArchTailCallCodeObject: { | 364 case kArchTailCallCodeObject: { |
358 AssembleDeconstructActivationRecord(); | 365 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 366 AssembleDeconstructActivationRecord(stack_param_delta); |
359 if (HasImmediateInput(instr, 0)) { | 367 if (HasImmediateInput(instr, 0)) { |
360 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 368 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
361 __ jmp(code, RelocInfo::CODE_TARGET); | 369 __ jmp(code, RelocInfo::CODE_TARGET); |
362 } else { | 370 } else { |
363 Register reg = i.InputRegister(0); | 371 Register reg = i.InputRegister(0); |
364 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 372 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
365 __ jmp(reg); | 373 __ jmp(reg); |
366 } | 374 } |
367 break; | 375 break; |
368 } | 376 } |
369 case kArchCallJSFunction: { | 377 case kArchCallJSFunction: { |
370 EnsureSpaceForLazyDeopt(); | 378 EnsureSpaceForLazyDeopt(); |
371 Register func = i.InputRegister(0); | 379 Register func = i.InputRegister(0); |
372 if (FLAG_debug_code) { | 380 if (FLAG_debug_code) { |
373 // Check the function's context matches the context argument. | 381 // Check the function's context matches the context argument. |
374 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 382 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
375 __ Assert(equal, kWrongFunctionContext); | 383 __ Assert(equal, kWrongFunctionContext); |
376 } | 384 } |
377 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 385 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
378 RecordCallPosition(instr); | 386 RecordCallPosition(instr); |
379 break; | 387 break; |
380 } | 388 } |
381 case kArchTailCallJSFunction: { | 389 case kArchTailCallJSFunction: { |
382 Register func = i.InputRegister(0); | 390 Register func = i.InputRegister(0); |
383 if (FLAG_debug_code) { | 391 if (FLAG_debug_code) { |
384 // Check the function's context matches the context argument. | 392 // Check the function's context matches the context argument. |
385 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 393 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
386 __ Assert(equal, kWrongFunctionContext); | 394 __ Assert(equal, kWrongFunctionContext); |
387 } | 395 } |
388 AssembleDeconstructActivationRecord(); | 396 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 397 AssembleDeconstructActivationRecord(stack_param_delta); |
389 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 398 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
390 break; | 399 break; |
391 } | 400 } |
392 case kArchLazyBailout: { | 401 case kArchLazyBailout: { |
393 EnsureSpaceForLazyDeopt(); | 402 EnsureSpaceForLazyDeopt(); |
394 RecordCallPosition(instr); | 403 RecordCallPosition(instr); |
395 break; | 404 break; |
396 } | 405 } |
397 case kArchPrepareCallCFunction: { | 406 case kArchPrepareCallCFunction: { |
398 int const num_parameters = MiscField::decode(instr->opcode()); | 407 int const num_parameters = MiscField::decode(instr->opcode()); |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1615 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1607 __ Nop(padding_size); | 1616 __ Nop(padding_size); |
1608 } | 1617 } |
1609 } | 1618 } |
1610 | 1619 |
1611 #undef __ | 1620 #undef __ |
1612 | 1621 |
1613 } // namespace compiler | 1622 } // namespace compiler |
1614 } // namespace internal | 1623 } // namespace internal |
1615 } // namespace v8 | 1624 } // namespace v8 |
OLD | NEW |