OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset)); | 91 __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset)); |
92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize)); | 92 __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize)); |
93 __ jmp(rbx); | 93 __ jmp(rbx); |
94 | 94 |
95 // rdi: called object | 95 // rdi: called object |
96 // rax: number of arguments | 96 // rax: number of arguments |
97 __ bind(&non_function_call); | 97 __ bind(&non_function_call); |
98 // Set expected number of arguments to zero (not changing rax). | 98 // Set expected number of arguments to zero (not changing rax). |
99 __ movq(rbx, Immediate(0)); | 99 __ movq(rbx, Immediate(0)); |
100 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 100 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
101 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( | 101 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
102 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 102 RelocInfo::CODE_TARGET); |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 106 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
107 bool is_api_function, | 107 bool is_api_function, |
108 bool count_constructions) { | 108 bool count_constructions) { |
109 // Should never count constructions for api objects. | 109 // Should never count constructions for api objects. |
110 ASSERT(!is_api_function || !count_constructions); | 110 ASSERT(!is_api_function || !count_constructions); |
111 | 111 |
112 // Enter a construct frame. | 112 // Enter a construct frame. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 __ jmp(&entry); | 332 __ jmp(&entry); |
333 __ bind(&loop); | 333 __ bind(&loop); |
334 __ push(Operand(rbx, rcx, times_pointer_size, 0)); | 334 __ push(Operand(rbx, rcx, times_pointer_size, 0)); |
335 __ bind(&entry); | 335 __ bind(&entry); |
336 __ decq(rcx); | 336 __ decq(rcx); |
337 __ j(greater_equal, &loop); | 337 __ j(greater_equal, &loop); |
338 | 338 |
339 // Call the function. | 339 // Call the function. |
340 if (is_api_function) { | 340 if (is_api_function) { |
341 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 341 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
342 Handle<Code> code = Handle<Code>(masm->isolate()->builtins()->builtin( | 342 Handle<Code> code = |
343 Builtins::HandleApiCallConstruct)); | 343 masm->isolate()->builtins()->HandleApiCallConstruct(); |
344 ParameterCount expected(0); | 344 ParameterCount expected(0); |
345 __ InvokeCode(code, expected, expected, | 345 __ InvokeCode(code, expected, expected, |
346 RelocInfo::CODE_TARGET, CALL_FUNCTION); | 346 RelocInfo::CODE_TARGET, CALL_FUNCTION); |
347 } else { | 347 } else { |
348 ParameterCount actual(rax); | 348 ParameterCount actual(rax); |
349 __ InvokeFunction(rdi, actual, CALL_FUNCTION); | 349 __ InvokeFunction(rdi, actual, CALL_FUNCTION); |
350 } | 350 } |
351 | 351 |
352 // Restore context from the frame. | 352 // Restore context from the frame. |
353 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 353 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); | 485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); |
486 __ push(Operand(kScratchRegister, 0)); // dereference handle | 486 __ push(Operand(kScratchRegister, 0)); // dereference handle |
487 __ addq(rcx, Immediate(1)); | 487 __ addq(rcx, Immediate(1)); |
488 __ bind(&entry); | 488 __ bind(&entry); |
489 __ cmpq(rcx, rax); | 489 __ cmpq(rcx, rax); |
490 __ j(not_equal, &loop); | 490 __ j(not_equal, &loop); |
491 | 491 |
492 // Invoke the code. | 492 // Invoke the code. |
493 if (is_construct) { | 493 if (is_construct) { |
494 // Expects rdi to hold function pointer. | 494 // Expects rdi to hold function pointer. |
495 __ Call(Handle<Code>(masm->isolate()->builtins()->builtin( | 495 __ Call(masm->isolate()->builtins()->JSConstructCall(), |
496 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); | 496 RelocInfo::CODE_TARGET); |
497 } else { | 497 } else { |
498 ParameterCount actual(rax); | 498 ParameterCount actual(rax); |
499 // Function must be in rdi. | 499 // Function must be in rdi. |
500 __ InvokeFunction(rdi, actual, CALL_FUNCTION); | 500 __ InvokeFunction(rdi, actual, CALL_FUNCTION); |
501 } | 501 } |
502 | 502 |
503 // Exit the JS frame. Notice that this also removes the empty | 503 // Exit the JS frame. Notice that this also removes the empty |
504 // context and the function left on the stack by the code | 504 // context and the function left on the stack by the code |
505 // invocation. | 505 // invocation. |
506 __ LeaveInternalFrame(); | 506 __ LeaveInternalFrame(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 __ pop(rbx); // Discard copy of return address. | 726 __ pop(rbx); // Discard copy of return address. |
727 __ decq(rax); // One fewer argument (first argument is new receiver). | 727 __ decq(rax); // One fewer argument (first argument is new receiver). |
728 } | 728 } |
729 | 729 |
730 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. | 730 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. |
731 { Label function; | 731 { Label function; |
732 __ testq(rdi, rdi); | 732 __ testq(rdi, rdi); |
733 __ j(not_zero, &function); | 733 __ j(not_zero, &function); |
734 __ Set(rbx, 0); | 734 __ Set(rbx, 0); |
735 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); | 735 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); |
736 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( | 736 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
737 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 737 RelocInfo::CODE_TARGET); |
738 __ bind(&function); | 738 __ bind(&function); |
739 } | 739 } |
740 | 740 |
741 // 5b. Get the code to call from the function and check that the number of | 741 // 5b. Get the code to call from the function and check that the number of |
742 // expected arguments matches what we're providing. If so, jump | 742 // expected arguments matches what we're providing. If so, jump |
743 // (tail-call) to the code in register edx without checking arguments. | 743 // (tail-call) to the code in register edx without checking arguments. |
744 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 744 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
745 __ movsxlq(rbx, | 745 __ movsxlq(rbx, |
746 FieldOperand(rdx, | 746 FieldOperand(rdx, |
747 SharedFunctionInfo::kFormalParameterCountOffset)); | 747 SharedFunctionInfo::kFormalParameterCountOffset)); |
748 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 748 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
749 __ cmpq(rax, rbx); | 749 __ cmpq(rax, rbx); |
750 __ j(not_equal, | 750 __ j(not_equal, |
751 Handle<Code>(masm->isolate()->builtins()->builtin( | 751 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
752 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 752 RelocInfo::CODE_TARGET); |
753 | 753 |
754 ParameterCount expected(0); | 754 ParameterCount expected(0); |
755 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION); | 755 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION); |
756 } | 756 } |
757 | 757 |
758 | 758 |
759 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 759 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
760 // Stack at entry: | 760 // Stack at entry: |
761 // rsp: return address | 761 // rsp: return address |
762 // rsp+8: arguments | 762 // rsp+8: arguments |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 __ push(rbx); | 856 __ push(rbx); |
857 | 857 |
858 // Copy all arguments from the array to the stack. | 858 // Copy all arguments from the array to the stack. |
859 Label entry, loop; | 859 Label entry, loop; |
860 __ movq(rax, Operand(rbp, kIndexOffset)); | 860 __ movq(rax, Operand(rbp, kIndexOffset)); |
861 __ jmp(&entry); | 861 __ jmp(&entry); |
862 __ bind(&loop); | 862 __ bind(&loop); |
863 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments | 863 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments |
864 | 864 |
865 // Use inline caching to speed up access to arguments. | 865 // Use inline caching to speed up access to arguments. |
866 Handle<Code> ic(masm->isolate()->builtins()->builtin( | 866 Handle<Code> ic = |
867 Builtins::KeyedLoadIC_Initialize)); | 867 masm->isolate()->builtins()->KeyedLoadIC_Initialize(); |
868 __ Call(ic, RelocInfo::CODE_TARGET); | 868 __ Call(ic, RelocInfo::CODE_TARGET); |
869 // It is important that we do not have a test instruction after the | 869 // It is important that we do not have a test instruction after the |
870 // call. A test instruction after the call is used to indicate that | 870 // call. A test instruction after the call is used to indicate that |
871 // we have generated an inline version of the keyed load. In this | 871 // we have generated an inline version of the keyed load. In this |
872 // case, we know that we are not generating a test instruction next. | 872 // case, we know that we are not generating a test instruction next. |
873 | 873 |
874 // Push the nth argument. | 874 // Push the nth argument. |
875 __ push(rax); | 875 __ push(rax); |
876 | 876 |
877 // Update the index on the stack and in register rax. | 877 // Update the index on the stack and in register rax. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 __ CmpObjectType(rbx, MAP_TYPE, rcx); | 1258 __ CmpObjectType(rbx, MAP_TYPE, rcx); |
1259 __ Check(equal, "Unexpected initial map for Array function"); | 1259 __ Check(equal, "Unexpected initial map for Array function"); |
1260 } | 1260 } |
1261 | 1261 |
1262 // Run the native code for the Array function called as a normal function. | 1262 // Run the native code for the Array function called as a normal function. |
1263 ArrayNativeCode(masm, &generic_array_code); | 1263 ArrayNativeCode(masm, &generic_array_code); |
1264 | 1264 |
1265 // Jump to the generic array code in case the specialized code cannot handle | 1265 // Jump to the generic array code in case the specialized code cannot handle |
1266 // the construction. | 1266 // the construction. |
1267 __ bind(&generic_array_code); | 1267 __ bind(&generic_array_code); |
1268 Code* code = | 1268 Handle<Code> array_code = |
1269 masm->isolate()->builtins()->builtin(Builtins::ArrayCodeGeneric); | 1269 masm->isolate()->builtins()->ArrayCodeGeneric(); |
1270 Handle<Code> array_code(code); | |
1271 __ Jump(array_code, RelocInfo::CODE_TARGET); | 1270 __ Jump(array_code, RelocInfo::CODE_TARGET); |
1272 } | 1271 } |
1273 | 1272 |
1274 | 1273 |
1275 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 1274 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
1276 // ----------- S t a t e ------------- | 1275 // ----------- S t a t e ------------- |
1277 // -- rax : argc | 1276 // -- rax : argc |
1278 // -- rdi : constructor | 1277 // -- rdi : constructor |
1279 // -- rsp[0] : return address | 1278 // -- rsp[0] : return address |
1280 // -- rsp[8] : last argument | 1279 // -- rsp[8] : last argument |
(...skipping 12 matching lines...) Expand all Loading... |
1293 __ CmpObjectType(rbx, MAP_TYPE, rcx); | 1292 __ CmpObjectType(rbx, MAP_TYPE, rcx); |
1294 __ Check(equal, "Unexpected initial map for Array function"); | 1293 __ Check(equal, "Unexpected initial map for Array function"); |
1295 } | 1294 } |
1296 | 1295 |
1297 // Run the native code for the Array function called as constructor. | 1296 // Run the native code for the Array function called as constructor. |
1298 ArrayNativeCode(masm, &generic_constructor); | 1297 ArrayNativeCode(masm, &generic_constructor); |
1299 | 1298 |
1300 // Jump to the generic construct code in case the specialized code cannot | 1299 // Jump to the generic construct code in case the specialized code cannot |
1301 // handle the construction. | 1300 // handle the construction. |
1302 __ bind(&generic_constructor); | 1301 __ bind(&generic_constructor); |
1303 Code* code = | 1302 Handle<Code> generic_construct_stub = |
1304 masm->isolate()->builtins()->builtin(Builtins::JSConstructStubGeneric); | 1303 masm->isolate()->builtins()->JSConstructStubGeneric(); |
1305 Handle<Code> generic_construct_stub(code); | |
1306 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 1304 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
1307 } | 1305 } |
1308 | 1306 |
1309 | 1307 |
1310 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 1308 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
1311 // TODO(849): implement custom construct stub. | 1309 // TODO(849): implement custom construct stub. |
1312 // Generate a copy of the generic stub for now. | 1310 // Generate a copy of the generic stub for now. |
1313 Generate_JSConstructStubGeneric(masm); | 1311 Generate_JSConstructStubGeneric(masm); |
1314 } | 1312 } |
1315 | 1313 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1481 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1484 generator.Generate(); | 1482 generator.Generate(); |
1485 } | 1483 } |
1486 | 1484 |
1487 | 1485 |
1488 #undef __ | 1486 #undef __ |
1489 | 1487 |
1490 } } // namespace v8::internal | 1488 } } // namespace v8::internal |
1491 | 1489 |
1492 #endif // V8_TARGET_ARCH_X64 | 1490 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |