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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); | 66 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); |
67 } | 67 } |
68 | 68 |
69 // JumpToExternalReference expects rax to contain the number of arguments | 69 // JumpToExternalReference expects rax to contain the number of arguments |
70 // including the receiver and the extra arguments. | 70 // including the receiver and the extra arguments. |
71 __ addq(rax, Immediate(num_extra_args + 1)); | 71 __ addq(rax, Immediate(num_extra_args + 1)); |
72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); | 72 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), 1); |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 static void CallRuntimePassFunction(MacroAssembler* masm, | 76 static void CallRuntimePassFunctionAndTailCall( |
77 Runtime::FunctionId function_id) { | 77 MacroAssembler* masm, Runtime::FunctionId function_id) { |
78 FrameScope scope(masm, StackFrame::INTERNAL); | 78 { FrameScope scope(masm, StackFrame::INTERNAL); |
79 // Push a copy of the function onto the stack. | 79 // Push a copy of the function onto the stack. |
80 __ push(rdi); | 80 __ push(rdi); |
81 // Push call kind information. | 81 // Push call kind information. |
82 __ push(rcx); | 82 __ push(rcx); |
83 // Function is also the parameter to the runtime call. | 83 // Function is also the parameter to the runtime call. |
84 __ push(rdi); | 84 __ push(rdi); |
85 | 85 |
86 __ CallRuntime(function_id, 1); | 86 __ CallRuntime(function_id, 1); |
87 // Restore call kind information. | 87 // Restore call kind information. |
88 __ pop(rcx); | 88 __ pop(rcx); |
89 // Restore receiver. | 89 // Restore receiver. |
90 __ pop(rdi); | 90 __ pop(rdi); |
| 91 } |
| 92 // Tail call to returned code. |
| 93 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); |
| 94 __ jmp(rax); |
91 } | 95 } |
92 | 96 |
93 | 97 |
94 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 98 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
95 __ movq(kScratchRegister, | 99 __ movq(kScratchRegister, |
96 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 100 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
97 __ movq(kScratchRegister, | 101 __ movq(kScratchRegister, |
98 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); | 102 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); |
99 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); | 103 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); |
100 __ jmp(kScratchRegister); | 104 __ jmp(kScratchRegister); |
101 } | 105 } |
102 | 106 |
103 | 107 |
104 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { | 108 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
105 // Checking whether the queued function is ready for install is optional, | 109 // Checking whether the queued function is ready for install is optional, |
106 // since we come across interrupts and stack checks elsewhere. However, | 110 // since we come across interrupts and stack checks elsewhere. However, |
107 // not checking may delay installing ready functions, and always checking | 111 // not checking may delay installing ready functions, and always checking |
108 // would be quite expensive. A good compromise is to first check against | 112 // would be quite expensive. A good compromise is to first check against |
109 // stack limit as a cue for an interrupt signal. | 113 // stack limit as a cue for an interrupt signal. |
110 Label ok; | 114 Label ok; |
111 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 115 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
112 __ j(above_equal, &ok); | 116 __ j(above_equal, &ok); |
113 | 117 |
114 CallRuntimePassFunction(masm, Runtime::kTryInstallRecompiledCode); | 118 CallRuntimePassFunctionAndTailCall(masm, Runtime::kTryInstallOptimizedCode); |
115 // Tail call to returned code. | |
116 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); | |
117 __ jmp(rax); | |
118 | 119 |
119 __ bind(&ok); | 120 __ bind(&ok); |
120 GenerateTailCallToSharedCode(masm); | 121 GenerateTailCallToSharedCode(masm); |
121 } | 122 } |
122 | 123 |
123 | 124 |
124 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) { | |
125 CallRuntimePassFunction(masm, Runtime::kConcurrentRecompile); | |
126 GenerateTailCallToSharedCode(masm); | |
127 } | |
128 | |
129 | |
130 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 125 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
131 bool is_api_function, | 126 bool is_api_function, |
132 bool count_constructions) { | 127 bool count_constructions) { |
133 // ----------- S t a t e ------------- | 128 // ----------- S t a t e ------------- |
134 // -- rax: number of arguments | 129 // -- rax: number of arguments |
135 // -- rdi: constructor function | 130 // -- rdi: constructor function |
136 // ----------------------------------- | 131 // ----------------------------------- |
137 | 132 |
138 // Should never count constructions for api objects. | 133 // Should never count constructions for api objects. |
139 ASSERT(!is_api_function || !count_constructions); | 134 ASSERT(!is_api_function || !count_constructions); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 Generate_JSEntryTrampolineHelper(masm, false); | 562 Generate_JSEntryTrampolineHelper(masm, false); |
568 } | 563 } |
569 | 564 |
570 | 565 |
571 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 566 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
572 Generate_JSEntryTrampolineHelper(masm, true); | 567 Generate_JSEntryTrampolineHelper(masm, true); |
573 } | 568 } |
574 | 569 |
575 | 570 |
576 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { | 571 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { |
577 CallRuntimePassFunction(masm, Runtime::kLazyCompile); | 572 CallRuntimePassFunctionAndTailCall(masm, Runtime::kCompileUnoptimized); |
578 // Do a tail-call of the compiled function. | 573 } |
| 574 |
| 575 |
| 576 static void CallCompileOptimizedAndTailCall(MacroAssembler* masm, |
| 577 bool concurrent) { |
| 578 { FrameScope scope(masm, StackFrame::INTERNAL); |
| 579 // Push a copy of the function onto the stack. |
| 580 __ push(rdi); |
| 581 // Push call kind information. |
| 582 __ push(rcx); |
| 583 // Function is also the parameter to the runtime call. |
| 584 __ push(rdi); |
| 585 // Whether to compile in a background thread. |
| 586 __ Push(masm->isolate()->factory()->ToBoolean(concurrent)); |
| 587 |
| 588 __ CallRuntime(Runtime::kCompileOptimized, 2); |
| 589 // Restore call kind information. |
| 590 __ pop(rcx); |
| 591 // Restore receiver. |
| 592 __ pop(rdi); |
| 593 } |
| 594 // Tail call to returned code. |
579 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); | 595 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); |
580 __ jmp(rax); | 596 __ jmp(rax); |
581 } | 597 } |
582 | 598 |
583 | 599 |
584 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { | 600 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
585 CallRuntimePassFunction(masm, Runtime::kLazyRecompile); | 601 CallCompileOptimizedAndTailCall(masm, false); |
586 // Do a tail-call of the compiled function. | 602 } |
587 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); | 603 |
588 __ jmp(rax); | 604 |
| 605 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
| 606 CallCompileOptimizedAndTailCall(masm, true); |
589 } | 607 } |
590 | 608 |
591 | 609 |
592 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 610 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
593 // For now, we are relying on the fact that make_code_young doesn't do any | 611 // For now, we are relying on the fact that make_code_young doesn't do any |
594 // garbage collection which allows us to save/restore the registers without | 612 // garbage collection which allows us to save/restore the registers without |
595 // worrying about which of them contain pointers. We also don't build an | 613 // worrying about which of them contain pointers. We also don't build an |
596 // internal frame to make the code faster, since we shouldn't have to do stack | 614 // internal frame to make the code faster, since we shouldn't have to do stack |
597 // crawls in MakeCodeYoung. This seems a bit fragile. | 615 // crawls in MakeCodeYoung. This seems a bit fragile. |
598 | 616 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 __ bind(&ok); | 1457 __ bind(&ok); |
1440 __ ret(0); | 1458 __ ret(0); |
1441 } | 1459 } |
1442 | 1460 |
1443 | 1461 |
1444 #undef __ | 1462 #undef __ |
1445 | 1463 |
1446 } } // namespace v8::internal | 1464 } } // namespace v8::internal |
1447 | 1465 |
1448 #endif // V8_TARGET_ARCH_X64 | 1466 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |