| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    52   //  -- rsp[8]              : last argument |    52   //  -- rsp[8]              : last argument | 
|    53   //  -- ... |    53   //  -- ... | 
|    54   //  -- rsp[8 * argc]       : first argument (argc == rax) |    54   //  -- rsp[8 * argc]       : first argument (argc == rax) | 
|    55   //  -- rsp[8 * (argc + 1)] : receiver |    55   //  -- rsp[8 * (argc + 1)] : receiver | 
|    56   // ----------------------------------- |    56   // ----------------------------------- | 
|    57  |    57  | 
|    58   // Insert extra arguments. |    58   // Insert extra arguments. | 
|    59   int num_extra_args = 0; |    59   int num_extra_args = 0; | 
|    60   if (extra_args == NEEDS_CALLED_FUNCTION) { |    60   if (extra_args == NEEDS_CALLED_FUNCTION) { | 
|    61     num_extra_args = 1; |    61     num_extra_args = 1; | 
|    62     __ pop(kScratchRegister);  // Save return address. |    62     __ PopReturnAddressTo(kScratchRegister); | 
|    63     __ push(rdi); |    63     __ push(rdi); | 
|    64     __ push(kScratchRegister);  // Restore return address. |    64     __ PushReturnAddressFrom(kScratchRegister); | 
|    65   } else { |    65   } else { | 
|    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  | 
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   422     __ movq(rax, Operand(rsp, 0)); |   422     __ movq(rax, Operand(rsp, 0)); | 
|   423  |   423  | 
|   424     // Restore the arguments count and leave the construct frame. |   424     // Restore the arguments count and leave the construct frame. | 
|   425     __ bind(&exit); |   425     __ bind(&exit); | 
|   426     __ movq(rbx, Operand(rsp, kPointerSize));  // Get arguments count. |   426     __ movq(rbx, Operand(rsp, kPointerSize));  // Get arguments count. | 
|   427  |   427  | 
|   428     // Leave construct frame. |   428     // Leave construct frame. | 
|   429   } |   429   } | 
|   430  |   430  | 
|   431   // Remove caller arguments from the stack and return. |   431   // Remove caller arguments from the stack and return. | 
|   432   __ pop(rcx); |   432   __ PopReturnAddressTo(rcx); | 
|   433   SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |   433   SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); | 
|   434   __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |   434   __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); | 
|   435   __ push(rcx); |   435   __ PushReturnAddressFrom(rcx); | 
|   436   Counters* counters = masm->isolate()->counters(); |   436   Counters* counters = masm->isolate()->counters(); | 
|   437   __ IncrementCounter(counters->constructed_objects(), 1); |   437   __ IncrementCounter(counters->constructed_objects(), 1); | 
|   438   __ ret(0); |   438   __ ret(0); | 
|   439 } |   439 } | 
|   440  |   440  | 
|   441  |   441  | 
|   442 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) { |   442 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) { | 
|   443   Generate_JSConstructStubHelper(masm, false, true); |   443   Generate_JSConstructStubHelper(masm, false, true); | 
|   444 } |   444 } | 
|   445  |   445  | 
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   765   //  ... |   765   //  ... | 
|   766   // rsp[8 * n]       : Argument 1 |   766   // rsp[8 * n]       : Argument 1 | 
|   767   // rsp[8 * (n + 1)] : Receiver (function to call) |   767   // rsp[8 * (n + 1)] : Receiver (function to call) | 
|   768   // |   768   // | 
|   769   // rax contains the number of arguments, n, not counting the receiver. |   769   // rax contains the number of arguments, n, not counting the receiver. | 
|   770   // |   770   // | 
|   771   // 1. Make sure we have at least one argument. |   771   // 1. Make sure we have at least one argument. | 
|   772   { Label done; |   772   { Label done; | 
|   773     __ testq(rax, rax); |   773     __ testq(rax, rax); | 
|   774     __ j(not_zero, &done); |   774     __ j(not_zero, &done); | 
|   775     __ pop(rbx); |   775     __ PopReturnAddressTo(rbx); | 
|   776     __ Push(masm->isolate()->factory()->undefined_value()); |   776     __ Push(masm->isolate()->factory()->undefined_value()); | 
|   777     __ push(rbx); |   777     __ PushReturnAddressFrom(rbx); | 
|   778     __ incq(rax); |   778     __ incq(rax); | 
|   779     __ bind(&done); |   779     __ bind(&done); | 
|   780   } |   780   } | 
|   781  |   781  | 
|   782   // 2. Get the function to call (passed as receiver) from the stack, check |   782   // 2. Get the function to call (passed as receiver) from the stack, check | 
|   783   //    if it is a function. |   783   //    if it is a function. | 
|   784   Label slow, non_function; |   784   Label slow, non_function; | 
|   785   // The function to call is at position n+1 on the stack. |   785   // The function to call is at position n+1 on the stack. | 
|   786   __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); |   786   __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 
|   787   __ JumpIfSmi(rdi, &non_function); |   787   __ JumpIfSmi(rdi, &non_function); | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   888   // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, |   888   // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, | 
|   889   //     or a function proxy via CALL_FUNCTION_PROXY. |   889   //     or a function proxy via CALL_FUNCTION_PROXY. | 
|   890   { Label function, non_proxy; |   890   { Label function, non_proxy; | 
|   891     __ testq(rdx, rdx); |   891     __ testq(rdx, rdx); | 
|   892     __ j(zero, &function); |   892     __ j(zero, &function); | 
|   893     __ Set(rbx, 0); |   893     __ Set(rbx, 0); | 
|   894     __ SetCallKind(rcx, CALL_AS_METHOD); |   894     __ SetCallKind(rcx, CALL_AS_METHOD); | 
|   895     __ cmpq(rdx, Immediate(1)); |   895     __ cmpq(rdx, Immediate(1)); | 
|   896     __ j(not_equal, &non_proxy); |   896     __ j(not_equal, &non_proxy); | 
|   897  |   897  | 
|   898     __ pop(rdx);   // return address |   898     __ PopReturnAddressTo(rdx); | 
|   899     __ push(rdi);  // re-add proxy object as additional argument |   899     __ push(rdi);  // re-add proxy object as additional argument | 
|   900     __ push(rdx); |   900     __ PushReturnAddressFrom(rdx); | 
|   901     __ incq(rax); |   901     __ incq(rax); | 
|   902     __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); |   902     __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); | 
|   903     __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |   903     __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 
|   904            RelocInfo::CODE_TARGET); |   904            RelocInfo::CODE_TARGET); | 
|   905  |   905  | 
|   906     __ bind(&non_proxy); |   906     __ bind(&non_proxy); | 
|   907     __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); |   907     __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); | 
|   908     __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |   908     __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 
|   909             RelocInfo::CODE_TARGET); |   909             RelocInfo::CODE_TARGET); | 
|   910     __ bind(&function); |   910     __ bind(&function); | 
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1175     __ cmpq(rdi, rcx); |  1175     __ cmpq(rdi, rcx); | 
|  1176     __ Assert(equal, "Unexpected String function"); |  1176     __ Assert(equal, "Unexpected String function"); | 
|  1177   } |  1177   } | 
|  1178  |  1178  | 
|  1179   // Load the first argument into rax and get rid of the rest |  1179   // Load the first argument into rax and get rid of the rest | 
|  1180   // (including the receiver). |  1180   // (including the receiver). | 
|  1181   Label no_arguments; |  1181   Label no_arguments; | 
|  1182   __ testq(rax, rax); |  1182   __ testq(rax, rax); | 
|  1183   __ j(zero, &no_arguments); |  1183   __ j(zero, &no_arguments); | 
|  1184   __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); |  1184   __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 
|  1185   __ pop(rcx); |  1185   __ PopReturnAddressTo(rcx); | 
|  1186   __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); |  1186   __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); | 
|  1187   __ push(rcx); |  1187   __ PushReturnAddressFrom(rcx); | 
|  1188   __ movq(rax, rbx); |  1188   __ movq(rax, rbx); | 
|  1189  |  1189  | 
|  1190   // Lookup the argument in the number to string cache. |  1190   // Lookup the argument in the number to string cache. | 
|  1191   Label not_cached, argument_is_string; |  1191   Label not_cached, argument_is_string; | 
|  1192   NumberToStringStub::GenerateLookupNumberStringCache( |  1192   NumberToStringStub::GenerateLookupNumberStringCache( | 
|  1193       masm, |  1193       masm, | 
|  1194       rax,  // Input. |  1194       rax,  // Input. | 
|  1195       rbx,  // Result. |  1195       rbx,  // Result. | 
|  1196       rcx,  // Scratch 1. |  1196       rcx,  // Scratch 1. | 
|  1197       rdx,  // Scratch 2. |  1197       rdx,  // Scratch 2. | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1261     __ InvokeBuiltin(Builtins::TO_STRING, CALL_FUNCTION); |  1261     __ InvokeBuiltin(Builtins::TO_STRING, CALL_FUNCTION); | 
|  1262     __ pop(rdi); |  1262     __ pop(rdi); | 
|  1263   } |  1263   } | 
|  1264   __ movq(rbx, rax); |  1264   __ movq(rbx, rax); | 
|  1265   __ jmp(&argument_is_string); |  1265   __ jmp(&argument_is_string); | 
|  1266  |  1266  | 
|  1267   // Load the empty string into rbx, remove the receiver from the |  1267   // Load the empty string into rbx, remove the receiver from the | 
|  1268   // stack, and jump back to the case where the argument is a string. |  1268   // stack, and jump back to the case where the argument is a string. | 
|  1269   __ bind(&no_arguments); |  1269   __ bind(&no_arguments); | 
|  1270   __ LoadRoot(rbx, Heap::kempty_stringRootIndex); |  1270   __ LoadRoot(rbx, Heap::kempty_stringRootIndex); | 
|  1271   __ pop(rcx); |  1271   __ PopReturnAddressTo(rcx); | 
|  1272   __ lea(rsp, Operand(rsp, kPointerSize)); |  1272   __ lea(rsp, Operand(rsp, kPointerSize)); | 
|  1273   __ push(rcx); |  1273   __ PushReturnAddressFrom(rcx); | 
|  1274   __ jmp(&argument_is_string); |  1274   __ jmp(&argument_is_string); | 
|  1275  |  1275  | 
|  1276   // At this point the argument is already a string. Call runtime to |  1276   // At this point the argument is already a string. Call runtime to | 
|  1277   // create a string wrapper. |  1277   // create a string wrapper. | 
|  1278   __ bind(&gc_required); |  1278   __ bind(&gc_required); | 
|  1279   __ IncrementCounter(counters->string_ctor_gc_required(), 1); |  1279   __ IncrementCounter(counters->string_ctor_gc_required(), 1); | 
|  1280   { |  1280   { | 
|  1281     FrameScope scope(masm, StackFrame::INTERNAL); |  1281     FrameScope scope(masm, StackFrame::INTERNAL); | 
|  1282     __ push(rbx); |  1282     __ push(rbx); | 
|  1283     __ CallRuntime(Runtime::kNewStringWrapper, 1); |  1283     __ CallRuntime(Runtime::kNewStringWrapper, 1); | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  1306  |  1306  | 
|  1307 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { |  1307 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { | 
|  1308   // Retrieve the number of arguments from the stack. Number is a Smi. |  1308   // Retrieve the number of arguments from the stack. Number is a Smi. | 
|  1309   __ movq(rbx, Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |  1309   __ movq(rbx, Operand(rbp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 
|  1310  |  1310  | 
|  1311   // Leave the frame. |  1311   // Leave the frame. | 
|  1312   __ movq(rsp, rbp); |  1312   __ movq(rsp, rbp); | 
|  1313   __ pop(rbp); |  1313   __ pop(rbp); | 
|  1314  |  1314  | 
|  1315   // Remove caller arguments from the stack. |  1315   // Remove caller arguments from the stack. | 
|  1316   __ pop(rcx); |  1316   __ PopReturnAddressTo(rcx); | 
|  1317   SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |  1317   SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); | 
|  1318   __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |  1318   __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); | 
|  1319   __ push(rcx); |  1319   __ PushReturnAddressFrom(rcx); | 
|  1320 } |  1320 } | 
|  1321  |  1321  | 
|  1322  |  1322  | 
|  1323 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |  1323 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 
|  1324   // ----------- S t a t e ------------- |  1324   // ----------- S t a t e ------------- | 
|  1325   //  -- rax : actual number of arguments |  1325   //  -- rax : actual number of arguments | 
|  1326   //  -- rbx : expected number of arguments |  1326   //  -- rbx : expected number of arguments | 
|  1327   //  -- rcx : call kind information |  1327   //  -- rcx : call kind information | 
|  1328   //  -- rdx : code entry to call |  1328   //  -- rdx : code entry to call | 
|  1329   // ----------------------------------- |  1329   // ----------------------------------- | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1434   Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |  1434   Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 
|  1435   generator.Generate(); |  1435   generator.Generate(); | 
|  1436 } |  1436 } | 
|  1437  |  1437  | 
|  1438  |  1438  | 
|  1439 #undef __ |  1439 #undef __ | 
|  1440  |  1440  | 
|  1441 } }  // namespace v8::internal |  1441 } }  // namespace v8::internal | 
|  1442  |  1442  | 
|  1443 #endif  // V8_TARGET_ARCH_X64 |  1443 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW |