| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 | 3364 |
| 3365 | 3365 |
| 3366 void CallFunctionStub::Generate(MacroAssembler* masm) { | 3366 void CallFunctionStub::Generate(MacroAssembler* masm) { |
| 3367 ASM_LOCATION("CallFunctionStub::Generate"); | 3367 ASM_LOCATION("CallFunctionStub::Generate"); |
| 3368 // x1 function the function to call | 3368 // x1 function the function to call |
| 3369 // x2 cache_cell cache cell for call target | 3369 // x2 cache_cell cache cell for call target |
| 3370 Register function = x1; | 3370 Register function = x1; |
| 3371 Register cache_cell = x2; | 3371 Register cache_cell = x2; |
| 3372 Label slow, non_function; | 3372 Label slow, non_function; |
| 3373 | 3373 |
| 3374 // The receiver might implicitly be the global object. This is | 3374 // Check that the function is really a JavaScript function. |
| 3375 // indicated by passing the hole as the receiver to the call | 3375 __ JumpIfSmi(function, &non_function); |
| 3376 // function stub. | |
| 3377 if (ReceiverMightBeImplicit()) { | |
| 3378 Label call; | |
| 3379 // Get the receiver from the stack. | |
| 3380 // jssp[0] - jssp[argc_ - 1] : arguments | |
| 3381 // jssp[argc_] : receiver | |
| 3382 // jssp[argc_ + 1] : function | |
| 3383 __ Peek(x4, argc_ * kXRegSizeInBytes); | |
| 3384 // Call as function is indicated with the hole. | |
| 3385 __ JumpIfNotRoot(x4, Heap::kTheHoleValueRootIndex, &call); | |
| 3386 // Patch the receiver on the stack with the global receiver object. | |
| 3387 __ Ldr(x10, GlobalObjectMemOperand()); | |
| 3388 __ Ldr(x11, FieldMemOperand(x10, GlobalObject::kGlobalReceiverOffset)); | |
| 3389 __ Poke(x11, argc_ * kXRegSizeInBytes); | |
| 3390 __ Bind(&call); | |
| 3391 } | |
| 3392 | 3376 |
| 3393 // Check that the function is really a JavaScript function. | 3377 // Goto slow case if we do not have a function. |
| 3394 // x1 function pushed function (to be verified) | |
| 3395 __ JumpIfSmi(function, &non_function); | |
| 3396 // Get the map of the function object. | |
| 3397 __ JumpIfNotObjectType(function, x10, x10, JS_FUNCTION_TYPE, &slow); | 3378 __ JumpIfNotObjectType(function, x10, x10, JS_FUNCTION_TYPE, &slow); |
| 3398 | 3379 |
| 3399 if (RecordCallTarget()) { | 3380 if (RecordCallTarget()) { |
| 3400 GenerateRecordCallTarget(masm); | 3381 GenerateRecordCallTarget(masm); |
| 3401 } | 3382 } |
| 3402 | 3383 |
| 3403 // Fast-case: Invoke the function now. | 3384 // Fast-case: Invoke the function now. |
| 3404 // x1 function pushed function | 3385 // x1 function pushed function |
| 3405 ParameterCount actual(argc_); | 3386 ParameterCount actual(argc_); |
| 3406 | 3387 |
| 3407 if (ReceiverMightBeImplicit()) { | |
| 3408 Label call_as_function; | |
| 3409 __ JumpIfRoot(x4, Heap::kTheHoleValueRootIndex, &call_as_function); | |
| 3410 __ InvokeFunction(function, | |
| 3411 actual, | |
| 3412 JUMP_FUNCTION, | |
| 3413 NullCallWrapper(), | |
| 3414 CALL_AS_METHOD); | |
| 3415 __ Bind(&call_as_function); | |
| 3416 } | |
| 3417 __ InvokeFunction(function, | 3388 __ InvokeFunction(function, |
| 3418 actual, | 3389 actual, |
| 3419 JUMP_FUNCTION, | 3390 JUMP_FUNCTION, |
| 3420 NullCallWrapper(), | 3391 NullCallWrapper(), |
| 3421 CALL_AS_FUNCTION); | 3392 CALL_AS_FUNCTION); |
| 3422 | 3393 |
| 3423 // Slow-case: Non-function called. | 3394 // Slow-case: Non-function called. |
| 3424 __ Bind(&slow); | 3395 __ Bind(&slow); |
| 3425 if (RecordCallTarget()) { | 3396 if (RecordCallTarget()) { |
| 3426 // If there is a call target cache, mark it megamorphic in the | 3397 // If there is a call target cache, mark it megamorphic in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3446 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 3417 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
| 3447 } | 3418 } |
| 3448 | 3419 |
| 3449 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 3420 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 3450 // of the original receiver from the call site). | 3421 // of the original receiver from the call site). |
| 3451 __ Bind(&non_function); | 3422 __ Bind(&non_function); |
| 3452 __ Poke(function, argc_ * kXRegSizeInBytes); | 3423 __ Poke(function, argc_ * kXRegSizeInBytes); |
| 3453 __ Mov(x0, argc_); // Set up the number of arguments. | 3424 __ Mov(x0, argc_); // Set up the number of arguments. |
| 3454 __ Mov(x2, 0); | 3425 __ Mov(x2, 0); |
| 3455 __ GetBuiltinEntry(x3, Builtins::CALL_NON_FUNCTION); | 3426 __ GetBuiltinEntry(x3, Builtins::CALL_NON_FUNCTION); |
| 3456 __ SetCallKind(x5, CALL_AS_METHOD); | 3427 __ SetCallKind(x5, CALL_AS_FUNCTION); |
| 3457 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 3428 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 3458 RelocInfo::CODE_TARGET); | 3429 RelocInfo::CODE_TARGET); |
| 3459 } | 3430 } |
| 3460 | 3431 |
| 3461 | 3432 |
| 3462 void CallConstructStub::Generate(MacroAssembler* masm) { | 3433 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 3463 ASM_LOCATION("CallConstructStub::Generate"); | 3434 ASM_LOCATION("CallConstructStub::Generate"); |
| 3464 // x0 : number of arguments | 3435 // x0 : number of arguments |
| 3465 // x1 : the function to call | 3436 // x1 : the function to call |
| 3466 // x2 : cache cell for call target | 3437 // x2 : cache cell for call target |
| (...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5606 __ Bind(¬_in_dictionary); | 5577 __ Bind(¬_in_dictionary); |
| 5607 __ Mov(result, 0); | 5578 __ Mov(result, 0); |
| 5608 __ Ret(); | 5579 __ Ret(); |
| 5609 } | 5580 } |
| 5610 | 5581 |
| 5611 | 5582 |
| 5612 template<class T> | 5583 template<class T> |
| 5613 static void CreateArrayDispatch(MacroAssembler* masm, | 5584 static void CreateArrayDispatch(MacroAssembler* masm, |
| 5614 AllocationSiteOverrideMode mode) { | 5585 AllocationSiteOverrideMode mode) { |
| 5615 if (mode == DISABLE_ALLOCATION_SITES) { | 5586 if (mode == DISABLE_ALLOCATION_SITES) { |
| 5616 T stub(GetInitialFastElementsKind(), | 5587 T stub(GetInitialFastElementsKind(), mode); |
| 5617 CONTEXT_CHECK_REQUIRED, | |
| 5618 mode); | |
| 5619 __ TailCallStub(&stub); | 5588 __ TailCallStub(&stub); |
| 5620 | 5589 |
| 5621 } else if (mode == DONT_OVERRIDE) { | 5590 } else if (mode == DONT_OVERRIDE) { |
| 5622 Register kind = x3; | 5591 Register kind = x3; |
| 5623 int last_index = | 5592 int last_index = |
| 5624 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); | 5593 GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); |
| 5625 for (int i = 0; i <= last_index; ++i) { | 5594 for (int i = 0; i <= last_index; ++i) { |
| 5626 Label next; | 5595 Label next; |
| 5627 ElementsKind candidate_kind = GetFastElementsKindFromSequenceIndex(i); | 5596 ElementsKind candidate_kind = GetFastElementsKindFromSequenceIndex(i); |
| 5628 // TODO(jbramley): Is this the best way to handle this? Can we make the | 5597 // TODO(jbramley): Is this the best way to handle this? Can we make the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5671 // Look at the last argument. | 5640 // Look at the last argument. |
| 5672 // TODO(jbramley): What does a 0 argument represent? | 5641 // TODO(jbramley): What does a 0 argument represent? |
| 5673 __ Peek(x10, 0); | 5642 __ Peek(x10, 0); |
| 5674 __ Cbz(x10, &normal_sequence); | 5643 __ Cbz(x10, &normal_sequence); |
| 5675 | 5644 |
| 5676 if (mode == DISABLE_ALLOCATION_SITES) { | 5645 if (mode == DISABLE_ALLOCATION_SITES) { |
| 5677 ElementsKind initial = GetInitialFastElementsKind(); | 5646 ElementsKind initial = GetInitialFastElementsKind(); |
| 5678 ElementsKind holey_initial = GetHoleyElementsKind(initial); | 5647 ElementsKind holey_initial = GetHoleyElementsKind(initial); |
| 5679 | 5648 |
| 5680 ArraySingleArgumentConstructorStub stub_holey(holey_initial, | 5649 ArraySingleArgumentConstructorStub stub_holey(holey_initial, |
| 5681 CONTEXT_CHECK_REQUIRED, | |
| 5682 DISABLE_ALLOCATION_SITES); | 5650 DISABLE_ALLOCATION_SITES); |
| 5683 __ TailCallStub(&stub_holey); | 5651 __ TailCallStub(&stub_holey); |
| 5684 | 5652 |
| 5685 __ Bind(&normal_sequence); | 5653 __ Bind(&normal_sequence); |
| 5686 ArraySingleArgumentConstructorStub stub(initial, | 5654 ArraySingleArgumentConstructorStub stub(initial, |
| 5687 CONTEXT_CHECK_REQUIRED, | |
| 5688 DISABLE_ALLOCATION_SITES); | 5655 DISABLE_ALLOCATION_SITES); |
| 5689 __ TailCallStub(&stub); | 5656 __ TailCallStub(&stub); |
| 5690 } else if (mode == DONT_OVERRIDE) { | 5657 } else if (mode == DONT_OVERRIDE) { |
| 5691 // We are going to create a holey array, but our kind is non-holey. | 5658 // We are going to create a holey array, but our kind is non-holey. |
| 5692 // Fix kind and retry (only if we have an allocation site in the cell). | 5659 // Fix kind and retry (only if we have an allocation site in the cell). |
| 5693 __ Orr(kind, kind, 1); | 5660 __ Orr(kind, kind, 1); |
| 5694 | 5661 |
| 5695 __ Ldr(x10, FieldMemOperand(type_info_cell, Cell::kValueOffset)); | 5662 __ Ldr(x10, FieldMemOperand(type_info_cell, Cell::kValueOffset)); |
| 5696 | 5663 |
| 5697 if (FLAG_debug_code) { | 5664 if (FLAG_debug_code) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5727 // If we reached this point there is a problem. | 5694 // If we reached this point there is a problem. |
| 5728 __ Abort(kUnexpectedElementsKindInArrayConstructor); | 5695 __ Abort(kUnexpectedElementsKindInArrayConstructor); |
| 5729 } else { | 5696 } else { |
| 5730 UNREACHABLE(); | 5697 UNREACHABLE(); |
| 5731 } | 5698 } |
| 5732 } | 5699 } |
| 5733 | 5700 |
| 5734 | 5701 |
| 5735 template<class T> | 5702 template<class T> |
| 5736 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 5703 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
| 5737 ElementsKind initial_kind = GetInitialFastElementsKind(); | |
| 5738 ElementsKind initial_holey_kind = GetHoleyElementsKind(initial_kind); | |
| 5739 | |
| 5740 int to_index = GetSequenceIndexFromFastElementsKind( | 5704 int to_index = GetSequenceIndexFromFastElementsKind( |
| 5741 TERMINAL_FAST_ELEMENTS_KIND); | 5705 TERMINAL_FAST_ELEMENTS_KIND); |
| 5742 for (int i = 0; i <= to_index; ++i) { | 5706 for (int i = 0; i <= to_index; ++i) { |
| 5743 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 5707 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
| 5744 T stub(kind); | 5708 T stub(kind); |
| 5745 stub.GetCode(isolate); | 5709 stub.GetCode(isolate); |
| 5746 if ((AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) || | 5710 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
| 5747 (!FLAG_track_allocation_sites && | 5711 T stub1(kind, DISABLE_ALLOCATION_SITES); |
| 5748 ((kind == initial_kind) || (kind == initial_holey_kind)))) { | |
| 5749 T stub1(kind, CONTEXT_CHECK_REQUIRED, DISABLE_ALLOCATION_SITES); | |
| 5750 stub1.GetCode(isolate); | 5712 stub1.GetCode(isolate); |
| 5751 } | 5713 } |
| 5752 } | 5714 } |
| 5753 } | 5715 } |
| 5754 | 5716 |
| 5755 | 5717 |
| 5756 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 5718 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
| 5757 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 5719 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
| 5758 isolate); | 5720 isolate); |
| 5759 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 5721 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5960 __ Bind(&fast_elements_case); | 5922 __ Bind(&fast_elements_case); |
| 5961 GenerateCase(masm, FAST_ELEMENTS); | 5923 GenerateCase(masm, FAST_ELEMENTS); |
| 5962 } | 5924 } |
| 5963 | 5925 |
| 5964 | 5926 |
| 5965 #undef __ | 5927 #undef __ |
| 5966 | 5928 |
| 5967 } } // namespace v8::internal | 5929 } } // namespace v8::internal |
| 5968 | 5930 |
| 5969 #endif // V8_TARGET_ARCH_A64 | 5931 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |