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