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

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

Issue 23542029: Simplify installing concurrently recompiled code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add stack check when calling function that is in recompile queue. Created 7 years, 3 months 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
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,
77 Runtime::FunctionId function_id) {
78 FrameScope scope(masm, StackFrame::INTERNAL);
79 // Push a copy of the function onto the stack.
80 __ push(rdi);
81 // Push call kind information.
82 __ push(rcx);
83 // Function is also the parameter to the runtime call.
84 __ push(rdi);
85
86 __ CallRuntime(function_id, 1);
87 // Restore call kind information.
88 __ pop(rcx);
89 // Restore receiver.
90 __ pop(rdi);
91 }
92
93
76 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { 94 static void GenerateTailCallToSharedCode(MacroAssembler* masm) {
77 __ movq(kScratchRegister, 95 __ movq(kScratchRegister,
78 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 96 FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
79 __ movq(kScratchRegister, 97 __ movq(kScratchRegister,
80 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset)); 98 FieldOperand(kScratchRegister, SharedFunctionInfo::kCodeOffset));
81 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize)); 99 __ lea(kScratchRegister, FieldOperand(kScratchRegister, Code::kHeaderSize));
82 __ jmp(kScratchRegister); 100 __ jmp(kScratchRegister);
83 } 101 }
84 102
85 103
86 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { 104 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) {
105 Label ok;
106 // Check stack limit for signal to install code.
107 __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
108 __ j(above_equal, &ok);
109
110 CallRuntimePassFunction(masm, Runtime::kTryInstallRecompiledCode);
111 // Tail call to returned code.
112 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
113 __ jmp(rax);
114
115 __ bind(&ok);
87 GenerateTailCallToSharedCode(masm); 116 GenerateTailCallToSharedCode(masm);
88 } 117 }
89 118
90 119
91 void Builtins::Generate_InstallRecompiledCode(MacroAssembler* masm) {
92 // Enter an internal frame.
93 {
94 FrameScope scope(masm, StackFrame::INTERNAL);
95
96 // Push a copy of the function onto the stack.
97 __ push(rdi);
98 // Push call kind information.
99 __ push(rcx);
100
101 __ push(rdi); // Function is also the parameter to the runtime call.
102 __ CallRuntime(Runtime::kInstallRecompiledCode, 1);
103
104 // Restore call kind information.
105 __ pop(rcx);
106 // Restore function.
107 __ pop(rdi);
108
109 // Tear down internal frame.
110 }
111
112 // Do a tail-call of the compiled function.
113 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
114 __ jmp(rax);
115 }
116
117
118 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) { 120 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) {
119 { 121 CallRuntimePassFunction(masm, Runtime::kConcurrentRecompile);
120 FrameScope scope(masm, StackFrame::INTERNAL);
121
122 // Push a copy of the function onto the stack.
123 __ push(rdi);
124 // Push call kind information.
125 __ push(rcx);
126
127 __ push(rdi); // Function is also the parameter to the runtime call.
128 __ CallRuntime(Runtime::kConcurrentRecompile, 1);
129
130 // Restore call kind information.
131 __ pop(rcx);
132 // Restore receiver.
133 __ pop(rdi);
134
135 // Tear down internal frame.
136 }
137
138 GenerateTailCallToSharedCode(masm); 122 GenerateTailCallToSharedCode(masm);
139 } 123 }
140 124
141 125
142 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 126 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
143 bool is_api_function, 127 bool is_api_function,
144 bool count_constructions) { 128 bool count_constructions) {
145 // ----------- S t a t e ------------- 129 // ----------- S t a t e -------------
146 // -- rax: number of arguments 130 // -- rax: number of arguments
147 // -- rdi: constructor function 131 // -- rdi: constructor function
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 Generate_JSEntryTrampolineHelper(masm, false); 563 Generate_JSEntryTrampolineHelper(masm, false);
580 } 564 }
581 565
582 566
583 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 567 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
584 Generate_JSEntryTrampolineHelper(masm, true); 568 Generate_JSEntryTrampolineHelper(masm, true);
585 } 569 }
586 570
587 571
588 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { 572 void Builtins::Generate_LazyCompile(MacroAssembler* masm) {
589 // Enter an internal frame. 573 CallRuntimePassFunction(masm, Runtime::kLazyCompile);
590 {
591 FrameScope scope(masm, StackFrame::INTERNAL);
592
593 // Push a copy of the function onto the stack.
594 __ push(rdi);
595 // Push call kind information.
596 __ push(rcx);
597
598 __ push(rdi); // Function is also the parameter to the runtime call.
599 __ CallRuntime(Runtime::kLazyCompile, 1);
600
601 // Restore call kind information.
602 __ pop(rcx);
603 // Restore receiver.
604 __ pop(rdi);
605
606 // Tear down internal frame.
607 }
608
609 // Do a tail-call of the compiled function. 574 // Do a tail-call of the compiled function.
610 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); 575 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
611 __ jmp(rax); 576 __ jmp(rax);
612 } 577 }
613 578
614 579
615 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { 580 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) {
616 // Enter an internal frame. 581 CallRuntimePassFunction(masm, Runtime::kLazyRecompile);
617 {
618 FrameScope scope(masm, StackFrame::INTERNAL);
619
620 // Push a copy of the function onto the stack.
621 __ push(rdi);
622 // Push call kind information.
623 __ push(rcx);
624
625 __ push(rdi); // Function is also the parameter to the runtime call.
626 __ CallRuntime(Runtime::kLazyRecompile, 1);
627
628 // Restore call kind information.
629 __ pop(rcx);
630 // Restore function.
631 __ pop(rdi);
632
633 // Tear down internal frame.
634 }
635
636 // Do a tail-call of the compiled function. 582 // Do a tail-call of the compiled function.
637 __ lea(rax, FieldOperand(rax, Code::kHeaderSize)); 583 __ lea(rax, FieldOperand(rax, Code::kHeaderSize));
638 __ jmp(rax); 584 __ jmp(rax);
639 } 585 }
640 586
641 587
642 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { 588 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) {
643 // For now, we are relying on the fact that make_code_young doesn't do any 589 // For now, we are relying on the fact that make_code_young doesn't do any
644 // garbage collection which allows us to save/restore the registers without 590 // garbage collection which allows us to save/restore the registers without
645 // worrying about which of them contain pointers. We also don't build an 591 // worrying about which of them contain pointers. We also don't build an
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 // And "return" to the OSR entry point of the function. 1395 // And "return" to the OSR entry point of the function.
1450 __ ret(0); 1396 __ ret(0);
1451 } 1397 }
1452 1398
1453 1399
1454 #undef __ 1400 #undef __
1455 1401
1456 } } // namespace v8::internal 1402 } } // namespace v8::internal
1457 1403
1458 #endif // V8_TARGET_ARCH_X64 1404 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/objects.h ('K') | « src/runtime-profiler.cc ('k') | test/mjsunit/fuzz-natives-part1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698