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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 __ bind(&miss); | 76 __ bind(&miss); |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 // Helper function used to check that the dictionary doesn't contain | 80 // Helper function used to check that the dictionary doesn't contain |
81 // the property. This function may return false negatives, so miss_label | 81 // the property. This function may return false negatives, so miss_label |
82 // must always call a backup property check that is complete. | 82 // must always call a backup property check that is complete. |
83 // This function is safe to call if the receiver has fast properties. | 83 // This function is safe to call if the receiver has fast properties. |
84 // Name must be a symbol and receiver must be a heap object. | 84 // Name must be a symbol and receiver must be a heap object. |
85 static void GenerateDictionaryNegativeLookup(MacroAssembler* masm, | 85 MUST_USE_RESULT static MaybeObject* GenerateDictionaryNegativeLookup( |
86 Label* miss_label, | 86 MacroAssembler* masm, |
87 Register receiver, | 87 Label* miss_label, |
88 String* name, | 88 Register receiver, |
89 Register r0, | 89 String* name, |
90 Register r1) { | 90 Register r0, |
| 91 Register r1) { |
91 ASSERT(name->IsSymbol()); | 92 ASSERT(name->IsSymbol()); |
92 Counters* counters = masm->isolate()->counters(); | 93 Counters* counters = masm->isolate()->counters(); |
93 __ IncrementCounter(counters->negative_lookups(), 1); | 94 __ IncrementCounter(counters->negative_lookups(), 1); |
94 __ IncrementCounter(counters->negative_lookups_miss(), 1); | 95 __ IncrementCounter(counters->negative_lookups_miss(), 1); |
95 | 96 |
96 __ movq(r0, FieldOperand(receiver, HeapObject::kMapOffset)); | 97 __ movq(r0, FieldOperand(receiver, HeapObject::kMapOffset)); |
97 | 98 |
98 const int kInterceptorOrAccessCheckNeededMask = | 99 const int kInterceptorOrAccessCheckNeededMask = |
99 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | 100 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
100 | 101 |
101 // Bail out if the receiver has a named interceptor or requires access checks. | 102 // Bail out if the receiver has a named interceptor or requires access checks. |
102 __ testb(FieldOperand(r0, Map::kBitFieldOffset), | 103 __ testb(FieldOperand(r0, Map::kBitFieldOffset), |
103 Immediate(kInterceptorOrAccessCheckNeededMask)); | 104 Immediate(kInterceptorOrAccessCheckNeededMask)); |
104 __ j(not_zero, miss_label); | 105 __ j(not_zero, miss_label); |
105 | 106 |
106 // Check that receiver is a JSObject. | 107 // Check that receiver is a JSObject. |
107 __ CmpInstanceType(r0, FIRST_JS_OBJECT_TYPE); | 108 __ CmpInstanceType(r0, FIRST_JS_OBJECT_TYPE); |
108 __ j(below, miss_label); | 109 __ j(below, miss_label); |
109 | 110 |
110 // Load properties array. | 111 // Load properties array. |
111 Register properties = r0; | 112 Register properties = r0; |
112 __ movq(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); | 113 __ movq(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
113 | 114 |
114 // Check that the properties array is a dictionary. | 115 // Check that the properties array is a dictionary. |
115 __ CompareRoot(FieldOperand(properties, HeapObject::kMapOffset), | 116 __ CompareRoot(FieldOperand(properties, HeapObject::kMapOffset), |
116 Heap::kHashTableMapRootIndex); | 117 Heap::kHashTableMapRootIndex); |
117 __ j(not_equal, miss_label); | 118 __ j(not_equal, miss_label); |
118 | 119 |
119 Label done; | 120 Label done; |
120 StringDictionaryLookupStub::GenerateNegativeLookup(masm, | 121 MaybeObject* result = StringDictionaryLookupStub::GenerateNegativeLookup( |
121 miss_label, | 122 masm, |
122 &done, | 123 miss_label, |
123 properties, | 124 &done, |
124 name, | 125 properties, |
125 r1); | 126 name, |
| 127 r1); |
| 128 if (result->IsFailure()) return result; |
| 129 |
126 __ bind(&done); | 130 __ bind(&done); |
127 __ DecrementCounter(counters->negative_lookups_miss(), 1); | 131 __ DecrementCounter(counters->negative_lookups_miss(), 1); |
| 132 |
| 133 return result; |
128 } | 134 } |
129 | 135 |
130 | 136 |
131 void StubCache::GenerateProbe(MacroAssembler* masm, | 137 void StubCache::GenerateProbe(MacroAssembler* masm, |
132 Code::Flags flags, | 138 Code::Flags flags, |
133 Register receiver, | 139 Register receiver, |
134 Register name, | 140 Register name, |
135 Register scratch, | 141 Register scratch, |
136 Register extra, | 142 Register extra, |
137 Register extra2) { | 143 Register extra2) { |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 if (lookup_result->IsFailure()) { | 856 if (lookup_result->IsFailure()) { |
851 set_failure(Failure::cast(lookup_result)); | 857 set_failure(Failure::cast(lookup_result)); |
852 return reg; | 858 return reg; |
853 } else { | 859 } else { |
854 name = String::cast(lookup_result->ToObjectUnchecked()); | 860 name = String::cast(lookup_result->ToObjectUnchecked()); |
855 } | 861 } |
856 } | 862 } |
857 ASSERT(current->property_dictionary()->FindEntry(name) == | 863 ASSERT(current->property_dictionary()->FindEntry(name) == |
858 StringDictionary::kNotFound); | 864 StringDictionary::kNotFound); |
859 | 865 |
860 GenerateDictionaryNegativeLookup(masm(), | 866 MaybeObject* negative_lookup = GenerateDictionaryNegativeLookup(masm(), |
861 miss, | 867 miss, |
862 reg, | 868 reg, |
863 name, | 869 name, |
864 scratch1, | 870 scratch1, |
865 scratch2); | 871 scratch2); |
| 872 if (negative_lookup->IsFailure()) { |
| 873 set_failure(Failure::cast(negative_lookup)); |
| 874 return reg; |
| 875 } |
| 876 |
866 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); | 877 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); |
867 reg = holder_reg; // from now the object is in holder_reg | 878 reg = holder_reg; // from now the object is in holder_reg |
868 __ movq(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); | 879 __ movq(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); |
869 } else if (heap()->InNewSpace(prototype)) { | 880 } else if (heap()->InNewSpace(prototype)) { |
870 // Get the map of the current object. | 881 // Get the map of the current object. |
871 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); | 882 __ movq(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); |
872 __ Cmp(scratch1, Handle<Map>(current->map())); | 883 __ Cmp(scratch1, Handle<Map>(current->map())); |
873 // Branch on the result of the map check. | 884 // Branch on the result of the map check. |
874 __ j(not_equal, miss); | 885 __ j(not_equal, miss); |
875 // Check access rights to the global object. This has to happen | 886 // Check access rights to the global object. This has to happen |
(...skipping 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); | 3424 __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
3414 | 3425 |
3415 return GetCode(flags); | 3426 return GetCode(flags); |
3416 } | 3427 } |
3417 | 3428 |
3418 #undef __ | 3429 #undef __ |
3419 | 3430 |
3420 } } // namespace v8::internal | 3431 } } // namespace v8::internal |
3421 | 3432 |
3422 #endif // V8_TARGET_ARCH_X64 | 3433 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |