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

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

Issue 652118: Refactored TailCallRuntime (splitted to TailCallRuntime and TailCallExternalReference) (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/ic-x64.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 6327 matching lines...) Expand 10 before | Expand all | Expand 10 after
6338 // Return and remove the on-stack parameter. 6338 // Return and remove the on-stack parameter.
6339 __ ret(1 * kPointerSize); 6339 __ ret(1 * kPointerSize);
6340 6340
6341 // Create a new closure through the slower runtime call. 6341 // Create a new closure through the slower runtime call.
6342 __ bind(&gc); 6342 __ bind(&gc);
6343 __ pop(rcx); // Temporarily remove return address. 6343 __ pop(rcx); // Temporarily remove return address.
6344 __ pop(rdx); 6344 __ pop(rdx);
6345 __ push(rsi); 6345 __ push(rsi);
6346 __ push(rdx); 6346 __ push(rdx);
6347 __ push(rcx); // Restore return address. 6347 __ push(rcx); // Restore return address.
6348 __ TailCallRuntime(ExternalReference(Runtime::kNewClosure), 2, 1); 6348 __ TailCallRuntime(Runtime::kNewClosure, 2, 1);
6349 } 6349 }
6350 6350
6351 6351
6352 void FastNewContextStub::Generate(MacroAssembler* masm) { 6352 void FastNewContextStub::Generate(MacroAssembler* masm) {
6353 // Try to allocate the context in new space. 6353 // Try to allocate the context in new space.
6354 Label gc; 6354 Label gc;
6355 int length = slots_ + Context::MIN_CONTEXT_SLOTS; 6355 int length = slots_ + Context::MIN_CONTEXT_SLOTS;
6356 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, 6356 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize,
6357 rax, rbx, rcx, &gc, TAG_OBJECT); 6357 rax, rbx, rcx, &gc, TAG_OBJECT);
6358 6358
(...skipping 21 matching lines...) Expand all
6380 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { 6380 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
6381 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); 6381 __ movq(Operand(rax, Context::SlotOffset(i)), rbx);
6382 } 6382 }
6383 6383
6384 // Return and remove the on-stack parameter. 6384 // Return and remove the on-stack parameter.
6385 __ movq(rsi, rax); 6385 __ movq(rsi, rax);
6386 __ ret(1 * kPointerSize); 6386 __ ret(1 * kPointerSize);
6387 6387
6388 // Need to collect. Call into runtime system. 6388 // Need to collect. Call into runtime system.
6389 __ bind(&gc); 6389 __ bind(&gc);
6390 __ TailCallRuntime(ExternalReference(Runtime::kNewContext), 1, 1); 6390 __ TailCallRuntime(Runtime::kNewContext, 1, 1);
6391 } 6391 }
6392 6392
6393 6393
6394 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { 6394 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
6395 // Stack layout on entry: 6395 // Stack layout on entry:
6396 // 6396 //
6397 // [rsp + kPointerSize]: constant elements. 6397 // [rsp + kPointerSize]: constant elements.
6398 // [rsp + (2 * kPointerSize)]: literal index. 6398 // [rsp + (2 * kPointerSize)]: literal index.
6399 // [rsp + (3 * kPointerSize)]: literals array. 6399 // [rsp + (3 * kPointerSize)]: literals array.
6400 6400
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6436 for (int i = 0; i < elements_size; i += kPointerSize) { 6436 for (int i = 0; i < elements_size; i += kPointerSize) {
6437 __ movq(rbx, FieldOperand(rcx, i)); 6437 __ movq(rbx, FieldOperand(rcx, i));
6438 __ movq(FieldOperand(rdx, i), rbx); 6438 __ movq(FieldOperand(rdx, i), rbx);
6439 } 6439 }
6440 } 6440 }
6441 6441
6442 // Return and remove the on-stack parameters. 6442 // Return and remove the on-stack parameters.
6443 __ ret(3 * kPointerSize); 6443 __ ret(3 * kPointerSize);
6444 6444
6445 __ bind(&slow_case); 6445 __ bind(&slow_case);
6446 ExternalReference runtime(Runtime::kCreateArrayLiteralShallow); 6446 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
6447 __ TailCallRuntime(runtime, 3, 1);
6448 } 6447 }
6449 6448
6450 6449
6451 void ToBooleanStub::Generate(MacroAssembler* masm) { 6450 void ToBooleanStub::Generate(MacroAssembler* masm) {
6452 Label false_result, true_result, not_string; 6451 Label false_result, true_result, not_string;
6453 __ movq(rax, Operand(rsp, 1 * kPointerSize)); 6452 __ movq(rax, Operand(rsp, 1 * kPointerSize));
6454 6453
6455 // 'null' => false. 6454 // 'null' => false.
6456 __ CompareRoot(rax, Heap::kNullValueRootIndex); 6455 __ CompareRoot(rax, Heap::kNullValueRootIndex);
6457 __ j(equal, &false_result); 6456 __ j(equal, &false_result);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
6796 UNREACHABLE(); 6795 UNREACHABLE();
6797 } 6796 }
6798 } 6797 }
6799 6798
6800 6799
6801 void RegExpExecStub::Generate(MacroAssembler* masm) { 6800 void RegExpExecStub::Generate(MacroAssembler* masm) {
6802 // Just jump directly to runtime if native RegExp is not selected at compile 6801 // Just jump directly to runtime if native RegExp is not selected at compile
6803 // time or if regexp entry in generated code is turned off runtime switch or 6802 // time or if regexp entry in generated code is turned off runtime switch or
6804 // at compilation. 6803 // at compilation.
6805 #ifndef V8_NATIVE_REGEXP 6804 #ifndef V8_NATIVE_REGEXP
6806 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 6805 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
6807 #else // V8_NATIVE_REGEXP 6806 #else // V8_NATIVE_REGEXP
6808 if (!FLAG_regexp_entry_native) { 6807 if (!FLAG_regexp_entry_native) {
6809 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 6808 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
6810 return; 6809 return;
6811 } 6810 }
6812 6811
6813 // Stack frame on entry. 6812 // Stack frame on entry.
6814 // esp[0]: return address 6813 // esp[0]: return address
6815 // esp[8]: last_match_info (expected JSArray) 6814 // esp[8]: last_match_info (expected JSArray)
6816 // esp[16]: previous index 6815 // esp[16]: previous index
6817 // esp[24]: subject string 6816 // esp[24]: subject string
6818 // esp[32]: JSRegExp object 6817 // esp[32]: JSRegExp object
6819 6818
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7143 rdi); 7142 rdi);
7144 __ jmp(&next_capture); 7143 __ jmp(&next_capture);
7145 __ bind(&done); 7144 __ bind(&done);
7146 7145
7147 // Return last match info. 7146 // Return last match info.
7148 __ movq(rax, Operand(rsp, kLastMatchInfoOffset)); 7147 __ movq(rax, Operand(rsp, kLastMatchInfoOffset));
7149 __ ret(4 * kPointerSize); 7148 __ ret(4 * kPointerSize);
7150 7149
7151 // Do the runtime call to execute the regexp. 7150 // Do the runtime call to execute the regexp.
7152 __ bind(&runtime); 7151 __ bind(&runtime);
7153 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 7152 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
7154 #endif // V8_NATIVE_REGEXP 7153 #endif // V8_NATIVE_REGEXP
7155 } 7154 }
7156 7155
7157 7156
7158 void CompareStub::Generate(MacroAssembler* masm) { 7157 void CompareStub::Generate(MacroAssembler* masm) {
7159 Label call_builtin, done; 7158 Label call_builtin, done;
7160 7159
7161 // NOTICE! This code is only reached after a smi-fast-case check, so 7160 // NOTICE! This code is only reached after a smi-fast-case check, so
7162 // it is certain that at least one operand isn't a smi. 7161 // it is certain that at least one operand isn't a smi.
7163 7162
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
7554 __ subq(rdx, Immediate(kPointerSize)); 7553 __ subq(rdx, Immediate(kPointerSize));
7555 __ decq(rcx); 7554 __ decq(rcx);
7556 __ j(not_zero, &loop); 7555 __ j(not_zero, &loop);
7557 7556
7558 // Return and remove the on-stack parameters. 7557 // Return and remove the on-stack parameters.
7559 __ bind(&done); 7558 __ bind(&done);
7560 __ ret(3 * kPointerSize); 7559 __ ret(3 * kPointerSize);
7561 7560
7562 // Do the runtime call to allocate the arguments object. 7561 // Do the runtime call to allocate the arguments object.
7563 __ bind(&runtime); 7562 __ bind(&runtime);
7564 __ TailCallRuntime(ExternalReference(Runtime::kNewArgumentsFast), 3, 1); 7563 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
7565 } 7564 }
7566 7565
7567 7566
7568 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { 7567 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
7569 // The key is in rdx and the parameter count is in rax. 7568 // The key is in rdx and the parameter count is in rax.
7570 7569
7571 // The displacement is used for skipping the frame pointer on the 7570 // The displacement is used for skipping the frame pointer on the
7572 // stack. It is the offset of the last parameter (if any) relative 7571 // stack. It is the offset of the last parameter (if any) relative
7573 // to the frame pointer. 7572 // to the frame pointer.
7574 static const int kDisplacement = 1 * kPointerSize; 7573 static const int kDisplacement = 1 * kPointerSize;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7611 index = masm->SmiToNegativeIndex(rdx, rdx, kPointerSizeLog2); 7610 index = masm->SmiToNegativeIndex(rdx, rdx, kPointerSizeLog2);
7612 __ movq(rax, Operand(rbx, index.reg, index.scale, kDisplacement)); 7611 __ movq(rax, Operand(rbx, index.reg, index.scale, kDisplacement));
7613 __ Ret(); 7612 __ Ret();
7614 7613
7615 // Slow-case: Handle non-smi or out-of-bounds access to arguments 7614 // Slow-case: Handle non-smi or out-of-bounds access to arguments
7616 // by calling the runtime system. 7615 // by calling the runtime system.
7617 __ bind(&slow); 7616 __ bind(&slow);
7618 __ pop(rbx); // Return address. 7617 __ pop(rbx); // Return address.
7619 __ push(rdx); 7618 __ push(rdx);
7620 __ push(rbx); 7619 __ push(rbx);
7621 Runtime::Function* f = 7620 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1);
7622 Runtime::FunctionForId(Runtime::kGetArgumentsProperty);
7623 __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
7624 } 7621 }
7625 7622
7626 7623
7627 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { 7624 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) {
7628 // Check if the calling frame is an arguments adaptor frame. 7625 // Check if the calling frame is an arguments adaptor frame.
7629 Label adaptor; 7626 Label adaptor;
7630 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); 7627 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
7631 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset), 7628 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset),
7632 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); 7629 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
7633 7630
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
8102 void StackCheckStub::Generate(MacroAssembler* masm) { 8099 void StackCheckStub::Generate(MacroAssembler* masm) {
8103 // Because builtins always remove the receiver from the stack, we 8100 // Because builtins always remove the receiver from the stack, we
8104 // have to fake one to avoid underflowing the stack. The receiver 8101 // have to fake one to avoid underflowing the stack. The receiver
8105 // must be inserted below the return address on the stack so we 8102 // must be inserted below the return address on the stack so we
8106 // temporarily store that in a register. 8103 // temporarily store that in a register.
8107 __ pop(rax); 8104 __ pop(rax);
8108 __ Push(Smi::FromInt(0)); 8105 __ Push(Smi::FromInt(0));
8109 __ push(rax); 8106 __ push(rax);
8110 8107
8111 // Do tail-call to runtime routine. 8108 // Do tail-call to runtime routine.
8112 Runtime::Function* f = Runtime::FunctionForId(Runtime::kStackGuard); 8109 __ TailCallRuntime(Runtime::kStackGuard, 1, 1);
8113 __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
8114 } 8110 }
8115 8111
8116 8112
8117 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm, 8113 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
8118 Register number) { 8114 Register number) {
8119 Label load_smi, done; 8115 Label load_smi, done;
8120 8116
8121 __ JumpIfSmi(number, &load_smi); 8117 __ JumpIfSmi(number, &load_smi);
8122 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset)); 8118 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset));
8123 __ jmp(&done); 8119 __ jmp(&done);
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
9101 // rcx: next character of result 9097 // rcx: next character of result
9102 // rdx: first char of second argument 9098 // rdx: first char of second argument
9103 // rdi: length of second argument 9099 // rdi: length of second argument
9104 GenerateCopyCharacters(masm, rcx, rdx, rdi, false); 9100 GenerateCopyCharacters(masm, rcx, rdx, rdi, false);
9105 __ movq(rax, rbx); 9101 __ movq(rax, rbx);
9106 __ IncrementCounter(&Counters::string_add_native, 1); 9102 __ IncrementCounter(&Counters::string_add_native, 1);
9107 __ ret(2 * kPointerSize); 9103 __ ret(2 * kPointerSize);
9108 9104
9109 // Just jump to runtime to add the two strings. 9105 // Just jump to runtime to add the two strings.
9110 __ bind(&string_add_runtime); 9106 __ bind(&string_add_runtime);
9111 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); 9107 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
9112 } 9108 }
9113 9109
9114 9110
9115 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, 9111 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm,
9116 Register dest, 9112 Register dest,
9117 Register src, 9113 Register src,
9118 Register count, 9114 Register count,
9119 bool ascii) { 9115 bool ascii) {
9120 Label loop; 9116 Label loop;
9121 __ bind(&loop); 9117 __ bind(&loop);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
9295 // rdx: original value of rsi 9291 // rdx: original value of rsi
9296 // rdi: first character of result 9292 // rdi: first character of result
9297 // rsi: character of sub string start 9293 // rsi: character of sub string start
9298 GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false); 9294 GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false);
9299 __ movq(rsi, rdx); // Restore esi. 9295 __ movq(rsi, rdx); // Restore esi.
9300 __ IncrementCounter(&Counters::sub_string_native, 1); 9296 __ IncrementCounter(&Counters::sub_string_native, 1);
9301 __ ret(kArgumentsSize); 9297 __ ret(kArgumentsSize);
9302 9298
9303 // Just jump to runtime to create the sub string. 9299 // Just jump to runtime to create the sub string.
9304 __ bind(&runtime); 9300 __ bind(&runtime);
9305 __ TailCallRuntime(ExternalReference(Runtime::kSubString), 3, 1); 9301 __ TailCallRuntime(Runtime::kSubString, 3, 1);
9306 } 9302 }
9307 9303
9308 9304
9309 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, 9305 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
9310 Register left, 9306 Register left,
9311 Register right, 9307 Register right,
9312 Register scratch1, 9308 Register scratch1,
9313 Register scratch2, 9309 Register scratch2,
9314 Register scratch3, 9310 Register scratch3,
9315 Register scratch4) { 9311 Register scratch4) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
9415 // Check that both are sequential ASCII strings. 9411 // Check that both are sequential ASCII strings.
9416 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime); 9412 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime);
9417 9413
9418 // Inline comparison of ascii strings. 9414 // Inline comparison of ascii strings.
9419 __ IncrementCounter(&Counters::string_compare_native, 1); 9415 __ IncrementCounter(&Counters::string_compare_native, 1);
9420 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); 9416 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
9421 9417
9422 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 9418 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
9423 // tagged as a small integer. 9419 // tagged as a small integer.
9424 __ bind(&runtime); 9420 __ bind(&runtime);
9425 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); 9421 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
9426 } 9422 }
9427 9423
9428 #undef __ 9424 #undef __
9429 9425
9430 #define __ masm. 9426 #define __ masm.
9431 9427
9432 #ifdef _WIN64 9428 #ifdef _WIN64
9433 typedef double (*ModuloFunction)(double, double); 9429 typedef double (*ModuloFunction)(double, double);
9434 // Define custom fmod implementation. 9430 // Define custom fmod implementation.
9435 ModuloFunction CreateModuloFunction() { 9431 ModuloFunction CreateModuloFunction() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
9515 // Call the function from C++. 9511 // Call the function from C++.
9516 return FUNCTION_CAST<ModuloFunction>(buffer); 9512 return FUNCTION_CAST<ModuloFunction>(buffer);
9517 } 9513 }
9518 9514
9519 #endif 9515 #endif
9520 9516
9521 9517
9522 #undef __ 9518 #undef __
9523 9519
9524 } } // namespace v8::internal 9520 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698