| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 __ CompareObjectType(r2, r3, r4, MAP_TYPE); | 435 __ CompareObjectType(r2, r3, r4, MAP_TYPE); |
| 436 __ Assert(eq, "Unexpected initial map for Array function"); | 436 __ Assert(eq, "Unexpected initial map for Array function"); |
| 437 } | 437 } |
| 438 | 438 |
| 439 // Run the native code for the Array function called as a normal function. | 439 // Run the native code for the Array function called as a normal function. |
| 440 ArrayNativeCode(masm, &generic_array_code); | 440 ArrayNativeCode(masm, &generic_array_code); |
| 441 | 441 |
| 442 // Jump to the generic array code if the specialized code cannot handle | 442 // Jump to the generic array code if the specialized code cannot handle |
| 443 // the construction. | 443 // the construction. |
| 444 __ bind(&generic_array_code); | 444 __ bind(&generic_array_code); |
| 445 Code* code = masm->isolate()->builtins()->builtin( | 445 |
| 446 Builtins::ArrayCodeGeneric); | 446 Handle<Code> array_code = |
| 447 Handle<Code> array_code(code); | 447 Builtins::builtin(Builtins::ArrayCodeGeneric, masm->isolate()); |
| 448 __ Jump(array_code, RelocInfo::CODE_TARGET); | 448 __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 449 } | 449 } |
| 450 | 450 |
| 451 | 451 |
| 452 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 452 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
| 453 // ----------- S t a t e ------------- | 453 // ----------- S t a t e ------------- |
| 454 // -- r0 : number of arguments | 454 // -- r0 : number of arguments |
| 455 // -- r1 : constructor function | 455 // -- r1 : constructor function |
| 456 // -- lr : return address | 456 // -- lr : return address |
| 457 // -- sp[...]: constructor arguments | 457 // -- sp[...]: constructor arguments |
| (...skipping 10 matching lines...) Expand all Loading... |
| 468 __ CompareObjectType(r2, r3, r4, MAP_TYPE); | 468 __ CompareObjectType(r2, r3, r4, MAP_TYPE); |
| 469 __ Assert(eq, "Unexpected initial map for Array function"); | 469 __ Assert(eq, "Unexpected initial map for Array function"); |
| 470 } | 470 } |
| 471 | 471 |
| 472 // Run the native code for the Array function called as a constructor. | 472 // Run the native code for the Array function called as a constructor. |
| 473 ArrayNativeCode(masm, &generic_constructor); | 473 ArrayNativeCode(masm, &generic_constructor); |
| 474 | 474 |
| 475 // Jump to the generic construct code in case the specialized code cannot | 475 // Jump to the generic construct code in case the specialized code cannot |
| 476 // handle the construction. | 476 // handle the construction. |
| 477 __ bind(&generic_constructor); | 477 __ bind(&generic_constructor); |
| 478 Code* code = masm->isolate()->builtins()->builtin( | 478 Handle<Code> generic_construct_stub = |
| 479 Builtins::JSConstructStubGeneric); | 479 Builtins::builtin(Builtins::JSConstructStubGeneric, masm->isolate()); |
| 480 Handle<Code> generic_construct_stub(code); | |
| 481 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 480 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 482 } | 481 } |
| 483 | 482 |
| 484 | 483 |
| 485 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 484 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
| 486 // ----------- S t a t e ------------- | 485 // ----------- S t a t e ------------- |
| 487 // -- r0 : number of arguments | 486 // -- r0 : number of arguments |
| 488 // -- r1 : constructor function | 487 // -- r1 : constructor function |
| 489 // -- lr : return address | 488 // -- lr : return address |
| 490 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 489 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 627 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 629 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); | 628 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); |
| 630 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); | 629 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 631 | 630 |
| 632 // r0: number of arguments | 631 // r0: number of arguments |
| 633 // r1: called object | 632 // r1: called object |
| 634 __ bind(&non_function_call); | 633 __ bind(&non_function_call); |
| 635 // Set expected number of arguments to zero (not changing r0). | 634 // Set expected number of arguments to zero (not changing r0). |
| 636 __ mov(r2, Operand(0, RelocInfo::NONE)); | 635 __ mov(r2, Operand(0, RelocInfo::NONE)); |
| 637 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 636 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 638 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( | 637 __ Jump(builtin(ArgumentsAdaptorTrampoline, masm->isolate()), |
| 639 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 638 RelocInfo::CODE_TARGET); |
| 640 } | 639 } |
| 641 | 640 |
| 642 | 641 |
| 643 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 642 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 644 bool is_api_function, | 643 bool is_api_function, |
| 645 bool count_constructions) { | 644 bool count_constructions) { |
| 646 // Should never count constructions for api objects. | 645 // Should never count constructions for api objects. |
| 647 ASSERT(!is_api_function || !count_constructions); | 646 ASSERT(!is_api_function || !count_constructions); |
| 648 | 647 |
| 649 // Enter a construct frame. | 648 // Enter a construct frame. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 __ push(ip); | 899 __ push(ip); |
| 901 __ bind(&entry); | 900 __ bind(&entry); |
| 902 __ sub(r3, r3, Operand(2), SetCC); | 901 __ sub(r3, r3, Operand(2), SetCC); |
| 903 __ b(ge, &loop); | 902 __ b(ge, &loop); |
| 904 | 903 |
| 905 // Call the function. | 904 // Call the function. |
| 906 // r0: number of arguments | 905 // r0: number of arguments |
| 907 // r1: constructor function | 906 // r1: constructor function |
| 908 if (is_api_function) { | 907 if (is_api_function) { |
| 909 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 908 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 910 Handle<Code> code = Handle<Code>( | 909 Handle<Code> code = |
| 911 masm->isolate()->builtins()->builtin( | 910 Builtins::builtin(Builtins::HandleApiCallConstruct, masm->isolate()); |
| 912 Builtins::HandleApiCallConstruct)); | |
| 913 ParameterCount expected(0); | 911 ParameterCount expected(0); |
| 914 __ InvokeCode(code, expected, expected, | 912 __ InvokeCode(code, expected, expected, |
| 915 RelocInfo::CODE_TARGET, CALL_FUNCTION); | 913 RelocInfo::CODE_TARGET, CALL_FUNCTION); |
| 916 } else { | 914 } else { |
| 917 ParameterCount actual(r0); | 915 ParameterCount actual(r0); |
| 918 __ InvokeFunction(r1, actual, CALL_FUNCTION); | 916 __ InvokeFunction(r1, actual, CALL_FUNCTION); |
| 919 } | 917 } |
| 920 | 918 |
| 921 // Pop the function from the stack. | 919 // Pop the function from the stack. |
| 922 // sp[0]: constructor function | 920 // sp[0]: constructor function |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 __ mov(r5, Operand(r4)); | 1034 __ mov(r5, Operand(r4)); |
| 1037 __ mov(r6, Operand(r4)); | 1035 __ mov(r6, Operand(r4)); |
| 1038 __ mov(r7, Operand(r4)); | 1036 __ mov(r7, Operand(r4)); |
| 1039 if (kR9Available == 1) { | 1037 if (kR9Available == 1) { |
| 1040 __ mov(r9, Operand(r4)); | 1038 __ mov(r9, Operand(r4)); |
| 1041 } | 1039 } |
| 1042 | 1040 |
| 1043 // Invoke the code and pass argc as r0. | 1041 // Invoke the code and pass argc as r0. |
| 1044 __ mov(r0, Operand(r3)); | 1042 __ mov(r0, Operand(r3)); |
| 1045 if (is_construct) { | 1043 if (is_construct) { |
| 1046 __ Call(Handle<Code>(masm->isolate()->builtins()->builtin( | 1044 __ Call(Builtins::builtin(Builtins::JSConstructCall, masm->isolate()), |
| 1047 Builtins::JSConstructCall)), RelocInfo::CODE_TARGET); | 1045 RelocInfo::CODE_TARGET); |
| 1048 } else { | 1046 } else { |
| 1049 ParameterCount actual(r0); | 1047 ParameterCount actual(r0); |
| 1050 __ InvokeFunction(r1, actual, CALL_FUNCTION); | 1048 __ InvokeFunction(r1, actual, CALL_FUNCTION); |
| 1051 } | 1049 } |
| 1052 | 1050 |
| 1053 // Exit the JS frame and remove the parameters (except function), and return. | 1051 // Exit the JS frame and remove the parameters (except function), and return. |
| 1054 // Respect ABI stack constraint. | 1052 // Respect ABI stack constraint. |
| 1055 __ LeaveInternalFrame(); | 1053 __ LeaveInternalFrame(); |
| 1056 __ Jump(lr); | 1054 __ Jump(lr); |
| 1057 | 1055 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 | 1327 |
| 1330 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. | 1328 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. |
| 1331 // r0: actual number of arguments | 1329 // r0: actual number of arguments |
| 1332 // r1: function | 1330 // r1: function |
| 1333 { Label function; | 1331 { Label function; |
| 1334 __ tst(r1, r1); | 1332 __ tst(r1, r1); |
| 1335 __ b(ne, &function); | 1333 __ b(ne, &function); |
| 1336 // Expected number of arguments is 0 for CALL_NON_FUNCTION. | 1334 // Expected number of arguments is 0 for CALL_NON_FUNCTION. |
| 1337 __ mov(r2, Operand(0, RelocInfo::NONE)); | 1335 __ mov(r2, Operand(0, RelocInfo::NONE)); |
| 1338 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 1336 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 1339 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( | 1337 __ Jump(builtin(ArgumentsAdaptorTrampoline, masm->isolate()), |
| 1340 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); | 1338 RelocInfo::CODE_TARGET); |
| 1341 __ bind(&function); | 1339 __ bind(&function); |
| 1342 } | 1340 } |
| 1343 | 1341 |
| 1344 // 5b. Get the code to call from the function and check that the number of | 1342 // 5b. Get the code to call from the function and check that the number of |
| 1345 // expected arguments matches what we're providing. If so, jump | 1343 // expected arguments matches what we're providing. If so, jump |
| 1346 // (tail-call) to the code in register edx without checking arguments. | 1344 // (tail-call) to the code in register edx without checking arguments. |
| 1347 // r0: actual number of arguments | 1345 // r0: actual number of arguments |
| 1348 // r1: function | 1346 // r1: function |
| 1349 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 1347 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 1350 __ ldr(r2, | 1348 __ ldr(r2, |
| 1351 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); | 1349 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1352 __ mov(r2, Operand(r2, ASR, kSmiTagSize)); | 1350 __ mov(r2, Operand(r2, ASR, kSmiTagSize)); |
| 1353 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1351 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 1354 __ cmp(r2, r0); // Check formal and actual parameter counts. | 1352 __ cmp(r2, r0); // Check formal and actual parameter counts. |
| 1355 __ Jump(Handle<Code>(masm->isolate()->builtins()->builtin( | 1353 __ Jump(builtin(ArgumentsAdaptorTrampoline, masm->isolate()), |
| 1356 ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET, ne); | 1354 RelocInfo::CODE_TARGET, |
| 1355 ne); |
| 1357 | 1356 |
| 1358 ParameterCount expected(0); | 1357 ParameterCount expected(0); |
| 1359 __ InvokeCode(r3, expected, expected, JUMP_FUNCTION); | 1358 __ InvokeCode(r3, expected, expected, JUMP_FUNCTION); |
| 1360 } | 1359 } |
| 1361 | 1360 |
| 1362 | 1361 |
| 1363 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1362 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| 1364 const int kIndexOffset = -5 * kPointerSize; | 1363 const int kIndexOffset = -5 * kPointerSize; |
| 1365 const int kLimitOffset = -4 * kPointerSize; | 1364 const int kLimitOffset = -4 * kPointerSize; |
| 1366 const int kArgsOffset = 2 * kPointerSize; | 1365 const int kArgsOffset = 2 * kPointerSize; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 __ bind(&dont_adapt_arguments); | 1619 __ bind(&dont_adapt_arguments); |
| 1621 __ Jump(r3); | 1620 __ Jump(r3); |
| 1622 } | 1621 } |
| 1623 | 1622 |
| 1624 | 1623 |
| 1625 #undef __ | 1624 #undef __ |
| 1626 | 1625 |
| 1627 } } // namespace v8::internal | 1626 } } // namespace v8::internal |
| 1628 | 1627 |
| 1629 #endif // V8_TARGET_ARCH_ARM | 1628 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |