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

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

Issue 598072: Direct call C++ functions (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
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 6286 matching lines...) Expand 10 before | Expand all | Expand 10 after
6297 // Return and remove the on-stack parameter. 6297 // Return and remove the on-stack parameter.
6298 __ ret(1 * kPointerSize); 6298 __ ret(1 * kPointerSize);
6299 6299
6300 // Create a new closure through the slower runtime call. 6300 // Create a new closure through the slower runtime call.
6301 __ bind(&gc); 6301 __ bind(&gc);
6302 __ pop(rcx); // Temporarily remove return address. 6302 __ pop(rcx); // Temporarily remove return address.
6303 __ pop(rdx); 6303 __ pop(rdx);
6304 __ push(rsi); 6304 __ push(rsi);
6305 __ push(rdx); 6305 __ push(rdx);
6306 __ push(rcx); // Restore return address. 6306 __ push(rcx); // Restore return address.
6307 __ TailCallRuntime(ExternalReference(Runtime::kNewClosure), 2, 1); 6307 __ TailCallRuntime(Runtime::kNewClosure, 2, 1);
6308 } 6308 }
6309 6309
6310 6310
6311 void FastNewContextStub::Generate(MacroAssembler* masm) { 6311 void FastNewContextStub::Generate(MacroAssembler* masm) {
6312 // Try to allocate the context in new space. 6312 // Try to allocate the context in new space.
6313 Label gc; 6313 Label gc;
6314 int length = slots_ + Context::MIN_CONTEXT_SLOTS; 6314 int length = slots_ + Context::MIN_CONTEXT_SLOTS;
6315 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize, 6315 __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize,
6316 rax, rbx, rcx, &gc, TAG_OBJECT); 6316 rax, rbx, rcx, &gc, TAG_OBJECT);
6317 6317
(...skipping 21 matching lines...) Expand all
6339 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) { 6339 for (int i = Context::MIN_CONTEXT_SLOTS; i < length; i++) {
6340 __ movq(Operand(rax, Context::SlotOffset(i)), rbx); 6340 __ movq(Operand(rax, Context::SlotOffset(i)), rbx);
6341 } 6341 }
6342 6342
6343 // Return and remove the on-stack parameter. 6343 // Return and remove the on-stack parameter.
6344 __ movq(rsi, rax); 6344 __ movq(rsi, rax);
6345 __ ret(1 * kPointerSize); 6345 __ ret(1 * kPointerSize);
6346 6346
6347 // Need to collect. Call into runtime system. 6347 // Need to collect. Call into runtime system.
6348 __ bind(&gc); 6348 __ bind(&gc);
6349 __ TailCallRuntime(ExternalReference(Runtime::kNewContext), 1, 1); 6349 __ TailCallRuntime(Runtime::kNewContext, 1, 1);
6350 } 6350 }
6351 6351
6352 6352
6353 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { 6353 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
6354 // Stack layout on entry: 6354 // Stack layout on entry:
6355 // 6355 //
6356 // [rsp + kPointerSize]: constant elements. 6356 // [rsp + kPointerSize]: constant elements.
6357 // [rsp + (2 * kPointerSize)]: literal index. 6357 // [rsp + (2 * kPointerSize)]: literal index.
6358 // [rsp + (3 * kPointerSize)]: literals array. 6358 // [rsp + (3 * kPointerSize)]: literals array.
6359 6359
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6395 for (int i = 0; i < elements_size; i += kPointerSize) { 6395 for (int i = 0; i < elements_size; i += kPointerSize) {
6396 __ movq(rbx, FieldOperand(rcx, i)); 6396 __ movq(rbx, FieldOperand(rcx, i));
6397 __ movq(FieldOperand(rdx, i), rbx); 6397 __ movq(FieldOperand(rdx, i), rbx);
6398 } 6398 }
6399 } 6399 }
6400 6400
6401 // Return and remove the on-stack parameters. 6401 // Return and remove the on-stack parameters.
6402 __ ret(3 * kPointerSize); 6402 __ ret(3 * kPointerSize);
6403 6403
6404 __ bind(&slow_case); 6404 __ bind(&slow_case);
6405 ExternalReference runtime(Runtime::kCreateArrayLiteralShallow); 6405 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
6406 __ TailCallRuntime(runtime, 3, 1);
6407 } 6406 }
6408 6407
6409 6408
6410 void ToBooleanStub::Generate(MacroAssembler* masm) { 6409 void ToBooleanStub::Generate(MacroAssembler* masm) {
6411 Label false_result, true_result, not_string; 6410 Label false_result, true_result, not_string;
6412 __ movq(rax, Operand(rsp, 1 * kPointerSize)); 6411 __ movq(rax, Operand(rsp, 1 * kPointerSize));
6413 6412
6414 // 'null' => false. 6413 // 'null' => false.
6415 __ CompareRoot(rax, Heap::kNullValueRootIndex); 6414 __ CompareRoot(rax, Heap::kNullValueRootIndex);
6416 __ j(equal, &false_result); 6415 __ j(equal, &false_result);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
6755 UNREACHABLE(); 6754 UNREACHABLE();
6756 } 6755 }
6757 } 6756 }
6758 6757
6759 6758
6760 void RegExpExecStub::Generate(MacroAssembler* masm) { 6759 void RegExpExecStub::Generate(MacroAssembler* masm) {
6761 // Just jump directly to runtime if native RegExp is not selected at compile 6760 // Just jump directly to runtime if native RegExp is not selected at compile
6762 // time or if regexp entry in generated code is turned off runtime switch or 6761 // time or if regexp entry in generated code is turned off runtime switch or
6763 // at compilation. 6762 // at compilation.
6764 #ifndef V8_NATIVE_REGEXP 6763 #ifndef V8_NATIVE_REGEXP
6765 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 6764 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
6766 #else // V8_NATIVE_REGEXP 6765 #else // V8_NATIVE_REGEXP
6767 if (!FLAG_regexp_entry_native) { 6766 if (!FLAG_regexp_entry_native) {
6768 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 6767 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
6769 return; 6768 return;
6770 } 6769 }
6771 6770
6772 // Stack frame on entry. 6771 // Stack frame on entry.
6773 // esp[0]: return address 6772 // esp[0]: return address
6774 // esp[8]: last_match_info (expected JSArray) 6773 // esp[8]: last_match_info (expected JSArray)
6775 // esp[16]: previous index 6774 // esp[16]: previous index
6776 // esp[24]: subject string 6775 // esp[24]: subject string
6777 // esp[32]: JSRegExp object 6776 // esp[32]: JSRegExp object
6778 6777
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7102 rdi); 7101 rdi);
7103 __ jmp(&next_capture); 7102 __ jmp(&next_capture);
7104 __ bind(&done); 7103 __ bind(&done);
7105 7104
7106 // Return last match info. 7105 // Return last match info.
7107 __ movq(rax, Operand(rsp, kLastMatchInfoOffset)); 7106 __ movq(rax, Operand(rsp, kLastMatchInfoOffset));
7108 __ ret(4 * kPointerSize); 7107 __ ret(4 * kPointerSize);
7109 7108
7110 // Do the runtime call to execute the regexp. 7109 // Do the runtime call to execute the regexp.
7111 __ bind(&runtime); 7110 __ bind(&runtime);
7112 __ TailCallRuntime(ExternalReference(Runtime::kRegExpExec), 4, 1); 7111 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
7113 #endif // V8_NATIVE_REGEXP 7112 #endif // V8_NATIVE_REGEXP
7114 } 7113 }
7115 7114
7116 7115
7117 void CompareStub::Generate(MacroAssembler* masm) { 7116 void CompareStub::Generate(MacroAssembler* masm) {
7118 Label call_builtin, done; 7117 Label call_builtin, done;
7119 7118
7120 // NOTICE! This code is only reached after a smi-fast-case check, so 7119 // NOTICE! This code is only reached after a smi-fast-case check, so
7121 // it is certain that at least one operand isn't a smi. 7120 // it is certain that at least one operand isn't a smi.
7122 7121
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
7513 __ subq(rdx, Immediate(kPointerSize)); 7512 __ subq(rdx, Immediate(kPointerSize));
7514 __ decq(rcx); 7513 __ decq(rcx);
7515 __ j(not_zero, &loop); 7514 __ j(not_zero, &loop);
7516 7515
7517 // Return and remove the on-stack parameters. 7516 // Return and remove the on-stack parameters.
7518 __ bind(&done); 7517 __ bind(&done);
7519 __ ret(3 * kPointerSize); 7518 __ ret(3 * kPointerSize);
7520 7519
7521 // Do the runtime call to allocate the arguments object. 7520 // Do the runtime call to allocate the arguments object.
7522 __ bind(&runtime); 7521 __ bind(&runtime);
7523 __ TailCallRuntime(ExternalReference(Runtime::kNewArgumentsFast), 3, 1); 7522 __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
7524 } 7523 }
7525 7524
7526 7525
7527 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { 7526 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
7528 // The key is in rdx and the parameter count is in rax. 7527 // The key is in rdx and the parameter count is in rax.
7529 7528
7530 // The displacement is used for skipping the frame pointer on the 7529 // The displacement is used for skipping the frame pointer on the
7531 // stack. It is the offset of the last parameter (if any) relative 7530 // stack. It is the offset of the last parameter (if any) relative
7532 // to the frame pointer. 7531 // to the frame pointer.
7533 static const int kDisplacement = 1 * kPointerSize; 7532 static const int kDisplacement = 1 * kPointerSize;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7570 index = masm->SmiToNegativeIndex(rdx, rdx, kPointerSizeLog2); 7569 index = masm->SmiToNegativeIndex(rdx, rdx, kPointerSizeLog2);
7571 __ movq(rax, Operand(rbx, index.reg, index.scale, kDisplacement)); 7570 __ movq(rax, Operand(rbx, index.reg, index.scale, kDisplacement));
7572 __ Ret(); 7571 __ Ret();
7573 7572
7574 // Slow-case: Handle non-smi or out-of-bounds access to arguments 7573 // Slow-case: Handle non-smi or out-of-bounds access to arguments
7575 // by calling the runtime system. 7574 // by calling the runtime system.
7576 __ bind(&slow); 7575 __ bind(&slow);
7577 __ pop(rbx); // Return address. 7576 __ pop(rbx); // Return address.
7578 __ push(rdx); 7577 __ push(rdx);
7579 __ push(rbx); 7578 __ push(rbx);
7580 Runtime::Function* f = 7579 __ TailCallRuntime(Runtime::kGetArgumentsProperty, 1, 1);
7581 Runtime::FunctionForId(Runtime::kGetArgumentsProperty);
7582 __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
7583 } 7580 }
7584 7581
7585 7582
7586 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) { 7583 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) {
7587 // Check if the calling frame is an arguments adaptor frame. 7584 // Check if the calling frame is an arguments adaptor frame.
7588 Label adaptor; 7585 Label adaptor;
7589 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); 7586 __ movq(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
7590 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset), 7587 __ SmiCompare(Operand(rdx, StandardFrameConstants::kContextOffset),
7591 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); 7588 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
7592 7589
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
8061 void StackCheckStub::Generate(MacroAssembler* masm) { 8058 void StackCheckStub::Generate(MacroAssembler* masm) {
8062 // Because builtins always remove the receiver from the stack, we 8059 // Because builtins always remove the receiver from the stack, we
8063 // have to fake one to avoid underflowing the stack. The receiver 8060 // have to fake one to avoid underflowing the stack. The receiver
8064 // must be inserted below the return address on the stack so we 8061 // must be inserted below the return address on the stack so we
8065 // temporarily store that in a register. 8062 // temporarily store that in a register.
8066 __ pop(rax); 8063 __ pop(rax);
8067 __ Push(Smi::FromInt(0)); 8064 __ Push(Smi::FromInt(0));
8068 __ push(rax); 8065 __ push(rax);
8069 8066
8070 // Do tail-call to runtime routine. 8067 // Do tail-call to runtime routine.
8071 Runtime::Function* f = Runtime::FunctionForId(Runtime::kStackGuard); 8068 __ TailCallRuntime(Runtime::kStackGuard, 1, 1);
8072 __ TailCallRuntime(ExternalReference(f), 1, f->result_size);
8073 } 8069 }
8074 8070
8075 8071
8076 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm, 8072 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
8077 Register number) { 8073 Register number) {
8078 Label load_smi, done; 8074 Label load_smi, done;
8079 8075
8080 __ JumpIfSmi(number, &load_smi); 8076 __ JumpIfSmi(number, &load_smi);
8081 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset)); 8077 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset));
8082 __ jmp(&done); 8078 __ jmp(&done);
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
9060 // rcx: next character of result 9056 // rcx: next character of result
9061 // rdx: first char of second argument 9057 // rdx: first char of second argument
9062 // rdi: length of second argument 9058 // rdi: length of second argument
9063 GenerateCopyCharacters(masm, rcx, rdx, rdi, false); 9059 GenerateCopyCharacters(masm, rcx, rdx, rdi, false);
9064 __ movq(rax, rbx); 9060 __ movq(rax, rbx);
9065 __ IncrementCounter(&Counters::string_add_native, 1); 9061 __ IncrementCounter(&Counters::string_add_native, 1);
9066 __ ret(2 * kPointerSize); 9062 __ ret(2 * kPointerSize);
9067 9063
9068 // Just jump to runtime to add the two strings. 9064 // Just jump to runtime to add the two strings.
9069 __ bind(&string_add_runtime); 9065 __ bind(&string_add_runtime);
9070 __ TailCallRuntime(ExternalReference(Runtime::kStringAdd), 2, 1); 9066 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
9071 } 9067 }
9072 9068
9073 9069
9074 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, 9070 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm,
9075 Register dest, 9071 Register dest,
9076 Register src, 9072 Register src,
9077 Register count, 9073 Register count,
9078 bool ascii) { 9074 bool ascii) {
9079 Label loop; 9075 Label loop;
9080 __ bind(&loop); 9076 __ bind(&loop);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
9254 // rdx: original value of rsi 9250 // rdx: original value of rsi
9255 // rdi: first character of result 9251 // rdi: first character of result
9256 // rsi: character of sub string start 9252 // rsi: character of sub string start
9257 GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false); 9253 GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false);
9258 __ movq(rsi, rdx); // Restore esi. 9254 __ movq(rsi, rdx); // Restore esi.
9259 __ IncrementCounter(&Counters::sub_string_native, 1); 9255 __ IncrementCounter(&Counters::sub_string_native, 1);
9260 __ ret(kArgumentsSize); 9256 __ ret(kArgumentsSize);
9261 9257
9262 // Just jump to runtime to create the sub string. 9258 // Just jump to runtime to create the sub string.
9263 __ bind(&runtime); 9259 __ bind(&runtime);
9264 __ TailCallRuntime(ExternalReference(Runtime::kSubString), 3, 1); 9260 __ TailCallRuntime(Runtime::kSubString, 3, 1);
9265 } 9261 }
9266 9262
9267 9263
9268 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, 9264 void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
9269 Register left, 9265 Register left,
9270 Register right, 9266 Register right,
9271 Register scratch1, 9267 Register scratch1,
9272 Register scratch2, 9268 Register scratch2,
9273 Register scratch3, 9269 Register scratch3,
9274 Register scratch4) { 9270 Register scratch4) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
9374 // Check that both are sequential ASCII strings. 9370 // Check that both are sequential ASCII strings.
9375 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime); 9371 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &runtime);
9376 9372
9377 // Inline comparison of ascii strings. 9373 // Inline comparison of ascii strings.
9378 __ IncrementCounter(&Counters::string_compare_native, 1); 9374 __ IncrementCounter(&Counters::string_compare_native, 1);
9379 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); 9375 GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
9380 9376
9381 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 9377 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
9382 // tagged as a small integer. 9378 // tagged as a small integer.
9383 __ bind(&runtime); 9379 __ bind(&runtime);
9384 __ TailCallRuntime(ExternalReference(Runtime::kStringCompare), 2, 1); 9380 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
9385 } 9381 }
9386 9382
9387 #undef __ 9383 #undef __
9388 9384
9389 #define __ masm. 9385 #define __ masm.
9390 9386
9391 #ifdef _WIN64 9387 #ifdef _WIN64
9392 typedef double (*ModuloFunction)(double, double); 9388 typedef double (*ModuloFunction)(double, double);
9393 // Define custom fmod implementation. 9389 // Define custom fmod implementation.
9394 ModuloFunction CreateModuloFunction() { 9390 ModuloFunction CreateModuloFunction() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
9474 // Call the function from C++. 9470 // Call the function from C++.
9475 return FUNCTION_CAST<ModuloFunction>(buffer); 9471 return FUNCTION_CAST<ModuloFunction>(buffer);
9476 } 9472 }
9477 9473
9478 #endif 9474 #endif
9479 9475
9480 9476
9481 #undef __ 9477 #undef __
9482 9478
9483 } } // namespace v8::internal 9479 } } // namespace v8::internal
OLDNEW
« src/runtime.h ('K') | « src/runtime.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698