Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: src/x64/builtins-x64.cc

Issue 110203002: Refactor the compiling pipeline. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 CallRuntimePassFunction(
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 } 91 }
92 92
93 93
94 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { 94 static void GenerateTailCallToSharedCode(MacroAssembler* masm) {
95 __ movq(kScratchRegister, 95 __ movq(kScratchRegister,
96 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 96 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
97 __ movq(kScratchRegister, 97 __ movq(kScratchRegister,
98 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); 98 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset));
99 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); 99 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize));
100 __ jmp(kScratchRegister); 100 __ jmp(kScratchRegister);
101 } 101 }
102 102
103 103
104 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { 104 static void GenerateTailCallToReturnedCode(MacroAssembler* masm) {
105 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
106 __ jmp(rax);
107 }
108
109
110 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) {
105 // Checking whether the queued function is ready for install is optional, 111 // Checking whether the queued function is ready for install is optional,
106 // since we come across interrupts and stack checks elsewhere. However, 112 // since we come across interrupts and stack checks elsewhere. However,
107 // not checking may delay installing ready functions, and always checking 113 // not checking may delay installing ready functions, and always checking
108 // would be quite expensive. A good compromise is to first check against 114 // would be quite expensive. A good compromise is to first check against
109 // stack limit as a cue for an interrupt signal. 115 // stack limit as a cue for an interrupt signal.
110 Label ok; 116 Label ok;
111 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); 117 __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
112 __ j(above_equal, &ok); 118 __ j(above_equal, &ok);
113 119
114 CallRuntimePassFunction(masm, Runtime::kTryInstallRecompiledCode); 120 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode);
115 // Tail call to returned code. 121 GenerateTailCallToReturnedCode(masm);
116 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
117 __ jmp(rax);
118 122
119 __ bind(&ok); 123 __ bind(&ok);
120 GenerateTailCallToSharedCode(masm); 124 GenerateTailCallToSharedCode(masm);
121 } 125 }
122 126
123 127
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, 128 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
131 bool is_api_function, 129 bool is_api_function,
132 bool count_constructions) { 130 bool count_constructions) {
133 // ----------- S t a t e ------------- 131 // ----------- S t a t e -------------
134 // -- rax: number of arguments 132 // -- rax: number of arguments
135 // -- rdi: constructor function 133 // -- rdi: constructor function
136 // ----------------------------------- 134 // -----------------------------------
137 135
138 // Should never count constructions for api objects. 136 // Should never count constructions for api objects.
139 ASSERT(!is_api_function || !count_constructions); 137 ASSERT(!is_api_function || !count_constructions);
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 564 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
567 Generate_JSEntryTrampolineHelper(masm, false); 565 Generate_JSEntryTrampolineHelper(masm, false);
568 } 566 }
569 567
570 568
571 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 569 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
572 Generate_JSEntryTrampolineHelper(masm, true); 570 Generate_JSEntryTrampolineHelper(masm, true);
573 } 571 }
574 572
575 573
576 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { 574 void Builtins::Generate_CompileUnoptimized(MacroAssembler* masm) {
577 CallRuntimePassFunction(masm, Runtime::kLazyCompile); 575 CallRuntimePassFunction(masm, Runtime::kCompileUnoptimized);
578 // Do a tail-call of the compiled function. 576 GenerateTailCallToReturnedCode(masm);
579 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
580 __ jmp(rax);
581 } 577 }
582 578
583 579
584 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { 580 static void CallCompileOptimized(MacroAssembler* masm,
585 CallRuntimePassFunction(masm, Runtime::kLazyRecompile); 581 bool concurrent) {
586 // Do a tail-call of the compiled function. 582 FrameScope scope(masm, StackFrame::INTERNAL);
587 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); 583 // Push a copy of the function onto the stack.
588 __ jmp(rax); 584 __ push(rdi);
585 // Push call kind information.
586 __ push(rcx);
587 // Function is also the parameter to the runtime call.
588 __ push(rdi);
589 // Whether to compile in a background thread.
590 __ Push(masm->isolate()->factory()->ToBoolean(concurrent));
591
592 __ CallRuntime(Runtime::kCompileOptimized, 2);
593 // Restore call kind information.
594 __ pop(rcx);
595 // Restore receiver.
596 __ pop(rdi);
589 } 597 }
590 598
591 599
600 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
601 CallCompileOptimized(masm, false);
602 GenerateTailCallToReturnedCode(masm);
603 }
604
605
606 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) {
607 CallCompileOptimized(masm, true);
608 GenerateTailCallToReturnedCode(masm);
609 }
610
611
592 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 612 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
593 // For now, we are relying on the fact that make_code_young doesn't do any 613 // 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 614 // 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 615 // 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 616 // internal frame to make the code faster, since we shouldn't have to do stack
597 // crawls in MakeCodeYoung. This seems a bit fragile. 617 // crawls in MakeCodeYoung. This seems a bit fragile.
598 618
599 // Re-execute the code that was patched back to the young age when 619 // Re-execute the code that was patched back to the young age when
600 // the stub returns. 620 // the stub returns.
601 __ subq(Operand(rsp, 0), Immediate(5)); 621 __ subq(Operand(rsp, 0), Immediate(5));
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 __ bind(&ok); 1459 __ bind(&ok);
1440 __ ret(0); 1460 __ ret(0);
1441 } 1461 }
1442 1462
1443 1463
1444 #undef __ 1464 #undef __
1445 1465
1446 } } // namespace v8::internal 1466 } } // namespace v8::internal
1447 1467
1448 #endif // V8_TARGET_ARCH_X64 1468 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/utils.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698