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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 __ j(above_equal, &done, Label::kNear); \ | 323 __ j(above_equal, &done, Label::kNear); \ |
324 if (instr->InputAt(2)->IsRegister()) { \ | 324 if (instr->InputAt(2)->IsRegister()) { \ |
325 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ | 325 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ |
326 } else { \ | 326 } else { \ |
327 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ | 327 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ |
328 } \ | 328 } \ |
329 __ bind(&done); \ | 329 __ bind(&done); \ |
330 } while (false) | 330 } while (false) |
331 | 331 |
332 | 332 |
333 void CodeGenerator::AssembleDeconstructActivationRecord() { | 333 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
334 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 334 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
335 int stack_slots = frame()->GetSpillSlotCount(); | 335 int stack_slots = frame()->GetSpillSlotCount(); |
336 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { | 336 if (descriptor->IsJSFunctionCall() || stack_slots > 0) { |
337 __ mov(esp, ebp); | 337 __ mov(esp, ebp); |
338 __ pop(ebp); | 338 __ pop(ebp); |
339 } | 339 } |
| 340 if (stack_param_delta < 0) { |
| 341 int offset = -(stack_param_delta + 1) * kPointerSize; |
| 342 __ pop(Operand(esp, offset)); |
| 343 if (offset != 0) { |
| 344 __ add(esp, Immediate(offset)); |
| 345 } |
| 346 } |
340 } | 347 } |
341 | 348 |
342 | 349 |
343 // Assembles an instruction after register allocation, producing machine code. | 350 // Assembles an instruction after register allocation, producing machine code. |
344 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { | 351 void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
345 X87OperandConverter i(this, instr); | 352 X87OperandConverter i(this, instr); |
346 | 353 |
347 switch (ArchOpcodeField::decode(instr->opcode())) { | 354 switch (ArchOpcodeField::decode(instr->opcode())) { |
348 case kArchCallCodeObject: { | 355 case kArchCallCodeObject: { |
349 EnsureSpaceForLazyDeopt(); | 356 EnsureSpaceForLazyDeopt(); |
(...skipping 15 matching lines...) Expand all Loading... |
365 __ fninit(); | 372 __ fninit(); |
366 if (double_result) { | 373 if (double_result) { |
367 __ fld_d(Operand(esp, 0)); | 374 __ fld_d(Operand(esp, 0)); |
368 __ lea(esp, Operand(esp, kDoubleSize)); | 375 __ lea(esp, Operand(esp, kDoubleSize)); |
369 } else { | 376 } else { |
370 __ fld1(); | 377 __ fld1(); |
371 } | 378 } |
372 break; | 379 break; |
373 } | 380 } |
374 case kArchTailCallCodeObject: { | 381 case kArchTailCallCodeObject: { |
375 AssembleDeconstructActivationRecord(); | 382 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 383 AssembleDeconstructActivationRecord(stack_param_delta); |
376 if (HasImmediateInput(instr, 0)) { | 384 if (HasImmediateInput(instr, 0)) { |
377 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); | 385 Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0)); |
378 __ jmp(code, RelocInfo::CODE_TARGET); | 386 __ jmp(code, RelocInfo::CODE_TARGET); |
379 } else { | 387 } else { |
380 Register reg = i.InputRegister(0); | 388 Register reg = i.InputRegister(0); |
381 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 389 __ add(reg, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
382 __ jmp(reg); | 390 __ jmp(reg); |
383 } | 391 } |
384 break; | 392 break; |
385 } | 393 } |
(...skipping 22 matching lines...) Expand all Loading... |
408 } | 416 } |
409 break; | 417 break; |
410 } | 418 } |
411 case kArchTailCallJSFunction: { | 419 case kArchTailCallJSFunction: { |
412 Register func = i.InputRegister(0); | 420 Register func = i.InputRegister(0); |
413 if (FLAG_debug_code) { | 421 if (FLAG_debug_code) { |
414 // Check the function's context matches the context argument. | 422 // Check the function's context matches the context argument. |
415 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 423 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
416 __ Assert(equal, kWrongFunctionContext); | 424 __ Assert(equal, kWrongFunctionContext); |
417 } | 425 } |
418 AssembleDeconstructActivationRecord(); | 426 int stack_param_delta = i.InputInt32(instr->InputCount() - 1); |
| 427 AssembleDeconstructActivationRecord(stack_param_delta); |
419 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 428 __ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
420 break; | 429 break; |
421 } | 430 } |
422 case kArchLazyBailout: { | 431 case kArchLazyBailout: { |
423 EnsureSpaceForLazyDeopt(); | 432 EnsureSpaceForLazyDeopt(); |
424 RecordCallPosition(instr); | 433 RecordCallPosition(instr); |
425 break; | 434 break; |
426 } | 435 } |
427 case kArchPrepareCallCFunction: { | 436 case kArchPrepareCallCFunction: { |
428 int const num_parameters = MiscField::decode(instr->opcode()); | 437 int const num_parameters = MiscField::decode(instr->opcode()); |
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1961 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1953 __ Nop(padding_size); | 1962 __ Nop(padding_size); |
1954 } | 1963 } |
1955 } | 1964 } |
1956 | 1965 |
1957 #undef __ | 1966 #undef __ |
1958 | 1967 |
1959 } // namespace compiler | 1968 } // namespace compiler |
1960 } // namespace internal | 1969 } // namespace internal |
1961 } // namespace v8 | 1970 } // namespace v8 |
OLD | NEW |