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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); | 67 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); |
68 } | 68 } |
69 | 69 |
70 // JumpToExternalReference expects a0 to contain the number of arguments | 70 // JumpToExternalReference expects a0 to contain the number of arguments |
71 // including the receiver and the extra arguments. | 71 // including the receiver and the extra arguments. |
72 __ Addu(a0, a0, Operand(num_extra_args + 1)); | 72 __ Addu(a0, a0, Operand(num_extra_args + 1)); |
73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 73 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
74 } | 74 } |
75 | 75 |
76 | 76 |
| 77 // Load the built-in InternalArray function from the current context. |
| 78 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
| 79 Register result) { |
| 80 // Load the global context. |
| 81 |
| 82 __ lw(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 83 __ lw(result, |
| 84 FieldMemOperand(result, GlobalObject::kGlobalContextOffset)); |
| 85 // Load the InternalArray function from the global context. |
| 86 __ lw(result, |
| 87 MemOperand(result, |
| 88 Context::SlotOffset( |
| 89 Context::INTERNAL_ARRAY_FUNCTION_INDEX))); |
| 90 } |
| 91 |
| 92 |
77 // Load the built-in Array function from the current context. | 93 // Load the built-in Array function from the current context. |
78 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { | 94 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { |
79 // Load the global context. | 95 // Load the global context. |
80 | 96 |
81 __ lw(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | 97 __ lw(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
82 __ lw(result, | 98 __ lw(result, |
83 FieldMemOperand(result, GlobalObject::kGlobalContextOffset)); | 99 FieldMemOperand(result, GlobalObject::kGlobalContextOffset)); |
84 // Load the Array function from the global context. | 100 // Load the Array function from the global context. |
85 __ lw(result, | 101 __ lw(result, |
86 MemOperand(result, | 102 MemOperand(result, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // return. | 434 // return. |
419 // a0: argc | 435 // a0: argc |
420 // a3: JSArray | 436 // a3: JSArray |
421 // sp[0]: receiver | 437 // sp[0]: receiver |
422 __ Addu(sp, sp, Operand(kPointerSize)); | 438 __ Addu(sp, sp, Operand(kPointerSize)); |
423 __ mov(v0, a3); | 439 __ mov(v0, a3); |
424 __ Ret(); | 440 __ Ret(); |
425 } | 441 } |
426 | 442 |
427 | 443 |
| 444 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
| 445 // ----------- S t a t e ------------- |
| 446 // -- a0 : number of arguments |
| 447 // -- ra : return address |
| 448 // -- sp[...]: constructor arguments |
| 449 // ----------------------------------- |
| 450 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; |
| 451 |
| 452 // Get the InternalArray function. |
| 453 GenerateLoadInternalArrayFunction(masm, a1); |
| 454 |
| 455 if (FLAG_debug_code) { |
| 456 // Initial map for the builtin InternalArray functions should be maps. |
| 457 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
| 458 __ And(t0, a2, Operand(kSmiTagMask)); |
| 459 __ Assert(ne, "Unexpected initial map for InternalArray function", |
| 460 t0, Operand(zero_reg)); |
| 461 __ GetObjectType(a2, a3, t0); |
| 462 __ Assert(eq, "Unexpected initial map for InternalArray function", |
| 463 t0, Operand(MAP_TYPE)); |
| 464 } |
| 465 |
| 466 // Run the native code for the InternalArray function called as a normal |
| 467 // function. |
| 468 ArrayNativeCode(masm, &generic_array_code); |
| 469 |
| 470 // Jump to the generic array code if the specialized code cannot handle the |
| 471 // construction. |
| 472 __ bind(&generic_array_code); |
| 473 |
| 474 Handle<Code> array_code = |
| 475 masm->isolate()->builtins()->ArrayCodeGeneric(); |
| 476 __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 477 } |
| 478 |
| 479 |
428 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 480 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
429 // ----------- S t a t e ------------- | 481 // ----------- S t a t e ------------- |
430 // -- a0 : number of arguments | 482 // -- a0 : number of arguments |
431 // -- ra : return address | 483 // -- ra : return address |
432 // -- sp[...]: constructor arguments | 484 // -- sp[...]: constructor arguments |
433 // ----------------------------------- | 485 // ----------------------------------- |
434 Label generic_array_code; | 486 Label generic_array_code; |
435 | 487 |
436 // Get the Array function. | 488 // Get the Array function. |
437 GenerateLoadArrayFunction(masm, a1); | 489 GenerateLoadArrayFunction(masm, a1); |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 __ bind(&dont_adapt_arguments); | 1809 __ bind(&dont_adapt_arguments); |
1758 __ Jump(a3); | 1810 __ Jump(a3); |
1759 } | 1811 } |
1760 | 1812 |
1761 | 1813 |
1762 #undef __ | 1814 #undef __ |
1763 | 1815 |
1764 } } // namespace v8::internal | 1816 } } // namespace v8::internal |
1765 | 1817 |
1766 #endif // V8_TARGET_ARCH_MIPS | 1818 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |