| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); | 67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // JumpToExternalReference expects eax to contain the number of arguments | 70 // JumpToExternalReference expects eax to contain the number of arguments |
| 71 // including the receiver and the extra arguments. | 71 // including the receiver and the extra arguments. |
| 72 __ add(eax, Immediate(num_extra_args + 1)); | 72 __ add(eax, Immediate(num_extra_args + 1)); |
| 73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 static void CallRuntimePassFunction(MacroAssembler* masm, |
| 78 Runtime::FunctionId function_id) { |
| 79 FrameScope scope(masm, StackFrame::INTERNAL); |
| 80 // Push a copy of the function. |
| 81 __ push(edi); |
| 82 // Push call kind information. |
| 83 __ push(ecx); |
| 84 // Function is also the parameter to the runtime call. |
| 85 __ push(edi); |
| 86 |
| 87 __ CallRuntime(function_id, 1); |
| 88 // Restore call kind information. |
| 89 __ pop(ecx); |
| 90 // Restore receiver. |
| 91 __ pop(edi); |
| 92 } |
| 93 |
| 94 |
| 77 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 95 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
| 78 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 96 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 79 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); | 97 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); |
| 80 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 98 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 81 __ jmp(eax); | 99 __ jmp(eax); |
| 82 } | 100 } |
| 83 | 101 |
| 84 | 102 |
| 85 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { | 103 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { |
| 104 // Checking whether the queued function is ready for install is optional, |
| 105 // since we come across interrupts and stack checks elsewhere. However, |
| 106 // not checking may delay installing ready functions, and always checking |
| 107 // would be quite expensive. A good compromise is to first check against |
| 108 // stack limit as a cue for an interrupt signal. |
| 109 Label ok; |
| 110 ExternalReference stack_limit = |
| 111 ExternalReference::address_of_stack_limit(masm->isolate()); |
| 112 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 113 __ j(above_equal, &ok, Label::kNear); |
| 114 |
| 115 CallRuntimePassFunction(masm, Runtime::kTryInstallRecompiledCode); |
| 116 // Tail call to returned code. |
| 117 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 118 __ jmp(eax); |
| 119 |
| 120 __ bind(&ok); |
| 86 GenerateTailCallToSharedCode(masm); | 121 GenerateTailCallToSharedCode(masm); |
| 87 } | 122 } |
| 88 | 123 |
| 89 | 124 |
| 90 void Builtins::Generate_InstallRecompiledCode(MacroAssembler* masm) { | |
| 91 { | |
| 92 FrameScope scope(masm, StackFrame::INTERNAL); | |
| 93 | |
| 94 // Push a copy of the function. | |
| 95 __ push(edi); | |
| 96 // Push call kind information. | |
| 97 __ push(ecx); | |
| 98 | |
| 99 __ push(edi); // Function is also the parameter to the runtime call. | |
| 100 __ CallRuntime(Runtime::kInstallRecompiledCode, 1); | |
| 101 | |
| 102 // Restore call kind information. | |
| 103 __ pop(ecx); | |
| 104 // Restore receiver. | |
| 105 __ pop(edi); | |
| 106 | |
| 107 // Tear down internal frame. | |
| 108 } | |
| 109 | |
| 110 // Do a tail-call of the compiled function. | |
| 111 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | |
| 112 __ jmp(eax); | |
| 113 } | |
| 114 | |
| 115 | |
| 116 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) { | 125 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) { |
| 117 { | 126 CallRuntimePassFunction(masm, Runtime::kConcurrentRecompile); |
| 118 FrameScope scope(masm, StackFrame::INTERNAL); | |
| 119 | |
| 120 // Push a copy of the function onto the stack. | |
| 121 __ push(edi); | |
| 122 // Push call kind information. | |
| 123 __ push(ecx); | |
| 124 | |
| 125 __ push(edi); // Function is also the parameter to the runtime call. | |
| 126 __ CallRuntime(Runtime::kConcurrentRecompile, 1); | |
| 127 | |
| 128 // Restore call kind information. | |
| 129 __ pop(ecx); | |
| 130 // Restore receiver. | |
| 131 __ pop(edi); | |
| 132 | |
| 133 // Tear down internal frame. | |
| 134 } | |
| 135 | |
| 136 GenerateTailCallToSharedCode(masm); | 127 GenerateTailCallToSharedCode(masm); |
| 137 } | 128 } |
| 138 | 129 |
| 139 | 130 |
| 140 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 131 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 141 bool is_api_function, | 132 bool is_api_function, |
| 142 bool count_constructions) { | 133 bool count_constructions) { |
| 143 // ----------- S t a t e ------------- | 134 // ----------- S t a t e ------------- |
| 144 // -- eax: number of arguments | 135 // -- eax: number of arguments |
| 145 // -- edi: constructor function | 136 // -- edi: constructor function |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 Generate_JSEntryTrampolineHelper(masm, false); | 503 Generate_JSEntryTrampolineHelper(masm, false); |
| 513 } | 504 } |
| 514 | 505 |
| 515 | 506 |
| 516 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 507 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
| 517 Generate_JSEntryTrampolineHelper(masm, true); | 508 Generate_JSEntryTrampolineHelper(masm, true); |
| 518 } | 509 } |
| 519 | 510 |
| 520 | 511 |
| 521 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { | 512 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { |
| 522 { | 513 CallRuntimePassFunction(masm, Runtime::kLazyCompile); |
| 523 FrameScope scope(masm, StackFrame::INTERNAL); | |
| 524 | |
| 525 // Push a copy of the function. | |
| 526 __ push(edi); | |
| 527 // Push call kind information. | |
| 528 __ push(ecx); | |
| 529 | |
| 530 __ push(edi); // Function is also the parameter to the runtime call. | |
| 531 __ CallRuntime(Runtime::kLazyCompile, 1); | |
| 532 | |
| 533 // Restore call kind information. | |
| 534 __ pop(ecx); | |
| 535 // Restore receiver. | |
| 536 __ pop(edi); | |
| 537 | |
| 538 // Tear down internal frame. | |
| 539 } | |
| 540 | |
| 541 // Do a tail-call of the compiled function. | 514 // Do a tail-call of the compiled function. |
| 542 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 515 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 543 __ jmp(eax); | 516 __ jmp(eax); |
| 544 } | 517 } |
| 545 | 518 |
| 546 | 519 |
| 547 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { | 520 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { |
| 548 { | 521 CallRuntimePassFunction(masm, Runtime::kLazyRecompile); |
| 549 FrameScope scope(masm, StackFrame::INTERNAL); | |
| 550 | |
| 551 // Push a copy of the function onto the stack. | |
| 552 __ push(edi); | |
| 553 // Push call kind information. | |
| 554 __ push(ecx); | |
| 555 | |
| 556 __ push(edi); // Function is also the parameter to the runtime call. | |
| 557 __ CallRuntime(Runtime::kLazyRecompile, 1); | |
| 558 | |
| 559 // Restore call kind information. | |
| 560 __ pop(ecx); | |
| 561 // Restore receiver. | |
| 562 __ pop(edi); | |
| 563 | |
| 564 // Tear down internal frame. | |
| 565 } | |
| 566 | |
| 567 // Do a tail-call of the compiled function. | 522 // Do a tail-call of the compiled function. |
| 568 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 523 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 569 __ jmp(eax); | 524 __ jmp(eax); |
| 570 } | 525 } |
| 571 | 526 |
| 572 | 527 |
| 573 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 528 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
| 574 // For now, we are relying on the fact that make_code_young doesn't do any | 529 // For now, we are relying on the fact that make_code_young doesn't do any |
| 575 // garbage collection which allows us to save/restore the registers without | 530 // garbage collection which allows us to save/restore the registers without |
| 576 // worrying about which of them contain pointers. We also don't build an | 531 // worrying about which of them contain pointers. We also don't build an |
| 577 // internal frame to make the code faster, since we shouldn't have to do stack | 532 // internal frame to make the code faster, since we shouldn't have to do stack |
| 578 // crawls in MakeCodeYoung. This seems a bit fragile. | 533 // crawls in MakeCodeYoung. This seems a bit fragile. |
| 579 | 534 |
| 580 // Re-execute the code that was patched back to the young age when | 535 // Re-execute the code that was patched back to the young age when |
| 581 // the stub returns. | 536 // the stub returns. |
| 582 __ sub(Operand(esp, 0), Immediate(5)); | 537 __ sub(Operand(esp, 0), Immediate(5)); |
| 583 __ pushad(); | 538 __ pushad(); |
| 584 __ mov(eax, Operand(esp, 8 * kPointerSize)); | 539 __ mov(eax, Operand(esp, 8 * kPointerSize)); |
| 585 { | 540 { |
| 586 FrameScope scope(masm, StackFrame::MANUAL); | 541 FrameScope scope(masm, StackFrame::MANUAL); |
| 587 __ PrepareCallCFunction(1, ebx); | 542 __ PrepareCallCFunction(2, ebx); |
| 543 __ mov(Operand(esp, 1 * kPointerSize), |
| 544 Immediate(ExternalReference::isolate_address(masm->isolate()))); |
| 588 __ mov(Operand(esp, 0), eax); | 545 __ mov(Operand(esp, 0), eax); |
| 589 __ CallCFunction( | 546 __ CallCFunction( |
| 590 ExternalReference::get_make_code_young_function(masm->isolate()), 1); | 547 ExternalReference::get_make_code_young_function(masm->isolate()), 2); |
| 591 } | 548 } |
| 592 __ popad(); | 549 __ popad(); |
| 593 __ ret(0); | 550 __ ret(0); |
| 594 } | 551 } |
| 595 | 552 |
| 596 #define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ | 553 #define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ |
| 597 void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \ | 554 void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \ |
| 598 MacroAssembler* masm) { \ | 555 MacroAssembler* masm) { \ |
| 599 GenerateMakeCodeYoungAgainCommon(masm); \ | 556 GenerateMakeCodeYoungAgainCommon(masm); \ |
| 600 } \ | 557 } \ |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 // And "return" to the OSR entry point of the function. | 1326 // And "return" to the OSR entry point of the function. |
| 1370 __ ret(0); | 1327 __ ret(0); |
| 1371 } | 1328 } |
| 1372 | 1329 |
| 1373 | 1330 |
| 1374 #undef __ | 1331 #undef __ |
| 1375 } | 1332 } |
| 1376 } // namespace v8::internal | 1333 } // namespace v8::internal |
| 1377 | 1334 |
| 1378 #endif // V8_TARGET_ARCH_IA32 | 1335 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |