jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 30 | #if V8_TARGET_ARCH_IA32 |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 31 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 32 | #include "codegen.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 33 | #include "ic-inl.h" |
| 34 | #include "runtime.h" |
| 35 | #include "stub-cache.h" |
| 36 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 37 | namespace v8 { |
| 38 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 39 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 40 | // ---------------------------------------------------------------------------- |
| 41 | // Static IC stub generators. |
| 42 | // |
| 43 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 44 | #define __ ACCESS_MASM(masm) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 45 | |
| 46 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 47 | static void GenerateGlobalInstanceTypeCheck(MacroAssembler* masm, |
| 48 | Register type, |
| 49 | Label* global_object) { |
| 50 | // Register usage: |
| 51 | // type: holds the receiver instance type on entry. |
| 52 | __ cmp(type, JS_GLOBAL_OBJECT_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 53 | __ j(equal, global_object); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 54 | __ cmp(type, JS_BUILTINS_OBJECT_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 55 | __ j(equal, global_object); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 56 | __ cmp(type, JS_GLOBAL_PROXY_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 57 | __ j(equal, global_object); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | |
| 61 | // Generated code falls through if the receiver is a regular non-global |
| 62 | // JS object with slow properties and no interceptors. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 63 | static void GenerateNameDictionaryReceiverCheck(MacroAssembler* masm, |
| 64 | Register receiver, |
| 65 | Register r0, |
| 66 | Register r1, |
| 67 | Label* miss) { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 68 | // Register usage: |
| 69 | // receiver: holds the receiver on entry and is unchanged. |
| 70 | // r0: used to hold receiver instance type. |
| 71 | // Holds the property dictionary on fall through. |
| 72 | // r1: used to hold receivers map. |
| 73 | |
| 74 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 75 | __ JumpIfSmi(receiver, miss); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 76 | |
| 77 | // Check that the receiver is a valid JS object. |
| 78 | __ mov(r1, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 79 | __ movzx_b(r0, FieldOperand(r1, Map::kInstanceTypeOffset)); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 80 | __ cmp(r0, FIRST_SPEC_OBJECT_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 81 | __ j(below, miss); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 82 | |
| 83 | // If this assert fails, we have to check upper bound too. |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 84 | STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 85 | |
| 86 | GenerateGlobalInstanceTypeCheck(masm, r0, miss); |
| 87 | |
| 88 | // Check for non-global object that requires access check. |
| 89 | __ test_b(FieldOperand(r1, Map::kBitFieldOffset), |
| 90 | (1 << Map::kIsAccessCheckNeeded) | |
| 91 | (1 << Map::kHasNamedInterceptor)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 92 | __ j(not_zero, miss); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 93 | |
| 94 | __ mov(r0, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 95 | __ CheckMap(r0, masm->isolate()->factory()->hash_table_map(), miss, |
| 96 | DONT_DO_SMI_CHECK); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 100 | // Helper function used to load a property from a dictionary backing |
| 101 | // storage. This function may fail to load a property even though it is |
| 102 | // in the dictionary, so code at miss_label must always call a backup |
| 103 | // property load that is complete. This function is safe to call if |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 104 | // name is not internalized, and will jump to the miss_label in that |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 105 | // case. The generated code assumes that the receiver has slow |
| 106 | // properties, is not a global object and does not have interceptors. |
| 107 | static void GenerateDictionaryLoad(MacroAssembler* masm, |
| 108 | Label* miss_label, |
| 109 | Register elements, |
| 110 | Register name, |
| 111 | Register r0, |
| 112 | Register r1, |
| 113 | Register result) { |
| 114 | // Register use: |
| 115 | // |
| 116 | // elements - holds the property dictionary on entry and is unchanged. |
| 117 | // |
| 118 | // name - holds the name of the property on entry and is unchanged. |
| 119 | // |
| 120 | // Scratch registers: |
| 121 | // |
| 122 | // r0 - used for the index into the property dictionary |
| 123 | // |
| 124 | // r1 - used to hold the capacity of the property dictionary. |
| 125 | // |
| 126 | // result - holds the result on exit. |
| 127 | |
| 128 | Label done; |
| 129 | |
| 130 | // Probe the dictionary. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 131 | NameDictionaryLookupStub::GeneratePositiveLookup(masm, |
| 132 | miss_label, |
| 133 | &done, |
| 134 | elements, |
| 135 | name, |
| 136 | r0, |
| 137 | r1); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 138 | |
| 139 | // If probing finds an entry in the dictionary, r0 contains the |
| 140 | // index into the dictionary. Check that the value is a normal |
| 141 | // property. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 142 | __ bind(&done); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 143 | const int kElementsStartOffset = |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 144 | NameDictionary::kHeaderSize + |
| 145 | NameDictionary::kElementsStartIndex * kPointerSize; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 146 | const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 147 | __ test(Operand(elements, r0, times_4, kDetailsOffset - kHeapObjectTag), |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 148 | Immediate(PropertyDetails::TypeField::kMask << kSmiTagSize)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 149 | __ j(not_zero, miss_label); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 150 | |
| 151 | // Get the value at the masked, scaled index. |
| 152 | const int kValueOffset = kElementsStartOffset + kPointerSize; |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 153 | __ mov(result, Operand(elements, r0, times_4, kValueOffset - kHeapObjectTag)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 157 | // Helper function used to store a property to a dictionary backing |
| 158 | // storage. This function may fail to store a property eventhough it |
| 159 | // is in the dictionary, so code at miss_label must always call a |
| 160 | // backup property store that is complete. This function is safe to |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 161 | // call if name is not internalized, and will jump to the miss_label in |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 162 | // that case. The generated code assumes that the receiver has slow |
| 163 | // properties, is not a global object and does not have interceptors. |
| 164 | static void GenerateDictionaryStore(MacroAssembler* masm, |
| 165 | Label* miss_label, |
| 166 | Register elements, |
| 167 | Register name, |
| 168 | Register value, |
| 169 | Register r0, |
| 170 | Register r1) { |
| 171 | // Register use: |
| 172 | // |
| 173 | // elements - holds the property dictionary on entry and is clobbered. |
| 174 | // |
| 175 | // name - holds the name of the property on entry and is unchanged. |
| 176 | // |
| 177 | // value - holds the value to store and is unchanged. |
| 178 | // |
| 179 | // r0 - used for index into the property dictionary and is clobbered. |
| 180 | // |
| 181 | // r1 - used to hold the capacity of the property dictionary and is clobbered. |
| 182 | Label done; |
| 183 | |
| 184 | |
| 185 | // Probe the dictionary. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 186 | NameDictionaryLookupStub::GeneratePositiveLookup(masm, |
| 187 | miss_label, |
| 188 | &done, |
| 189 | elements, |
| 190 | name, |
| 191 | r0, |
| 192 | r1); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 193 | |
| 194 | // If probing finds an entry in the dictionary, r0 contains the |
| 195 | // index into the dictionary. Check that the value is a normal |
| 196 | // property that is not read only. |
| 197 | __ bind(&done); |
| 198 | const int kElementsStartOffset = |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 199 | NameDictionary::kHeaderSize + |
| 200 | NameDictionary::kElementsStartIndex * kPointerSize; |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 201 | const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 202 | const int kTypeAndReadOnlyMask = |
| 203 | (PropertyDetails::TypeField::kMask | |
| 204 | PropertyDetails::AttributesField::encode(READ_ONLY)) << kSmiTagSize; |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 205 | __ test(Operand(elements, r0, times_4, kDetailsOffset - kHeapObjectTag), |
| 206 | Immediate(kTypeAndReadOnlyMask)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 207 | __ j(not_zero, miss_label); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 208 | |
| 209 | // Store the value at the masked, scaled index. |
| 210 | const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 211 | __ lea(r0, Operand(elements, r0, times_4, kValueOffset - kHeapObjectTag)); |
| 212 | __ mov(Operand(r0, 0), value); |
| 213 | |
| 214 | // Update write barrier. Make sure not to clobber the value. |
| 215 | __ mov(r1, value); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 216 | __ RecordWrite(elements, r0, r1, kDontSaveFPRegs); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 220 | // Checks the receiver for special cases (value type, slow case bits). |
| 221 | // Falls through for regular JS object. |
| 222 | static void GenerateKeyedLoadReceiverCheck(MacroAssembler* masm, |
| 223 | Register receiver, |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 224 | Register map, |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 225 | int interceptor_bit, |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 226 | Label* slow) { |
| 227 | // Register use: |
| 228 | // receiver - holds the receiver and is unchanged. |
| 229 | // Scratch registers: |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 230 | // map - used to hold the map of the receiver. |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 231 | |
| 232 | // Check that the object isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 233 | __ JumpIfSmi(receiver, slow); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 234 | |
| 235 | // Get the map of the receiver. |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 236 | __ mov(map, FieldOperand(receiver, HeapObject::kMapOffset)); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 237 | |
| 238 | // Check bit field. |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 239 | __ test_b(FieldOperand(map, Map::kBitFieldOffset), |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 240 | (1 << Map::kIsAccessCheckNeeded) | (1 << interceptor_bit)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 241 | __ j(not_zero, slow); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 242 | // Check that the object is some kind of JS object EXCEPT JS Value type. |
| 243 | // In the case that the object is a value-wrapper object, |
| 244 | // we enter the runtime system to make sure that indexing |
| 245 | // into string objects works as intended. |
| 246 | ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE); |
| 247 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 248 | __ CmpInstanceType(map, JS_OBJECT_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 249 | __ j(below, slow); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | |
| 253 | // Loads an indexed element from a fast case array. |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 254 | // If not_fast_array is NULL, doesn't perform the elements map check. |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 255 | static void GenerateFastArrayLoad(MacroAssembler* masm, |
| 256 | Register receiver, |
| 257 | Register key, |
| 258 | Register scratch, |
| 259 | Register result, |
| 260 | Label* not_fast_array, |
| 261 | Label* out_of_range) { |
| 262 | // Register use: |
| 263 | // receiver - holds the receiver and is unchanged. |
| 264 | // key - holds the key and is unchanged (must be a smi). |
| 265 | // Scratch registers: |
| 266 | // scratch - used to hold elements of the receiver and the loaded value. |
| 267 | // result - holds the result on exit if the load succeeds and |
| 268 | // we fall through. |
| 269 | |
| 270 | __ mov(scratch, FieldOperand(receiver, JSObject::kElementsOffset)); |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 271 | if (not_fast_array != NULL) { |
| 272 | // Check that the object is in fast mode and writable. |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 273 | __ CheckMap(scratch, |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 274 | masm->isolate()->factory()->fixed_array_map(), |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 275 | not_fast_array, |
| 276 | DONT_DO_SMI_CHECK); |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 277 | } else { |
| 278 | __ AssertFastElements(scratch); |
| 279 | } |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 280 | // Check that the key (index) is within bounds. |
| 281 | __ cmp(key, FieldOperand(scratch, FixedArray::kLengthOffset)); |
| 282 | __ j(above_equal, out_of_range); |
| 283 | // Fast case: Do the load. |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 284 | STATIC_ASSERT((kPointerSize == 4) && (kSmiTagSize == 1) && (kSmiTag == 0)); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 285 | __ mov(scratch, FieldOperand(scratch, key, times_2, FixedArray::kHeaderSize)); |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 286 | __ cmp(scratch, Immediate(masm->isolate()->factory()->the_hole_value())); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 287 | // In case the loaded value is the_hole we have to consult GetProperty |
| 288 | // to ensure the prototype chain is searched. |
| 289 | __ j(equal, out_of_range); |
| 290 | if (!result.is(scratch)) { |
| 291 | __ mov(result, scratch); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 296 | // Checks whether a key is an array index string or a unique name. |
| 297 | // Falls through if the key is a unique name. |
| 298 | static void GenerateKeyNameCheck(MacroAssembler* masm, |
| 299 | Register key, |
| 300 | Register map, |
| 301 | Register hash, |
| 302 | Label* index_string, |
| 303 | Label* not_unique) { |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 304 | // Register use: |
| 305 | // key - holds the key and is unchanged. Assumed to be non-smi. |
| 306 | // Scratch registers: |
| 307 | // map - used to hold the map of the key. |
| 308 | // hash - used to hold the hash of the key. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 309 | Label unique; |
| 310 | __ CmpObjectType(key, LAST_UNIQUE_NAME_TYPE, map); |
| 311 | __ j(above, not_unique); |
| 312 | STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE); |
| 313 | __ j(equal, &unique); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 314 | |
| 315 | // Is the string an array index, with cached numeric value? |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 316 | __ mov(hash, FieldOperand(key, Name::kHashFieldOffset)); |
| 317 | __ test(hash, Immediate(Name::kContainsCachedArrayIndexMask)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 318 | __ j(zero, index_string); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 319 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 320 | // Is the string internalized? We already know it's a string so a single |
| 321 | // bit test is enough. |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 322 | STATIC_ASSERT(kNotInternalizedTag != 0); |
| 323 | __ test_b(FieldOperand(map, Map::kInstanceTypeOffset), |
| 324 | kIsNotInternalizedMask); |
| 325 | __ j(not_zero, not_unique); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 326 | |
| 327 | __ bind(&unique); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 331 | static Operand GenerateMappedArgumentsLookup(MacroAssembler* masm, |
| 332 | Register object, |
| 333 | Register key, |
| 334 | Register scratch1, |
| 335 | Register scratch2, |
| 336 | Label* unmapped_case, |
| 337 | Label* slow_case) { |
| 338 | Heap* heap = masm->isolate()->heap(); |
| 339 | Factory* factory = masm->isolate()->factory(); |
| 340 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 341 | // Check that the receiver is a JSObject. Because of the elements |
| 342 | // map check later, we do not need to check for interceptors or |
| 343 | // whether it requires access checks. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 344 | __ JumpIfSmi(object, slow_case); |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 345 | // Check that the object is some kind of JSObject. |
| 346 | __ CmpObjectType(object, FIRST_JS_RECEIVER_TYPE, scratch1); |
| 347 | __ j(below, slow_case); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 348 | |
| 349 | // Check that the key is a positive smi. |
danno@chromium.org | b10deab | 2012-05-07 14:28:47 +0000 | [diff] [blame] | 350 | __ test(key, Immediate(0x80000001)); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 351 | __ j(not_zero, slow_case); |
| 352 | |
| 353 | // Load the elements into scratch1 and check its map. |
| 354 | Handle<Map> arguments_map(heap->non_strict_arguments_elements_map()); |
| 355 | __ mov(scratch1, FieldOperand(object, JSObject::kElementsOffset)); |
| 356 | __ CheckMap(scratch1, arguments_map, slow_case, DONT_DO_SMI_CHECK); |
| 357 | |
| 358 | // Check if element is in the range of mapped arguments. If not, jump |
| 359 | // to the unmapped lookup with the parameter map in scratch1. |
| 360 | __ mov(scratch2, FieldOperand(scratch1, FixedArray::kLengthOffset)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 361 | __ sub(scratch2, Immediate(Smi::FromInt(2))); |
| 362 | __ cmp(key, scratch2); |
danno@chromium.org | b10deab | 2012-05-07 14:28:47 +0000 | [diff] [blame] | 363 | __ j(above_equal, unmapped_case); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 364 | |
| 365 | // Load element index and check whether it is the hole. |
| 366 | const int kHeaderSize = FixedArray::kHeaderSize + 2 * kPointerSize; |
| 367 | __ mov(scratch2, FieldOperand(scratch1, |
| 368 | key, |
| 369 | times_half_pointer_size, |
| 370 | kHeaderSize)); |
| 371 | __ cmp(scratch2, factory->the_hole_value()); |
| 372 | __ j(equal, unmapped_case); |
| 373 | |
| 374 | // Load value from context and return it. We can reuse scratch1 because |
| 375 | // we do not jump to the unmapped lookup (which requires the parameter |
| 376 | // map in scratch1). |
| 377 | const int kContextOffset = FixedArray::kHeaderSize; |
| 378 | __ mov(scratch1, FieldOperand(scratch1, kContextOffset)); |
| 379 | return FieldOperand(scratch1, |
| 380 | scratch2, |
| 381 | times_half_pointer_size, |
| 382 | Context::kHeaderSize); |
| 383 | } |
| 384 | |
| 385 | |
| 386 | static Operand GenerateUnmappedArgumentsLookup(MacroAssembler* masm, |
| 387 | Register key, |
| 388 | Register parameter_map, |
| 389 | Register scratch, |
| 390 | Label* slow_case) { |
| 391 | // Element is in arguments backing store, which is referenced by the |
| 392 | // second element of the parameter_map. |
| 393 | const int kBackingStoreOffset = FixedArray::kHeaderSize + kPointerSize; |
| 394 | Register backing_store = parameter_map; |
| 395 | __ mov(backing_store, FieldOperand(parameter_map, kBackingStoreOffset)); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 396 | Handle<Map> fixed_array_map(masm->isolate()->heap()->fixed_array_map()); |
| 397 | __ CheckMap(backing_store, fixed_array_map, slow_case, DONT_DO_SMI_CHECK); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 398 | __ mov(scratch, FieldOperand(backing_store, FixedArray::kLengthOffset)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 399 | __ cmp(key, scratch); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 400 | __ j(greater_equal, slow_case); |
| 401 | return FieldOperand(backing_store, |
| 402 | key, |
| 403 | times_half_pointer_size, |
| 404 | FixedArray::kHeaderSize); |
| 405 | } |
| 406 | |
| 407 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 408 | void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
| 409 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 410 | // -- ecx : key |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 411 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 412 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 413 | // ----------------------------------- |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 414 | Label slow, check_name, index_smi, index_name, property_array_property; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 415 | Label probe_dictionary, check_number_dictionary; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 416 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 417 | // Check that the key is a smi. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 418 | __ JumpIfNotSmi(ecx, &check_name); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 419 | __ bind(&index_smi); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 420 | // Now the key is known to be a smi. This place is also jumped to from |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 421 | // where a numeric string is converted to a smi. |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 422 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 423 | GenerateKeyedLoadReceiverCheck( |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 424 | masm, edx, eax, Map::kHasIndexedInterceptor, &slow); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 425 | |
erik.corry@gmail.com | d6076d9 | 2011-06-06 09:39:18 +0000 | [diff] [blame] | 426 | // Check the receiver's map to see if it has fast elements. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 427 | __ CheckFastElements(eax, &check_number_dictionary); |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 428 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 429 | GenerateFastArrayLoad(masm, edx, ecx, eax, eax, NULL, &slow); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 430 | Isolate* isolate = masm->isolate(); |
| 431 | Counters* counters = isolate->counters(); |
| 432 | __ IncrementCounter(counters->keyed_load_generic_smi(), 1); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 433 | __ ret(0); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 434 | |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 435 | __ bind(&check_number_dictionary); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 436 | __ mov(ebx, ecx); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 437 | __ SmiUntag(ebx); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 438 | __ mov(eax, FieldOperand(edx, JSObject::kElementsOffset)); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 439 | |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 440 | // Check whether the elements is a number dictionary. |
| 441 | // edx: receiver |
| 442 | // ebx: untagged index |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 443 | // ecx: key |
| 444 | // eax: elements |
| 445 | __ CheckMap(eax, |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 446 | isolate->factory()->hash_table_map(), |
| 447 | &slow, |
| 448 | DONT_DO_SMI_CHECK); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 449 | Label slow_pop_receiver; |
| 450 | // Push receiver on the stack to free up a register for the dictionary |
| 451 | // probing. |
| 452 | __ push(edx); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 453 | __ LoadFromNumberDictionary(&slow_pop_receiver, eax, ecx, ebx, edx, edi, eax); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 454 | // Pop receiver before returning. |
| 455 | __ pop(edx); |
| 456 | __ ret(0); |
| 457 | |
| 458 | __ bind(&slow_pop_receiver); |
| 459 | // Pop the receiver from the stack and jump to runtime. |
| 460 | __ pop(edx); |
| 461 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 462 | __ bind(&slow); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 463 | // Slow case: jump to runtime. |
| 464 | // edx: receiver |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 465 | // ecx: key |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 466 | __ IncrementCounter(counters->keyed_load_generic_slow(), 1); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 467 | GenerateRuntimeGetProperty(masm); |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 468 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 469 | __ bind(&check_name); |
| 470 | GenerateKeyNameCheck(masm, ecx, eax, ebx, &index_name, &slow); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 471 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 472 | GenerateKeyedLoadReceiverCheck( |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 473 | masm, edx, eax, Map::kHasNamedInterceptor, &slow); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 474 | |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 475 | // If the receiver is a fast-case object, check the keyed lookup |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 476 | // cache. Otherwise probe the dictionary. |
| 477 | __ mov(ebx, FieldOperand(edx, JSObject::kPropertiesOffset)); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 478 | __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 479 | Immediate(isolate->factory()->hash_table_map())); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 480 | __ j(equal, &probe_dictionary); |
| 481 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 482 | // The receiver's map is still in eax, compute the keyed lookup cache hash |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 483 | // based on 32 bits of the map pointer and the string hash. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 484 | if (FLAG_debug_code) { |
| 485 | __ cmp(eax, FieldOperand(edx, HeapObject::kMapOffset)); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 486 | __ Check(equal, kMapIsNoLongerInEax); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 487 | } |
| 488 | __ mov(ebx, eax); // Keep the map around for later. |
| 489 | __ shr(eax, KeyedLookupCache::kMapHashShift); |
| 490 | __ mov(edi, FieldOperand(ecx, String::kHashFieldOffset)); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 491 | __ shr(edi, String::kHashShift); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 492 | __ xor_(eax, edi); |
| 493 | __ and_(eax, KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 494 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 495 | // Load the key (consisting of map and internalized string) from the cache and |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 496 | // check for match. |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 497 | Label load_in_object_property; |
| 498 | static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket; |
| 499 | Label hit_on_nth_entry[kEntriesPerBucket]; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 500 | ExternalReference cache_keys = |
| 501 | ExternalReference::keyed_lookup_cache_keys(masm->isolate()); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 502 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 503 | for (int i = 0; i < kEntriesPerBucket - 1; i++) { |
| 504 | Label try_next_entry; |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 505 | __ mov(edi, eax); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 506 | __ shl(edi, kPointerSizeLog2 + 1); |
| 507 | if (i != 0) { |
| 508 | __ add(edi, Immediate(kPointerSize * i * 2)); |
| 509 | } |
| 510 | __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); |
| 511 | __ j(not_equal, &try_next_entry); |
| 512 | __ add(edi, Immediate(kPointerSize)); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 513 | __ cmp(ecx, Operand::StaticArray(edi, times_1, cache_keys)); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 514 | __ j(equal, &hit_on_nth_entry[i]); |
| 515 | __ bind(&try_next_entry); |
| 516 | } |
| 517 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 518 | __ lea(edi, Operand(eax, 1)); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 519 | __ shl(edi, kPointerSizeLog2 + 1); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 520 | __ add(edi, Immediate(kPointerSize * (kEntriesPerBucket - 1) * 2)); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 521 | __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys)); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 522 | __ j(not_equal, &slow); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 523 | __ add(edi, Immediate(kPointerSize)); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 524 | __ cmp(ecx, Operand::StaticArray(edi, times_1, cache_keys)); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 525 | __ j(not_equal, &slow); |
| 526 | |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 527 | // Get field offset. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 528 | // edx : receiver |
| 529 | // ebx : receiver's map |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 530 | // ecx : key |
| 531 | // eax : lookup cache index |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 532 | ExternalReference cache_field_offsets = |
| 533 | ExternalReference::keyed_lookup_cache_field_offsets(masm->isolate()); |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 534 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 535 | // Hit on nth entry. |
| 536 | for (int i = kEntriesPerBucket - 1; i >= 0; i--) { |
| 537 | __ bind(&hit_on_nth_entry[i]); |
| 538 | if (i != 0) { |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 539 | __ add(eax, Immediate(i)); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 540 | } |
| 541 | __ mov(edi, |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 542 | Operand::StaticArray(eax, times_pointer_size, cache_field_offsets)); |
| 543 | __ movzx_b(eax, FieldOperand(ebx, Map::kInObjectPropertiesOffset)); |
| 544 | __ sub(edi, eax); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 545 | __ j(above_equal, &property_array_property); |
| 546 | if (i != 0) { |
| 547 | __ jmp(&load_in_object_property); |
| 548 | } |
| 549 | } |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 550 | |
| 551 | // Load in-object property. |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 552 | __ bind(&load_in_object_property); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 553 | __ movzx_b(eax, FieldOperand(ebx, Map::kInstanceSizeOffset)); |
| 554 | __ add(eax, edi); |
| 555 | __ mov(eax, FieldOperand(edx, eax, times_pointer_size, 0)); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 556 | __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 557 | __ ret(0); |
| 558 | |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 559 | // Load property array property. |
| 560 | __ bind(&property_array_property); |
| 561 | __ mov(eax, FieldOperand(edx, JSObject::kPropertiesOffset)); |
| 562 | __ mov(eax, FieldOperand(eax, edi, times_pointer_size, |
| 563 | FixedArray::kHeaderSize)); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 564 | __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 565 | __ ret(0); |
| 566 | |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 567 | // Do a quick inline probe of the receiver's dictionary, if it |
| 568 | // exists. |
| 569 | __ bind(&probe_dictionary); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 570 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 571 | __ mov(eax, FieldOperand(edx, JSObject::kMapOffset)); |
| 572 | __ movzx_b(eax, FieldOperand(eax, Map::kInstanceTypeOffset)); |
| 573 | GenerateGlobalInstanceTypeCheck(masm, eax, &slow); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 574 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 575 | GenerateDictionaryLoad(masm, &slow, ebx, ecx, eax, edi, eax); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 576 | __ IncrementCounter(counters->keyed_load_generic_symbol(), 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 577 | __ ret(0); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 578 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 579 | __ bind(&index_name); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 580 | __ IndexFromHash(ebx, ecx); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 581 | // Now jump to the place where smi keys are handled. |
| 582 | __ jmp(&index_smi); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 586 | void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
| 587 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 588 | // -- ecx : key (index) |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 589 | // -- edx : receiver |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 590 | // -- esp[0] : return address |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 591 | // ----------------------------------- |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 592 | Label miss; |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 593 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 594 | Register receiver = edx; |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 595 | Register index = ecx; |
| 596 | Register scratch = ebx; |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 597 | Register result = eax; |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 598 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 599 | StringCharAtGenerator char_at_generator(receiver, |
| 600 | index, |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 601 | scratch, |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 602 | result, |
| 603 | &miss, // When not a string. |
| 604 | &miss, // When not a number. |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 605 | &miss, // When index out of range. |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 606 | STRING_INDEX_IS_ARRAY_INDEX); |
| 607 | char_at_generator.GenerateFast(masm); |
| 608 | __ ret(0); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 609 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 610 | StubRuntimeCallHelper call_helper; |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 611 | char_at_generator.GenerateSlow(masm, call_helper); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 612 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 613 | __ bind(&miss); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 614 | GenerateMiss(masm, MISS); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 618 | void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { |
| 619 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 620 | // -- ecx : key |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 621 | // -- edx : receiver |
| 622 | // -- esp[0] : return address |
| 623 | // ----------------------------------- |
| 624 | Label slow; |
| 625 | |
| 626 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 627 | __ JumpIfSmi(edx, &slow); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 628 | |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 629 | // Check that the key is an array index, that is Uint32. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 630 | __ test(ecx, Immediate(kSmiTagMask | kSmiSignMask)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 631 | __ j(not_zero, &slow); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 632 | |
| 633 | // Get the map of the receiver. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 634 | __ mov(eax, FieldOperand(edx, HeapObject::kMapOffset)); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 635 | |
| 636 | // Check that it has indexed interceptor and access checks |
| 637 | // are not enabled for this object. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 638 | __ movzx_b(eax, FieldOperand(eax, Map::kBitFieldOffset)); |
| 639 | __ and_(eax, Immediate(kSlowCaseBitFieldMask)); |
| 640 | __ cmp(eax, Immediate(1 << Map::kHasIndexedInterceptor)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 641 | __ j(not_zero, &slow); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 642 | |
| 643 | // Everything is fine, call runtime. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 644 | __ pop(eax); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 645 | __ push(edx); // receiver |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 646 | __ push(ecx); // key |
| 647 | __ push(eax); // return address |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 648 | |
| 649 | // Perform tail call to the entry. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 650 | ExternalReference ref = |
| 651 | ExternalReference(IC_Utility(kKeyedLoadPropertyWithInterceptor), |
| 652 | masm->isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 653 | __ TailCallExternalReference(ref, 2, 1); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 654 | |
| 655 | __ bind(&slow); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 656 | GenerateMiss(masm, MISS); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 660 | void KeyedLoadIC::GenerateNonStrictArguments(MacroAssembler* masm) { |
| 661 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 662 | // -- ecx : key |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 663 | // -- edx : receiver |
| 664 | // -- esp[0] : return address |
| 665 | // ----------------------------------- |
| 666 | Label slow, notin; |
| 667 | Factory* factory = masm->isolate()->factory(); |
| 668 | Operand mapped_location = |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 669 | GenerateMappedArgumentsLookup(masm, edx, ecx, ebx, eax, ¬in, &slow); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 670 | __ mov(eax, mapped_location); |
| 671 | __ Ret(); |
| 672 | __ bind(¬in); |
| 673 | // The unmapped lookup expects that the parameter map is in ebx. |
| 674 | Operand unmapped_location = |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 675 | GenerateUnmappedArgumentsLookup(masm, ecx, ebx, eax, &slow); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 676 | __ cmp(unmapped_location, factory->the_hole_value()); |
| 677 | __ j(equal, &slow); |
| 678 | __ mov(eax, unmapped_location); |
| 679 | __ Ret(); |
| 680 | __ bind(&slow); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 681 | GenerateMiss(masm, MISS); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | |
| 685 | void KeyedStoreIC::GenerateNonStrictArguments(MacroAssembler* masm) { |
| 686 | // ----------- S t a t e ------------- |
| 687 | // -- eax : value |
| 688 | // -- ecx : key |
| 689 | // -- edx : receiver |
| 690 | // -- esp[0] : return address |
| 691 | // ----------------------------------- |
| 692 | Label slow, notin; |
| 693 | Operand mapped_location = |
| 694 | GenerateMappedArgumentsLookup(masm, edx, ecx, ebx, edi, ¬in, &slow); |
| 695 | __ mov(mapped_location, eax); |
fschneider@chromium.org | 59c1426 | 2011-06-23 10:27:56 +0000 | [diff] [blame] | 696 | __ lea(ecx, mapped_location); |
| 697 | __ mov(edx, eax); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 698 | __ RecordWrite(ebx, ecx, edx, kDontSaveFPRegs); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 699 | __ Ret(); |
| 700 | __ bind(¬in); |
| 701 | // The unmapped lookup expects that the parameter map is in ebx. |
| 702 | Operand unmapped_location = |
| 703 | GenerateUnmappedArgumentsLookup(masm, ecx, ebx, edi, &slow); |
| 704 | __ mov(unmapped_location, eax); |
fschneider@chromium.org | 59c1426 | 2011-06-23 10:27:56 +0000 | [diff] [blame] | 705 | __ lea(edi, unmapped_location); |
| 706 | __ mov(edx, eax); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 707 | __ RecordWrite(ebx, edi, edx, kDontSaveFPRegs); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 708 | __ Ret(); |
| 709 | __ bind(&slow); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 710 | GenerateMiss(masm, MISS); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 714 | static void KeyedStoreGenerateGenericHelper( |
| 715 | MacroAssembler* masm, |
| 716 | Label* fast_object, |
| 717 | Label* fast_double, |
| 718 | Label* slow, |
| 719 | KeyedStoreCheckMap check_map, |
| 720 | KeyedStoreIncrementLength increment_length) { |
| 721 | Label transition_smi_elements; |
| 722 | Label finish_object_store, non_double_value, transition_double_elements; |
| 723 | Label fast_double_without_map_check; |
| 724 | // eax: value |
| 725 | // ecx: key (a smi) |
| 726 | // edx: receiver |
| 727 | // ebx: FixedArray receiver->elements |
| 728 | // edi: receiver map |
| 729 | // Fast case: Do the store, could either Object or double. |
| 730 | __ bind(fast_object); |
| 731 | if (check_map == kCheckMap) { |
| 732 | __ mov(edi, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 733 | __ cmp(edi, masm->isolate()->factory()->fixed_array_map()); |
| 734 | __ j(not_equal, fast_double); |
| 735 | } |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 736 | |
| 737 | // HOLECHECK: guards "A[i] = V" |
| 738 | // We have to go to the runtime if the current value is the hole because |
| 739 | // there may be a callback on the element |
| 740 | Label holecheck_passed1; |
| 741 | __ cmp(CodeGenerator::FixedArrayElementOperand(ebx, ecx), |
| 742 | masm->isolate()->factory()->the_hole_value()); |
| 743 | __ j(not_equal, &holecheck_passed1); |
| 744 | __ JumpIfDictionaryInPrototypeChain(edx, ebx, edi, slow); |
| 745 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 746 | |
| 747 | __ bind(&holecheck_passed1); |
| 748 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 749 | // Smi stores don't require further checks. |
| 750 | Label non_smi_value; |
| 751 | __ JumpIfNotSmi(eax, &non_smi_value); |
| 752 | if (increment_length == kIncrementLength) { |
| 753 | // Add 1 to receiver->length. |
| 754 | __ add(FieldOperand(edx, JSArray::kLengthOffset), |
| 755 | Immediate(Smi::FromInt(1))); |
| 756 | } |
| 757 | // It's irrelevant whether array is smi-only or not when writing a smi. |
| 758 | __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax); |
| 759 | __ ret(0); |
| 760 | |
| 761 | __ bind(&non_smi_value); |
| 762 | // Escape to elements kind transition case. |
| 763 | __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
| 764 | __ CheckFastObjectElements(edi, &transition_smi_elements); |
| 765 | |
| 766 | // Fast elements array, store the value to the elements backing store. |
| 767 | __ bind(&finish_object_store); |
| 768 | if (increment_length == kIncrementLength) { |
| 769 | // Add 1 to receiver->length. |
| 770 | __ add(FieldOperand(edx, JSArray::kLengthOffset), |
| 771 | Immediate(Smi::FromInt(1))); |
| 772 | } |
| 773 | __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax); |
| 774 | // Update write barrier for the elements array address. |
| 775 | __ mov(edx, eax); // Preserve the value which is returned. |
| 776 | __ RecordWriteArray( |
| 777 | ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 778 | __ ret(0); |
| 779 | |
| 780 | __ bind(fast_double); |
| 781 | if (check_map == kCheckMap) { |
| 782 | // Check for fast double array case. If this fails, call through to the |
| 783 | // runtime. |
| 784 | __ cmp(edi, masm->isolate()->factory()->fixed_double_array_map()); |
| 785 | __ j(not_equal, slow); |
| 786 | // If the value is a number, store it as a double in the FastDoubleElements |
| 787 | // array. |
| 788 | } |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 789 | |
| 790 | // HOLECHECK: guards "A[i] double hole?" |
| 791 | // We have to see if the double version of the hole is present. If so |
| 792 | // go to the runtime. |
| 793 | uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32); |
| 794 | __ cmp(FieldOperand(ebx, ecx, times_4, offset), Immediate(kHoleNanUpper32)); |
| 795 | __ j(not_equal, &fast_double_without_map_check); |
| 796 | __ JumpIfDictionaryInPrototypeChain(edx, ebx, edi, slow); |
| 797 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 798 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 799 | __ bind(&fast_double_without_map_check); |
| 800 | __ StoreNumberToDoubleElements(eax, ebx, ecx, edi, xmm0, |
| 801 | &transition_double_elements, false); |
| 802 | if (increment_length == kIncrementLength) { |
| 803 | // Add 1 to receiver->length. |
| 804 | __ add(FieldOperand(edx, JSArray::kLengthOffset), |
| 805 | Immediate(Smi::FromInt(1))); |
| 806 | } |
| 807 | __ ret(0); |
| 808 | |
| 809 | __ bind(&transition_smi_elements); |
| 810 | __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 811 | |
| 812 | // Transition the array appropriately depending on the value type. |
| 813 | __ CheckMap(eax, |
| 814 | masm->isolate()->factory()->heap_number_map(), |
| 815 | &non_double_value, |
| 816 | DONT_DO_SMI_CHECK); |
| 817 | |
| 818 | // Value is a double. Transition FAST_SMI_ELEMENTS -> FAST_DOUBLE_ELEMENTS |
| 819 | // and complete the store. |
| 820 | __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
| 821 | FAST_DOUBLE_ELEMENTS, |
| 822 | ebx, |
| 823 | edi, |
| 824 | slow); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 825 | AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, |
| 826 | FAST_DOUBLE_ELEMENTS); |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 827 | ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 828 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 829 | __ jmp(&fast_double_without_map_check); |
| 830 | |
| 831 | __ bind(&non_double_value); |
| 832 | // Value is not a double, FAST_SMI_ELEMENTS -> FAST_ELEMENTS |
| 833 | __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
| 834 | FAST_ELEMENTS, |
| 835 | ebx, |
| 836 | edi, |
| 837 | slow); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 838 | mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 839 | ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, |
| 840 | slow); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 841 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 842 | __ jmp(&finish_object_store); |
| 843 | |
| 844 | __ bind(&transition_double_elements); |
| 845 | // Elements are FAST_DOUBLE_ELEMENTS, but value is an Object that's not a |
| 846 | // HeapNumber. Make sure that the receiver is a Array with FAST_ELEMENTS and |
| 847 | // transition array from FAST_DOUBLE_ELEMENTS to FAST_ELEMENTS |
| 848 | __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 849 | __ LoadTransitionedArrayMapConditional(FAST_DOUBLE_ELEMENTS, |
| 850 | FAST_ELEMENTS, |
| 851 | ebx, |
| 852 | edi, |
| 853 | slow); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 854 | mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 855 | ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 856 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 857 | __ jmp(&finish_object_store); |
| 858 | } |
| 859 | |
| 860 | |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 861 | void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
| 862 | StrictModeFlag strict_mode) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 863 | // ----------- S t a t e ------------- |
| 864 | // -- eax : value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 865 | // -- ecx : key |
| 866 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 867 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 868 | // ----------------------------------- |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 869 | Label slow, fast_object, fast_object_grow; |
| 870 | Label fast_double, fast_double_grow; |
| 871 | Label array, extra, check_if_double_array; |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 872 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 873 | // Check that the object isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 874 | __ JumpIfSmi(edx, &slow); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 875 | // Get the map from the receiver. |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 876 | __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 877 | // Check that the receiver does not require access checks and is not observed. |
| 878 | // The generic stub does not perform map checks or handle observed objects. |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 879 | __ test_b(FieldOperand(edi, Map::kBitFieldOffset), |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 880 | 1 << Map::kIsAccessCheckNeeded | 1 << Map::kIsObserved); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 881 | __ j(not_zero, &slow); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 882 | // Check that the key is a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 883 | __ JumpIfNotSmi(ecx, &slow); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 884 | __ CmpInstanceType(edi, JS_ARRAY_TYPE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 885 | __ j(equal, &array); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 886 | // Check that the object is some kind of JSObject. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 887 | __ CmpInstanceType(edi, FIRST_JS_OBJECT_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 888 | __ j(below, &slow); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 889 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 890 | // Object case: Check key against length in the elements array. |
| 891 | // eax: value |
| 892 | // edx: JSObject |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 893 | // ecx: key (a smi) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 894 | // edi: receiver map |
| 895 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 896 | // Check array bounds. Both the key and the length of FixedArray are smis. |
| 897 | __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 898 | __ j(below, &fast_object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 899 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 900 | // Slow case: call runtime. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 901 | __ bind(&slow); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 902 | GenerateRuntimeSetProperty(masm, strict_mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 903 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 904 | // Extra capacity case: Check if there is extra capacity to |
| 905 | // perform the store and update the length. Used for adding one |
| 906 | // element to the array by writing to array[array.length]. |
| 907 | __ bind(&extra); |
| 908 | // eax: value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 909 | // edx: receiver, a JSArray |
| 910 | // ecx: key, a smi. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 911 | // ebx: receiver->elements, a FixedArray |
| 912 | // edi: receiver map |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 913 | // flags: compare (ecx, edx.length()) |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 914 | // do not leave holes in the array: |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 915 | __ j(not_equal, &slow); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 916 | __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 917 | __ j(above_equal, &slow); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 918 | __ mov(edi, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 919 | __ cmp(edi, masm->isolate()->factory()->fixed_array_map()); |
| 920 | __ j(not_equal, &check_if_double_array); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 921 | __ jmp(&fast_object_grow); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 922 | |
| 923 | __ bind(&check_if_double_array); |
| 924 | __ cmp(edi, masm->isolate()->factory()->fixed_double_array_map()); |
| 925 | __ j(not_equal, &slow); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 926 | __ jmp(&fast_double_grow); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 927 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 928 | // Array case: Get the length and the elements array from the JS |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 929 | // array. Check that the array is in fast mode (and writable); if it |
| 930 | // is the length is always a smi. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 931 | __ bind(&array); |
| 932 | // eax: value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 933 | // edx: receiver, a JSArray |
| 934 | // ecx: key, a smi. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 935 | // edi: receiver map |
| 936 | __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 937 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 938 | // Check the key against the length in the array and fall through to the |
| 939 | // common store code. |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 940 | __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 941 | __ j(above_equal, &extra); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 942 | |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 943 | KeyedStoreGenerateGenericHelper(masm, &fast_object, &fast_double, |
| 944 | &slow, kCheckMap, kDontIncrementLength); |
| 945 | KeyedStoreGenerateGenericHelper(masm, &fast_object_grow, &fast_double_grow, |
| 946 | &slow, kDontCheckMap, kIncrementLength); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 950 | // The generated code does not accept smi keys. |
| 951 | // The generated code falls through if both probes miss. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 952 | void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
| 953 | int argc, |
| 954 | Code::Kind kind, |
| 955 | Code::ExtraICState extra_state) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 956 | // ----------- S t a t e ------------- |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 957 | // -- ecx : name |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 958 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 959 | // ----------------------------------- |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 960 | Label number, non_number, non_string, boolean, probe, miss; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 961 | |
| 962 | // Probe the stub cache. |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 963 | Code::Flags flags = Code::ComputeFlags(kind, |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 964 | MONOMORPHIC, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 965 | extra_state, |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 966 | Code::NORMAL, |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 967 | argc); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 968 | Isolate* isolate = masm->isolate(); |
| 969 | isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, eax); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 970 | |
| 971 | // If the stub cache probing failed, the receiver might be a value. |
| 972 | // For value objects, we use the map of the prototype objects for |
| 973 | // the corresponding JSValue for the cache and that is what we need |
| 974 | // to probe. |
| 975 | // |
| 976 | // Check for number. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 977 | __ JumpIfSmi(edx, &number); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 978 | __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ebx); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 979 | __ j(not_equal, &non_number); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 980 | __ bind(&number); |
| 981 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 982 | masm, Context::NUMBER_FUNCTION_INDEX, edx); |
| 983 | __ jmp(&probe); |
| 984 | |
| 985 | // Check for string. |
| 986 | __ bind(&non_number); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 987 | __ CmpInstanceType(ebx, FIRST_NONSTRING_TYPE); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 988 | __ j(above_equal, &non_string); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 989 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 990 | masm, Context::STRING_FUNCTION_INDEX, edx); |
| 991 | __ jmp(&probe); |
| 992 | |
| 993 | // Check for boolean. |
| 994 | __ bind(&non_string); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 995 | __ cmp(edx, isolate->factory()->true_value()); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 996 | __ j(equal, &boolean); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 997 | __ cmp(edx, isolate->factory()->false_value()); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 998 | __ j(not_equal, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 999 | __ bind(&boolean); |
| 1000 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 1001 | masm, Context::BOOLEAN_FUNCTION_INDEX, edx); |
| 1002 | |
| 1003 | // Probe the stub cache for the value object. |
| 1004 | __ bind(&probe); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1005 | isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, no_reg); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1006 | __ bind(&miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1010 | static void GenerateFunctionTailCall(MacroAssembler* masm, |
| 1011 | int argc, |
| 1012 | Label* miss) { |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1013 | // ----------- S t a t e ------------- |
| 1014 | // -- ecx : name |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1015 | // -- edi : function |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1016 | // -- esp[0] : return address |
| 1017 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1018 | // -- ... |
| 1019 | // -- esp[(argc + 1) * 4] : receiver |
| 1020 | // ----------------------------------- |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1021 | |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1022 | // Check that the result is not a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1023 | __ JumpIfSmi(edi, miss); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1024 | |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1025 | // Check that the value is a JavaScript function, fetching its map into eax. |
| 1026 | __ CmpObjectType(edi, JS_FUNCTION_TYPE, eax); |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 1027 | __ j(not_equal, miss); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1028 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1029 | // Invoke the function. |
| 1030 | ParameterCount actual(argc); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1031 | __ InvokeFunction(edi, actual, JUMP_FUNCTION, |
| 1032 | NullCallWrapper(), CALL_AS_METHOD); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1035 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1036 | // The generated code falls through if the call should be handled by runtime. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1037 | void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1038 | // ----------- S t a t e ------------- |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1039 | // -- ecx : name |
| 1040 | // -- esp[0] : return address |
| 1041 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1042 | // -- ... |
| 1043 | // -- esp[(argc + 1) * 4] : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1044 | // ----------------------------------- |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1045 | Label miss; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1046 | |
| 1047 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 1048 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1049 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1050 | GenerateNameDictionaryReceiverCheck(masm, edx, eax, ebx, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1051 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1052 | // eax: elements |
| 1053 | // Search the dictionary placing the result in edi. |
| 1054 | GenerateDictionaryLoad(masm, &miss, eax, ecx, edi, ebx, edi); |
| 1055 | GenerateFunctionTailCall(masm, argc, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1056 | |
| 1057 | __ bind(&miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1061 | void CallICBase::GenerateMiss(MacroAssembler* masm, |
| 1062 | int argc, |
| 1063 | IC::UtilityId id, |
| 1064 | Code::ExtraICState extra_state) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1065 | // ----------- S t a t e ------------- |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 1066 | // -- ecx : name |
| 1067 | // -- esp[0] : return address |
| 1068 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1069 | // -- ... |
| 1070 | // -- esp[(argc + 1) * 4] : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1071 | // ----------------------------------- |
| 1072 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1073 | Counters* counters = masm->isolate()->counters(); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1074 | if (id == IC::kCallIC_Miss) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1075 | __ IncrementCounter(counters->call_miss(), 1); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1076 | } else { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1077 | __ IncrementCounter(counters->keyed_call_miss(), 1); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1078 | } |
| 1079 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1080 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 1081 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1082 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1083 | { |
| 1084 | FrameScope scope(masm, StackFrame::INTERNAL); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1085 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1086 | // Push the receiver and the name of the function. |
| 1087 | __ push(edx); |
| 1088 | __ push(ecx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1089 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1090 | // Call the entry. |
| 1091 | CEntryStub stub(1); |
| 1092 | __ mov(eax, Immediate(2)); |
| 1093 | __ mov(ebx, Immediate(ExternalReference(IC_Utility(id), masm->isolate()))); |
| 1094 | __ CallStub(&stub); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1095 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1096 | // Move result to edi and exit the internal frame. |
| 1097 | __ mov(edi, eax); |
| 1098 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1099 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1100 | // Check if the receiver is a global object of some sort. |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1101 | // This can happen only for regular CallIC but not KeyedCallIC. |
| 1102 | if (id == IC::kCallIC_Miss) { |
| 1103 | Label invoke, global; |
| 1104 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); // receiver |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1105 | __ JumpIfSmi(edx, &invoke, Label::kNear); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1106 | __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 1107 | __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 1108 | __ cmp(ebx, JS_GLOBAL_OBJECT_TYPE); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1109 | __ j(equal, &global, Label::kNear); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1110 | __ cmp(ebx, JS_BUILTINS_OBJECT_TYPE); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1111 | __ j(not_equal, &invoke, Label::kNear); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1112 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1113 | // Patch the receiver on the stack. |
| 1114 | __ bind(&global); |
| 1115 | __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
| 1116 | __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
| 1117 | __ bind(&invoke); |
| 1118 | } |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1119 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1120 | // Invoke the function. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1121 | CallKind call_kind = CallICBase::Contextual::decode(extra_state) |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1122 | ? CALL_AS_FUNCTION |
| 1123 | : CALL_AS_METHOD; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1124 | ParameterCount actual(argc); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1125 | __ InvokeFunction(edi, |
| 1126 | actual, |
| 1127 | JUMP_FUNCTION, |
| 1128 | NullCallWrapper(), |
| 1129 | call_kind); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1133 | void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
| 1134 | int argc, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1135 | Code::ExtraICState extra_state) { |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1136 | // ----------- S t a t e ------------- |
| 1137 | // -- ecx : name |
| 1138 | // -- esp[0] : return address |
| 1139 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1140 | // -- ... |
| 1141 | // -- esp[(argc + 1) * 4] : receiver |
| 1142 | // ----------------------------------- |
| 1143 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1144 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 1145 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1146 | CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, |
| 1147 | extra_state); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1148 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1149 | GenerateMiss(masm, argc, extra_state); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1150 | } |
| 1151 | |
| 1152 | |
| 1153 | void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
| 1154 | // ----------- S t a t e ------------- |
| 1155 | // -- ecx : name |
| 1156 | // -- esp[0] : return address |
| 1157 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1158 | // -- ... |
| 1159 | // -- esp[(argc + 1) * 4] : receiver |
| 1160 | // ----------------------------------- |
| 1161 | |
| 1162 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 1163 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1164 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1165 | Label do_call, slow_call, slow_load, slow_reload_receiver; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1166 | Label check_number_dictionary, check_name, lookup_monomorphic_cache; |
| 1167 | Label index_smi, index_name; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1168 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1169 | // Check that the key is a smi. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1170 | __ JumpIfNotSmi(ecx, &check_name); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1171 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1172 | __ bind(&index_smi); |
| 1173 | // Now the key is known to be a smi. This place is also jumped to from |
| 1174 | // where a numeric string is converted to a smi. |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1175 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1176 | GenerateKeyedLoadReceiverCheck( |
| 1177 | masm, edx, eax, Map::kHasIndexedInterceptor, &slow_call); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1178 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1179 | GenerateFastArrayLoad( |
| 1180 | masm, edx, ecx, eax, edi, &check_number_dictionary, &slow_load); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1181 | Isolate* isolate = masm->isolate(); |
| 1182 | Counters* counters = isolate->counters(); |
| 1183 | __ IncrementCounter(counters->keyed_call_generic_smi_fast(), 1); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1184 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1185 | __ bind(&do_call); |
| 1186 | // receiver in edx is not used after this point. |
| 1187 | // ecx: key |
| 1188 | // edi: function |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1189 | GenerateFunctionTailCall(masm, argc, &slow_call); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1190 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1191 | __ bind(&check_number_dictionary); |
| 1192 | // eax: elements |
| 1193 | // ecx: smi key |
| 1194 | // Check whether the elements is a number dictionary. |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1195 | __ CheckMap(eax, |
| 1196 | isolate->factory()->hash_table_map(), |
| 1197 | &slow_load, |
| 1198 | DONT_DO_SMI_CHECK); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1199 | __ mov(ebx, ecx); |
| 1200 | __ SmiUntag(ebx); |
| 1201 | // ebx: untagged index |
| 1202 | // Receiver in edx will be clobbered, need to reload it on miss. |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 1203 | __ LoadFromNumberDictionary( |
| 1204 | &slow_reload_receiver, eax, ecx, ebx, edx, edi, edi); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1205 | __ IncrementCounter(counters->keyed_call_generic_smi_dict(), 1); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1206 | __ jmp(&do_call); |
| 1207 | |
| 1208 | __ bind(&slow_reload_receiver); |
| 1209 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1210 | |
| 1211 | __ bind(&slow_load); |
| 1212 | // This branch is taken when calling KeyedCallIC_Miss is neither required |
| 1213 | // nor beneficial. |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1214 | __ IncrementCounter(counters->keyed_call_generic_slow_load(), 1); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1215 | |
| 1216 | { |
| 1217 | FrameScope scope(masm, StackFrame::INTERNAL); |
| 1218 | __ push(ecx); // save the key |
| 1219 | __ push(edx); // pass the receiver |
| 1220 | __ push(ecx); // pass the key |
| 1221 | __ CallRuntime(Runtime::kKeyedGetProperty, 2); |
| 1222 | __ pop(ecx); // restore the key |
| 1223 | // Leave the internal frame. |
| 1224 | } |
| 1225 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1226 | __ mov(edi, eax); |
| 1227 | __ jmp(&do_call); |
| 1228 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1229 | __ bind(&check_name); |
| 1230 | GenerateKeyNameCheck(masm, ecx, eax, ebx, &index_name, &slow_call); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1231 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1232 | // The key is known to be a unique name. |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1233 | // If the receiver is a regular JS object with slow properties then do |
| 1234 | // a quick inline probe of the receiver's dictionary. |
| 1235 | // Otherwise do the monomorphic cache probe. |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1236 | GenerateKeyedLoadReceiverCheck( |
| 1237 | masm, edx, eax, Map::kHasNamedInterceptor, &lookup_monomorphic_cache); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1238 | |
| 1239 | __ mov(ebx, FieldOperand(edx, JSObject::kPropertiesOffset)); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1240 | __ CheckMap(ebx, |
| 1241 | isolate->factory()->hash_table_map(), |
| 1242 | &lookup_monomorphic_cache, |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1243 | DONT_DO_SMI_CHECK); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1244 | |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1245 | GenerateDictionaryLoad(masm, &slow_load, ebx, ecx, eax, edi, edi); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1246 | __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1247 | __ jmp(&do_call); |
| 1248 | |
| 1249 | __ bind(&lookup_monomorphic_cache); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1250 | __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1251 | CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::KEYED_CALL_IC, |
| 1252 | Code::kNoExtraICState); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1253 | // Fall through on miss. |
| 1254 | |
| 1255 | __ bind(&slow_call); |
| 1256 | // This branch is taken if: |
| 1257 | // - the receiver requires boxing or access check, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1258 | // - the key is neither smi nor a unique name, |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1259 | // - the value loaded is not a function, |
| 1260 | // - there is hope that the runtime will create a monomorphic call stub |
| 1261 | // that will get fetched next time. |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1262 | __ IncrementCounter(counters->keyed_call_generic_slow(), 1); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1263 | GenerateMiss(masm, argc); |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 1264 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1265 | __ bind(&index_name); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1266 | __ IndexFromHash(ebx, ecx); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1267 | // Now jump to the place where smi keys are handled. |
| 1268 | __ jmp(&index_smi); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1272 | void KeyedCallIC::GenerateNonStrictArguments(MacroAssembler* masm, |
| 1273 | int argc) { |
| 1274 | // ----------- S t a t e ------------- |
| 1275 | // -- ecx : name |
| 1276 | // -- esp[0] : return address |
| 1277 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1278 | // -- ... |
| 1279 | // -- esp[(argc + 1) * 4] : receiver |
| 1280 | // ----------------------------------- |
| 1281 | Label slow, notin; |
| 1282 | Factory* factory = masm->isolate()->factory(); |
| 1283 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 1284 | Operand mapped_location = |
| 1285 | GenerateMappedArgumentsLookup(masm, edx, ecx, ebx, eax, ¬in, &slow); |
| 1286 | __ mov(edi, mapped_location); |
| 1287 | GenerateFunctionTailCall(masm, argc, &slow); |
| 1288 | __ bind(¬in); |
| 1289 | // The unmapped lookup expects that the parameter map is in ebx. |
| 1290 | Operand unmapped_location = |
| 1291 | GenerateUnmappedArgumentsLookup(masm, ecx, ebx, eax, &slow); |
| 1292 | __ cmp(unmapped_location, factory->the_hole_value()); |
| 1293 | __ j(equal, &slow); |
| 1294 | __ mov(edi, unmapped_location); |
| 1295 | GenerateFunctionTailCall(masm, argc, &slow); |
| 1296 | __ bind(&slow); |
| 1297 | GenerateMiss(masm, argc); |
| 1298 | } |
| 1299 | |
| 1300 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1301 | void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1302 | // ----------- S t a t e ------------- |
| 1303 | // -- ecx : name |
| 1304 | // -- esp[0] : return address |
| 1305 | // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1306 | // -- ... |
| 1307 | // -- esp[(argc + 1) * 4] : receiver |
| 1308 | // ----------------------------------- |
| 1309 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1310 | // Check if the name is really a name. |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 1311 | Label miss; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1312 | __ JumpIfSmi(ecx, &miss); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1313 | Condition cond = masm->IsObjectNameType(ecx, eax, eax); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 1314 | __ j(NegateCondition(cond), &miss); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1315 | CallICBase::GenerateNormal(masm, argc); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 1316 | __ bind(&miss); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 1317 | GenerateMiss(masm, argc); |
| 1318 | } |
| 1319 | |
| 1320 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1321 | void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
| 1322 | // ----------- S t a t e ------------- |
| 1323 | // -- ecx : name |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1324 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1325 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1326 | // ----------------------------------- |
| 1327 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1328 | // Probe the stub cache. |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1329 | Code::Flags flags = Code::ComputeFlags( |
jkummerow@chromium.org | 32aa03c | 2013-10-01 08:21:50 +0000 | [diff] [blame] | 1330 | Code::HANDLER, MONOMORPHIC, Code::kNoExtraICState, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1331 | Code::NORMAL, Code::LOAD_IC); |
dslomov@chromium.org | e97852d | 2013-09-12 09:02:59 +0000 | [diff] [blame] | 1332 | masm->isolate()->stub_cache()->GenerateProbe( |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1333 | masm, flags, edx, ecx, ebx, eax); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1334 | |
| 1335 | // Cache miss: Jump to runtime. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1336 | GenerateMiss(masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | void LoadIC::GenerateNormal(MacroAssembler* masm) { |
| 1341 | // ----------- S t a t e ------------- |
| 1342 | // -- ecx : name |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1343 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1344 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1345 | // ----------------------------------- |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1346 | Label miss; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1347 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1348 | GenerateNameDictionaryReceiverCheck(masm, edx, eax, ebx, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1349 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1350 | // eax: elements |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1351 | // Search the dictionary placing the result in eax. |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1352 | GenerateDictionaryLoad(masm, &miss, eax, ecx, edi, ebx, eax); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1353 | __ ret(0); |
| 1354 | |
sgjesse@chromium.org | 82dbbab | 2010-06-02 08:57:44 +0000 | [diff] [blame] | 1355 | // Cache miss: Jump to runtime. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1356 | __ bind(&miss); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1357 | GenerateMiss(masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | |
| 1361 | void LoadIC::GenerateMiss(MacroAssembler* masm) { |
| 1362 | // ----------- S t a t e ------------- |
| 1363 | // -- ecx : name |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1364 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1365 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1366 | // ----------------------------------- |
| 1367 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1368 | __ IncrementCounter(masm->isolate()->counters()->load_miss(), 1); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1369 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1370 | __ pop(ebx); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1371 | __ push(edx); // receiver |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1372 | __ push(ecx); // name |
| 1373 | __ push(ebx); // return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1374 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 1375 | // Perform tail call to the entry. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1376 | ExternalReference ref = |
| 1377 | ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1378 | __ TailCallExternalReference(ref, 2, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 1382 | void LoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
| 1383 | // ----------- S t a t e ------------- |
| 1384 | // -- ecx : key |
| 1385 | // -- edx : receiver |
| 1386 | // -- esp[0] : return address |
| 1387 | // ----------------------------------- |
| 1388 | |
| 1389 | __ pop(ebx); |
| 1390 | __ push(edx); // receiver |
| 1391 | __ push(ecx); // name |
| 1392 | __ push(ebx); // return address |
| 1393 | |
| 1394 | // Perform tail call to the entry. |
| 1395 | __ TailCallRuntime(Runtime::kGetProperty, 2, 1); |
| 1396 | } |
| 1397 | |
| 1398 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1399 | void KeyedLoadIC::GenerateMiss(MacroAssembler* masm, ICMissMode miss_mode) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1400 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1401 | // -- ecx : key |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1402 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1403 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1404 | // ----------------------------------- |
| 1405 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1406 | __ IncrementCounter(masm->isolate()->counters()->keyed_load_miss(), 1); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1407 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1408 | __ pop(ebx); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1409 | __ push(edx); // receiver |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1410 | __ push(ecx); // name |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1411 | __ push(ebx); // return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1412 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 1413 | // Perform tail call to the entry. |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1414 | ExternalReference ref = miss_mode == MISS_FORCE_GENERIC |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1415 | ? ExternalReference(IC_Utility(kKeyedLoadIC_MissForceGeneric), |
| 1416 | masm->isolate()) |
| 1417 | : ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1418 | __ TailCallExternalReference(ref, 2, 1); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1419 | } |
| 1420 | |
| 1421 | |
| 1422 | void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) { |
| 1423 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1424 | // -- ecx : key |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1425 | // -- edx : receiver |
| 1426 | // -- esp[0] : return address |
| 1427 | // ----------------------------------- |
| 1428 | |
| 1429 | __ pop(ebx); |
| 1430 | __ push(edx); // receiver |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 1431 | __ push(ecx); // name |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1432 | __ push(ebx); // return address |
| 1433 | |
| 1434 | // Perform tail call to the entry. |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1435 | __ TailCallRuntime(Runtime::kKeyedGetProperty, 2, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1436 | } |
| 1437 | |
| 1438 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1439 | void StoreIC::GenerateMegamorphic(MacroAssembler* masm, |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1440 | StrictModeFlag strict_mode) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1441 | // ----------- S t a t e ------------- |
| 1442 | // -- eax : value |
| 1443 | // -- ecx : name |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1444 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1445 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1446 | // ----------------------------------- |
| 1447 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1448 | Code::Flags flags = Code::ComputeFlags( |
jkummerow@chromium.org | 32aa03c | 2013-10-01 08:21:50 +0000 | [diff] [blame] | 1449 | Code::HANDLER, MONOMORPHIC, strict_mode, |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1450 | Code::NORMAL, Code::STORE_IC); |
dslomov@chromium.org | e97852d | 2013-09-12 09:02:59 +0000 | [diff] [blame] | 1451 | masm->isolate()->stub_cache()->GenerateProbe( |
| 1452 | masm, flags, edx, ecx, ebx, no_reg); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1453 | |
| 1454 | // Cache miss: Jump to runtime. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1455 | GenerateMiss(masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1459 | void StoreIC::GenerateMiss(MacroAssembler* masm) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1460 | // ----------- S t a t e ------------- |
| 1461 | // -- eax : value |
| 1462 | // -- ecx : name |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1463 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1464 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1465 | // ----------------------------------- |
| 1466 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1467 | __ pop(ebx); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1468 | __ push(edx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1469 | __ push(ecx); |
| 1470 | __ push(eax); |
| 1471 | __ push(ebx); |
| 1472 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 1473 | // Perform tail call to the entry. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1474 | ExternalReference ref = |
| 1475 | ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1476 | __ TailCallExternalReference(ref, 3, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1477 | } |
| 1478 | |
| 1479 | |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1480 | void StoreIC::GenerateNormal(MacroAssembler* masm) { |
| 1481 | // ----------- S t a t e ------------- |
| 1482 | // -- eax : value |
| 1483 | // -- ecx : name |
| 1484 | // -- edx : receiver |
| 1485 | // -- esp[0] : return address |
| 1486 | // ----------------------------------- |
| 1487 | |
| 1488 | Label miss, restore_miss; |
| 1489 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1490 | GenerateNameDictionaryReceiverCheck(masm, edx, ebx, edi, &miss); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1491 | |
| 1492 | // A lot of registers are needed for storing to slow case |
| 1493 | // objects. Push and restore receiver but rely on |
| 1494 | // GenerateDictionaryStore preserving the value and name. |
| 1495 | __ push(edx); |
| 1496 | GenerateDictionaryStore(masm, &restore_miss, ebx, ecx, eax, edx, edi); |
| 1497 | __ Drop(1); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1498 | Counters* counters = masm->isolate()->counters(); |
| 1499 | __ IncrementCounter(counters->store_normal_hit(), 1); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1500 | __ ret(0); |
| 1501 | |
| 1502 | __ bind(&restore_miss); |
| 1503 | __ pop(edx); |
| 1504 | |
| 1505 | __ bind(&miss); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1506 | __ IncrementCounter(counters->store_normal_miss(), 1); |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 1507 | GenerateMiss(masm); |
| 1508 | } |
| 1509 | |
| 1510 | |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1511 | void StoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 1512 | StrictModeFlag strict_mode) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1513 | // ----------- S t a t e ------------- |
| 1514 | // -- eax : value |
| 1515 | // -- ecx : name |
| 1516 | // -- edx : receiver |
| 1517 | // -- esp[0] : return address |
| 1518 | // ----------------------------------- |
| 1519 | __ pop(ebx); |
| 1520 | __ push(edx); |
| 1521 | __ push(ecx); |
| 1522 | __ push(eax); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1523 | __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes |
| 1524 | __ push(Immediate(Smi::FromInt(strict_mode))); |
| 1525 | __ push(ebx); // return address |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1526 | |
| 1527 | // Do tail-call to runtime routine. |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1528 | __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1529 | } |
| 1530 | |
| 1531 | |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1532 | void KeyedStoreIC::GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 1533 | StrictModeFlag strict_mode) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1534 | // ----------- S t a t e ------------- |
| 1535 | // -- eax : value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1536 | // -- ecx : key |
| 1537 | // -- edx : receiver |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1538 | // -- esp[0] : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1539 | // ----------------------------------- |
| 1540 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1541 | __ pop(ebx); |
| 1542 | __ push(edx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1543 | __ push(ecx); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1544 | __ push(eax); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1545 | __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes |
| 1546 | __ push(Immediate(Smi::FromInt(strict_mode))); // Strict mode. |
| 1547 | __ push(ebx); // return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1548 | |
| 1549 | // Do tail-call to runtime routine. |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1550 | __ TailCallRuntime(Runtime::kSetProperty, 5, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1554 | void KeyedStoreIC::GenerateMiss(MacroAssembler* masm, ICMissMode miss_mode) { |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 1555 | // ----------- S t a t e ------------- |
| 1556 | // -- eax : value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1557 | // -- ecx : key |
| 1558 | // -- edx : receiver |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 1559 | // -- esp[0] : return address |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 1560 | // ----------------------------------- |
| 1561 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1562 | __ pop(ebx); |
| 1563 | __ push(edx); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1564 | __ push(ecx); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1565 | __ push(eax); |
| 1566 | __ push(ebx); |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 1567 | |
| 1568 | // Do tail-call to runtime routine. |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1569 | ExternalReference ref = miss_mode == MISS_FORCE_GENERIC |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1570 | ? ExternalReference(IC_Utility(kKeyedStoreIC_MissForceGeneric), |
| 1571 | masm->isolate()) |
| 1572 | : ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate()); |
| 1573 | __ TailCallExternalReference(ref, 3, 1); |
| 1574 | } |
| 1575 | |
| 1576 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1577 | void StoreIC::GenerateSlow(MacroAssembler* masm) { |
| 1578 | // ----------- S t a t e ------------- |
| 1579 | // -- eax : value |
| 1580 | // -- ecx : key |
| 1581 | // -- edx : receiver |
| 1582 | // -- esp[0] : return address |
| 1583 | // ----------------------------------- |
| 1584 | |
| 1585 | __ pop(ebx); |
| 1586 | __ push(edx); |
| 1587 | __ push(ecx); |
| 1588 | __ push(eax); |
| 1589 | __ push(ebx); // return address |
| 1590 | |
| 1591 | // Do tail-call to runtime routine. |
| 1592 | ExternalReference ref(IC_Utility(kStoreIC_Slow), masm->isolate()); |
| 1593 | __ TailCallExternalReference(ref, 3, 1); |
| 1594 | } |
| 1595 | |
| 1596 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1597 | void KeyedStoreIC::GenerateSlow(MacroAssembler* masm) { |
| 1598 | // ----------- S t a t e ------------- |
| 1599 | // -- eax : value |
| 1600 | // -- ecx : key |
| 1601 | // -- edx : receiver |
| 1602 | // -- esp[0] : return address |
| 1603 | // ----------------------------------- |
| 1604 | |
| 1605 | __ pop(ebx); |
| 1606 | __ push(edx); |
| 1607 | __ push(ecx); |
| 1608 | __ push(eax); |
| 1609 | __ push(ebx); // return address |
| 1610 | |
| 1611 | // Do tail-call to runtime routine. |
| 1612 | ExternalReference ref(IC_Utility(kKeyedStoreIC_Slow), masm->isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1613 | __ TailCallExternalReference(ref, 3, 1); |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 1614 | } |
| 1615 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1616 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1617 | #undef __ |
| 1618 | |
| 1619 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1620 | Condition CompareIC::ComputeCondition(Token::Value op) { |
| 1621 | switch (op) { |
| 1622 | case Token::EQ_STRICT: |
| 1623 | case Token::EQ: |
| 1624 | return equal; |
| 1625 | case Token::LT: |
| 1626 | return less; |
| 1627 | case Token::GT: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1628 | return greater; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1629 | case Token::LTE: |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1630 | return less_equal; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1631 | case Token::GTE: |
| 1632 | return greater_equal; |
| 1633 | default: |
| 1634 | UNREACHABLE(); |
| 1635 | return no_condition; |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1640 | bool CompareIC::HasInlinedSmiCode(Address address) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1641 | // The address of the instruction following the call. |
| 1642 | Address test_instruction_address = |
| 1643 | address + Assembler::kCallTargetAddressOffset; |
| 1644 | |
| 1645 | // If the instruction following the call is not a test al, nothing |
| 1646 | // was inlined. |
| 1647 | return *test_instruction_address == Assembler::kTestAlByte; |
| 1648 | } |
| 1649 | |
| 1650 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1651 | void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1652 | // The address of the instruction following the call. |
| 1653 | Address test_instruction_address = |
| 1654 | address + Assembler::kCallTargetAddressOffset; |
| 1655 | |
| 1656 | // If the instruction following the call is not a test al, nothing |
| 1657 | // was inlined. |
| 1658 | if (*test_instruction_address != Assembler::kTestAlByte) { |
| 1659 | ASSERT(*test_instruction_address == Assembler::kNopByte); |
| 1660 | return; |
| 1661 | } |
| 1662 | |
| 1663 | Address delta_address = test_instruction_address + 1; |
| 1664 | // The delta to the start of the map check instruction and the |
| 1665 | // condition code uses at the patched jump. |
| 1666 | int8_t delta = *reinterpret_cast<int8_t*>(delta_address); |
| 1667 | if (FLAG_trace_ic) { |
| 1668 | PrintF("[ patching ic at %p, test=%p, delta=%d\n", |
| 1669 | address, test_instruction_address, delta); |
| 1670 | } |
| 1671 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1672 | // Patch with a short conditional jump. Enabling means switching from a short |
| 1673 | // jump-if-carry/not-carry to jump-if-zero/not-zero, whereas disabling is the |
| 1674 | // reverse operation of that. |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1675 | Address jmp_address = test_instruction_address - delta; |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1676 | ASSERT((check == ENABLE_INLINED_SMI_CHECK) |
| 1677 | ? (*jmp_address == Assembler::kJncShortOpcode || |
| 1678 | *jmp_address == Assembler::kJcShortOpcode) |
| 1679 | : (*jmp_address == Assembler::kJnzShortOpcode || |
| 1680 | *jmp_address == Assembler::kJzShortOpcode)); |
| 1681 | Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
| 1682 | ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
| 1683 | : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1684 | *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1688 | } } // namespace v8::internal |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1689 | |
| 1690 | #endif // V8_TARGET_ARCH_IA32 |