Chromium Code Reviews| 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, | 77 static void CallRuntimePassFunctionAndTailCall( |
|
titzer
2013/12/09 14:49:28
Similar comments to the arm port on naming here.
Yang
2013/12/10 11:22:04
Done.
| |
| 78 Runtime::FunctionId function_id) { | 78 MacroAssembler* masm, Runtime::FunctionId function_id) { |
| 79 FrameScope scope(masm, StackFrame::INTERNAL); | 79 { FrameScope scope(masm, StackFrame::INTERNAL); |
| 80 // Push a copy of the function. | 80 // Push a copy of the function. |
| 81 __ push(edi); | 81 __ push(edi); |
| 82 // Push call kind information. | 82 // Push call kind information. |
| 83 __ push(ecx); | 83 __ push(ecx); |
| 84 // Function is also the parameter to the runtime call. | 84 // Function is also the parameter to the runtime call. |
| 85 __ push(edi); | 85 __ push(edi); |
| 86 | 86 |
| 87 __ CallRuntime(function_id, 1); | 87 __ CallRuntime(function_id, 1); |
| 88 // Restore call kind information. | 88 // Restore call kind information. |
| 89 __ pop(ecx); | 89 __ pop(ecx); |
| 90 // Restore receiver. | 90 // Restore receiver. |
| 91 __ pop(edi); | 91 __ pop(edi); |
| 92 } | |
| 93 // Tail call to returned code. | |
| 94 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | |
| 95 __ jmp(eax); | |
| 92 } | 96 } |
| 93 | 97 |
| 94 | 98 |
| 95 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 99 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
| 96 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 100 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 97 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); | 101 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); |
| 98 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 102 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 99 __ jmp(eax); | 103 __ jmp(eax); |
| 100 } | 104 } |
| 101 | 105 |
| 102 | 106 |
| 103 void Builtins::Generate_InRecompileQueue(MacroAssembler* masm) { | 107 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
| 104 // Checking whether the queued function is ready for install is optional, | 108 // Checking whether the queued function is ready for install is optional, |
| 105 // since we come across interrupts and stack checks elsewhere. However, | 109 // since we come across interrupts and stack checks elsewhere. However, |
| 106 // not checking may delay installing ready functions, and always checking | 110 // not checking may delay installing ready functions, and always checking |
| 107 // would be quite expensive. A good compromise is to first check against | 111 // would be quite expensive. A good compromise is to first check against |
| 108 // stack limit as a cue for an interrupt signal. | 112 // stack limit as a cue for an interrupt signal. |
| 109 Label ok; | 113 Label ok; |
| 110 ExternalReference stack_limit = | 114 ExternalReference stack_limit = |
| 111 ExternalReference::address_of_stack_limit(masm->isolate()); | 115 ExternalReference::address_of_stack_limit(masm->isolate()); |
| 112 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 116 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 113 __ j(above_equal, &ok, Label::kNear); | 117 __ j(above_equal, &ok, Label::kNear); |
| 114 | 118 |
| 115 CallRuntimePassFunction(masm, Runtime::kTryInstallRecompiledCode); | 119 CallRuntimePassFunctionAndTailCall(masm, Runtime::kTryInstallOptimizedCode); |
| 116 // Tail call to returned code. | |
| 117 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | |
| 118 __ jmp(eax); | |
| 119 | 120 |
| 120 __ bind(&ok); | 121 __ bind(&ok); |
| 121 GenerateTailCallToSharedCode(masm); | 122 GenerateTailCallToSharedCode(masm); |
| 122 } | 123 } |
| 123 | 124 |
| 124 | 125 |
| 125 void Builtins::Generate_ConcurrentRecompile(MacroAssembler* masm) { | |
| 126 CallRuntimePassFunction(masm, Runtime::kConcurrentRecompile); | |
| 127 GenerateTailCallToSharedCode(masm); | |
| 128 } | |
| 129 | |
| 130 | |
| 131 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 126 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 132 bool is_api_function, | 127 bool is_api_function, |
| 133 bool count_constructions) { | 128 bool count_constructions) { |
| 134 // ----------- S t a t e ------------- | 129 // ----------- S t a t e ------------- |
| 135 // -- eax: number of arguments | 130 // -- eax: number of arguments |
| 136 // -- edi: constructor function | 131 // -- edi: constructor function |
| 137 // ----------------------------------- | 132 // ----------------------------------- |
| 138 | 133 |
| 139 // Should never count constructions for api objects. | 134 // Should never count constructions for api objects. |
| 140 ASSERT(!is_api_function || !count_constructions); | 135 ASSERT(!is_api_function || !count_constructions); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 Generate_JSEntryTrampolineHelper(masm, false); | 498 Generate_JSEntryTrampolineHelper(masm, false); |
| 504 } | 499 } |
| 505 | 500 |
| 506 | 501 |
| 507 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 502 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
| 508 Generate_JSEntryTrampolineHelper(masm, true); | 503 Generate_JSEntryTrampolineHelper(masm, true); |
| 509 } | 504 } |
| 510 | 505 |
| 511 | 506 |
| 512 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { | 507 void Builtins::Generate_LazyCompile(MacroAssembler* masm) { |
| 513 CallRuntimePassFunction(masm, Runtime::kLazyCompile); | 508 CallRuntimePassFunctionAndTailCall(masm, Runtime::kCompileUnoptimized); |
| 514 // Do a tail-call of the compiled function. | 509 } |
| 510 | |
| 511 | |
| 512 | |
| 513 static void CallCompileOptimizedAndTailCall(MacroAssembler* masm, | |
| 514 bool concurrent) { | |
| 515 { FrameScope scope(masm, StackFrame::INTERNAL); | |
| 516 // Push a copy of the function. | |
| 517 __ push(edi); | |
| 518 // Push call kind information. | |
| 519 __ push(ecx); | |
| 520 // Function is also the parameter to the runtime call. | |
| 521 __ push(edi); | |
| 522 // Whether to compile in a background thread. | |
| 523 __ Push(masm->isolate()->factory()->ToBoolean(concurrent)); | |
| 524 | |
| 525 __ CallRuntime(Runtime::kCompileOptimized, 2); | |
| 526 // Restore call kind information. | |
| 527 __ pop(ecx); | |
| 528 // Restore receiver. | |
| 529 __ pop(edi); | |
| 530 } | |
| 531 // Tail call to returned code. | |
| 515 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 532 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| 516 __ jmp(eax); | 533 __ jmp(eax); |
| 517 } | 534 } |
| 518 | 535 |
| 519 | 536 |
| 520 void Builtins::Generate_LazyRecompile(MacroAssembler* masm) { | 537 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| 521 CallRuntimePassFunction(masm, Runtime::kLazyRecompile); | 538 CallCompileOptimizedAndTailCall(masm, false); |
| 522 // Do a tail-call of the compiled function. | 539 } |
| 523 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 540 |
| 524 __ jmp(eax); | 541 |
| 542 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { | |
| 543 CallCompileOptimizedAndTailCall(masm, true); | |
| 525 } | 544 } |
| 526 | 545 |
| 527 | 546 |
| 528 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 547 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
| 529 // For now, we are relying on the fact that make_code_young doesn't do any | 548 // For now, we are relying on the fact that make_code_young doesn't do any |
| 530 // garbage collection which allows us to save/restore the registers without | 549 // garbage collection which allows us to save/restore the registers without |
| 531 // worrying about which of them contain pointers. We also don't build an | 550 // worrying about which of them contain pointers. We also don't build an |
| 532 // internal frame to make the code faster, since we shouldn't have to do stack | 551 // internal frame to make the code faster, since we shouldn't have to do stack |
| 533 // crawls in MakeCodeYoung. This seems a bit fragile. | 552 // crawls in MakeCodeYoung. This seems a bit fragile. |
| 534 | 553 |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 | 1383 |
| 1365 __ bind(&ok); | 1384 __ bind(&ok); |
| 1366 __ ret(0); | 1385 __ ret(0); |
| 1367 } | 1386 } |
| 1368 | 1387 |
| 1369 #undef __ | 1388 #undef __ |
| 1370 } | 1389 } |
| 1371 } // namespace v8::internal | 1390 } // namespace v8::internal |
| 1372 | 1391 |
| 1373 #endif // V8_TARGET_ARCH_IA32 | 1392 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |