OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kConstructStubOffset)); | 93 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kConstructStubOffset)); |
94 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); | 94 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); |
95 __ jmp(Operand(ebx)); | 95 __ jmp(Operand(ebx)); |
96 | 96 |
97 // edi: called object | 97 // edi: called object |
98 // eax: number of arguments | 98 // eax: number of arguments |
99 __ bind(&non_function_call); | 99 __ bind(&non_function_call); |
100 // Set expected number of arguments to zero (not changing eax). | 100 // Set expected number of arguments to zero (not changing eax). |
101 __ Set(ebx, Immediate(0)); | 101 __ Set(ebx, Immediate(0)); |
102 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 102 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
103 __ jmp(Handle<Code>(masm->isolate()->builtins()->builtin( | 103 Handle<Code> arguments_adaptor = |
104 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 104 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
| 105 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); |
105 } | 106 } |
106 | 107 |
107 | 108 |
108 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 109 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
109 bool is_api_function, | 110 bool is_api_function, |
110 bool count_constructions) { | 111 bool count_constructions) { |
111 // Should never count constructions for api objects. | 112 // Should never count constructions for api objects. |
112 ASSERT(!is_api_function || !count_constructions); | 113 ASSERT(!is_api_function || !count_constructions); |
113 | 114 |
114 // Enter a construct frame. | 115 // Enter a construct frame. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 __ jmp(&entry); | 328 __ jmp(&entry); |
328 __ bind(&loop); | 329 __ bind(&loop); |
329 __ push(Operand(ebx, ecx, times_4, 0)); | 330 __ push(Operand(ebx, ecx, times_4, 0)); |
330 __ bind(&entry); | 331 __ bind(&entry); |
331 __ dec(ecx); | 332 __ dec(ecx); |
332 __ j(greater_equal, &loop); | 333 __ j(greater_equal, &loop); |
333 | 334 |
334 // Call the function. | 335 // Call the function. |
335 if (is_api_function) { | 336 if (is_api_function) { |
336 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 337 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
337 Handle<Code> code = Handle<Code>( | 338 Handle<Code> code = |
338 masm->isolate()->builtins()->builtin(Builtins::HandleApiCallConstruct)); | 339 masm->isolate()->builtins()->HandleApiCallConstruct(); |
339 ParameterCount expected(0); | 340 ParameterCount expected(0); |
340 __ InvokeCode(code, expected, expected, | 341 __ InvokeCode(code, expected, expected, |
341 RelocInfo::CODE_TARGET, CALL_FUNCTION); | 342 RelocInfo::CODE_TARGET, CALL_FUNCTION); |
342 } else { | 343 } else { |
343 ParameterCount actual(eax); | 344 ParameterCount actual(eax); |
344 __ InvokeFunction(edi, actual, CALL_FUNCTION); | 345 __ InvokeFunction(edi, actual, CALL_FUNCTION); |
345 } | 346 } |
346 | 347 |
347 // Restore context from the frame. | 348 // Restore context from the frame. |
348 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 349 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 __ inc(Operand(ecx)); | 430 __ inc(Operand(ecx)); |
430 __ bind(&entry); | 431 __ bind(&entry); |
431 __ cmp(ecx, Operand(eax)); | 432 __ cmp(ecx, Operand(eax)); |
432 __ j(not_equal, &loop); | 433 __ j(not_equal, &loop); |
433 | 434 |
434 // Get the function from the stack and call it. | 435 // Get the function from the stack and call it. |
435 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); // +1 ~ receiver | 436 __ mov(edi, Operand(esp, eax, times_4, +1 * kPointerSize)); // +1 ~ receiver |
436 | 437 |
437 // Invoke the code. | 438 // Invoke the code. |
438 if (is_construct) { | 439 if (is_construct) { |
439 __ call(Handle<Code>(masm->isolate()->builtins()->builtin( | 440 __ call(masm->isolate()->builtins()->JSConstructCall(), |
440 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); | 441 RelocInfo::CODE_TARGET); |
441 } else { | 442 } else { |
442 ParameterCount actual(eax); | 443 ParameterCount actual(eax); |
443 __ InvokeFunction(edi, actual, CALL_FUNCTION); | 444 __ InvokeFunction(edi, actual, CALL_FUNCTION); |
444 } | 445 } |
445 | 446 |
446 // Exit the JS frame. Notice that this also removes the empty | 447 // Exit the JS frame. Notice that this also removes the empty |
447 // context and the function left on the stack by the code | 448 // context and the function left on the stack by the code |
448 // invocation. | 449 // invocation. |
449 __ LeaveInternalFrame(); | 450 __ LeaveInternalFrame(); |
450 __ ret(1 * kPointerSize); // remove receiver | 451 __ ret(1 * kPointerSize); // remove receiver |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 __ pop(ebx); // Discard copy of return address. | 668 __ pop(ebx); // Discard copy of return address. |
668 __ dec(eax); // One fewer argument (first argument is new receiver). | 669 __ dec(eax); // One fewer argument (first argument is new receiver). |
669 } | 670 } |
670 | 671 |
671 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. | 672 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. |
672 { Label function; | 673 { Label function; |
673 __ test(edi, Operand(edi)); | 674 __ test(edi, Operand(edi)); |
674 __ j(not_zero, &function, taken); | 675 __ j(not_zero, &function, taken); |
675 __ Set(ebx, Immediate(0)); | 676 __ Set(ebx, Immediate(0)); |
676 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | 677 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); |
677 __ jmp(Handle<Code>(masm->isolate()->builtins()->builtin( | 678 __ jmp(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
678 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 679 RelocInfo::CODE_TARGET); |
679 __ bind(&function); | 680 __ bind(&function); |
680 } | 681 } |
681 | 682 |
682 // 5b. Get the code to call from the function and check that the number of | 683 // 5b. Get the code to call from the function and check that the number of |
683 // expected arguments matches what we're providing. If so, jump | 684 // expected arguments matches what we're providing. If so, jump |
684 // (tail-call) to the code in register edx without checking arguments. | 685 // (tail-call) to the code in register edx without checking arguments. |
685 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 686 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
686 __ mov(ebx, | 687 __ mov(ebx, |
687 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 688 FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
688 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 689 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
689 __ SmiUntag(ebx); | 690 __ SmiUntag(ebx); |
690 __ cmp(eax, Operand(ebx)); | 691 __ cmp(eax, Operand(ebx)); |
691 __ j(not_equal, Handle<Code>(masm->isolate()->builtins()->builtin( | 692 __ j(not_equal, |
692 ArgumentsAdaptorTrampoline))); | 693 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline()); |
693 | 694 |
694 ParameterCount expected(0); | 695 ParameterCount expected(0); |
695 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); | 696 __ InvokeCode(Operand(edx), expected, expected, JUMP_FUNCTION); |
696 } | 697 } |
697 | 698 |
698 | 699 |
699 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 700 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
700 __ EnterInternalFrame(); | 701 __ EnterInternalFrame(); |
701 | 702 |
702 __ push(Operand(ebp, 4 * kPointerSize)); // push this | 703 __ push(Operand(ebp, 4 * kPointerSize)); // push this |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 __ push(ebx); | 790 __ push(ebx); |
790 | 791 |
791 // Copy all arguments from the array to the stack. | 792 // Copy all arguments from the array to the stack. |
792 Label entry, loop; | 793 Label entry, loop; |
793 __ mov(eax, Operand(ebp, kIndexOffset)); | 794 __ mov(eax, Operand(ebp, kIndexOffset)); |
794 __ jmp(&entry); | 795 __ jmp(&entry); |
795 __ bind(&loop); | 796 __ bind(&loop); |
796 __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments | 797 __ mov(edx, Operand(ebp, 2 * kPointerSize)); // load arguments |
797 | 798 |
798 // Use inline caching to speed up access to arguments. | 799 // Use inline caching to speed up access to arguments. |
799 Handle<Code> ic(masm->isolate()->builtins()->builtin( | 800 Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Initialize(); |
800 Builtins::KeyedLoadIC_Initialize)); | |
801 __ call(ic, RelocInfo::CODE_TARGET); | 801 __ call(ic, RelocInfo::CODE_TARGET); |
802 // It is important that we do not have a test instruction after the | 802 // It is important that we do not have a test instruction after the |
803 // call. A test instruction after the call is used to indicate that | 803 // call. A test instruction after the call is used to indicate that |
804 // we have generated an inline version of the keyed load. In this | 804 // we have generated an inline version of the keyed load. In this |
805 // case, we know that we are not generating a test instruction next. | 805 // case, we know that we are not generating a test instruction next. |
806 | 806 |
807 // Push the nth argument. | 807 // Push the nth argument. |
808 __ push(eax); | 808 __ push(eax); |
809 | 809 |
810 // Update the index on the stack and in register eax. | 810 // Update the index on the stack and in register eax. |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1228 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1229 __ Assert(equal, "Unexpected initial map for Array function"); | 1229 __ Assert(equal, "Unexpected initial map for Array function"); |
1230 } | 1230 } |
1231 | 1231 |
1232 // Run the native code for the Array function called as a normal function. | 1232 // Run the native code for the Array function called as a normal function. |
1233 ArrayNativeCode(masm, false, &generic_array_code); | 1233 ArrayNativeCode(masm, false, &generic_array_code); |
1234 | 1234 |
1235 // Jump to the generic array code in case the specialized code cannot handle | 1235 // Jump to the generic array code in case the specialized code cannot handle |
1236 // the construction. | 1236 // the construction. |
1237 __ bind(&generic_array_code); | 1237 __ bind(&generic_array_code); |
1238 Code* code = masm->isolate()->builtins()->builtin(Builtins::ArrayCodeGeneric); | 1238 Handle<Code> array_code = |
1239 Handle<Code> array_code(code); | 1239 masm->isolate()->builtins()->ArrayCodeGeneric(); |
1240 __ jmp(array_code, RelocInfo::CODE_TARGET); | 1240 __ jmp(array_code, RelocInfo::CODE_TARGET); |
1241 } | 1241 } |
1242 | 1242 |
1243 | 1243 |
1244 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 1244 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
1245 // ----------- S t a t e ------------- | 1245 // ----------- S t a t e ------------- |
1246 // -- eax : argc | 1246 // -- eax : argc |
1247 // -- edi : constructor | 1247 // -- edi : constructor |
1248 // -- esp[0] : return address | 1248 // -- esp[0] : return address |
1249 // -- esp[4] : last argument | 1249 // -- esp[4] : last argument |
(...skipping 12 matching lines...) Expand all Loading... |
1262 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1262 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1263 __ Assert(equal, "Unexpected initial map for Array function"); | 1263 __ Assert(equal, "Unexpected initial map for Array function"); |
1264 } | 1264 } |
1265 | 1265 |
1266 // Run the native code for the Array function called as constructor. | 1266 // Run the native code for the Array function called as constructor. |
1267 ArrayNativeCode(masm, true, &generic_constructor); | 1267 ArrayNativeCode(masm, true, &generic_constructor); |
1268 | 1268 |
1269 // Jump to the generic construct code in case the specialized code cannot | 1269 // Jump to the generic construct code in case the specialized code cannot |
1270 // handle the construction. | 1270 // handle the construction. |
1271 __ bind(&generic_constructor); | 1271 __ bind(&generic_constructor); |
1272 Code* code = masm->isolate()->builtins()->builtin( | 1272 Handle<Code> generic_construct_stub = |
1273 Builtins::JSConstructStubGeneric); | 1273 masm->isolate()->builtins()->JSConstructStubGeneric(); |
1274 Handle<Code> generic_construct_stub(code); | |
1275 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 1274 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
1276 } | 1275 } |
1277 | 1276 |
1278 | 1277 |
1279 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 1278 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
1280 // ----------- S t a t e ------------- | 1279 // ----------- S t a t e ------------- |
1281 // -- eax : number of arguments | 1280 // -- eax : number of arguments |
1282 // -- edi : constructor function | 1281 // -- edi : constructor function |
1283 // -- esp[0] : return address | 1282 // -- esp[0] : return address |
1284 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1283 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 __ push(eax); | 1580 __ push(eax); |
1582 | 1581 |
1583 // Generate the code for doing the frame-to-frame translation using | 1582 // Generate the code for doing the frame-to-frame translation using |
1584 // the deoptimizer infrastructure. | 1583 // the deoptimizer infrastructure. |
1585 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1584 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1586 generator.Generate(); | 1585 generator.Generate(); |
1587 } | 1586 } |
1588 | 1587 |
1589 | 1588 |
1590 #undef __ | 1589 #undef __ |
1591 | 1590 } |
1592 } } // namespace v8::internal | 1591 } // namespace v8::internal |
1593 | 1592 |
1594 #endif // V8_TARGET_ARCH_IA32 | 1593 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |