ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
| 30 | #include "codegen-inl.h" |
| 31 | #include "ic-inl.h" |
| 32 | #include "runtime.h" |
| 33 | #include "stub-cache.h" |
| 34 | |
| 35 | namespace v8 { namespace internal { |
| 36 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | // ---------------------------------------------------------------------------- |
| 38 | // Static IC stub generators. |
| 39 | // |
| 40 | |
| 41 | #define __ masm-> |
| 42 | |
| 43 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 44 | // Helper function used to load a property from a dictionary backing storage. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 45 | static void GenerateDictionaryLoad(MacroAssembler* masm, Label* miss_label, |
| 46 | Register r0, Register r1, Register r2, |
| 47 | Register name) { |
| 48 | // Register use: |
| 49 | // |
| 50 | // r0 - used to hold the property dictionary. |
| 51 | // |
| 52 | // r1 - initially the receiver |
| 53 | // - used for the index into the property dictionary |
| 54 | // - holds the result on exit. |
| 55 | // |
| 56 | // r2 - used to hold the capacity of the property dictionary. |
| 57 | // |
| 58 | // name - holds the name of the property and is unchanges. |
| 59 | |
| 60 | Label done; |
| 61 | |
| 62 | // Check for the absence of an interceptor. |
| 63 | // Load the map into r0. |
| 64 | __ mov(r0, FieldOperand(r1, JSObject::kMapOffset)); |
| 65 | // Test the has_named_interceptor bit in the map. |
| 66 | __ test(FieldOperand(r0, Map::kInstanceAttributesOffset), |
| 67 | Immediate(1 << (Map::kHasNamedInterceptor + (3 * 8)))); |
| 68 | // Jump to miss if the interceptor bit is set. |
| 69 | __ j(not_zero, miss_label, not_taken); |
| 70 | |
| 71 | // Check that the properties array is a dictionary. |
| 72 | __ mov(r0, FieldOperand(r1, JSObject::kPropertiesOffset)); |
| 73 | __ cmp(FieldOperand(r0, HeapObject::kMapOffset), |
| 74 | Immediate(Factory::hash_table_map())); |
| 75 | __ j(not_equal, miss_label); |
| 76 | |
| 77 | // Compute the capacity mask. |
| 78 | const int kCapacityOffset = |
| 79 | Array::kHeaderSize + Dictionary::kCapacityIndex * kPointerSize; |
| 80 | __ mov(r2, FieldOperand(r0, kCapacityOffset)); |
| 81 | __ shr(r2, kSmiTagSize); // convert smi to int |
| 82 | __ dec(r2); |
| 83 | |
| 84 | // Generate an unrolled loop that performs a few probes before |
| 85 | // giving up. Measurements done on Gmail indicate that 2 probes |
| 86 | // cover ~93% of loads from dictionaries. |
| 87 | static const int kProbes = 4; |
| 88 | const int kElementsStartOffset = |
| 89 | Array::kHeaderSize + Dictionary::kElementsStartIndex * kPointerSize; |
| 90 | for (int i = 0; i < kProbes; i++) { |
| 91 | // Compute the masked index: (hash + i + i * i) & mask. |
| 92 | __ mov(r1, FieldOperand(name, String::kLengthOffset)); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 93 | __ shr(r1, String::kHashShift); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 94 | if (i > 0) __ add(Operand(r1), Immediate(Dictionary::GetProbeOffset(i))); |
| 95 | __ and_(r1, Operand(r2)); |
| 96 | |
| 97 | // Scale the index by multiplying by the element size. |
| 98 | ASSERT(Dictionary::kElementSize == 3); |
| 99 | __ lea(r1, Operand(r1, r1, times_2, 0)); // r1 = r1 * 3 |
| 100 | |
| 101 | // Check if the key is identical to the name. |
| 102 | __ cmp(name, |
| 103 | Operand(r0, r1, times_4, kElementsStartOffset - kHeapObjectTag)); |
| 104 | if (i != kProbes - 1) { |
| 105 | __ j(equal, &done, taken); |
| 106 | } else { |
| 107 | __ j(not_equal, miss_label, not_taken); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // Check that the value is a normal property. |
| 112 | __ bind(&done); |
| 113 | const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; |
| 114 | __ test(Operand(r0, r1, times_4, kDetailsOffset - kHeapObjectTag), |
| 115 | Immediate(PropertyDetails::TypeField::mask() << kSmiTagSize)); |
| 116 | __ j(not_zero, miss_label, not_taken); |
| 117 | |
| 118 | // Get the value at the masked, scaled index. |
| 119 | const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 120 | __ mov(r1, Operand(r0, r1, times_4, kValueOffset - kHeapObjectTag)); |
| 121 | } |
| 122 | |
| 123 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 124 | // Helper function used to check that a value is either not a function |
| 125 | // or is loaded if it is a function. |
| 126 | static void GenerateCheckNonFunctionOrLoaded(MacroAssembler* masm, Label* miss, |
| 127 | Register value, Register scratch) { |
| 128 | Label done; |
| 129 | // Check if the value is a Smi. |
| 130 | __ test(value, Immediate(kSmiTagMask)); |
| 131 | __ j(zero, &done, not_taken); |
| 132 | // Check if the value is a function. |
| 133 | __ mov(scratch, FieldOperand(value, HeapObject::kMapOffset)); |
| 134 | __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
| 135 | __ cmp(scratch, JS_FUNCTION_TYPE); |
| 136 | __ j(not_equal, &done, taken); |
| 137 | // Check if the function has been loaded. |
| 138 | __ mov(scratch, FieldOperand(value, JSFunction::kSharedFunctionInfoOffset)); |
| 139 | __ mov(scratch, |
| 140 | FieldOperand(scratch, SharedFunctionInfo::kLazyLoadDataOffset)); |
| 141 | __ cmp(scratch, Factory::undefined_value()); |
| 142 | __ j(not_equal, miss, not_taken); |
| 143 | __ bind(&done); |
| 144 | } |
| 145 | |
| 146 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 147 | void LoadIC::GenerateArrayLength(MacroAssembler* masm) { |
| 148 | // ----------- S t a t e ------------- |
| 149 | // -- ecx : name |
| 150 | // -- esp[0] : return address |
| 151 | // -- esp[4] : receiver |
| 152 | // ----------------------------------- |
| 153 | |
| 154 | Label miss; |
| 155 | |
| 156 | __ mov(eax, Operand(esp, kPointerSize)); |
| 157 | |
| 158 | StubCompiler::GenerateLoadArrayLength(masm, eax, edx, &miss); |
| 159 | __ bind(&miss); |
| 160 | StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); |
| 161 | } |
| 162 | |
| 163 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 164 | void LoadIC::GenerateStringLength(MacroAssembler* masm) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 165 | // ----------- S t a t e ------------- |
| 166 | // -- ecx : name |
| 167 | // -- esp[0] : return address |
| 168 | // -- esp[4] : receiver |
| 169 | // ----------------------------------- |
| 170 | |
| 171 | Label miss; |
| 172 | |
| 173 | __ mov(eax, Operand(esp, kPointerSize)); |
| 174 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 175 | StubCompiler::GenerateLoadStringLength(masm, eax, edx, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 176 | __ bind(&miss); |
| 177 | StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { |
| 182 | // ----------- S t a t e ------------- |
| 183 | // -- ecx : name |
| 184 | // -- esp[0] : return address |
| 185 | // -- esp[4] : receiver |
| 186 | // ----------------------------------- |
| 187 | |
| 188 | Label miss; |
| 189 | |
| 190 | __ mov(eax, Operand(esp, kPointerSize)); |
| 191 | |
| 192 | StubCompiler::GenerateLoadFunctionPrototype(masm, eax, edx, ebx, &miss); |
| 193 | __ bind(&miss); |
| 194 | StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); |
| 195 | } |
| 196 | |
| 197 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 198 | #ifdef DEBUG |
| 199 | // For use in assert below. |
| 200 | static int TenToThe(int exponent) { |
| 201 | ASSERT(exponent <= 9); |
| 202 | ASSERT(exponent >= 1); |
| 203 | int answer = 10; |
| 204 | for (int i = 1; i < exponent; i++) answer *= 10; |
| 205 | return answer; |
| 206 | } |
| 207 | #endif |
| 208 | |
| 209 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 210 | void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { |
| 211 | // ----------- S t a t e ------------- |
| 212 | // -- esp[0] : return address |
| 213 | // -- esp[4] : name |
| 214 | // -- esp[8] : receiver |
| 215 | // ----------------------------------- |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 216 | Label slow, fast, check_string, index_int, index_string; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 217 | |
| 218 | __ mov(eax, (Operand(esp, kPointerSize))); |
| 219 | __ mov(ecx, (Operand(esp, 2 * kPointerSize))); |
| 220 | |
| 221 | // Check that the object isn't a smi. |
| 222 | __ test(ecx, Immediate(kSmiTagMask)); |
| 223 | __ j(zero, &slow, not_taken); |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 224 | // Check that the object is some kind of JS object EXCEPT JS Value type. |
| 225 | // In the case that the object is a value-wrapper object, |
| 226 | // we enter the runtime system to make sure that indexing |
| 227 | // into string objects work as intended. |
| 228 | ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 229 | __ mov(edx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 230 | __ movzx_b(edx, FieldOperand(edx, Map::kInstanceTypeOffset)); |
| 231 | __ cmp(edx, JS_OBJECT_TYPE); |
| 232 | __ j(less, &slow, not_taken); |
| 233 | // Check that the key is a smi. |
| 234 | __ test(eax, Immediate(kSmiTagMask)); |
| 235 | __ j(not_zero, &check_string, not_taken); |
| 236 | __ sar(eax, kSmiTagSize); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 237 | // Get the elements array of the object. |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 238 | __ bind(&index_int); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 239 | __ mov(ecx, FieldOperand(ecx, JSObject::kElementsOffset)); |
| 240 | // Check that the object is in fast mode (not dictionary). |
| 241 | __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), |
| 242 | Immediate(Factory::hash_table_map())); |
| 243 | __ j(equal, &slow, not_taken); |
| 244 | // Check that the key (index) is within bounds. |
| 245 | __ cmp(eax, FieldOperand(ecx, Array::kLengthOffset)); |
| 246 | __ j(below, &fast, taken); |
| 247 | // Slow case: Load name and receiver from stack and jump to runtime. |
| 248 | __ bind(&slow); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 249 | __ IncrementCounter(&Counters::keyed_load_generic_slow, 1); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 250 | KeyedLoadIC::Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 251 | // Check if the key is a symbol that is not an array index. |
| 252 | __ bind(&check_string); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 253 | __ mov(ebx, FieldOperand(eax, String::kLengthOffset)); |
| 254 | __ test(ebx, Immediate(String::kIsArrayIndexMask)); |
| 255 | __ j(not_zero, &index_string, not_taken); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 256 | __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 257 | __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 258 | __ test(ebx, Immediate(kIsSymbolMask)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 259 | __ j(not_zero, &slow, not_taken); |
| 260 | // Probe the dictionary leaving result in ecx. |
| 261 | GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 262 | GenerateCheckNonFunctionOrLoaded(masm, &slow, ecx, edx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 263 | __ mov(eax, Operand(ecx)); |
| 264 | __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); |
| 265 | __ ret(0); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 266 | // Array index string: If short enough use cache in length/hash field (ebx). |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 267 | // We assert that there are enough bits in an int32_t after the hash shift |
| 268 | // bits have been subtracted to allow space for the length and the cached |
| 269 | // array index. |
| 270 | ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < |
| 271 | (1 << (String::kShortLengthShift - String::kHashShift))); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 272 | __ bind(&index_string); |
| 273 | const int kLengthFieldLimit = |
| 274 | (String::kMaxCachedArrayIndexLength + 1) << String::kShortLengthShift; |
| 275 | __ cmp(ebx, kLengthFieldLimit); |
| 276 | __ j(above_equal, &slow); |
| 277 | __ mov(eax, Operand(ebx)); |
| 278 | __ and_(eax, (1 << String::kShortLengthShift) - 1); |
| 279 | __ shr(eax, String::kLongLengthShift); |
| 280 | __ jmp(&index_int); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 281 | // Fast case: Do the load. |
| 282 | __ bind(&fast); |
| 283 | __ mov(eax, Operand(ecx, eax, times_4, Array::kHeaderSize - kHeapObjectTag)); |
| 284 | __ cmp(Operand(eax), Immediate(Factory::the_hole_value())); |
| 285 | // In case the loaded value is the_hole we have to consult GetProperty |
| 286 | // to ensure the prototype chain is searched. |
| 287 | __ j(equal, &slow, not_taken); |
| 288 | __ IncrementCounter(&Counters::keyed_load_generic_smi, 1); |
| 289 | __ ret(0); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm) { |
| 294 | // ----------- S t a t e ------------- |
| 295 | // -- eax : value |
| 296 | // -- esp[0] : return address |
| 297 | // -- esp[4] : key |
| 298 | // -- esp[8] : receiver |
| 299 | // ----------------------------------- |
| 300 | Label slow, fast, array, extra; |
| 301 | // Get the key and the object from the stack. |
| 302 | __ mov(ebx, Operand(esp, 1 * kPointerSize)); // 1 ~ return address |
| 303 | __ mov(edx, Operand(esp, 2 * kPointerSize)); // 2 ~ return address, key |
| 304 | // Check that the key is a smi. |
| 305 | __ test(ebx, Immediate(kSmiTagMask)); |
| 306 | __ j(not_zero, &slow, not_taken); |
| 307 | // Check that the object isn't a smi. |
| 308 | __ test(edx, Immediate(kSmiTagMask)); |
| 309 | __ j(zero, &slow, not_taken); |
| 310 | // Get the type of the object from its map. |
| 311 | __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 312 | __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
| 313 | // Check if the object is a JS array or not. |
| 314 | __ cmp(ecx, JS_ARRAY_TYPE); |
| 315 | __ j(equal, &array); |
| 316 | // Check that the object is some kind of JS object. |
ager@chromium.org | c27e4e7 | 2008-09-04 13:52:27 +0000 | [diff] [blame] | 317 | __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 318 | __ j(less, &slow, not_taken); |
| 319 | |
| 320 | |
| 321 | // Object case: Check key against length in the elements array. |
| 322 | // eax: value |
| 323 | // edx: JSObject |
| 324 | // ebx: index (as a smi) |
| 325 | __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 326 | // Check that the object is in fast mode (not dictionary). |
| 327 | __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), |
| 328 | Immediate(Factory::hash_table_map())); |
| 329 | __ j(equal, &slow, not_taken); |
| 330 | // Untag the key (for checking against untagged length in the fixed array). |
| 331 | __ mov(edx, Operand(ebx)); |
| 332 | __ sar(edx, kSmiTagSize); // untag the index and use it for the comparison |
| 333 | __ cmp(edx, FieldOperand(ecx, Array::kLengthOffset)); |
| 334 | // eax: value |
| 335 | // ecx: FixedArray |
| 336 | // ebx: index (as a smi) |
| 337 | __ j(below, &fast, taken); |
| 338 | |
| 339 | |
| 340 | // Slow case: Push extra copies of the arguments (3). |
| 341 | __ bind(&slow); |
| 342 | __ pop(ecx); |
| 343 | __ push(Operand(esp, 1 * kPointerSize)); |
| 344 | __ push(Operand(esp, 1 * kPointerSize)); |
| 345 | __ push(eax); |
| 346 | __ push(ecx); |
| 347 | // Do tail-call to runtime routine. |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 348 | __ TailCallRuntime(ExternalReference(Runtime::kSetProperty), 3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 349 | |
| 350 | |
| 351 | // Extra capacity case: Check if there is extra capacity to |
| 352 | // perform the store and update the length. Used for adding one |
| 353 | // element to the array by writing to array[array.length]. |
| 354 | __ bind(&extra); |
| 355 | // eax: value |
| 356 | // edx: JSArray |
| 357 | // ecx: FixedArray |
| 358 | // ebx: index (as a smi) |
| 359 | // flags: compare (ebx, edx.length()) |
| 360 | __ j(not_equal, &slow, not_taken); // do not leave holes in the array |
| 361 | __ sar(ebx, kSmiTagSize); // untag |
| 362 | __ cmp(ebx, FieldOperand(ecx, Array::kLengthOffset)); |
| 363 | __ j(above_equal, &slow, not_taken); |
| 364 | // Restore tag and increment. |
| 365 | __ lea(ebx, Operand(ebx, times_2, 1 << kSmiTagSize)); |
| 366 | __ mov(FieldOperand(edx, JSArray::kLengthOffset), ebx); |
| 367 | __ sub(Operand(ebx), Immediate(1 << kSmiTagSize)); // decrement ebx again |
| 368 | __ jmp(&fast); |
| 369 | |
| 370 | |
| 371 | // Array case: Get the length and the elements array from the JS |
| 372 | // array. Check that the array is in fast mode; if it is the |
| 373 | // length is always a smi. |
| 374 | __ bind(&array); |
| 375 | // eax: value |
| 376 | // edx: JSArray |
| 377 | // ebx: index (as a smi) |
| 378 | __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); |
| 379 | __ cmp(FieldOperand(ecx, HeapObject::kMapOffset), |
| 380 | Immediate(Factory::hash_table_map())); |
| 381 | __ j(equal, &slow, not_taken); |
| 382 | |
| 383 | // Check the key against the length in the array, compute the |
| 384 | // address to store into and fall through to fast case. |
| 385 | __ cmp(ebx, FieldOperand(edx, JSArray::kLengthOffset)); |
| 386 | __ j(above_equal, &extra, not_taken); |
| 387 | |
| 388 | |
| 389 | // Fast case: Do the store. |
| 390 | __ bind(&fast); |
| 391 | // eax: value |
| 392 | // ecx: FixedArray |
| 393 | // ebx: index (as a smi) |
| 394 | __ mov(Operand(ecx, ebx, times_2, Array::kHeaderSize - kHeapObjectTag), eax); |
| 395 | // Update write barrier for the elements array address. |
| 396 | __ mov(edx, Operand(eax)); |
| 397 | __ RecordWrite(ecx, 0, edx, ebx); |
| 398 | __ ret(0); |
| 399 | } |
| 400 | |
| 401 | |
| 402 | // Defined in ic.cc. |
| 403 | Object* CallIC_Miss(Arguments args); |
| 404 | |
| 405 | void CallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
| 406 | // ----------- S t a t e ------------- |
| 407 | // ----------------------------------- |
| 408 | Label number, non_number, non_string, boolean, probe, miss; |
| 409 | |
| 410 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 411 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 412 | // Get the name of the function from the stack; 2 ~ return address, receiver |
| 413 | __ mov(ecx, Operand(esp, (argc + 2) * kPointerSize)); |
| 414 | |
| 415 | // Probe the stub cache. |
| 416 | Code::Flags flags = |
| 417 | Code::ComputeFlags(Code::CALL_IC, MONOMORPHIC, NORMAL, argc); |
| 418 | StubCache::GenerateProbe(masm, flags, edx, ecx, ebx); |
| 419 | |
| 420 | // If the stub cache probing failed, the receiver might be a value. |
| 421 | // For value objects, we use the map of the prototype objects for |
| 422 | // the corresponding JSValue for the cache and that is what we need |
| 423 | // to probe. |
| 424 | // |
| 425 | // Check for number. |
| 426 | __ test(edx, Immediate(kSmiTagMask)); |
| 427 | __ j(zero, &number, not_taken); |
| 428 | __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 429 | __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 430 | __ cmp(ebx, HEAP_NUMBER_TYPE); |
| 431 | __ j(not_equal, &non_number, taken); |
| 432 | __ bind(&number); |
| 433 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 434 | masm, Context::NUMBER_FUNCTION_INDEX, edx); |
| 435 | __ jmp(&probe); |
| 436 | |
| 437 | // Check for string. |
| 438 | __ bind(&non_number); |
| 439 | __ cmp(ebx, FIRST_NONSTRING_TYPE); |
| 440 | __ j(above_equal, &non_string, taken); |
| 441 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 442 | masm, Context::STRING_FUNCTION_INDEX, edx); |
| 443 | __ jmp(&probe); |
| 444 | |
| 445 | // Check for boolean. |
| 446 | __ bind(&non_string); |
| 447 | __ cmp(edx, Factory::true_value()); |
| 448 | __ j(equal, &boolean, not_taken); |
| 449 | __ cmp(edx, Factory::false_value()); |
| 450 | __ j(not_equal, &miss, taken); |
| 451 | __ bind(&boolean); |
| 452 | StubCompiler::GenerateLoadGlobalFunctionPrototype( |
| 453 | masm, Context::BOOLEAN_FUNCTION_INDEX, edx); |
| 454 | |
| 455 | // Probe the stub cache for the value object. |
| 456 | __ bind(&probe); |
| 457 | StubCache::GenerateProbe(masm, flags, edx, ecx, ebx); |
| 458 | |
| 459 | // Cache miss: Jump to runtime. |
| 460 | __ bind(&miss); |
| 461 | Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); |
| 462 | } |
| 463 | |
| 464 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 465 | static void GenerateNormalHelper(MacroAssembler* masm, |
| 466 | int argc, |
| 467 | bool is_global_object, |
| 468 | Label* miss) { |
| 469 | // Search dictionary - put result in register edx. |
| 470 | GenerateDictionaryLoad(masm, miss, eax, edx, ebx, ecx); |
| 471 | |
| 472 | // Move the result to register edi and check that it isn't a smi. |
| 473 | __ mov(edi, Operand(edx)); |
| 474 | __ test(edx, Immediate(kSmiTagMask)); |
| 475 | __ j(zero, miss, not_taken); |
| 476 | |
| 477 | // Check that the value is a JavaScript function. |
| 478 | __ mov(edx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 479 | __ movzx_b(edx, FieldOperand(edx, Map::kInstanceTypeOffset)); |
| 480 | __ cmp(edx, JS_FUNCTION_TYPE); |
| 481 | __ j(not_equal, miss, not_taken); |
| 482 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 483 | // Check that the function has been loaded. |
| 484 | __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 485 | __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kLazyLoadDataOffset)); |
| 486 | __ cmp(edx, Factory::undefined_value()); |
| 487 | __ j(not_equal, miss, not_taken); |
| 488 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 489 | // Patch the receiver with the global proxy if necessary. |
| 490 | if (is_global_object) { |
| 491 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 492 | __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
| 493 | __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
| 494 | } |
| 495 | |
| 496 | // Invoke the function. |
| 497 | ParameterCount actual(argc); |
| 498 | __ InvokeFunction(edi, actual, JUMP_FUNCTION); |
| 499 | } |
| 500 | |
| 501 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 502 | void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
| 503 | // ----------- S t a t e ------------- |
| 504 | // ----------------------------------- |
| 505 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 506 | Label miss, global_object, non_global_object; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 507 | |
| 508 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 509 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 510 | // Get the name of the function from the stack; 2 ~ return address, receiver. |
| 511 | __ mov(ecx, Operand(esp, (argc + 2) * kPointerSize)); |
| 512 | |
| 513 | // Check that the receiver isn't a smi. |
| 514 | __ test(edx, Immediate(kSmiTagMask)); |
| 515 | __ j(zero, &miss, not_taken); |
| 516 | |
| 517 | // Check that the receiver is a valid JS object. |
| 518 | __ mov(eax, FieldOperand(edx, HeapObject::kMapOffset)); |
| 519 | __ movzx_b(eax, FieldOperand(eax, Map::kInstanceTypeOffset)); |
| 520 | __ cmp(eax, FIRST_JS_OBJECT_TYPE); |
| 521 | __ j(less, &miss, not_taken); |
| 522 | |
| 523 | // If this assert fails, we have to check upper bound too. |
| 524 | ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 525 | |
| 526 | // Check for access to global object. |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 527 | __ cmp(eax, JS_GLOBAL_OBJECT_TYPE); |
| 528 | __ j(equal, &global_object); |
| 529 | __ cmp(eax, JS_BUILTINS_OBJECT_TYPE); |
| 530 | __ j(not_equal, &non_global_object); |
| 531 | |
| 532 | // Accessing global object: Load and invoke. |
| 533 | __ bind(&global_object); |
| 534 | GenerateNormalHelper(masm, argc, true, &miss); |
| 535 | |
| 536 | // Accessing non-global object: Check for access to global proxy. |
| 537 | Label global_proxy, invoke; |
| 538 | __ bind(&non_global_object); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 539 | __ cmp(eax, JS_GLOBAL_PROXY_TYPE); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 540 | __ j(equal, &global_proxy, not_taken); |
| 541 | __ bind(&invoke); |
| 542 | GenerateNormalHelper(masm, argc, false, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 543 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 544 | // Global object proxy access: Check access rights. |
| 545 | __ bind(&global_proxy); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 546 | __ CheckAccessGlobalProxy(edx, eax, &miss); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 547 | __ jmp(&invoke); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 548 | |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 549 | // Cache miss: Jump to runtime. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 550 | __ bind(&miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 551 | Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); |
| 552 | } |
| 553 | |
| 554 | |
| 555 | void CallIC::Generate(MacroAssembler* masm, |
| 556 | int argc, |
| 557 | const ExternalReference& f) { |
| 558 | // ----------- S t a t e ------------- |
| 559 | // ----------------------------------- |
| 560 | |
| 561 | // Get the receiver of the function from the stack; 1 ~ return address. |
| 562 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 563 | // Get the name of the function to call from the stack. |
| 564 | // 2 ~ receiver, return address. |
| 565 | __ mov(ebx, Operand(esp, (argc + 2) * kPointerSize)); |
| 566 | |
| 567 | // Enter an internal frame. |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 568 | __ EnterInternalFrame(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 569 | |
| 570 | // Push the receiver and the name of the function. |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 571 | __ push(edx); |
| 572 | __ push(ebx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 573 | |
| 574 | // Call the entry. |
| 575 | CEntryStub stub; |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 576 | __ mov(eax, Immediate(2)); |
| 577 | __ mov(ebx, Immediate(f)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 578 | __ CallStub(&stub); |
| 579 | |
| 580 | // Move result to edi and exit the internal frame. |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 581 | __ mov(edi, eax); |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 582 | __ LeaveInternalFrame(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 583 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 584 | // Check if the receiver is a global object of some sort. |
| 585 | Label invoke, global; |
| 586 | __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); // receiver |
| 587 | __ test(edx, Immediate(kSmiTagMask)); |
| 588 | __ j(zero, &invoke, not_taken); |
| 589 | __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 590 | __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
| 591 | __ cmp(ecx, JS_GLOBAL_OBJECT_TYPE); |
| 592 | __ j(equal, &global); |
| 593 | __ cmp(ecx, JS_BUILTINS_OBJECT_TYPE); |
| 594 | __ j(not_equal, &invoke); |
| 595 | |
| 596 | // Patch the receiver on the stack. |
| 597 | __ bind(&global); |
| 598 | __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
| 599 | __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
| 600 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 601 | // Invoke the function. |
| 602 | ParameterCount actual(argc); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 603 | __ bind(&invoke); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 604 | __ InvokeFunction(edi, actual, JUMP_FUNCTION); |
| 605 | } |
| 606 | |
| 607 | |
| 608 | // Defined in ic.cc. |
| 609 | Object* LoadIC_Miss(Arguments args); |
| 610 | |
| 611 | void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
| 612 | // ----------- S t a t e ------------- |
| 613 | // -- ecx : name |
| 614 | // -- esp[0] : return address |
| 615 | // -- esp[4] : receiver |
| 616 | // ----------------------------------- |
| 617 | |
| 618 | __ mov(eax, Operand(esp, kPointerSize)); |
| 619 | |
| 620 | // Probe the stub cache. |
| 621 | Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, MONOMORPHIC); |
| 622 | StubCache::GenerateProbe(masm, flags, eax, ecx, ebx); |
| 623 | |
| 624 | // Cache miss: Jump to runtime. |
| 625 | Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); |
| 626 | } |
| 627 | |
| 628 | |
| 629 | void LoadIC::GenerateNormal(MacroAssembler* masm) { |
| 630 | // ----------- S t a t e ------------- |
| 631 | // -- ecx : name |
| 632 | // -- esp[0] : return address |
| 633 | // -- esp[4] : receiver |
| 634 | // ----------------------------------- |
| 635 | |
| 636 | Label miss, probe, global; |
| 637 | |
| 638 | __ mov(eax, Operand(esp, kPointerSize)); |
| 639 | |
| 640 | // Check that the receiver isn't a smi. |
| 641 | __ test(eax, Immediate(kSmiTagMask)); |
| 642 | __ j(zero, &miss, not_taken); |
| 643 | |
| 644 | // Check that the receiver is a valid JS object. |
| 645 | __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 646 | __ movzx_b(edx, FieldOperand(edx, Map::kInstanceTypeOffset)); |
| 647 | __ cmp(edx, FIRST_JS_OBJECT_TYPE); |
| 648 | __ j(less, &miss, not_taken); |
| 649 | |
| 650 | // If this assert fails, we have to check upper bound too. |
| 651 | ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 652 | |
| 653 | // Check for access to global object (unlikely). |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 654 | __ cmp(edx, JS_GLOBAL_PROXY_TYPE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 655 | __ j(equal, &global, not_taken); |
| 656 | |
| 657 | // Search the dictionary placing the result in eax. |
| 658 | __ bind(&probe); |
| 659 | GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame^] | 660 | GenerateCheckNonFunctionOrLoaded(masm, &miss, eax, edx); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 661 | __ ret(0); |
| 662 | |
| 663 | // Global object access: Check access rights. |
| 664 | __ bind(&global); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 665 | __ CheckAccessGlobalProxy(eax, edx, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 666 | __ jmp(&probe); |
| 667 | |
| 668 | // Cache miss: Restore receiver from stack and jump to runtime. |
| 669 | __ bind(&miss); |
| 670 | __ mov(eax, Operand(esp, 1 * kPointerSize)); |
| 671 | Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); |
| 672 | } |
| 673 | |
| 674 | |
| 675 | void LoadIC::GenerateMiss(MacroAssembler* masm) { |
| 676 | // ----------- S t a t e ------------- |
| 677 | // -- ecx : name |
| 678 | // -- esp[0] : return address |
| 679 | // -- esp[4] : receiver |
| 680 | // ----------------------------------- |
| 681 | |
| 682 | Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); |
| 683 | } |
| 684 | |
| 685 | |
| 686 | void LoadIC::Generate(MacroAssembler* masm, const ExternalReference& f) { |
| 687 | // ----------- S t a t e ------------- |
| 688 | // -- ecx : name |
| 689 | // -- esp[0] : return address |
| 690 | // -- esp[4] : receiver |
| 691 | // ----------------------------------- |
| 692 | |
| 693 | __ mov(eax, Operand(esp, kPointerSize)); |
| 694 | |
| 695 | // Move the return address below the arguments. |
| 696 | __ pop(ebx); |
| 697 | __ push(eax); |
| 698 | __ push(ecx); |
| 699 | __ push(ebx); |
| 700 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 701 | // Perform tail call to the entry. |
| 702 | __ TailCallRuntime(f, 2); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | |
| 706 | // Defined in ic.cc. |
| 707 | Object* KeyedLoadIC_Miss(Arguments args); |
| 708 | |
| 709 | |
| 710 | void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
| 711 | // ----------- S t a t e ------------- |
| 712 | // -- esp[0] : return address |
| 713 | // -- esp[4] : name |
| 714 | // -- esp[8] : receiver |
| 715 | // ----------------------------------- |
| 716 | |
| 717 | Generate(masm, ExternalReference(IC_Utility(kKeyedLoadIC_Miss))); |
| 718 | } |
| 719 | |
| 720 | |
| 721 | void KeyedLoadIC::Generate(MacroAssembler* masm, const ExternalReference& f) { |
| 722 | // ----------- S t a t e ------------- |
| 723 | // -- esp[0] : return address |
| 724 | // -- esp[4] : name |
| 725 | // -- esp[8] : receiver |
| 726 | // ----------------------------------- |
| 727 | |
| 728 | __ mov(eax, Operand(esp, kPointerSize)); |
| 729 | __ mov(ecx, Operand(esp, 2 * kPointerSize)); |
| 730 | |
| 731 | // Move the return address below the arguments. |
| 732 | __ pop(ebx); |
| 733 | __ push(ecx); |
| 734 | __ push(eax); |
| 735 | __ push(ebx); |
| 736 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 737 | // Perform tail call to the entry. |
| 738 | __ TailCallRuntime(f, 2); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 742 | void StoreIC::GenerateMegamorphic(MacroAssembler* masm) { |
| 743 | // ----------- S t a t e ------------- |
| 744 | // -- eax : value |
| 745 | // -- ecx : name |
| 746 | // -- esp[0] : return address |
| 747 | // -- esp[4] : receiver |
| 748 | // ----------------------------------- |
| 749 | |
| 750 | // Get the receiver from the stack and probe the stub cache. |
| 751 | __ mov(edx, Operand(esp, 4)); |
| 752 | Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, MONOMORPHIC); |
| 753 | StubCache::GenerateProbe(masm, flags, edx, ecx, ebx); |
| 754 | |
| 755 | // Cache miss: Jump to runtime. |
| 756 | Generate(masm, ExternalReference(IC_Utility(kStoreIC_Miss))); |
| 757 | } |
| 758 | |
| 759 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 760 | void StoreIC::GenerateExtendStorage(MacroAssembler* masm) { |
| 761 | // ----------- S t a t e ------------- |
| 762 | // -- eax : value |
| 763 | // -- ecx : transition map |
| 764 | // -- esp[0] : return address |
| 765 | // -- esp[4] : receiver |
| 766 | // ----------------------------------- |
| 767 | |
| 768 | // Move the return address below the arguments. |
| 769 | __ pop(ebx); |
| 770 | __ push(Operand(esp, 0)); |
| 771 | __ push(ecx); |
| 772 | __ push(eax); |
| 773 | __ push(ebx); |
| 774 | // Perform tail call to the entry. |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 775 | __ TailCallRuntime( |
| 776 | ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 780 | void StoreIC::Generate(MacroAssembler* masm, const ExternalReference& f) { |
| 781 | // ----------- S t a t e ------------- |
| 782 | // -- eax : value |
| 783 | // -- ecx : name |
| 784 | // -- esp[0] : return address |
| 785 | // -- esp[4] : receiver |
| 786 | // ----------------------------------- |
| 787 | |
| 788 | // Move the return address below the arguments. |
| 789 | __ pop(ebx); |
| 790 | __ push(Operand(esp, 0)); |
| 791 | __ push(ecx); |
| 792 | __ push(eax); |
| 793 | __ push(ebx); |
| 794 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 795 | // Perform tail call to the entry. |
| 796 | __ TailCallRuntime(f, 3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | |
| 800 | // Defined in ic.cc. |
| 801 | Object* KeyedStoreIC_Miss(Arguments args); |
| 802 | |
| 803 | void KeyedStoreIC::Generate(MacroAssembler* masm, const ExternalReference& f) { |
| 804 | // ----------- S t a t e ------------- |
| 805 | // -- eax : value |
| 806 | // -- esp[0] : return address |
| 807 | // -- esp[4] : key |
| 808 | // -- esp[8] : receiver |
| 809 | // ----------------------------------- |
| 810 | |
| 811 | // Move the return address below the arguments. |
| 812 | __ pop(ecx); |
| 813 | __ push(Operand(esp, 1 * kPointerSize)); |
| 814 | __ push(Operand(esp, 1 * kPointerSize)); |
| 815 | __ push(eax); |
| 816 | __ push(ecx); |
| 817 | |
| 818 | // Do tail-call to runtime routine. |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 819 | __ TailCallRuntime(f, 3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 820 | } |
| 821 | |
| 822 | |
kasperl@chromium.org | 1accd57 | 2008-10-07 10:57:21 +0000 | [diff] [blame] | 823 | void KeyedStoreIC::GenerateExtendStorage(MacroAssembler* masm) { |
| 824 | // ----------- S t a t e ------------- |
| 825 | // -- eax : value |
| 826 | // -- ecx : transition map |
| 827 | // -- esp[0] : return address |
| 828 | // -- esp[4] : key |
| 829 | // -- esp[8] : receiver |
| 830 | // ----------------------------------- |
| 831 | |
| 832 | // Move the return address below the arguments. |
| 833 | __ pop(ebx); |
| 834 | __ push(Operand(esp, 1 * kPointerSize)); |
| 835 | __ push(ecx); |
| 836 | __ push(eax); |
| 837 | __ push(ebx); |
| 838 | |
| 839 | // Do tail-call to runtime routine. |
| 840 | __ TailCallRuntime( |
| 841 | ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3); |
| 842 | } |
| 843 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 844 | #undef __ |
| 845 | |
| 846 | |
| 847 | } } // namespace v8::internal |