Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 412483003: Only to the relevant checks in LoadFunctionPrototype (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 3727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3738 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); 3738 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset));
3739 cmpb(instance_type, Immediate(static_cast<uint8_t>(LAST_NAME_TYPE))); 3739 cmpb(instance_type, Immediate(static_cast<uint8_t>(LAST_NAME_TYPE)));
3740 return below_equal; 3740 return below_equal;
3741 } 3741 }
3742 3742
3743 3743
3744 void MacroAssembler::TryGetFunctionPrototype(Register function, 3744 void MacroAssembler::TryGetFunctionPrototype(Register function,
3745 Register result, 3745 Register result,
3746 Label* miss, 3746 Label* miss,
3747 bool miss_on_bound_function) { 3747 bool miss_on_bound_function) {
3748 // Check that the receiver isn't a smi. 3748 Label non_instance;
3749 testl(function, Immediate(kSmiTagMask)); 3749 if (miss_on_bound_function) {
3750 j(zero, miss); 3750 // Check that the receiver isn't a smi.
3751 testl(function, Immediate(kSmiTagMask));
3752 j(zero, miss);
3751 3753
3752 // Check that the function really is a function. 3754 // Check that the function really is a function.
3753 CmpObjectType(function, JS_FUNCTION_TYPE, result); 3755 CmpObjectType(function, JS_FUNCTION_TYPE, result);
3754 j(not_equal, miss); 3756 j(not_equal, miss);
3755 3757
3756 if (miss_on_bound_function) {
3757 movp(kScratchRegister, 3758 movp(kScratchRegister,
3758 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); 3759 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
3759 // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte 3760 // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte
3760 // field). 3761 // field).
3761 TestBitSharedFunctionInfoSpecialField(kScratchRegister, 3762 TestBitSharedFunctionInfoSpecialField(kScratchRegister,
3762 SharedFunctionInfo::kCompilerHintsOffset, 3763 SharedFunctionInfo::kCompilerHintsOffset,
3763 SharedFunctionInfo::kBoundFunction); 3764 SharedFunctionInfo::kBoundFunction);
3764 j(not_zero, miss); 3765 j(not_zero, miss);
3766
3767 // Make sure that the function has an instance prototype.
3768 testb(FieldOperand(result, Map::kBitFieldOffset),
3769 Immediate(1 << Map::kHasNonInstancePrototype));
3770 j(not_zero, &non_instance, Label::kNear);
3765 } 3771 }
3766 3772
3767 // Make sure that the function has an instance prototype.
3768 Label non_instance;
3769 testb(FieldOperand(result, Map::kBitFieldOffset),
3770 Immediate(1 << Map::kHasNonInstancePrototype));
3771 j(not_zero, &non_instance, Label::kNear);
3772
3773 // Get the prototype or initial map from the function. 3773 // Get the prototype or initial map from the function.
3774 movp(result, 3774 movp(result,
3775 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 3775 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
3776 3776
3777 // If the prototype or initial map is the hole, don't return it and 3777 // If the prototype or initial map is the hole, don't return it and
3778 // simply miss the cache instead. This will allow us to allocate a 3778 // simply miss the cache instead. This will allow us to allocate a
3779 // prototype object on-demand in the runtime system. 3779 // prototype object on-demand in the runtime system.
3780 CompareRoot(result, Heap::kTheHoleValueRootIndex); 3780 CompareRoot(result, Heap::kTheHoleValueRootIndex);
3781 j(equal, miss); 3781 j(equal, miss);
3782 3782
3783 // If the function does not have an initial map, we're done. 3783 // If the function does not have an initial map, we're done.
3784 Label done; 3784 Label done;
3785 CmpObjectType(result, MAP_TYPE, kScratchRegister); 3785 CmpObjectType(result, MAP_TYPE, kScratchRegister);
3786 j(not_equal, &done, Label::kNear); 3786 j(not_equal, &done, Label::kNear);
3787 3787
3788 // Get the prototype from the initial map. 3788 // Get the prototype from the initial map.
3789 movp(result, FieldOperand(result, Map::kPrototypeOffset)); 3789 movp(result, FieldOperand(result, Map::kPrototypeOffset));
3790 jmp(&done, Label::kNear);
3791 3790
3792 // Non-instance prototype: Fetch prototype from constructor field 3791 if (miss_on_bound_function) {
3793 // in initial map. 3792 jmp(&done, Label::kNear);
3794 bind(&non_instance); 3793
3795 movp(result, FieldOperand(result, Map::kConstructorOffset)); 3794 // Non-instance prototype: Fetch prototype from constructor field
3795 // in initial map.
3796 bind(&non_instance);
3797 movp(result, FieldOperand(result, Map::kConstructorOffset));
3798 }
3796 3799
3797 // All done. 3800 // All done.
3798 bind(&done); 3801 bind(&done);
3799 } 3802 }
3800 3803
3801 3804
3802 void MacroAssembler::SetCounter(StatsCounter* counter, int value) { 3805 void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
3803 if (FLAG_native_code_counters && counter->Enabled()) { 3806 if (FLAG_native_code_counters && counter->Enabled()) {
3804 Operand counter_operand = ExternalOperand(ExternalReference(counter)); 3807 Operand counter_operand = ExternalOperand(ExternalReference(counter));
3805 movl(counter_operand, Immediate(value)); 3808 movl(counter_operand, Immediate(value));
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
5373 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); 5376 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift()));
5374 movl(rax, dividend); 5377 movl(rax, dividend);
5375 shrl(rax, Immediate(31)); 5378 shrl(rax, Immediate(31));
5376 addl(rdx, rax); 5379 addl(rdx, rax);
5377 } 5380 }
5378 5381
5379 5382
5380 } } // namespace v8::internal 5383 } } // namespace v8::internal
5381 5384
5382 #endif // V8_TARGET_ARCH_X64 5385 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698