erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 30 | #if V8_TARGET_ARCH_ARM |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 31 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | #include "ic-inl.h" |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 33 | #include "codegen.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | #include "stub-cache.h" |
| 35 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 36 | namespace v8 { |
| 37 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 38 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 39 | #define __ ACCESS_MASM(masm) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 40 | |
| 41 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 42 | static void ProbeTable(Isolate* isolate, |
| 43 | MacroAssembler* masm, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | Code::Flags flags, |
| 45 | StubCache::Table table, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 46 | Register receiver, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 47 | Register name, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 48 | // Number of the cache entry, not scaled. |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 49 | Register offset, |
| 50 | Register scratch, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 51 | Register scratch2, |
| 52 | Register offset_scratch) { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 53 | ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
| 54 | ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 55 | ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 56 | |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 57 | uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); |
| 58 | uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 59 | uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 60 | |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 61 | // Check the relative positions of the address fields. |
| 62 | ASSERT(value_off_addr > key_off_addr); |
| 63 | ASSERT((value_off_addr - key_off_addr) % 4 == 0); |
| 64 | ASSERT((value_off_addr - key_off_addr) < (256 * 4)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 65 | ASSERT(map_off_addr > key_off_addr); |
| 66 | ASSERT((map_off_addr - key_off_addr) % 4 == 0); |
| 67 | ASSERT((map_off_addr - key_off_addr) < (256 * 4)); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 68 | |
| 69 | Label miss; |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 70 | Register base_addr = scratch; |
| 71 | scratch = no_reg; |
| 72 | |
| 73 | // Multiply by 3 because there are 3 fields per entry (name, code, map). |
| 74 | __ add(offset_scratch, offset, Operand(offset, LSL, 1)); |
| 75 | |
| 76 | // Calculate the base address of the entry. |
| 77 | __ mov(base_addr, Operand(key_offset)); |
| 78 | __ add(base_addr, base_addr, Operand(offset_scratch, LSL, kPointerSizeLog2)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 79 | |
| 80 | // Check that the key in the entry matches the name. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 81 | __ ldr(ip, MemOperand(base_addr, 0)); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 82 | __ cmp(name, ip); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 83 | __ b(ne, &miss); |
| 84 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 85 | // Check the map matches. |
| 86 | __ ldr(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
| 87 | __ ldr(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 88 | __ cmp(ip, scratch2); |
| 89 | __ b(ne, &miss); |
| 90 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 91 | // Get the code entry from the cache. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 92 | Register code = scratch2; |
| 93 | scratch2 = no_reg; |
| 94 | __ ldr(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 95 | |
| 96 | // Check that the flags match what we're looking for. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 97 | Register flags_reg = base_addr; |
| 98 | base_addr = no_reg; |
| 99 | __ ldr(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 100 | // It's a nice optimization if this constant is encodable in the bic insn. |
| 101 | |
| 102 | uint32_t mask = Code::kFlagsNotUsedInLookup; |
| 103 | ASSERT(__ ImmediateFitsAddrMode1Instruction(mask)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 104 | __ bic(flags_reg, flags_reg, Operand(mask)); |
svenpanne@chromium.org | 876cca8 | 2013-03-18 14:43:20 +0000 | [diff] [blame] | 105 | __ cmp(flags_reg, Operand(flags)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 106 | __ b(ne, &miss); |
| 107 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 108 | #ifdef DEBUG |
| 109 | if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 110 | __ jmp(&miss); |
| 111 | } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 112 | __ jmp(&miss); |
| 113 | } |
| 114 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 115 | |
| 116 | // Jump to the first instruction in the code stub. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 117 | __ add(pc, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 118 | |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 119 | // Miss: fall through. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 120 | __ bind(&miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 124 | void StubCompiler::GenerateDictionaryNegativeLookup(MacroAssembler* masm, |
| 125 | Label* miss_label, |
| 126 | Register receiver, |
| 127 | Handle<Name> name, |
| 128 | Register scratch0, |
| 129 | Register scratch1) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 130 | ASSERT(name->IsUniqueName()); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 131 | ASSERT(!receiver.is(scratch0)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 132 | Counters* counters = masm->isolate()->counters(); |
| 133 | __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); |
| 134 | __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); |
| 135 | |
| 136 | Label done; |
| 137 | |
| 138 | const int kInterceptorOrAccessCheckNeededMask = |
| 139 | (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); |
| 140 | |
| 141 | // Bail out if the receiver has a named interceptor or requires access checks. |
| 142 | Register map = scratch1; |
| 143 | __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 144 | __ ldrb(scratch0, FieldMemOperand(map, Map::kBitFieldOffset)); |
| 145 | __ tst(scratch0, Operand(kInterceptorOrAccessCheckNeededMask)); |
| 146 | __ b(ne, miss_label); |
| 147 | |
| 148 | // Check that receiver is a JSObject. |
| 149 | __ ldrb(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
| 150 | __ cmp(scratch0, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 151 | __ b(lt, miss_label); |
| 152 | |
| 153 | // Load properties array. |
| 154 | Register properties = scratch0; |
| 155 | __ ldr(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| 156 | // Check that the properties array is a dictionary. |
| 157 | __ ldr(map, FieldMemOperand(properties, HeapObject::kMapOffset)); |
| 158 | Register tmp = properties; |
| 159 | __ LoadRoot(tmp, Heap::kHashTableMapRootIndex); |
| 160 | __ cmp(map, tmp); |
| 161 | __ b(ne, miss_label); |
| 162 | |
| 163 | // Restore the temporarily used register. |
| 164 | __ ldr(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); |
| 165 | |
| 166 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 167 | NameDictionaryLookupStub::GenerateNegativeLookup(masm, |
| 168 | miss_label, |
| 169 | &done, |
| 170 | receiver, |
| 171 | properties, |
| 172 | name, |
| 173 | scratch1); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 174 | __ bind(&done); |
| 175 | __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); |
| 176 | } |
| 177 | |
| 178 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 179 | void StubCache::GenerateProbe(MacroAssembler* masm, |
| 180 | Code::Flags flags, |
| 181 | Register receiver, |
| 182 | Register name, |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 183 | Register scratch, |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 184 | Register extra, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 185 | Register extra2, |
| 186 | Register extra3) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 187 | Isolate* isolate = masm->isolate(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 188 | Label miss; |
| 189 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 190 | // Make sure that code is valid. The multiplying code relies on the |
| 191 | // entry size being 12. |
| 192 | ASSERT(sizeof(Entry) == 12); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 193 | |
| 194 | // Make sure the flags does not name a specific type. |
| 195 | ASSERT(Code::ExtractTypeFromFlags(flags) == 0); |
| 196 | |
| 197 | // Make sure that there are no register conflicts. |
| 198 | ASSERT(!scratch.is(receiver)); |
| 199 | ASSERT(!scratch.is(name)); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 200 | ASSERT(!extra.is(receiver)); |
| 201 | ASSERT(!extra.is(name)); |
| 202 | ASSERT(!extra.is(scratch)); |
| 203 | ASSERT(!extra2.is(receiver)); |
| 204 | ASSERT(!extra2.is(name)); |
| 205 | ASSERT(!extra2.is(scratch)); |
| 206 | ASSERT(!extra2.is(extra)); |
| 207 | |
| 208 | // Check scratch, extra and extra2 registers are valid. |
| 209 | ASSERT(!scratch.is(no_reg)); |
| 210 | ASSERT(!extra.is(no_reg)); |
| 211 | ASSERT(!extra2.is(no_reg)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 212 | ASSERT(!extra3.is(no_reg)); |
| 213 | |
| 214 | Counters* counters = masm->isolate()->counters(); |
| 215 | __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, |
| 216 | extra2, extra3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 217 | |
| 218 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 219 | __ JumpIfSmi(receiver, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 220 | |
| 221 | // Get the map of the receiver and compute the hash. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 222 | __ ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 223 | __ ldr(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 224 | __ add(scratch, scratch, Operand(ip)); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 225 | uint32_t mask = kPrimaryTableSize - 1; |
| 226 | // We shift out the last two bits because they are not part of the hash and |
| 227 | // they are always 01 for maps. |
| 228 | __ mov(scratch, Operand(scratch, LSR, kHeapObjectTagSize)); |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 229 | // Mask down the eor argument to the minimum to keep the immediate |
| 230 | // ARM-encodable. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 231 | __ eor(scratch, scratch, Operand((flags >> kHeapObjectTagSize) & mask)); |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 232 | // Prefer and_ to ubfx here because ubfx takes 2 cycles. |
| 233 | __ and_(scratch, scratch, Operand(mask)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 234 | |
| 235 | // Probe the primary table. |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 236 | ProbeTable(isolate, |
| 237 | masm, |
| 238 | flags, |
| 239 | kPrimary, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 240 | receiver, |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 241 | name, |
| 242 | scratch, |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 243 | extra, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 244 | extra2, |
| 245 | extra3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 246 | |
| 247 | // Primary miss: Compute hash for secondary probe. |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 248 | __ sub(scratch, scratch, Operand(name, LSR, kHeapObjectTagSize)); |
| 249 | uint32_t mask2 = kSecondaryTableSize - 1; |
| 250 | __ add(scratch, scratch, Operand((flags >> kHeapObjectTagSize) & mask2)); |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 251 | __ and_(scratch, scratch, Operand(mask2)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 252 | |
| 253 | // Probe the secondary table. |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 254 | ProbeTable(isolate, |
| 255 | masm, |
| 256 | flags, |
| 257 | kSecondary, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 258 | receiver, |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 259 | name, |
| 260 | scratch, |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 261 | extra, |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 262 | extra2, |
| 263 | extra3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 264 | |
| 265 | // Cache miss: Fall-through and let caller handle the miss by |
| 266 | // entering the runtime system. |
| 267 | __ bind(&miss); |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 268 | __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, |
| 269 | extra2, extra3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | |
| 273 | void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
| 274 | int index, |
| 275 | Register prototype) { |
| 276 | // Load the global or builtins object from the current context. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 277 | __ ldr(prototype, |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 278 | MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 279 | // Load the native context from the global or builtins object. |
| 280 | __ ldr(prototype, |
| 281 | FieldMemOperand(prototype, GlobalObject::kNativeContextOffset)); |
| 282 | // Load the function from the native context. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 283 | __ ldr(prototype, MemOperand(prototype, Context::SlotOffset(index))); |
| 284 | // Load the initial map. The global functions all have initial maps. |
| 285 | __ ldr(prototype, |
| 286 | FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
| 287 | // Load the prototype from the initial map. |
| 288 | __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
| 289 | } |
| 290 | |
| 291 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 292 | void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 293 | MacroAssembler* masm, |
| 294 | int index, |
| 295 | Register prototype, |
| 296 | Label* miss) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 297 | Isolate* isolate = masm->isolate(); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 298 | // Check we're still in the same context. |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 299 | __ ldr(prototype, |
| 300 | MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 301 | __ Move(ip, isolate->global_object()); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 302 | __ cmp(prototype, ip); |
| 303 | __ b(ne, miss); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 304 | // Get the global function with the given index. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 305 | Handle<JSFunction> function( |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 306 | JSFunction::cast(isolate->native_context()->get(index))); |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 307 | // Load its initial map. The global functions all have initial maps. |
| 308 | __ Move(prototype, Handle<Map>(function->initial_map())); |
| 309 | // Load the prototype from the initial map. |
| 310 | __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
| 311 | } |
| 312 | |
| 313 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 314 | void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm, |
| 315 | Register dst, |
| 316 | Register src, |
| 317 | bool inobject, |
| 318 | int index, |
| 319 | Representation representation) { |
| 320 | ASSERT(!FLAG_track_double_fields || !representation.IsDouble()); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 321 | int offset = index * kPointerSize; |
| 322 | if (!inobject) { |
| 323 | // Calculate the offset into the properties array. |
| 324 | offset = offset + FixedArray::kHeaderSize; |
| 325 | __ ldr(dst, FieldMemOperand(src, JSObject::kPropertiesOffset)); |
| 326 | src = dst; |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 327 | } |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 328 | __ ldr(dst, FieldMemOperand(src, offset)); |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 332 | void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
| 333 | Register receiver, |
| 334 | Register scratch, |
| 335 | Label* miss_label) { |
| 336 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 337 | __ JumpIfSmi(receiver, miss_label); |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 338 | |
| 339 | // Check that the object is a JS array. |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 340 | __ CompareObjectType(receiver, scratch, scratch, JS_ARRAY_TYPE); |
ager@chromium.org | 3bf7b91 | 2008-11-17 09:09:45 +0000 | [diff] [blame] | 341 | __ b(ne, miss_label); |
| 342 | |
| 343 | // Load length directly from the JS array. |
| 344 | __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 345 | __ Ret(); |
| 346 | } |
| 347 | |
| 348 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 349 | // Generate code to check if an object is a string. If the object is a |
| 350 | // heap object, its map's instance type is left in the scratch1 register. |
| 351 | // If this is not needed, scratch1 and scratch2 may be the same register. |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 352 | static void GenerateStringCheck(MacroAssembler* masm, |
| 353 | Register receiver, |
| 354 | Register scratch1, |
| 355 | Register scratch2, |
| 356 | Label* smi, |
| 357 | Label* non_string_object) { |
| 358 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 359 | __ JumpIfSmi(receiver, smi); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 360 | |
| 361 | // Check that the object is a string. |
| 362 | __ ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 363 | __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 364 | __ and_(scratch2, scratch1, Operand(kIsNotStringMask)); |
| 365 | // The cast is to resolve the overload for the argument of 0x0. |
| 366 | __ cmp(scratch2, Operand(static_cast<int32_t>(kStringTag))); |
| 367 | __ b(ne, non_string_object); |
| 368 | } |
| 369 | |
| 370 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 371 | // Generate code to load the length from a string object and return the length. |
| 372 | // If the receiver object is not a string or a wrapped string object the |
| 373 | // execution continues at the miss label. The register containing the |
| 374 | // receiver is potentially clobbered. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 375 | void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, |
| 376 | Register receiver, |
| 377 | Register scratch1, |
| 378 | Register scratch2, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 379 | Label* miss) { |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 380 | Label check_wrapper; |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 381 | |
| 382 | // Check if the object is a string leaving the instance type in the |
| 383 | // scratch1 register. |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 384 | GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, &check_wrapper); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 385 | |
| 386 | // Load length directly from the string. |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 387 | __ ldr(r0, FieldMemOperand(receiver, String::kLengthOffset)); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 388 | __ Ret(); |
| 389 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 390 | // Check if the object is a JSValue wrapper. |
| 391 | __ bind(&check_wrapper); |
| 392 | __ cmp(scratch1, Operand(JS_VALUE_TYPE)); |
| 393 | __ b(ne, miss); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 394 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 395 | // Unwrap the value and check if the wrapped value is a string. |
| 396 | __ ldr(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); |
| 397 | GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss); |
| 398 | __ ldr(r0, FieldMemOperand(scratch1, String::kLengthOffset)); |
| 399 | __ Ret(); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 403 | void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 404 | Register receiver, |
| 405 | Register scratch1, |
| 406 | Register scratch2, |
| 407 | Label* miss_label) { |
| 408 | __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 409 | __ mov(r0, scratch1); |
| 410 | __ Ret(); |
| 411 | } |
| 412 | |
| 413 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 414 | // Generate code to check that a global property cell is empty. Create |
| 415 | // the property cell at compilation time if no cell exists for the |
| 416 | // property. |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 417 | void StubCompiler::GenerateCheckPropertyCell(MacroAssembler* masm, |
| 418 | Handle<JSGlobalObject> global, |
| 419 | Handle<Name> name, |
| 420 | Register scratch, |
| 421 | Label* miss) { |
| 422 | Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 423 | ASSERT(cell->value()->IsTheHole()); |
| 424 | __ mov(scratch, Operand(cell)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 425 | __ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 426 | __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 427 | __ cmp(scratch, ip); |
| 428 | __ b(ne, miss); |
| 429 | } |
| 430 | |
| 431 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 432 | void StoreStubCompiler::GenerateNegativeHolderLookup( |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 433 | MacroAssembler* masm, |
| 434 | Handle<JSObject> holder, |
| 435 | Register holder_reg, |
| 436 | Handle<Name> name, |
| 437 | Label* miss) { |
| 438 | if (holder->IsJSGlobalObject()) { |
| 439 | GenerateCheckPropertyCell( |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 440 | masm, Handle<JSGlobalObject>::cast(holder), name, scratch1(), miss); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 441 | } else if (!holder->HasFastProperties() && !holder->IsJSGlobalProxy()) { |
| 442 | GenerateDictionaryNegativeLookup( |
| 443 | masm, miss, holder_reg, name, scratch1(), scratch2()); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 448 | // Generate StoreTransition code, value is passed in r0 register. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 449 | // When leaving generated code after success, the receiver_reg and name_reg |
| 450 | // may be clobbered. Upon branch to miss_label, the receiver and name |
| 451 | // registers have their original values. |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 452 | void StoreStubCompiler::GenerateStoreTransition(MacroAssembler* masm, |
| 453 | Handle<JSObject> object, |
| 454 | LookupResult* lookup, |
| 455 | Handle<Map> transition, |
| 456 | Handle<Name> name, |
| 457 | Register receiver_reg, |
| 458 | Register storage_reg, |
| 459 | Register value_reg, |
| 460 | Register scratch1, |
| 461 | Register scratch2, |
| 462 | Register scratch3, |
| 463 | Label* miss_label, |
| 464 | Label* slow) { |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 465 | // r0 : value |
| 466 | Label exit; |
| 467 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 468 | int descriptor = transition->LastAdded(); |
| 469 | DescriptorArray* descriptors = transition->instance_descriptors(); |
| 470 | PropertyDetails details = descriptors->GetDetails(descriptor); |
| 471 | Representation representation = details.representation(); |
| 472 | ASSERT(!representation.IsNone()); |
| 473 | |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 474 | if (details.type() == CONSTANT) { |
| 475 | Handle<Object> constant(descriptors->GetValue(descriptor), masm->isolate()); |
bmeurer@chromium.org | e94b5ff | 2013-10-25 09:22:31 +0000 | [diff] [blame] | 476 | __ Move(scratch1, constant); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 477 | __ cmp(value_reg, scratch1); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 478 | __ b(ne, miss_label); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 479 | } else if (FLAG_track_fields && representation.IsSmi()) { |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 480 | __ JumpIfNotSmi(value_reg, miss_label); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 481 | } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 482 | __ JumpIfSmi(value_reg, miss_label); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 483 | } else if (FLAG_track_double_fields && representation.IsDouble()) { |
| 484 | Label do_store, heap_number; |
| 485 | __ LoadRoot(scratch3, Heap::kHeapNumberMapRootIndex); |
| 486 | __ AllocateHeapNumber(storage_reg, scratch1, scratch2, scratch3, slow); |
| 487 | |
| 488 | __ JumpIfNotSmi(value_reg, &heap_number); |
| 489 | __ SmiUntag(scratch1, value_reg); |
| 490 | __ vmov(s0, scratch1); |
| 491 | __ vcvt_f64_s32(d0, s0); |
| 492 | __ jmp(&do_store); |
| 493 | |
| 494 | __ bind(&heap_number); |
| 495 | __ CheckMap(value_reg, scratch1, Heap::kHeapNumberMapRootIndex, |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 496 | miss_label, DONT_DO_SMI_CHECK); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 497 | __ vldr(d0, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); |
| 498 | |
| 499 | __ bind(&do_store); |
| 500 | __ vstr(d0, FieldMemOperand(storage_reg, HeapNumber::kValueOffset)); |
| 501 | } |
| 502 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 503 | // Stub never generated for non-global objects that require access |
| 504 | // checks. |
| 505 | ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
| 506 | |
| 507 | // Perform map transition for the receiver if necessary. |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 508 | if (details.type() == FIELD && |
| 509 | object->map()->unused_property_fields() == 0) { |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 510 | // The properties must be extended before we can store the value. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 511 | // We jump to a runtime call that extends the properties array. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 512 | __ push(receiver_reg); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 513 | __ mov(r2, Operand(transition)); |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 514 | __ Push(r2, r0); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 515 | __ TailCallExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 516 | ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), |
| 517 | masm->isolate()), |
| 518 | 3, |
| 519 | 1); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 520 | return; |
| 521 | } |
| 522 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 523 | // Update the map of the object. |
| 524 | __ mov(scratch1, Operand(transition)); |
| 525 | __ str(scratch1, FieldMemOperand(receiver_reg, HeapObject::kMapOffset)); |
verwaest@chromium.org | 3714139 | 2012-05-31 13:27:02 +0000 | [diff] [blame] | 526 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 527 | // Update the write barrier for the map field. |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 528 | __ RecordWriteField(receiver_reg, |
| 529 | HeapObject::kMapOffset, |
| 530 | scratch1, |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 531 | scratch2, |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 532 | kLRHasNotBeenSaved, |
| 533 | kDontSaveFPRegs, |
| 534 | OMIT_REMEMBERED_SET, |
| 535 | OMIT_SMI_CHECK); |
| 536 | |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 537 | if (details.type() == CONSTANT) { |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 538 | ASSERT(value_reg.is(r0)); |
| 539 | __ Ret(); |
| 540 | return; |
| 541 | } |
| 542 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 543 | int index = transition->instance_descriptors()->GetFieldIndex( |
| 544 | transition->LastAdded()); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 545 | |
| 546 | // Adjust for the number of properties stored in the object. Even in the |
| 547 | // face of a transition we can use the old map here because the size of the |
| 548 | // object and the number of in-object properties is not going to change. |
| 549 | index -= object->map()->inobject_properties(); |
| 550 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 551 | // TODO(verwaest): Share this code as a code stub. |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 552 | SmiCheck smi_check = representation.IsTagged() |
| 553 | ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 554 | if (index < 0) { |
| 555 | // Set the property straight into the object. |
| 556 | int offset = object->map()->instance_size() + (index * kPointerSize); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 557 | if (FLAG_track_double_fields && representation.IsDouble()) { |
| 558 | __ str(storage_reg, FieldMemOperand(receiver_reg, offset)); |
| 559 | } else { |
| 560 | __ str(value_reg, FieldMemOperand(receiver_reg, offset)); |
| 561 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 562 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 563 | if (!FLAG_track_fields || !representation.IsSmi()) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 564 | // Update the write barrier for the array address. |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 565 | if (!FLAG_track_double_fields || !representation.IsDouble()) { |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 566 | __ mov(storage_reg, value_reg); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 567 | } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 568 | __ RecordWriteField(receiver_reg, |
| 569 | offset, |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 570 | storage_reg, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 571 | scratch1, |
| 572 | kLRHasNotBeenSaved, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 573 | kDontSaveFPRegs, |
| 574 | EMIT_REMEMBERED_SET, |
| 575 | smi_check); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 576 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 577 | } else { |
| 578 | // Write to the properties array. |
| 579 | int offset = index * kPointerSize + FixedArray::kHeaderSize; |
| 580 | // Get the properties array |
| 581 | __ ldr(scratch1, |
| 582 | FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 583 | if (FLAG_track_double_fields && representation.IsDouble()) { |
| 584 | __ str(storage_reg, FieldMemOperand(scratch1, offset)); |
| 585 | } else { |
| 586 | __ str(value_reg, FieldMemOperand(scratch1, offset)); |
| 587 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 588 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 589 | if (!FLAG_track_fields || !representation.IsSmi()) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 590 | // Update the write barrier for the array address. |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 591 | if (!FLAG_track_double_fields || !representation.IsDouble()) { |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 592 | __ mov(storage_reg, value_reg); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 593 | } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 594 | __ RecordWriteField(scratch1, |
| 595 | offset, |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 596 | storage_reg, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 597 | receiver_reg, |
| 598 | kLRHasNotBeenSaved, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 599 | kDontSaveFPRegs, |
| 600 | EMIT_REMEMBERED_SET, |
| 601 | smi_check); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 602 | } |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | // Return the value (register r0). |
| 606 | ASSERT(value_reg.is(r0)); |
| 607 | __ bind(&exit); |
| 608 | __ Ret(); |
| 609 | } |
| 610 | |
| 611 | |
| 612 | // Generate StoreField code, value is passed in r0 register. |
| 613 | // When leaving generated code after success, the receiver_reg and name_reg |
| 614 | // may be clobbered. Upon branch to miss_label, the receiver and name |
| 615 | // registers have their original values. |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 616 | void StoreStubCompiler::GenerateStoreField(MacroAssembler* masm, |
| 617 | Handle<JSObject> object, |
| 618 | LookupResult* lookup, |
| 619 | Register receiver_reg, |
| 620 | Register name_reg, |
| 621 | Register value_reg, |
| 622 | Register scratch1, |
| 623 | Register scratch2, |
| 624 | Label* miss_label) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 625 | // r0 : value |
| 626 | Label exit; |
| 627 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 628 | // Stub never generated for non-global objects that require access |
| 629 | // checks. |
| 630 | ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
| 631 | |
| 632 | int index = lookup->GetFieldIndex().field_index(); |
| 633 | |
| 634 | // Adjust for the number of properties stored in the object. Even in the |
| 635 | // face of a transition we can use the old map here because the size of the |
| 636 | // object and the number of in-object properties is not going to change. |
| 637 | index -= object->map()->inobject_properties(); |
| 638 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 639 | Representation representation = lookup->representation(); |
| 640 | ASSERT(!representation.IsNone()); |
| 641 | if (FLAG_track_fields && representation.IsSmi()) { |
| 642 | __ JumpIfNotSmi(value_reg, miss_label); |
ulan@chromium.org | 906e2fb | 2013-05-14 08:14:38 +0000 | [diff] [blame] | 643 | } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
| 644 | __ JumpIfSmi(value_reg, miss_label); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 645 | } else if (FLAG_track_double_fields && representation.IsDouble()) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 646 | // Load the double storage. |
| 647 | if (index < 0) { |
| 648 | int offset = object->map()->instance_size() + (index * kPointerSize); |
| 649 | __ ldr(scratch1, FieldMemOperand(receiver_reg, offset)); |
| 650 | } else { |
| 651 | __ ldr(scratch1, |
| 652 | FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 653 | int offset = index * kPointerSize + FixedArray::kHeaderSize; |
| 654 | __ ldr(scratch1, FieldMemOperand(scratch1, offset)); |
| 655 | } |
| 656 | |
| 657 | // Store the value into the storage. |
| 658 | Label do_store, heap_number; |
| 659 | __ JumpIfNotSmi(value_reg, &heap_number); |
| 660 | __ SmiUntag(scratch2, value_reg); |
| 661 | __ vmov(s0, scratch2); |
| 662 | __ vcvt_f64_s32(d0, s0); |
| 663 | __ jmp(&do_store); |
| 664 | |
| 665 | __ bind(&heap_number); |
| 666 | __ CheckMap(value_reg, scratch2, Heap::kHeapNumberMapRootIndex, |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 667 | miss_label, DONT_DO_SMI_CHECK); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 668 | __ vldr(d0, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); |
| 669 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 670 | __ bind(&do_store); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 671 | __ vstr(d0, FieldMemOperand(scratch1, HeapNumber::kValueOffset)); |
| 672 | // Return the value (register r0). |
| 673 | ASSERT(value_reg.is(r0)); |
| 674 | __ Ret(); |
| 675 | return; |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 676 | } |
| 677 | |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 678 | // TODO(verwaest): Share this code as a code stub. |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 679 | SmiCheck smi_check = representation.IsTagged() |
| 680 | ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 681 | if (index < 0) { |
| 682 | // Set the property straight into the object. |
| 683 | int offset = object->map()->instance_size() + (index * kPointerSize); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 684 | __ str(value_reg, FieldMemOperand(receiver_reg, offset)); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 685 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 686 | if (!FLAG_track_fields || !representation.IsSmi()) { |
| 687 | // Skip updating write barrier if storing a smi. |
| 688 | __ JumpIfSmi(value_reg, &exit); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 689 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 690 | // Update the write barrier for the array address. |
| 691 | // Pass the now unused name_reg as a scratch register. |
| 692 | __ mov(name_reg, value_reg); |
| 693 | __ RecordWriteField(receiver_reg, |
| 694 | offset, |
| 695 | name_reg, |
| 696 | scratch1, |
| 697 | kLRHasNotBeenSaved, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 698 | kDontSaveFPRegs, |
| 699 | EMIT_REMEMBERED_SET, |
| 700 | smi_check); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 701 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 702 | } else { |
| 703 | // Write to the properties array. |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 704 | int offset = index * kPointerSize + FixedArray::kHeaderSize; |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 705 | // Get the properties array |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 706 | __ ldr(scratch1, |
| 707 | FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 708 | __ str(value_reg, FieldMemOperand(scratch1, offset)); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 709 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 710 | if (!FLAG_track_fields || !representation.IsSmi()) { |
| 711 | // Skip updating write barrier if storing a smi. |
| 712 | __ JumpIfSmi(value_reg, &exit); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 713 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 714 | // Update the write barrier for the array address. |
| 715 | // Ok to clobber receiver_reg and name_reg, since we return. |
| 716 | __ mov(name_reg, value_reg); |
| 717 | __ RecordWriteField(scratch1, |
| 718 | offset, |
| 719 | name_reg, |
| 720 | receiver_reg, |
| 721 | kLRHasNotBeenSaved, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 722 | kDontSaveFPRegs, |
| 723 | EMIT_REMEMBERED_SET, |
| 724 | smi_check); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 725 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | // Return the value (register r0). |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 729 | ASSERT(value_reg.is(r0)); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 730 | __ bind(&exit); |
| 731 | __ Ret(); |
| 732 | } |
| 733 | |
| 734 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 735 | void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm, |
| 736 | Label* label, |
| 737 | Handle<Name> name) { |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 738 | if (!label->is_unused()) { |
| 739 | __ bind(label); |
| 740 | __ mov(this->name(), Operand(name)); |
| 741 | } |
mvstanton@chromium.org | d16d853 | 2013-01-25 13:29:10 +0000 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 745 | static void GenerateCallFunction(MacroAssembler* masm, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 746 | Handle<Object> object, |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 747 | const ParameterCount& arguments, |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 748 | Label* miss, |
| 749 | Code::ExtraICState extra_ic_state) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 750 | // ----------- S t a t e ------------- |
| 751 | // -- r0: receiver |
| 752 | // -- r1: function to call |
| 753 | // ----------------------------------- |
| 754 | |
| 755 | // Check that the function really is a function. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 756 | __ JumpIfSmi(r1, miss); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 757 | __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 758 | __ b(ne, miss); |
| 759 | |
| 760 | // Patch the receiver on the stack with the global proxy if |
| 761 | // necessary. |
| 762 | if (object->IsGlobalObject()) { |
| 763 | __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
| 764 | __ str(r3, MemOperand(sp, arguments.immediate() * kPointerSize)); |
| 765 | } |
| 766 | |
| 767 | // Invoke the function. |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 768 | CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state) |
| 769 | ? CALL_AS_FUNCTION |
| 770 | : CALL_AS_METHOD; |
| 771 | __ InvokeFunction(r1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 775 | static void PushInterceptorArguments(MacroAssembler* masm, |
| 776 | Register receiver, |
| 777 | Register holder, |
| 778 | Register name, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 779 | Handle<JSObject> holder_obj) { |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 780 | STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); |
| 781 | STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); |
| 782 | STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); |
| 783 | STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); |
| 784 | STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 785 | __ push(name); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 786 | Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); |
| 787 | ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 788 | Register scratch = name; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 789 | __ mov(scratch, Operand(interceptor)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 790 | __ push(scratch); |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 791 | __ push(receiver); |
| 792 | __ push(holder); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 796 | static void CompileCallLoadPropertyWithInterceptor( |
| 797 | MacroAssembler* masm, |
| 798 | Register receiver, |
| 799 | Register holder, |
| 800 | Register name, |
| 801 | Handle<JSObject> holder_obj) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 802 | PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
| 803 | |
| 804 | ExternalReference ref = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 805 | ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
| 806 | masm->isolate()); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 807 | __ mov(r0, Operand(StubCache::kInterceptorArgsLength)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 808 | __ mov(r1, Operand(ref)); |
| 809 | |
| 810 | CEntryStub stub(1); |
| 811 | __ CallStub(&stub); |
| 812 | } |
| 813 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 814 | |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 815 | static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 816 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 817 | // Reserves space for the extra arguments to API function in the |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 818 | // caller's frame. |
| 819 | // |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 820 | // These arguments are set by CheckPrototypes and GenerateFastApiDirectCall. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 821 | static void ReserveSpaceForFastApiCall(MacroAssembler* masm, |
| 822 | Register scratch) { |
| 823 | __ mov(scratch, Operand(Smi::FromInt(0))); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 824 | for (int i = 0; i < kFastApiCallArguments; i++) { |
| 825 | __ push(scratch); |
| 826 | } |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | |
| 830 | // Undoes the effects of ReserveSpaceForFastApiCall. |
| 831 | static void FreeSpaceForFastApiCall(MacroAssembler* masm) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 832 | __ Drop(kFastApiCallArguments); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 836 | static void GenerateFastApiDirectCall(MacroAssembler* masm, |
| 837 | const CallOptimization& optimization, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 838 | int argc, |
| 839 | bool restore_context) { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 840 | // ----------- S t a t e ------------- |
machenbach@chromium.org | cfdf67d | 2013-09-27 07:27:26 +0000 | [diff] [blame] | 841 | // -- sp[0] - sp[24] : FunctionCallbackInfo, incl. |
| 842 | // : holder (set by CheckPrototypes) |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 843 | // -- sp[28] : last JS argument |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 844 | // -- ... |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 845 | // -- sp[(argc + 6) * 4] : first JS argument |
| 846 | // -- sp[(argc + 7) * 4] : receiver |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 847 | // ----------------------------------- |
machenbach@chromium.org | cfdf67d | 2013-09-27 07:27:26 +0000 | [diff] [blame] | 848 | typedef FunctionCallbackArguments FCA; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 849 | // Save calling context. |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 850 | __ str(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize)); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 851 | // Get the function and setup the context. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 852 | Handle<JSFunction> function = optimization.constant_function(); |
bmeurer@chromium.org | e94b5ff | 2013-10-25 09:22:31 +0000 | [diff] [blame] | 853 | __ Move(r5, function); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 854 | __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 855 | __ str(r5, MemOperand(sp, FCA::kCalleeIndex * kPointerSize)); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 856 | |
machenbach@chromium.org | cfdf67d | 2013-09-27 07:27:26 +0000 | [diff] [blame] | 857 | // Construct the FunctionCallbackInfo. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 858 | Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
ulan@chromium.org | 09d7ab5 | 2013-02-25 15:50:35 +0000 | [diff] [blame] | 859 | Handle<Object> call_data(api_call_info->data(), masm->isolate()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 860 | if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
| 861 | __ Move(r0, api_call_info); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 862 | __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 863 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 864 | __ Move(r6, call_data); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 865 | } |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 866 | // Store call data. |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 867 | __ str(r6, MemOperand(sp, FCA::kDataIndex * kPointerSize)); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 868 | // Store isolate. |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 869 | __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate()))); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 870 | __ str(r5, MemOperand(sp, FCA::kIsolateIndex * kPointerSize)); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 871 | // Store ReturnValue default and ReturnValue. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 872 | __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 873 | __ str(r5, MemOperand(sp, FCA::kReturnValueOffset * kPointerSize)); |
| 874 | __ str(r5, MemOperand(sp, FCA::kReturnValueDefaultValueIndex * kPointerSize)); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 875 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 876 | // Prepare arguments. |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 877 | __ mov(r2, sp); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 878 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 879 | // Allocate the v8::Arguments structure in the arguments' space since |
| 880 | // it's not controlled by GC. |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 881 | const int kApiStackSpace = 4; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 882 | |
| 883 | FrameScope frame_scope(masm, StackFrame::MANUAL); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 884 | __ EnterExitFrame(false, kApiStackSpace); |
| 885 | |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 886 | // r0 = FunctionCallbackInfo& |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 887 | // Arguments is after the return address. |
| 888 | __ add(r0, sp, Operand(1 * kPointerSize)); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 889 | // FunctionCallbackInfo::implicit_args_ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 890 | __ str(r2, MemOperand(r0, 0 * kPointerSize)); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 891 | // FunctionCallbackInfo::values_ |
| 892 | __ add(ip, r2, Operand((kFastApiCallArguments - 1 + argc) * kPointerSize)); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 893 | __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 894 | // FunctionCallbackInfo::length_ = argc |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 895 | __ mov(ip, Operand(argc)); |
| 896 | __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 897 | // FunctionCallbackInfo::is_construct_call = 0 |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 898 | __ mov(ip, Operand::Zero()); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 899 | __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 900 | |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 901 | const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 902 | Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 903 | ApiFunction fun(function_address); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 904 | ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 905 | ExternalReference ref = ExternalReference(&fun, |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 906 | type, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 907 | masm->isolate()); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 908 | Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); |
| 909 | ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL; |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 910 | ApiFunction thunk_fun(thunk_address); |
| 911 | ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, |
| 912 | masm->isolate()); |
| 913 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 914 | AllowExternalCallThatCantCauseGC scope(masm); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 915 | MemOperand context_restore_operand( |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 916 | fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
| 917 | MemOperand return_value_operand(fp, |
| 918 | (2 + FCA::kReturnValueOffset) * kPointerSize); |
| 919 | |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 920 | __ CallApiFunctionAndReturn(ref, |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 921 | function_address, |
| 922 | thunk_ref, |
| 923 | r1, |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 924 | kStackUnwindSpace, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 925 | return_value_operand, |
| 926 | restore_context ? |
| 927 | &context_restore_operand : NULL); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 928 | } |
| 929 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 930 | |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 931 | // Generate call to api function. |
| 932 | static void GenerateFastApiCall(MacroAssembler* masm, |
| 933 | const CallOptimization& optimization, |
| 934 | Register receiver, |
| 935 | Register scratch, |
| 936 | int argc, |
| 937 | Register* values) { |
| 938 | ASSERT(optimization.is_simple_api_call()); |
| 939 | ASSERT(!receiver.is(scratch)); |
| 940 | |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 941 | typedef FunctionCallbackArguments FCA; |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 942 | const int stack_space = kFastApiCallArguments + argc + 1; |
| 943 | // Assign stack space for the call arguments. |
| 944 | __ sub(sp, sp, Operand(stack_space * kPointerSize)); |
| 945 | // Write holder to stack frame. |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 946 | __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 947 | // Write receiver to stack frame. |
| 948 | int index = stack_space - 1; |
| 949 | __ str(receiver, MemOperand(sp, index * kPointerSize)); |
| 950 | // Write the arguments to stack frame. |
| 951 | for (int i = 0; i < argc; i++) { |
| 952 | ASSERT(!receiver.is(values[i])); |
| 953 | ASSERT(!scratch.is(values[i])); |
| 954 | __ str(receiver, MemOperand(sp, index-- * kPointerSize)); |
| 955 | } |
| 956 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 957 | GenerateFastApiDirectCall(masm, optimization, argc, true); |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 961 | class CallInterceptorCompiler BASE_EMBEDDED { |
| 962 | public: |
| 963 | CallInterceptorCompiler(StubCompiler* stub_compiler, |
| 964 | const ParameterCount& arguments, |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 965 | Register name, |
| 966 | Code::ExtraICState extra_ic_state) |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 967 | : stub_compiler_(stub_compiler), |
| 968 | arguments_(arguments), |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 969 | name_(name), |
| 970 | extra_ic_state_(extra_ic_state) {} |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 971 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 972 | void Compile(MacroAssembler* masm, |
| 973 | Handle<JSObject> object, |
| 974 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 975 | Handle<Name> name, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 976 | LookupResult* lookup, |
| 977 | Register receiver, |
| 978 | Register scratch1, |
| 979 | Register scratch2, |
| 980 | Register scratch3, |
| 981 | Label* miss) { |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 982 | ASSERT(holder->HasNamedInterceptor()); |
| 983 | ASSERT(!holder->GetNamedInterceptor()->getter()->IsUndefined()); |
| 984 | |
| 985 | // Check that the receiver isn't a smi. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 986 | __ JumpIfSmi(receiver, miss); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 987 | CallOptimization optimization(lookup); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 988 | if (optimization.is_constant_call()) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 989 | CompileCacheable(masm, object, receiver, scratch1, scratch2, scratch3, |
| 990 | holder, lookup, name, optimization, miss); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 991 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 992 | CompileRegular(masm, object, receiver, scratch1, scratch2, scratch3, |
| 993 | name, holder, miss); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 994 | } |
| 995 | } |
| 996 | |
| 997 | private: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 998 | void CompileCacheable(MacroAssembler* masm, |
| 999 | Handle<JSObject> object, |
| 1000 | Register receiver, |
| 1001 | Register scratch1, |
| 1002 | Register scratch2, |
| 1003 | Register scratch3, |
| 1004 | Handle<JSObject> interceptor_holder, |
| 1005 | LookupResult* lookup, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1006 | Handle<Name> name, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1007 | const CallOptimization& optimization, |
| 1008 | Label* miss_label) { |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1009 | ASSERT(optimization.is_constant_call()); |
| 1010 | ASSERT(!lookup->holder()->IsGlobalObject()); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1011 | Counters* counters = masm->isolate()->counters(); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1012 | int depth1 = kInvalidProtoDepth; |
| 1013 | int depth2 = kInvalidProtoDepth; |
| 1014 | bool can_do_fast_api_call = false; |
| 1015 | if (optimization.is_simple_api_call() && |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1016 | !lookup->holder()->IsGlobalObject()) { |
| 1017 | depth1 = optimization.GetPrototypeDepthOfExpectedType( |
| 1018 | object, interceptor_holder); |
| 1019 | if (depth1 == kInvalidProtoDepth) { |
| 1020 | depth2 = optimization.GetPrototypeDepthOfExpectedType( |
| 1021 | interceptor_holder, Handle<JSObject>(lookup->holder())); |
| 1022 | } |
| 1023 | can_do_fast_api_call = |
| 1024 | depth1 != kInvalidProtoDepth || depth2 != kInvalidProtoDepth; |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1027 | __ IncrementCounter(counters->call_const_interceptor(), 1, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1028 | scratch1, scratch2); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1029 | |
| 1030 | if (can_do_fast_api_call) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1031 | __ IncrementCounter(counters->call_const_interceptor_fast_api(), 1, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1032 | scratch1, scratch2); |
| 1033 | ReserveSpaceForFastApiCall(masm, scratch1); |
| 1034 | } |
| 1035 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1036 | // Check that the maps from receiver to interceptor's holder |
| 1037 | // haven't changed and thus we can invoke interceptor. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1038 | Label miss_cleanup; |
| 1039 | Label* miss = can_do_fast_api_call ? &miss_cleanup : miss_label; |
| 1040 | Register holder = |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1041 | stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, |
| 1042 | scratch1, scratch2, scratch3, |
| 1043 | name, depth1, miss); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1044 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1045 | // Invoke an interceptor and if it provides a value, |
| 1046 | // branch to |regular_invoke|. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1047 | Label regular_invoke; |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1048 | LoadWithInterceptor(masm, receiver, holder, interceptor_holder, scratch2, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1049 | ®ular_invoke); |
| 1050 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1051 | // Interceptor returned nothing for this property. Try to use cached |
| 1052 | // constant function. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1053 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1054 | // Check that the maps from interceptor's holder to constant function's |
| 1055 | // holder haven't changed and thus we can use cached constant function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1056 | if (*interceptor_holder != lookup->holder()) { |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1057 | stub_compiler_->CheckPrototypes(interceptor_holder, receiver, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1058 | Handle<JSObject>(lookup->holder()), |
| 1059 | scratch1, scratch2, scratch3, |
| 1060 | name, depth2, miss); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1061 | } else { |
| 1062 | // CheckPrototypes has a side effect of fetching a 'holder' |
| 1063 | // for API (object which is instanceof for the signature). It's |
| 1064 | // safe to omit it here, as if present, it should be fetched |
| 1065 | // by the previous CheckPrototypes. |
| 1066 | ASSERT(depth2 == kInvalidProtoDepth); |
| 1067 | } |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1068 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1069 | // Invoke function. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1070 | if (can_do_fast_api_call) { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1071 | GenerateFastApiDirectCall( |
| 1072 | masm, optimization, arguments_.immediate(), false); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1073 | } else { |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1074 | CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_) |
| 1075 | ? CALL_AS_FUNCTION |
| 1076 | : CALL_AS_METHOD; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1077 | Handle<JSFunction> function = optimization.constant_function(); |
| 1078 | ParameterCount expected(function); |
| 1079 | __ InvokeFunction(function, expected, arguments_, |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 1080 | JUMP_FUNCTION, NullCallWrapper(), call_kind); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1083 | // Deferred code for fast API call case---clean preallocated space. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1084 | if (can_do_fast_api_call) { |
| 1085 | __ bind(&miss_cleanup); |
| 1086 | FreeSpaceForFastApiCall(masm); |
| 1087 | __ b(miss_label); |
| 1088 | } |
| 1089 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1090 | // Invoke a regular function. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1091 | __ bind(®ular_invoke); |
| 1092 | if (can_do_fast_api_call) { |
| 1093 | FreeSpaceForFastApiCall(masm); |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | void CompileRegular(MacroAssembler* masm, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1098 | Handle<JSObject> object, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1099 | Register receiver, |
| 1100 | Register scratch1, |
| 1101 | Register scratch2, |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1102 | Register scratch3, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1103 | Handle<Name> name, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1104 | Handle<JSObject> interceptor_holder, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1105 | Label* miss_label) { |
| 1106 | Register holder = |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1107 | stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1108 | scratch1, scratch2, scratch3, |
| 1109 | name, miss_label); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1110 | |
| 1111 | // Call a runtime function to load the interceptor property. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1112 | FrameScope scope(masm, StackFrame::INTERNAL); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1113 | // Save the name_ register across the call. |
| 1114 | __ push(name_); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1115 | PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1116 | __ CallExternalReference( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1117 | ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
| 1118 | masm->isolate()), |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1119 | StubCache::kInterceptorArgsLength); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1120 | // Restore the name_ register. |
| 1121 | __ pop(name_); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1122 | // Leave the internal frame. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1123 | } |
| 1124 | |
| 1125 | void LoadWithInterceptor(MacroAssembler* masm, |
| 1126 | Register receiver, |
| 1127 | Register holder, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1128 | Handle<JSObject> holder_obj, |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1129 | Register scratch, |
| 1130 | Label* interceptor_succeeded) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1131 | { |
| 1132 | FrameScope scope(masm, StackFrame::INTERNAL); |
| 1133 | __ Push(holder, name_); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1134 | CompileCallLoadPropertyWithInterceptor(masm, |
| 1135 | receiver, |
| 1136 | holder, |
| 1137 | name_, |
| 1138 | holder_obj); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1139 | __ pop(name_); // Restore the name. |
| 1140 | __ pop(receiver); // Restore the holder. |
| 1141 | } |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1142 | // If interceptor returns no-result sentinel, call the constant function. |
| 1143 | __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); |
| 1144 | __ cmp(r0, scratch); |
| 1145 | __ b(ne, interceptor_succeeded); |
| 1146 | } |
| 1147 | |
| 1148 | StubCompiler* stub_compiler_; |
| 1149 | const ParameterCount& arguments_; |
| 1150 | Register name_; |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1151 | Code::ExtraICState extra_ic_state_; |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 1152 | }; |
| 1153 | |
| 1154 | |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1155 | void StubCompiler::GenerateCheckPropertyCells(MacroAssembler* masm, |
| 1156 | Handle<JSObject> object, |
| 1157 | Handle<JSObject> holder, |
| 1158 | Handle<Name> name, |
| 1159 | Register scratch, |
| 1160 | Label* miss) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1161 | Handle<JSObject> current = object; |
| 1162 | while (!current.is_identical_to(holder)) { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1163 | if (current->IsJSGlobalObject()) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1164 | GenerateCheckPropertyCell(masm, |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1165 | Handle<JSGlobalObject>::cast(current), |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1166 | name, |
| 1167 | scratch, |
| 1168 | miss); |
| 1169 | } |
| 1170 | current = Handle<JSObject>(JSObject::cast(current->GetPrototype())); |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 1175 | void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1176 | __ Jump(code, RelocInfo::CODE_TARGET); |
| 1177 | } |
| 1178 | |
| 1179 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 1180 | #undef __ |
| 1181 | #define __ ACCESS_MASM(masm()) |
| 1182 | |
| 1183 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1184 | Register StubCompiler::CheckPrototypes(Handle<JSObject> object, |
| 1185 | Register object_reg, |
| 1186 | Handle<JSObject> holder, |
| 1187 | Register holder_reg, |
| 1188 | Register scratch1, |
| 1189 | Register scratch2, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1190 | Handle<Name> name, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1191 | int save_at_depth, |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1192 | Label* miss, |
| 1193 | PrototypeCheckType check) { |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 1194 | // Make sure that the type feedback oracle harvests the receiver map. |
| 1195 | // TODO(svenpanne) Remove this hack when all ICs are reworked. |
| 1196 | __ mov(scratch1, Operand(Handle<Map>(object->map()))); |
| 1197 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1198 | Handle<JSObject> first = object; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1199 | // Make sure there's no overlap between holder and object registers. |
| 1200 | ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
| 1201 | ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) |
| 1202 | && !scratch2.is(scratch1)); |
| 1203 | |
| 1204 | // Keep track of the current object in register reg. |
| 1205 | Register reg = object_reg; |
| 1206 | int depth = 0; |
| 1207 | |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1208 | typedef FunctionCallbackArguments FCA; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1209 | if (save_at_depth == depth) { |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1210 | __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | // Check the maps in the prototype chain. |
| 1214 | // Traverse the prototype chain from the object and do map checks. |
| 1215 | Handle<JSObject> current = object; |
| 1216 | while (!current.is_identical_to(holder)) { |
| 1217 | ++depth; |
| 1218 | |
| 1219 | // Only global objects and objects that do not require access |
| 1220 | // checks are allowed in stubs. |
| 1221 | ASSERT(current->IsJSGlobalProxy() || !current->IsAccessCheckNeeded()); |
| 1222 | |
| 1223 | Handle<JSObject> prototype(JSObject::cast(current->GetPrototype())); |
| 1224 | if (!current->HasFastProperties() && |
| 1225 | !current->IsJSGlobalObject() && |
| 1226 | !current->IsJSGlobalProxy()) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1227 | if (!name->IsUniqueName()) { |
| 1228 | ASSERT(name->IsString()); |
| 1229 | name = factory()->InternalizeString(Handle<String>::cast(name)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1230 | } |
| 1231 | ASSERT(current->property_dictionary()->FindEntry(*name) == |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1232 | NameDictionary::kNotFound); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1233 | |
| 1234 | GenerateDictionaryNegativeLookup(masm(), miss, reg, name, |
| 1235 | scratch1, scratch2); |
| 1236 | |
| 1237 | __ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 1238 | reg = holder_reg; // From now on the object will be in holder_reg. |
| 1239 | __ ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); |
| 1240 | } else { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1241 | Register map_reg = scratch1; |
| 1242 | if (!current.is_identical_to(first) || check == CHECK_ALL_MAPS) { |
| 1243 | Handle<Map> current_map(current->map()); |
| 1244 | // CheckMap implicitly loads the map of |reg| into |map_reg|. |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1245 | __ CheckMap(reg, map_reg, current_map, miss, DONT_DO_SMI_CHECK); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1246 | } else { |
| 1247 | __ ldr(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); |
| 1248 | } |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1249 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1250 | // Check access rights to the global object. This has to happen after |
| 1251 | // the map check so that we know that the object is actually a global |
| 1252 | // object. |
| 1253 | if (current->IsJSGlobalProxy()) { |
| 1254 | __ CheckAccessGlobalProxy(reg, scratch2, miss); |
| 1255 | } |
| 1256 | reg = holder_reg; // From now on the object will be in holder_reg. |
| 1257 | |
| 1258 | if (heap()->InNewSpace(*prototype)) { |
| 1259 | // The prototype is in new space; we cannot store a reference to it |
| 1260 | // in the code. Load it from the map. |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1261 | __ ldr(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1262 | } else { |
| 1263 | // The prototype is in old space; load it directly. |
| 1264 | __ mov(reg, Operand(prototype)); |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | if (save_at_depth == depth) { |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1269 | __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | // Go to the next object in the prototype chain. |
| 1273 | current = prototype; |
| 1274 | } |
| 1275 | |
| 1276 | // Log the check depth. |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1277 | LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1278 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1279 | if (!holder.is_identical_to(first) || check == CHECK_ALL_MAPS) { |
| 1280 | // Check the holder map. |
| 1281 | __ CheckMap(reg, scratch1, Handle<Map>(holder->map()), miss, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 1282 | DONT_DO_SMI_CHECK); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1283 | } |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1284 | |
| 1285 | // Perform security check for access to the global object. |
| 1286 | ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded()); |
| 1287 | if (holder->IsJSGlobalProxy()) { |
| 1288 | __ CheckAccessGlobalProxy(reg, scratch1, miss); |
| 1289 | } |
| 1290 | |
| 1291 | // If we've skipped any global objects, it's not enough to verify that |
| 1292 | // their maps haven't changed. We also need to check that the property |
| 1293 | // cell for the property is still empty. |
| 1294 | GenerateCheckPropertyCells(masm(), object, holder, name, scratch1, miss); |
| 1295 | |
| 1296 | // Return the register containing the holder. |
| 1297 | return reg; |
| 1298 | } |
| 1299 | |
| 1300 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1301 | void LoadStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) { |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1302 | if (!miss->is_unused()) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1303 | Label success; |
| 1304 | __ b(&success); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1305 | __ bind(miss); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 1306 | TailCallBuiltin(masm(), MissBuiltin(kind())); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1307 | __ bind(&success); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1308 | } |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1309 | } |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1310 | |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1311 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1312 | void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) { |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1313 | if (!miss->is_unused()) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1314 | Label success; |
| 1315 | __ b(&success); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1316 | GenerateRestoreName(masm(), miss, name); |
| 1317 | TailCallBuiltin(masm(), MissBuiltin(kind())); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1318 | __ bind(&success); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1323 | Register LoadStubCompiler::CallbackHandlerFrontend( |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1324 | Handle<Object> object, |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1325 | Register object_reg, |
| 1326 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1327 | Handle<Name> name, |
jkummerow@chromium.org | 2c9426b | 2013-09-05 16:31:13 +0000 | [diff] [blame] | 1328 | Handle<Object> callback) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1329 | Label miss; |
| 1330 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 1331 | Register reg = HandlerFrontendHeader(object, object_reg, holder, name, &miss); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1332 | |
| 1333 | if (!holder->HasFastProperties() && !holder->IsJSGlobalObject()) { |
| 1334 | ASSERT(!reg.is(scratch2())); |
| 1335 | ASSERT(!reg.is(scratch3())); |
| 1336 | ASSERT(!reg.is(scratch4())); |
| 1337 | |
| 1338 | // Load the properties dictionary. |
| 1339 | Register dictionary = scratch4(); |
| 1340 | __ ldr(dictionary, FieldMemOperand(reg, JSObject::kPropertiesOffset)); |
| 1341 | |
| 1342 | // Probe the dictionary. |
| 1343 | Label probe_done; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1344 | NameDictionaryLookupStub::GeneratePositiveLookup(masm(), |
| 1345 | &miss, |
| 1346 | &probe_done, |
| 1347 | dictionary, |
| 1348 | this->name(), |
| 1349 | scratch2(), |
| 1350 | scratch3()); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1351 | __ bind(&probe_done); |
| 1352 | |
| 1353 | // If probing finds an entry in the dictionary, scratch3 contains the |
| 1354 | // pointer into the dictionary. Check that the value is the callback. |
| 1355 | Register pointer = scratch3(); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1356 | const int kElementsStartOffset = NameDictionary::kHeaderSize + |
| 1357 | NameDictionary::kElementsStartIndex * kPointerSize; |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1358 | const int kValueOffset = kElementsStartOffset + kPointerSize; |
| 1359 | __ ldr(scratch2(), FieldMemOperand(pointer, kValueOffset)); |
| 1360 | __ cmp(scratch2(), Operand(callback)); |
| 1361 | __ b(ne, &miss); |
| 1362 | } |
| 1363 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1364 | HandlerFrontendFooter(name, &miss); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1365 | return reg; |
| 1366 | } |
| 1367 | |
| 1368 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1369 | void LoadStubCompiler::GenerateLoadField(Register reg, |
| 1370 | Handle<JSObject> holder, |
| 1371 | PropertyIndex field, |
| 1372 | Representation representation) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1373 | if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 1374 | if (kind() == Code::LOAD_IC) { |
| 1375 | LoadFieldStub stub(field.is_inobject(holder), |
| 1376 | field.translate(holder), |
| 1377 | representation); |
| 1378 | GenerateTailCall(masm(), stub.GetCode(isolate())); |
| 1379 | } else { |
| 1380 | KeyedLoadFieldStub stub(field.is_inobject(holder), |
| 1381 | field.translate(holder), |
| 1382 | representation); |
| 1383 | GenerateTailCall(masm(), stub.GetCode(isolate())); |
| 1384 | } |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1385 | } |
| 1386 | |
| 1387 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1388 | void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1389 | // Return the constant value. |
bmeurer@chromium.org | e94b5ff | 2013-10-25 09:22:31 +0000 | [diff] [blame] | 1390 | __ Move(r0, value); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1391 | __ Ret(); |
| 1392 | } |
| 1393 | |
| 1394 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1395 | void LoadStubCompiler::GenerateLoadCallback( |
jkummerow@chromium.org | 2c9426b | 2013-09-05 16:31:13 +0000 | [diff] [blame] | 1396 | const CallOptimization& call_optimization) { |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 1397 | GenerateFastApiCall( |
| 1398 | masm(), call_optimization, receiver(), scratch3(), 0, NULL); |
jkummerow@chromium.org | 2c9426b | 2013-09-05 16:31:13 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
| 1401 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1402 | void LoadStubCompiler::GenerateLoadCallback( |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1403 | Register reg, |
| 1404 | Handle<ExecutableAccessorInfo> callback) { |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1405 | // Build AccessorInfo::args_ list on the stack and push property name below |
| 1406 | // the exit frame to make GC aware of them and store pointers to them. |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1407 | STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
| 1408 | STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
| 1409 | STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); |
| 1410 | STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); |
| 1411 | STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); |
| 1412 | STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); |
| 1413 | STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1414 | ASSERT(!scratch2().is(reg)); |
| 1415 | ASSERT(!scratch3().is(reg)); |
| 1416 | ASSERT(!scratch4().is(reg)); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1417 | __ push(receiver()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1418 | if (heap()->InNewSpace(callback->data())) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1419 | __ Move(scratch3(), callback); |
| 1420 | __ ldr(scratch3(), FieldMemOperand(scratch3(), |
| 1421 | ExecutableAccessorInfo::kDataOffset)); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1422 | } else { |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1423 | __ Move(scratch3(), Handle<Object>(callback->data(), isolate())); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1424 | } |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1425 | __ push(scratch3()); |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1426 | __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex); |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 1427 | __ mov(scratch4(), scratch3()); |
| 1428 | __ Push(scratch3(), scratch4()); |
svenpanne@chromium.org | 53ad175 | 2013-05-27 12:20:38 +0000 | [diff] [blame] | 1429 | __ mov(scratch4(), |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1430 | Operand(ExternalReference::isolate_address(isolate()))); |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1431 | __ Push(scratch4(), reg); |
| 1432 | __ mov(scratch2(), sp); // scratch2 = PropertyAccessorInfo::args_ |
| 1433 | __ push(name()); |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1434 | __ mov(r0, sp); // r0 = Handle<Name> |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1435 | |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1436 | const int kApiStackSpace = 1; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1437 | FrameScope frame_scope(masm(), StackFrame::MANUAL); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1438 | __ EnterExitFrame(false, kApiStackSpace); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1439 | |
jkummerow@chromium.org | fb7a7c4 | 2013-10-02 11:41:02 +0000 | [diff] [blame] | 1440 | // Create PropertyAccessorInfo instance on the stack above the exit frame with |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1441 | // scratch2 (internal::Object** args_) as the data. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1442 | __ str(scratch2(), MemOperand(sp, 1 * kPointerSize)); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1443 | __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& |
| 1444 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1445 | const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1446 | Address getter_address = v8::ToCData<Address>(callback->getter()); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1447 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1448 | ApiFunction fun(getter_address); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1449 | ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL; |
danno@chromium.org | fe57867 | 2013-06-15 14:38:35 +0000 | [diff] [blame] | 1450 | ExternalReference ref = ExternalReference(&fun, type, isolate()); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1451 | |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1452 | Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1453 | ExternalReference::Type thunk_type = |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1454 | ExternalReference::PROFILING_GETTER_CALL; |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1455 | ApiFunction thunk_fun(thunk_address); |
| 1456 | ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, |
| 1457 | isolate()); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1458 | __ CallApiFunctionAndReturn(ref, |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1459 | getter_address, |
| 1460 | thunk_ref, |
| 1461 | r2, |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1462 | kStackUnwindSpace, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1463 | MemOperand(fp, 6 * kPointerSize), |
| 1464 | NULL); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 1468 | void LoadStubCompiler::GenerateLoadInterceptor( |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1469 | Register holder_reg, |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1470 | Handle<Object> object, |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1471 | Handle<JSObject> interceptor_holder, |
| 1472 | LookupResult* lookup, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1473 | Handle<Name> name) { |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1474 | ASSERT(interceptor_holder->HasNamedInterceptor()); |
| 1475 | ASSERT(!interceptor_holder->GetNamedInterceptor()->getter()->IsUndefined()); |
| 1476 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1477 | // So far the most popular follow ups for interceptor loads are FIELD |
| 1478 | // and CALLBACKS, so inline only them, other cases may be added |
| 1479 | // later. |
| 1480 | bool compile_followup_inline = false; |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 1481 | if (lookup->IsFound() && lookup->IsCacheable()) { |
yangguo@chromium.org | de0db00 | 2012-06-22 13:44:28 +0000 | [diff] [blame] | 1482 | if (lookup->IsField()) { |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1483 | compile_followup_inline = true; |
| 1484 | } else if (lookup->type() == CALLBACKS && |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 1485 | lookup->GetCallbackObject()->IsExecutableAccessorInfo()) { |
| 1486 | ExecutableAccessorInfo* callback = |
| 1487 | ExecutableAccessorInfo::cast(lookup->GetCallbackObject()); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1488 | compile_followup_inline = callback->getter() != NULL && |
| 1489 | callback->IsCompatibleReceiver(*object); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1490 | } |
| 1491 | } |
| 1492 | |
| 1493 | if (compile_followup_inline) { |
| 1494 | // Compile the interceptor call, followed by inline code to load the |
| 1495 | // property from further up the prototype chain if the call fails. |
| 1496 | // Check that the maps haven't changed. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1497 | ASSERT(holder_reg.is(receiver()) || holder_reg.is(scratch1())); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1498 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1499 | // Preserve the receiver register explicitly whenever it is different from |
| 1500 | // the holder and it is needed should the interceptor return without any |
| 1501 | // result. The CALLBACKS case needs the receiver to be passed into C++ code, |
| 1502 | // the FIELD case might cause a miss during the prototype check. |
| 1503 | bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder(); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1504 | bool must_preserve_receiver_reg = !receiver().is(holder_reg) && |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1505 | (lookup->type() == CALLBACKS || must_perfrom_prototype_check); |
| 1506 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1507 | // Save necessary data before invoking an interceptor. |
| 1508 | // Requires a frame to make GC aware of pushed pointers. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1509 | { |
| 1510 | FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1511 | if (must_preserve_receiver_reg) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1512 | __ Push(receiver(), holder_reg, this->name()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1513 | } else { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1514 | __ Push(holder_reg, this->name()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1515 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1516 | // Invoke an interceptor. Note: map checks from receiver to |
| 1517 | // interceptor's holder has been compiled before (see a caller |
| 1518 | // of this method.) |
| 1519 | CompileCallLoadPropertyWithInterceptor(masm(), |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1520 | receiver(), |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1521 | holder_reg, |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1522 | this->name(), |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1523 | interceptor_holder); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1524 | // Check if interceptor provided a value for property. If it's |
| 1525 | // the case, return immediately. |
| 1526 | Label interceptor_failed; |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1527 | __ LoadRoot(scratch1(), Heap::kNoInterceptorResultSentinelRootIndex); |
| 1528 | __ cmp(r0, scratch1()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1529 | __ b(eq, &interceptor_failed); |
| 1530 | frame_scope.GenerateLeaveFrame(); |
| 1531 | __ Ret(); |
| 1532 | |
| 1533 | __ bind(&interceptor_failed); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1534 | __ pop(this->name()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1535 | __ pop(holder_reg); |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1536 | if (must_preserve_receiver_reg) { |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1537 | __ pop(receiver()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1538 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1539 | // Leave the internal frame. |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1540 | } |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1541 | |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1542 | GenerateLoadPostInterceptor(holder_reg, interceptor_holder, name, lookup); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1543 | } else { // !compile_followup_inline |
| 1544 | // Call the runtime system to load the interceptor. |
| 1545 | // Check that the maps haven't changed. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1546 | PushInterceptorArguments(masm(), receiver(), holder_reg, |
| 1547 | this->name(), interceptor_holder); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1548 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1549 | ExternalReference ref = |
| 1550 | ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1551 | isolate()); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 1552 | __ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1553 | } |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1554 | } |
| 1555 | |
| 1556 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1557 | void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) { |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1558 | if (kind_ == Code::KEYED_CALL_IC) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1559 | __ cmp(r2, Operand(name)); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1560 | __ b(ne, miss); |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1565 | void CallStubCompiler::GenerateGlobalReceiverCheck(Handle<JSObject> object, |
| 1566 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1567 | Handle<Name> name, |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1568 | Label* miss) { |
| 1569 | ASSERT(holder->IsGlobalObject()); |
| 1570 | |
| 1571 | // Get the number of arguments. |
| 1572 | const int argc = arguments().immediate(); |
| 1573 | |
| 1574 | // Get the receiver from the stack. |
| 1575 | __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
| 1576 | |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1577 | // Check that the maps haven't changed. |
mstarzinger@chromium.org | 3233d2f | 2012-03-14 11:16:03 +0000 | [diff] [blame] | 1578 | __ JumpIfSmi(r0, miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1579 | CheckPrototypes(object, r0, holder, r3, r1, r4, name, miss); |
| 1580 | } |
| 1581 | |
| 1582 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1583 | void CallStubCompiler::GenerateLoadFunctionFromCell( |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1584 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1585 | Handle<JSFunction> function, |
| 1586 | Label* miss) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1587 | // Get the value from the cell. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1588 | __ mov(r3, Operand(cell)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1589 | __ ldr(r1, FieldMemOperand(r3, Cell::kValueOffset)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1590 | |
| 1591 | // Check that the cell contains the same function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1592 | if (heap()->InNewSpace(*function)) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1593 | // We can't embed a pointer to a function in new space so we have |
| 1594 | // to verify that the shared function info is unchanged. This has |
| 1595 | // the nice side effect that multiple closures based on the same |
| 1596 | // function can all use this call IC. Before we load through the |
| 1597 | // function, we have to verify that it still is a function. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1598 | __ JumpIfSmi(r1, miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1599 | __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE); |
| 1600 | __ b(ne, miss); |
| 1601 | |
| 1602 | // Check the shared function info. Make sure it hasn't changed. |
| 1603 | __ Move(r3, Handle<SharedFunctionInfo>(function->shared())); |
| 1604 | __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 1605 | __ cmp(r4, r3); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1606 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1607 | __ cmp(r1, Operand(function)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1608 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1609 | __ b(ne, miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1610 | } |
| 1611 | |
| 1612 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1613 | void CallStubCompiler::GenerateMissBranch() { |
| 1614 | Handle<Code> code = |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1615 | isolate()->stub_cache()->ComputeCallMiss(arguments().immediate(), |
| 1616 | kind_, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1617 | extra_state_); |
| 1618 | __ Jump(code, RelocInfo::CODE_TARGET); |
| 1619 | } |
| 1620 | |
| 1621 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1622 | Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object, |
| 1623 | Handle<JSObject> holder, |
yangguo@chromium.org | eeb44b6 | 2012-11-13 13:56:09 +0000 | [diff] [blame] | 1624 | PropertyIndex index, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1625 | Handle<Name> name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1626 | // ----------- S t a t e ------------- |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1627 | // -- r2 : name |
| 1628 | // -- lr : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1629 | // ----------------------------------- |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1630 | Label miss; |
| 1631 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1632 | GenerateNameCheck(name, &miss); |
| 1633 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 1634 | const int argc = arguments().immediate(); |
| 1635 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1636 | // Get the receiver of the function from the stack into r0. |
| 1637 | __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1638 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1639 | __ JumpIfSmi(r0, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1640 | |
| 1641 | // Do the right check and compute the holder register. |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1642 | Register reg = CheckPrototypes(object, r0, holder, r1, r3, r4, name, &miss); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1643 | GenerateFastPropertyLoad(masm(), r1, reg, index.is_inobject(holder), |
| 1644 | index.translate(holder), Representation::Tagged()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1645 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1646 | GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1647 | |
| 1648 | // Handle call cache miss. |
| 1649 | __ bind(&miss); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1650 | GenerateMissBranch(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1651 | |
| 1652 | // Return the generated code. |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 1653 | return GetCode(Code::FIELD, name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1657 | Handle<Code> CallStubCompiler::CompileArrayCodeCall( |
| 1658 | Handle<Object> object, |
| 1659 | Handle<JSObject> holder, |
| 1660 | Handle<Cell> cell, |
| 1661 | Handle<JSFunction> function, |
| 1662 | Handle<String> name, |
| 1663 | Code::StubType type) { |
| 1664 | Label miss; |
| 1665 | |
| 1666 | // Check that function is still array |
| 1667 | const int argc = arguments().immediate(); |
| 1668 | GenerateNameCheck(name, &miss); |
| 1669 | Register receiver = r1; |
| 1670 | |
| 1671 | if (cell.is_null()) { |
| 1672 | __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
| 1673 | |
| 1674 | // Check that the receiver isn't a smi. |
| 1675 | __ JumpIfSmi(receiver, &miss); |
| 1676 | |
| 1677 | // Check that the maps haven't changed. |
| 1678 | CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, r3, r0, |
| 1679 | r4, name, &miss); |
| 1680 | } else { |
| 1681 | ASSERT(cell->value() == *function); |
| 1682 | GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, |
| 1683 | &miss); |
| 1684 | GenerateLoadFunctionFromCell(cell, function, &miss); |
| 1685 | } |
| 1686 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1687 | Handle<AllocationSite> site = isolate()->factory()->NewAllocationSite(); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1688 | site->SetElementsKind(GetInitialFastElementsKind()); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1689 | Handle<Cell> site_feedback_cell = isolate()->factory()->NewCell(site); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1690 | __ mov(r0, Operand(argc)); |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 1691 | __ mov(r2, Operand(site_feedback_cell)); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1692 | __ mov(r1, Operand(function)); |
| 1693 | |
| 1694 | ArrayConstructorStub stub(isolate()); |
| 1695 | __ TailCallStub(&stub); |
| 1696 | |
| 1697 | __ bind(&miss); |
| 1698 | GenerateMissBranch(); |
| 1699 | |
| 1700 | // Return the generated code. |
| 1701 | return GetCode(type, name); |
| 1702 | } |
| 1703 | |
| 1704 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1705 | Handle<Code> CallStubCompiler::CompileArrayPushCall( |
| 1706 | Handle<Object> object, |
| 1707 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1708 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1709 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1710 | Handle<String> name, |
| 1711 | Code::StubType type) { |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1712 | // ----------- S t a t e ------------- |
| 1713 | // -- r2 : name |
| 1714 | // -- lr : return address |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1715 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 1716 | // -- ... |
| 1717 | // -- sp[argc * 4] : receiver |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1718 | // ----------------------------------- |
| 1719 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1720 | // If object is not an array or is observed, bail out to regular call. |
| 1721 | if (!object->IsJSArray() || |
| 1722 | !cell.is_null() || |
| 1723 | Handle<JSArray>::cast(object)->map()->is_observed()) { |
| 1724 | return Handle<Code>::null(); |
| 1725 | } |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1726 | |
| 1727 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1728 | GenerateNameCheck(name, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1729 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1730 | Register receiver = r1; |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1731 | // Get the receiver from the stack |
| 1732 | const int argc = arguments().immediate(); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1733 | __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1734 | |
| 1735 | // Check that the receiver isn't a smi. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1736 | __ JumpIfSmi(receiver, &miss); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1737 | |
| 1738 | // Check that the maps haven't changed. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1739 | CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, r3, r0, r4, |
| 1740 | name, &miss); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1741 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1742 | if (argc == 0) { |
| 1743 | // Nothing to do, just return the length. |
| 1744 | __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1745 | __ Drop(argc + 1); |
| 1746 | __ Ret(); |
| 1747 | } else { |
| 1748 | Label call_builtin; |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1749 | |
| 1750 | if (argc == 1) { // Otherwise fall through to call the builtin. |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1751 | Label attempt_to_grow_elements, with_write_barrier, check_double; |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1752 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1753 | Register elements = r6; |
| 1754 | Register end_elements = r5; |
| 1755 | // Get the elements array of the object. |
| 1756 | __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); |
| 1757 | |
| 1758 | // Check that the elements are in fast mode and writable. |
| 1759 | __ CheckMap(elements, |
| 1760 | r0, |
| 1761 | Heap::kFixedArrayMapRootIndex, |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1762 | &check_double, |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1763 | DONT_DO_SMI_CHECK); |
| 1764 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1765 | // Get the array's length into r0 and calculate new length. |
| 1766 | __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1767 | __ add(r0, r0, Operand(Smi::FromInt(argc))); |
| 1768 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1769 | // Get the elements' length. |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1770 | __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
| 1771 | |
| 1772 | // Check if we could survive without allocation. |
| 1773 | __ cmp(r0, r4); |
| 1774 | __ b(gt, &attempt_to_grow_elements); |
| 1775 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1776 | // Check if value is a smi. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1777 | __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); |
| 1778 | __ JumpIfNotSmi(r4, &with_write_barrier); |
| 1779 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1780 | // Save new length. |
| 1781 | __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1782 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1783 | // Store the value. |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1784 | // We may need a register containing the address end_elements below, |
| 1785 | // so write back the value in end_elements. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1786 | __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1787 | const int kEndElementsOffset = |
| 1788 | FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize; |
| 1789 | __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); |
| 1790 | |
| 1791 | // Check for a smi. |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1792 | __ Drop(argc + 1); |
| 1793 | __ Ret(); |
| 1794 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1795 | __ bind(&check_double); |
| 1796 | |
| 1797 | // Check that the elements are in fast mode and writable. |
| 1798 | __ CheckMap(elements, |
| 1799 | r0, |
| 1800 | Heap::kFixedDoubleArrayMapRootIndex, |
| 1801 | &call_builtin, |
| 1802 | DONT_DO_SMI_CHECK); |
| 1803 | |
| 1804 | // Get the array's length into r0 and calculate new length. |
| 1805 | __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1806 | __ add(r0, r0, Operand(Smi::FromInt(argc))); |
| 1807 | |
| 1808 | // Get the elements' length. |
| 1809 | __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
| 1810 | |
| 1811 | // Check if we could survive without allocation. |
| 1812 | __ cmp(r0, r4); |
| 1813 | __ b(gt, &call_builtin); |
| 1814 | |
| 1815 | __ ldr(r4, MemOperand(sp, (argc - 1) * kPointerSize)); |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1816 | __ StoreNumberToDoubleElements(r4, r0, elements, r5, d0, |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1817 | &call_builtin, argc * kDoubleSize); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1818 | |
| 1819 | // Save new length. |
| 1820 | __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1821 | |
| 1822 | // Check for a smi. |
| 1823 | __ Drop(argc + 1); |
| 1824 | __ Ret(); |
| 1825 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1826 | __ bind(&with_write_barrier); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1827 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1828 | __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 1829 | |
| 1830 | if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { |
| 1831 | Label fast_object, not_fast_object; |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1832 | __ CheckFastObjectElements(r3, r9, ¬_fast_object); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1833 | __ jmp(&fast_object); |
| 1834 | // In case of fast smi-only, convert to fast object, otherwise bail out. |
| 1835 | __ bind(¬_fast_object); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1836 | __ CheckFastSmiElements(r3, r9, &call_builtin); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1837 | |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1838 | __ ldr(r9, FieldMemOperand(r4, HeapObject::kMapOffset)); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1839 | __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1840 | __ cmp(r9, ip); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 1841 | __ b(eq, &call_builtin); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1842 | // edx: receiver |
| 1843 | // r3: map |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1844 | Label try_holey_map; |
| 1845 | __ LoadTransitionedArrayMapConditional(FAST_SMI_ELEMENTS, |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1846 | FAST_ELEMENTS, |
| 1847 | r3, |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1848 | r9, |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1849 | &try_holey_map); |
| 1850 | __ mov(r2, receiver); |
| 1851 | ElementsTransitionGenerator:: |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1852 | GenerateMapChangeElementsTransition(masm(), |
| 1853 | DONT_TRACK_ALLOCATION_SITE, |
| 1854 | NULL); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1855 | __ jmp(&fast_object); |
| 1856 | |
| 1857 | __ bind(&try_holey_map); |
| 1858 | __ LoadTransitionedArrayMapConditional(FAST_HOLEY_SMI_ELEMENTS, |
| 1859 | FAST_HOLEY_ELEMENTS, |
| 1860 | r3, |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1861 | r9, |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1862 | &call_builtin); |
| 1863 | __ mov(r2, receiver); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1864 | ElementsTransitionGenerator:: |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1865 | GenerateMapChangeElementsTransition(masm(), |
| 1866 | DONT_TRACK_ALLOCATION_SITE, |
| 1867 | NULL); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1868 | __ bind(&fast_object); |
| 1869 | } else { |
| 1870 | __ CheckFastObjectElements(r3, r3, &call_builtin); |
| 1871 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1872 | |
| 1873 | // Save new length. |
| 1874 | __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 1875 | |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1876 | // Store the value. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1877 | // We may need a register containing the address end_elements below, |
| 1878 | // so write back the value in end_elements. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1879 | __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1880 | __ str(r4, MemOperand(end_elements, kEndElementsOffset, PreIndex)); |
| 1881 | |
| 1882 | __ RecordWrite(elements, |
| 1883 | end_elements, |
| 1884 | r4, |
| 1885 | kLRHasNotBeenSaved, |
| 1886 | kDontSaveFPRegs, |
| 1887 | EMIT_REMEMBERED_SET, |
| 1888 | OMIT_SMI_CHECK); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1889 | __ Drop(argc + 1); |
| 1890 | __ Ret(); |
| 1891 | |
| 1892 | __ bind(&attempt_to_grow_elements); |
| 1893 | // r0: array's length + 1. |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1894 | |
| 1895 | if (!FLAG_inline_new) { |
| 1896 | __ b(&call_builtin); |
| 1897 | } |
| 1898 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1899 | __ ldr(r2, MemOperand(sp, (argc - 1) * kPointerSize)); |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 1900 | // Growing elements that are SMI-only requires special handling in case |
| 1901 | // the new element is non-Smi. For now, delegate to the builtin. |
| 1902 | Label no_fast_elements_check; |
| 1903 | __ JumpIfSmi(r2, &no_fast_elements_check); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1904 | __ ldr(r9, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 1905 | __ CheckFastObjectElements(r9, r9, &call_builtin); |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 1906 | __ bind(&no_fast_elements_check); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1907 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1908 | ExternalReference new_space_allocation_top = |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1909 | ExternalReference::new_space_allocation_top_address(isolate()); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1910 | ExternalReference new_space_allocation_limit = |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1911 | ExternalReference::new_space_allocation_limit_address(isolate()); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1912 | |
| 1913 | const int kAllocationDelta = 4; |
| 1914 | // Load top and check if it is the end of elements. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1915 | __ add(end_elements, elements, Operand::PointerOffsetFromSmiKey(r0)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1916 | __ add(end_elements, end_elements, Operand(kEndElementsOffset)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1917 | __ mov(r4, Operand(new_space_allocation_top)); |
| 1918 | __ ldr(r3, MemOperand(r4)); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1919 | __ cmp(end_elements, r3); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1920 | __ b(ne, &call_builtin); |
| 1921 | |
| 1922 | __ mov(r9, Operand(new_space_allocation_limit)); |
| 1923 | __ ldr(r9, MemOperand(r9)); |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1924 | __ add(r3, r3, Operand(kAllocationDelta * kPointerSize)); |
| 1925 | __ cmp(r3, r9); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1926 | __ b(hi, &call_builtin); |
| 1927 | |
| 1928 | // We fit and could grow elements. |
| 1929 | // Update new_space_allocation_top. |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1930 | __ str(r3, MemOperand(r4)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1931 | // Push the argument. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1932 | __ str(r2, MemOperand(end_elements)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1933 | // Fill the rest with holes. |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1934 | __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1935 | for (int i = 1; i < kAllocationDelta; i++) { |
yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1936 | __ str(r3, MemOperand(end_elements, i * kPointerSize)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1937 | } |
| 1938 | |
| 1939 | // Update elements' and array's sizes. |
| 1940 | __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 1941 | __ ldr(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1942 | __ add(r4, r4, Operand(Smi::FromInt(kAllocationDelta))); |
| 1943 | __ str(r4, FieldMemOperand(elements, FixedArray::kLengthOffset)); |
| 1944 | |
| 1945 | // Elements are in new space, so write barrier is not required. |
| 1946 | __ Drop(argc + 1); |
| 1947 | __ Ret(); |
| 1948 | } |
| 1949 | __ bind(&call_builtin); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 1950 | __ TailCallExternalReference( |
| 1951 | ExternalReference(Builtins::c_ArrayPush, isolate()), argc + 1, 1); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1952 | } |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1953 | |
| 1954 | // Handle call cache miss. |
| 1955 | __ bind(&miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1956 | GenerateMissBranch(); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1957 | |
| 1958 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1959 | return GetCode(type, name); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1960 | } |
| 1961 | |
| 1962 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1963 | Handle<Code> CallStubCompiler::CompileArrayPopCall( |
| 1964 | Handle<Object> object, |
| 1965 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1966 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1967 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1968 | Handle<String> name, |
| 1969 | Code::StubType type) { |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1970 | // ----------- S t a t e ------------- |
| 1971 | // -- r2 : name |
| 1972 | // -- lr : return address |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1973 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 1974 | // -- ... |
| 1975 | // -- sp[argc * 4] : receiver |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1976 | // ----------------------------------- |
| 1977 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 1978 | // If object is not an array or is observed, bail out to regular call. |
| 1979 | if (!object->IsJSArray() || |
| 1980 | !cell.is_null() || |
| 1981 | Handle<JSArray>::cast(object)->map()->is_observed()) { |
| 1982 | return Handle<Code>::null(); |
| 1983 | } |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1984 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1985 | Label miss, return_undefined, call_builtin; |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1986 | Register receiver = r1; |
| 1987 | Register elements = r3; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1988 | GenerateNameCheck(name, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 1989 | |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1990 | // Get the receiver from the stack |
| 1991 | const int argc = arguments().immediate(); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1992 | __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1993 | // Check that the receiver isn't a smi. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1994 | __ JumpIfSmi(receiver, &miss); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1995 | |
| 1996 | // Check that the maps haven't changed. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1997 | CheckPrototypes(Handle<JSObject>::cast(object), receiver, holder, elements, |
| 1998 | r4, r0, name, &miss); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1999 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 2000 | // Get the elements array of the object. |
| 2001 | __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); |
| 2002 | |
| 2003 | // Check that the elements are in fast mode and writable. |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2004 | __ CheckMap(elements, |
| 2005 | r0, |
| 2006 | Heap::kFixedArrayMapRootIndex, |
| 2007 | &call_builtin, |
| 2008 | DONT_DO_SMI_CHECK); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 2009 | |
| 2010 | // Get the array's length into r4 and calculate new length. |
| 2011 | __ ldr(r4, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 2012 | __ sub(r4, r4, Operand(Smi::FromInt(1)), SetCC); |
| 2013 | __ b(lt, &return_undefined); |
| 2014 | |
| 2015 | // Get the last element. |
| 2016 | __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 2017 | // We can't address the last element in one operation. Compute the more |
| 2018 | // expensive shift first, and use an offset later on. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2019 | __ add(elements, elements, Operand::PointerOffsetFromSmiKey(r4)); |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 2020 | __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 2021 | __ cmp(r0, r6); |
| 2022 | __ b(eq, &call_builtin); |
| 2023 | |
| 2024 | // Set the array's length. |
| 2025 | __ str(r4, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 2026 | |
| 2027 | // Fill with the hole. |
fschneider@chromium.org | 7d10be5 | 2012-04-10 12:30:14 +0000 | [diff] [blame] | 2028 | __ str(r6, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 2029 | __ Drop(argc + 1); |
| 2030 | __ Ret(); |
| 2031 | |
| 2032 | __ bind(&return_undefined); |
| 2033 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 2034 | __ Drop(argc + 1); |
| 2035 | __ Ret(); |
| 2036 | |
| 2037 | __ bind(&call_builtin); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2038 | __ TailCallExternalReference( |
| 2039 | ExternalReference(Builtins::c_ArrayPop, isolate()), argc + 1, 1); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 2040 | |
| 2041 | // Handle call cache miss. |
| 2042 | __ bind(&miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2043 | GenerateMissBranch(); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 2044 | |
| 2045 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2046 | return GetCode(type, name); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2050 | Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall( |
| 2051 | Handle<Object> object, |
| 2052 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2053 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2054 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2055 | Handle<String> name, |
| 2056 | Code::StubType type) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2057 | // ----------- S t a t e ------------- |
| 2058 | // -- r2 : function name |
| 2059 | // -- lr : return address |
| 2060 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 2061 | // -- ... |
| 2062 | // -- sp[argc * 4] : receiver |
| 2063 | // ----------------------------------- |
| 2064 | |
| 2065 | // If object is not a string, bail out to regular call. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2066 | if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2067 | |
| 2068 | const int argc = arguments().immediate(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2069 | Label miss; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2070 | Label name_miss; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2071 | Label index_out_of_range; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2072 | Label* index_out_of_range_label = &index_out_of_range; |
| 2073 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2074 | if (kind_ == Code::CALL_IC && |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2075 | (CallICBase::StringStubState::decode(extra_state_) == |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2076 | DEFAULT_STRING_STUB)) { |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2077 | index_out_of_range_label = &miss; |
| 2078 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2079 | GenerateNameCheck(name, &name_miss); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2080 | |
| 2081 | // Check that the maps starting from the prototype haven't changed. |
| 2082 | GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 2083 | Context::STRING_FUNCTION_INDEX, |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 2084 | r0, |
| 2085 | &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2086 | ASSERT(!object.is_identical_to(holder)); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2087 | CheckPrototypes( |
| 2088 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
| 2089 | r0, holder, r1, r3, r4, name, &miss); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2090 | |
| 2091 | Register receiver = r1; |
| 2092 | Register index = r4; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2093 | Register result = r0; |
| 2094 | __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
| 2095 | if (argc > 0) { |
| 2096 | __ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize)); |
| 2097 | } else { |
| 2098 | __ LoadRoot(index, Heap::kUndefinedValueRootIndex); |
| 2099 | } |
| 2100 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2101 | StringCharCodeAtGenerator generator(receiver, |
| 2102 | index, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2103 | result, |
| 2104 | &miss, // When not a string. |
| 2105 | &miss, // When not a number. |
| 2106 | index_out_of_range_label, |
| 2107 | STRING_INDEX_IS_NUMBER); |
| 2108 | generator.GenerateFast(masm()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2109 | __ Drop(argc + 1); |
| 2110 | __ Ret(); |
| 2111 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2112 | StubRuntimeCallHelper call_helper; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2113 | generator.GenerateSlow(masm(), call_helper); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2114 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2115 | if (index_out_of_range.is_linked()) { |
| 2116 | __ bind(&index_out_of_range); |
| 2117 | __ LoadRoot(r0, Heap::kNanValueRootIndex); |
| 2118 | __ Drop(argc + 1); |
| 2119 | __ Ret(); |
| 2120 | } |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2121 | |
| 2122 | __ bind(&miss); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2123 | // Restore function name in r2. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2124 | __ Move(r2, name); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2125 | __ bind(&name_miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2126 | GenerateMissBranch(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2127 | |
| 2128 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2129 | return GetCode(type, name); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 2130 | } |
| 2131 | |
| 2132 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2133 | Handle<Code> CallStubCompiler::CompileStringCharAtCall( |
| 2134 | Handle<Object> object, |
| 2135 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2136 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2137 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2138 | Handle<String> name, |
| 2139 | Code::StubType type) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2140 | // ----------- S t a t e ------------- |
| 2141 | // -- r2 : function name |
| 2142 | // -- lr : return address |
| 2143 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 2144 | // -- ... |
| 2145 | // -- sp[argc * 4] : receiver |
| 2146 | // ----------------------------------- |
| 2147 | |
| 2148 | // If object is not a string, bail out to regular call. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2149 | if (!object->IsString() || !cell.is_null()) return Handle<Code>::null(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2150 | |
| 2151 | const int argc = arguments().immediate(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2152 | Label miss; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2153 | Label name_miss; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2154 | Label index_out_of_range; |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2155 | Label* index_out_of_range_label = &index_out_of_range; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2156 | if (kind_ == Code::CALL_IC && |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2157 | (CallICBase::StringStubState::decode(extra_state_) == |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2158 | DEFAULT_STRING_STUB)) { |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2159 | index_out_of_range_label = &miss; |
| 2160 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2161 | GenerateNameCheck(name, &name_miss); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2162 | |
| 2163 | // Check that the maps starting from the prototype haven't changed. |
| 2164 | GenerateDirectLoadGlobalFunctionPrototype(masm(), |
| 2165 | Context::STRING_FUNCTION_INDEX, |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 2166 | r0, |
| 2167 | &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2168 | ASSERT(!object.is_identical_to(holder)); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2169 | CheckPrototypes( |
| 2170 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
| 2171 | r0, holder, r1, r3, r4, name, &miss); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2172 | |
| 2173 | Register receiver = r0; |
| 2174 | Register index = r4; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2175 | Register scratch = r3; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2176 | Register result = r0; |
| 2177 | __ ldr(receiver, MemOperand(sp, argc * kPointerSize)); |
| 2178 | if (argc > 0) { |
| 2179 | __ ldr(index, MemOperand(sp, (argc - 1) * kPointerSize)); |
| 2180 | } else { |
| 2181 | __ LoadRoot(index, Heap::kUndefinedValueRootIndex); |
| 2182 | } |
| 2183 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2184 | StringCharAtGenerator generator(receiver, |
| 2185 | index, |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2186 | scratch, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2187 | result, |
| 2188 | &miss, // When not a string. |
| 2189 | &miss, // When not a number. |
| 2190 | index_out_of_range_label, |
| 2191 | STRING_INDEX_IS_NUMBER); |
| 2192 | generator.GenerateFast(masm()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2193 | __ Drop(argc + 1); |
| 2194 | __ Ret(); |
| 2195 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2196 | StubRuntimeCallHelper call_helper; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2197 | generator.GenerateSlow(masm(), call_helper); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2198 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2199 | if (index_out_of_range.is_linked()) { |
| 2200 | __ bind(&index_out_of_range); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2201 | __ LoadRoot(r0, Heap::kempty_stringRootIndex); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2202 | __ Drop(argc + 1); |
| 2203 | __ Ret(); |
| 2204 | } |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2205 | |
| 2206 | __ bind(&miss); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2207 | // Restore function name in r2. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2208 | __ Move(r2, name); |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2209 | __ bind(&name_miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2210 | GenerateMissBranch(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2211 | |
| 2212 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2213 | return GetCode(type, name); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 2214 | } |
| 2215 | |
| 2216 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2217 | Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall( |
| 2218 | Handle<Object> object, |
| 2219 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2220 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2221 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2222 | Handle<String> name, |
| 2223 | Code::StubType type) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2224 | // ----------- S t a t e ------------- |
| 2225 | // -- r2 : function name |
| 2226 | // -- lr : return address |
| 2227 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 2228 | // -- ... |
| 2229 | // -- sp[argc * 4] : receiver |
| 2230 | // ----------------------------------- |
| 2231 | |
| 2232 | const int argc = arguments().immediate(); |
| 2233 | |
| 2234 | // If the object is not a JSObject or we got an unexpected number of |
| 2235 | // arguments, bail out to the regular call. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2236 | if (!object->IsJSObject() || argc != 1) return Handle<Code>::null(); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2237 | |
| 2238 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2239 | GenerateNameCheck(name, &miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2240 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2241 | if (cell.is_null()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2242 | __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
| 2243 | |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2244 | __ JumpIfSmi(r1, &miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2245 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2246 | CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, |
| 2247 | name, &miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2248 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2249 | ASSERT(cell->value() == *function); |
| 2250 | GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, |
| 2251 | &miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2252 | GenerateLoadFunctionFromCell(cell, function, &miss); |
| 2253 | } |
| 2254 | |
| 2255 | // Load the char code argument. |
| 2256 | Register code = r1; |
| 2257 | __ ldr(code, MemOperand(sp, 0 * kPointerSize)); |
| 2258 | |
| 2259 | // Check the code is a smi. |
| 2260 | Label slow; |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2261 | __ JumpIfNotSmi(code, &slow); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2262 | |
| 2263 | // Convert the smi code to uint16. |
| 2264 | __ and_(code, code, Operand(Smi::FromInt(0xffff))); |
| 2265 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2266 | StringCharFromCodeGenerator generator(code, r0); |
| 2267 | generator.GenerateFast(masm()); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2268 | __ Drop(argc + 1); |
| 2269 | __ Ret(); |
| 2270 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2271 | StubRuntimeCallHelper call_helper; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2272 | generator.GenerateSlow(masm(), call_helper); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2273 | |
| 2274 | // Tail call the full function. We do not have to patch the receiver |
| 2275 | // because the function makes no use of it. |
| 2276 | __ bind(&slow); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2277 | ParameterCount expected(function); |
| 2278 | __ InvokeFunction(function, expected, arguments(), |
| 2279 | JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2280 | |
| 2281 | __ bind(&miss); |
| 2282 | // r2: function name. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2283 | GenerateMissBranch(); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2284 | |
| 2285 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2286 | return GetCode(type, name); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2287 | } |
| 2288 | |
| 2289 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2290 | Handle<Code> CallStubCompiler::CompileMathFloorCall( |
| 2291 | Handle<Object> object, |
| 2292 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2293 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2294 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2295 | Handle<String> name, |
| 2296 | Code::StubType type) { |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2297 | // ----------- S t a t e ------------- |
| 2298 | // -- r2 : function name |
| 2299 | // -- lr : return address |
| 2300 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 2301 | // -- ... |
| 2302 | // -- sp[argc * 4] : receiver |
| 2303 | // ----------------------------------- |
| 2304 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2305 | const int argc = arguments().immediate(); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2306 | // If the object is not a JSObject or we got an unexpected number of |
| 2307 | // arguments, bail out to the regular call. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2308 | if (!object->IsJSObject() || argc != 1) return Handle<Code>::null(); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2309 | |
| 2310 | Label miss, slow; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2311 | GenerateNameCheck(name, &miss); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2312 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2313 | if (cell.is_null()) { |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2314 | __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2315 | __ JumpIfSmi(r1, &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2316 | CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, |
| 2317 | name, &miss); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2318 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2319 | ASSERT(cell->value() == *function); |
| 2320 | GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, |
| 2321 | &miss); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2322 | GenerateLoadFunctionFromCell(cell, function, &miss); |
| 2323 | } |
| 2324 | |
| 2325 | // Load the (only) argument into r0. |
| 2326 | __ ldr(r0, MemOperand(sp, 0 * kPointerSize)); |
| 2327 | |
| 2328 | // If the argument is a smi, just return. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2329 | __ SmiTst(r0); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2330 | __ Drop(argc + 1, eq); |
| 2331 | __ Ret(eq); |
| 2332 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2333 | __ CheckMap(r0, r1, Heap::kHeapNumberMapRootIndex, &slow, DONT_DO_SMI_CHECK); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2334 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2335 | Label smi_check, just_return; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2336 | |
| 2337 | // Load the HeapNumber value. |
| 2338 | // We will need access to the value in the core registers, so we load it |
| 2339 | // with ldrd and move it to the fpu. It also spares a sub instruction for |
| 2340 | // updating the HeapNumber value address, as vldr expects a multiple |
| 2341 | // of 4 offset. |
| 2342 | __ Ldrd(r4, r5, FieldMemOperand(r0, HeapNumber::kValueOffset)); |
| 2343 | __ vmov(d1, r4, r5); |
| 2344 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2345 | // Check for NaN, Infinities and -0. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2346 | // They are invariant through a Math.Floor call, so just |
| 2347 | // return the original argument. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2348 | __ Sbfx(r3, r5, HeapNumber::kExponentShift, HeapNumber::kExponentBits); |
| 2349 | __ cmp(r3, Operand(-1)); |
| 2350 | __ b(eq, &just_return); |
| 2351 | __ eor(r3, r5, Operand(0x80000000u)); |
| 2352 | __ orr(r3, r3, r4, SetCC); |
| 2353 | __ b(eq, &just_return); |
| 2354 | // Test for values that can be exactly represented as a |
| 2355 | // signed 32-bit integer. |
| 2356 | __ TryDoubleToInt32Exact(r0, d1, d2); |
| 2357 | // If exact, check smi |
| 2358 | __ b(eq, &smi_check); |
| 2359 | __ cmp(r5, Operand(0)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2360 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2361 | // If input is in ]+0, +inf[, the cmp has cleared overflow and negative |
| 2362 | // (V=0 and N=0), the two following instructions won't execute and |
| 2363 | // we fall through smi_check to check if the result can fit into a smi. |
| 2364 | |
| 2365 | // If input is in ]-inf, -0[, sub one and, go to slow if we have |
| 2366 | // an overflow. Else we fall through smi check. |
| 2367 | // Hint: if x is a negative, non integer number, |
| 2368 | // floor(x) <=> round_to_zero(x) - 1. |
| 2369 | __ sub(r0, r0, Operand(1), SetCC, mi); |
| 2370 | __ b(vs, &slow); |
| 2371 | |
| 2372 | __ bind(&smi_check); |
| 2373 | // Check if the result can fit into an smi. If we had an overflow, |
| 2374 | // the result is either 0x80000000 or 0x7FFFFFFF and won't fit into an smi. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2375 | // If result doesn't fit into an smi, branch to slow. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2376 | __ SmiTag(r0, SetCC); |
| 2377 | __ b(vs, &slow); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2378 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2379 | __ bind(&just_return); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2380 | __ Drop(argc + 1); |
| 2381 | __ Ret(); |
| 2382 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2383 | __ bind(&slow); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2384 | // Tail call the full function. We do not have to patch the receiver |
| 2385 | // because the function makes no use of it. |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2386 | ParameterCount expected(function); |
| 2387 | __ InvokeFunction(function, expected, arguments(), |
| 2388 | JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2389 | |
| 2390 | __ bind(&miss); |
| 2391 | // r2: function name. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2392 | GenerateMissBranch(); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2393 | |
| 2394 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2395 | return GetCode(type, name); |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 2396 | } |
| 2397 | |
| 2398 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2399 | Handle<Code> CallStubCompiler::CompileMathAbsCall( |
| 2400 | Handle<Object> object, |
| 2401 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2402 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2403 | Handle<JSFunction> function, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2404 | Handle<String> name, |
| 2405 | Code::StubType type) { |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2406 | // ----------- S t a t e ------------- |
| 2407 | // -- r2 : function name |
| 2408 | // -- lr : return address |
| 2409 | // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) |
| 2410 | // -- ... |
| 2411 | // -- sp[argc * 4] : receiver |
| 2412 | // ----------------------------------- |
| 2413 | |
| 2414 | const int argc = arguments().immediate(); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2415 | // If the object is not a JSObject or we got an unexpected number of |
| 2416 | // arguments, bail out to the regular call. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2417 | if (!object->IsJSObject() || argc != 1) return Handle<Code>::null(); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2418 | |
| 2419 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2420 | GenerateNameCheck(name, &miss); |
| 2421 | if (cell.is_null()) { |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2422 | __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2423 | __ JumpIfSmi(r1, &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2424 | CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, |
| 2425 | name, &miss); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2426 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2427 | ASSERT(cell->value() == *function); |
| 2428 | GenerateGlobalReceiverCheck(Handle<JSObject>::cast(object), holder, name, |
| 2429 | &miss); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2430 | GenerateLoadFunctionFromCell(cell, function, &miss); |
| 2431 | } |
| 2432 | |
| 2433 | // Load the (only) argument into r0. |
| 2434 | __ ldr(r0, MemOperand(sp, 0 * kPointerSize)); |
| 2435 | |
| 2436 | // Check if the argument is a smi. |
| 2437 | Label not_smi; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2438 | __ JumpIfNotSmi(r0, ¬_smi); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2439 | |
| 2440 | // Do bitwise not or do nothing depending on the sign of the |
| 2441 | // argument. |
| 2442 | __ eor(r1, r0, Operand(r0, ASR, kBitsPerInt - 1)); |
| 2443 | |
| 2444 | // Add 1 or do nothing depending on the sign of the argument. |
| 2445 | __ sub(r0, r1, Operand(r0, ASR, kBitsPerInt - 1), SetCC); |
| 2446 | |
| 2447 | // If the result is still negative, go to the slow case. |
| 2448 | // This only happens for the most negative smi. |
| 2449 | Label slow; |
| 2450 | __ b(mi, &slow); |
| 2451 | |
| 2452 | // Smi case done. |
| 2453 | __ Drop(argc + 1); |
| 2454 | __ Ret(); |
| 2455 | |
| 2456 | // Check if the argument is a heap number and load its exponent and |
| 2457 | // sign. |
| 2458 | __ bind(¬_smi); |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 2459 | __ CheckMap(r0, r1, Heap::kHeapNumberMapRootIndex, &slow, DONT_DO_SMI_CHECK); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2460 | __ ldr(r1, FieldMemOperand(r0, HeapNumber::kExponentOffset)); |
| 2461 | |
| 2462 | // Check the sign of the argument. If the argument is positive, |
| 2463 | // just return it. |
| 2464 | Label negative_sign; |
| 2465 | __ tst(r1, Operand(HeapNumber::kSignMask)); |
| 2466 | __ b(ne, &negative_sign); |
| 2467 | __ Drop(argc + 1); |
| 2468 | __ Ret(); |
| 2469 | |
| 2470 | // If the argument is negative, clear the sign, and return a new |
| 2471 | // number. |
| 2472 | __ bind(&negative_sign); |
| 2473 | __ eor(r1, r1, Operand(HeapNumber::kSignMask)); |
| 2474 | __ ldr(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); |
| 2475 | __ LoadRoot(r6, Heap::kHeapNumberMapRootIndex); |
| 2476 | __ AllocateHeapNumber(r0, r4, r5, r6, &slow); |
| 2477 | __ str(r1, FieldMemOperand(r0, HeapNumber::kExponentOffset)); |
| 2478 | __ str(r3, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); |
| 2479 | __ Drop(argc + 1); |
| 2480 | __ Ret(); |
| 2481 | |
| 2482 | // Tail call the full function. We do not have to patch the receiver |
| 2483 | // because the function makes no use of it. |
| 2484 | __ bind(&slow); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2485 | ParameterCount expected(function); |
| 2486 | __ InvokeFunction(function, expected, arguments(), |
| 2487 | JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2488 | |
| 2489 | __ bind(&miss); |
| 2490 | // r2: function name. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2491 | GenerateMissBranch(); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2492 | |
| 2493 | // Return the generated code. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2494 | return GetCode(type, name); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2495 | } |
| 2496 | |
| 2497 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2498 | Handle<Code> CallStubCompiler::CompileFastApiCall( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2499 | const CallOptimization& optimization, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2500 | Handle<Object> object, |
| 2501 | Handle<JSObject> holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2502 | Handle<Cell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2503 | Handle<JSFunction> function, |
| 2504 | Handle<String> name) { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2505 | Counters* counters = isolate()->counters(); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2506 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2507 | ASSERT(optimization.is_simple_api_call()); |
| 2508 | // Bail out if object is a global object as we don't want to |
| 2509 | // repatch it to global receiver. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2510 | if (object->IsGlobalObject()) return Handle<Code>::null(); |
| 2511 | if (!cell.is_null()) return Handle<Code>::null(); |
| 2512 | if (!object->IsJSObject()) return Handle<Code>::null(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2513 | int depth = optimization.GetPrototypeDepthOfExpectedType( |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2514 | Handle<JSObject>::cast(object), holder); |
| 2515 | if (depth == kInvalidProtoDepth) return Handle<Code>::null(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2516 | |
| 2517 | Label miss, miss_before_stack_reserved; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2518 | GenerateNameCheck(name, &miss_before_stack_reserved); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2519 | |
| 2520 | // Get the receiver from the stack. |
| 2521 | const int argc = arguments().immediate(); |
| 2522 | __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 2523 | |
| 2524 | // Check that the receiver isn't a smi. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2525 | __ JumpIfSmi(r1, &miss_before_stack_reserved); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2526 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2527 | __ IncrementCounter(counters->call_const(), 1, r0, r3); |
| 2528 | __ IncrementCounter(counters->call_const_fast_api(), 1, r0, r3); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2529 | |
| 2530 | ReserveSpaceForFastApiCall(masm(), r0); |
| 2531 | |
| 2532 | // Check that the maps haven't changed and find a Holder as a side effect. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2533 | CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, name, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2534 | depth, &miss); |
| 2535 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 2536 | GenerateFastApiDirectCall(masm(), optimization, argc, false); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2537 | |
| 2538 | __ bind(&miss); |
| 2539 | FreeSpaceForFastApiCall(masm()); |
| 2540 | |
| 2541 | __ bind(&miss_before_stack_reserved); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2542 | GenerateMissBranch(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2543 | |
| 2544 | // Return the generated code. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2545 | return GetCode(function); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2546 | } |
| 2547 | |
| 2548 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2549 | void StubCompiler::GenerateBooleanCheck(Register object, Label* miss) { |
| 2550 | Label success; |
| 2551 | // Check that the object is a boolean. |
| 2552 | __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 2553 | __ cmp(object, ip); |
| 2554 | __ b(eq, &success); |
| 2555 | __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
| 2556 | __ cmp(object, ip); |
| 2557 | __ b(ne, miss); |
| 2558 | __ bind(&success); |
| 2559 | } |
| 2560 | |
| 2561 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2562 | void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object, |
| 2563 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2564 | Handle<Name> name, |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2565 | CheckType check) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2566 | // ----------- S t a t e ------------- |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2567 | // -- r2 : name |
| 2568 | // -- lr : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2569 | // ----------------------------------- |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2570 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2571 | GenerateNameCheck(name, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2572 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 2573 | // Get the receiver from the stack |
| 2574 | const int argc = arguments().immediate(); |
| 2575 | __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 2576 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2577 | // Check that the receiver isn't a smi. |
| 2578 | if (check != NUMBER_CHECK) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2579 | __ JumpIfSmi(r1, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2580 | } |
| 2581 | |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 2582 | // Make sure that it's okay not to patch the on stack receiver |
| 2583 | // unless we're doing a receiver map check. |
| 2584 | ASSERT(!object->IsGlobalObject() || check == RECEIVER_MAP_CHECK); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2585 | switch (check) { |
| 2586 | case RECEIVER_MAP_CHECK: |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2587 | __ IncrementCounter(isolate()->counters()->call_const(), 1, r0, r3); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 2588 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2589 | // Check that the maps haven't changed. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2590 | CheckPrototypes(Handle<JSObject>::cast(object), r1, holder, r0, r3, r4, |
| 2591 | name, &miss); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 2592 | |
| 2593 | // Patch the receiver on the stack with the global proxy if |
| 2594 | // necessary. |
| 2595 | if (object->IsGlobalObject()) { |
| 2596 | __ ldr(r3, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); |
| 2597 | __ str(r3, MemOperand(sp, argc * kPointerSize)); |
| 2598 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2599 | break; |
| 2600 | |
| 2601 | case STRING_CHECK: |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2602 | // Check that the object is a string. |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2603 | __ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE); |
| 2604 | __ b(ge, &miss); |
| 2605 | // Check that the maps starting from the prototype haven't changed. |
| 2606 | GenerateDirectLoadGlobalFunctionPrototype( |
| 2607 | masm(), Context::STRING_FUNCTION_INDEX, r0, &miss); |
| 2608 | CheckPrototypes( |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2609 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2610 | r0, holder, r3, r1, r4, name, &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2611 | break; |
| 2612 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2613 | case SYMBOL_CHECK: |
| 2614 | // Check that the object is a symbol. |
| 2615 | __ CompareObjectType(r1, r1, r3, SYMBOL_TYPE); |
| 2616 | __ b(ne, &miss); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 2617 | // Check that the maps starting from the prototype haven't changed. |
| 2618 | GenerateDirectLoadGlobalFunctionPrototype( |
| 2619 | masm(), Context::SYMBOL_FUNCTION_INDEX, r0, &miss); |
| 2620 | CheckPrototypes( |
| 2621 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
| 2622 | r0, holder, r3, r1, r4, name, &miss); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 2623 | break; |
| 2624 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2625 | case NUMBER_CHECK: { |
| 2626 | Label fast; |
| 2627 | // Check that the object is a smi or a heap number. |
| 2628 | __ JumpIfSmi(r1, &fast); |
| 2629 | __ CompareObjectType(r1, r0, r0, HEAP_NUMBER_TYPE); |
| 2630 | __ b(ne, &miss); |
| 2631 | __ bind(&fast); |
| 2632 | // Check that the maps starting from the prototype haven't changed. |
| 2633 | GenerateDirectLoadGlobalFunctionPrototype( |
| 2634 | masm(), Context::NUMBER_FUNCTION_INDEX, r0, &miss); |
| 2635 | CheckPrototypes( |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2636 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2637 | r0, holder, r3, r1, r4, name, &miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2638 | break; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2639 | } |
| 2640 | case BOOLEAN_CHECK: { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2641 | GenerateBooleanCheck(r1, &miss); |
| 2642 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2643 | // Check that the maps starting from the prototype haven't changed. |
| 2644 | GenerateDirectLoadGlobalFunctionPrototype( |
| 2645 | masm(), Context::BOOLEAN_FUNCTION_INDEX, r0, &miss); |
| 2646 | CheckPrototypes( |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2647 | Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate()))), |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2648 | r0, holder, r3, r1, r4, name, &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2649 | break; |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2650 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2651 | } |
| 2652 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2653 | Label success; |
| 2654 | __ b(&success); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2655 | |
| 2656 | // Handle call cache miss. |
| 2657 | __ bind(&miss); |
| 2658 | GenerateMissBranch(); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2659 | |
| 2660 | __ bind(&success); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2661 | } |
| 2662 | |
| 2663 | |
| 2664 | void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2665 | CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2666 | ? CALL_AS_FUNCTION |
| 2667 | : CALL_AS_METHOD; |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2668 | ParameterCount expected(function); |
| 2669 | __ InvokeFunction(function, expected, arguments(), |
| 2670 | JUMP_FUNCTION, NullCallWrapper(), call_kind); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2671 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2672 | |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2673 | |
| 2674 | Handle<Code> CallStubCompiler::CompileCallConstant( |
| 2675 | Handle<Object> object, |
| 2676 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2677 | Handle<Name> name, |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2678 | CheckType check, |
| 2679 | Handle<JSFunction> function) { |
| 2680 | if (HasCustomCallGenerator(function)) { |
| 2681 | Handle<Code> code = CompileCustomCall(object, holder, |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2682 | Handle<Cell>::null(), |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2683 | function, Handle<String>::cast(name), |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 2684 | Code::CONSTANT); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2685 | // A null handle means bail out to the regular compiler code below. |
| 2686 | if (!code.is_null()) return code; |
| 2687 | } |
| 2688 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2689 | CompileHandlerFrontend(object, holder, name, check); |
mmassi@chromium.org | 2f0efde | 2013-02-06 14:12:58 +0000 | [diff] [blame] | 2690 | CompileHandlerBackend(function); |
| 2691 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2692 | // Return the generated code. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2693 | return GetCode(function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2694 | } |
| 2695 | |
| 2696 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2697 | Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
| 2698 | Handle<JSObject> holder, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2699 | Handle<Name> name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2700 | // ----------- S t a t e ------------- |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2701 | // -- r2 : name |
| 2702 | // -- lr : return address |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2703 | // ----------------------------------- |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 2704 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2705 | GenerateNameCheck(name, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2706 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2707 | // Get the number of arguments. |
| 2708 | const int argc = arguments().immediate(); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2709 | LookupResult lookup(isolate()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2710 | LookupPostInterceptor(holder, name, &lookup); |
| 2711 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 2712 | // Get the receiver from the stack. |
| 2713 | __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2714 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2715 | CallInterceptorCompiler compiler(this, arguments(), r2, extra_state_); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2716 | compiler.Compile(masm(), object, holder, name, &lookup, r1, r3, r4, r0, |
| 2717 | &miss); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2718 | |
| 2719 | // Move returned value, the function to call, to r1. |
| 2720 | __ mov(r1, r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2721 | // Restore receiver. |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 2722 | __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2723 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2724 | GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2725 | |
| 2726 | // Handle call cache miss. |
| 2727 | __ bind(&miss); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2728 | GenerateMissBranch(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2729 | |
| 2730 | // Return the generated code. |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 2731 | return GetCode(Code::INTERCEPTOR, name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2732 | } |
| 2733 | |
| 2734 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2735 | Handle<Code> CallStubCompiler::CompileCallGlobal( |
| 2736 | Handle<JSObject> object, |
| 2737 | Handle<GlobalObject> holder, |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 2738 | Handle<PropertyCell> cell, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2739 | Handle<JSFunction> function, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2740 | Handle<Name> name) { |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2741 | // ----------- S t a t e ------------- |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2742 | // -- r2 : name |
| 2743 | // -- lr : return address |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2744 | // ----------------------------------- |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2745 | if (HasCustomCallGenerator(function)) { |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2746 | Handle<Code> code = CompileCustomCall( |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2747 | object, holder, cell, function, Handle<String>::cast(name), |
| 2748 | Code::NORMAL); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2749 | // A null handle means bail out to the regular compiler code below. |
| 2750 | if (!code.is_null()) return code; |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2751 | } |
| 2752 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2753 | Label miss; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2754 | GenerateNameCheck(name, &miss); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2755 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2756 | // Get the number of arguments. |
| 2757 | const int argc = arguments().immediate(); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2758 | GenerateGlobalReceiverCheck(object, holder, name, &miss); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2759 | GenerateLoadFunctionFromCell(cell, function, &miss); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2760 | |
| 2761 | // Patch the receiver on the stack with the global proxy if |
| 2762 | // necessary. |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 2763 | if (object->IsGlobalObject()) { |
| 2764 | __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
| 2765 | __ str(r3, MemOperand(sp, argc * kPointerSize)); |
| 2766 | } |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2767 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 2768 | // Set up the context (function already in r1). |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2769 | __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 2770 | |
| 2771 | // Jump to the cached code (tail call). |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2772 | Counters* counters = isolate()->counters(); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2773 | __ IncrementCounter(counters->call_global_inline(), 1, r3, r4); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2774 | ParameterCount expected(function->shared()->formal_parameter_count()); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2775 | CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2776 | ? CALL_AS_FUNCTION |
| 2777 | : CALL_AS_METHOD; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2778 | // We call indirectly through the code field in the function to |
| 2779 | // allow recompilation to take effect without changing any of the |
| 2780 | // call sites. |
| 2781 | __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 2782 | __ InvokeCode(r3, expected, arguments(), JUMP_FUNCTION, |
| 2783 | NullCallWrapper(), call_kind); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2784 | |
| 2785 | // Handle call cache miss. |
| 2786 | __ bind(&miss); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2787 | __ IncrementCounter(counters->call_global_inline_miss(), 1, r1, r3); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2788 | GenerateMissBranch(); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2789 | |
| 2790 | // Return the generated code. |
jkummerow@chromium.org | 7a6fc81 | 2012-06-27 11:12:38 +0000 | [diff] [blame] | 2791 | return GetCode(Code::NORMAL, name); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 2792 | } |
| 2793 | |
| 2794 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2795 | Handle<Code> StoreStubCompiler::CompileStoreCallback( |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2796 | Handle<JSObject> object, |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 2797 | Handle<JSObject> holder, |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 2798 | Handle<Name> name, |
hpayer@chromium.org | 7c3372b | 2013-02-13 17:26:04 +0000 | [diff] [blame] | 2799 | Handle<ExecutableAccessorInfo> callback) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2800 | HandlerFrontend(object, receiver(), holder, name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2801 | |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 2802 | // Stub never generated for non-global objects that require access checks. |
| 2803 | ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2804 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2805 | __ push(receiver()); // receiver |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2806 | __ mov(ip, Operand(callback)); // callback info |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 2807 | __ push(ip); |
| 2808 | __ mov(ip, Operand(name)); |
| 2809 | __ Push(ip, value()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2810 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 2811 | // Do tail-call to the runtime system. |
| 2812 | ExternalReference store_callback_property = |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2813 | ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2814 | __ TailCallExternalReference(store_callback_property, 4, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2815 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2816 | // Return the generated code. |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 2817 | return GetCode(kind(), Code::CALLBACKS, name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2818 | } |
| 2819 | |
| 2820 | |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 2821 | Handle<Code> StoreStubCompiler::CompileStoreCallback( |
| 2822 | Handle<JSObject> object, |
| 2823 | Handle<JSObject> holder, |
| 2824 | Handle<Name> name, |
| 2825 | const CallOptimization& call_optimization) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2826 | HandlerFrontend(object, receiver(), holder, name); |
dslomov@chromium.org | 639bac0 | 2013-09-09 11:58:54 +0000 | [diff] [blame] | 2827 | |
| 2828 | Register values[] = { value() }; |
| 2829 | GenerateFastApiCall( |
| 2830 | masm(), call_optimization, receiver(), scratch3(), 1, values); |
| 2831 | |
| 2832 | // Return the generated code. |
| 2833 | return GetCode(kind(), Code::CALLBACKS, name); |
| 2834 | } |
| 2835 | |
| 2836 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 2837 | #undef __ |
| 2838 | #define __ ACCESS_MASM(masm) |
| 2839 | |
| 2840 | |
| 2841 | void StoreStubCompiler::GenerateStoreViaSetter( |
| 2842 | MacroAssembler* masm, |
| 2843 | Handle<JSFunction> setter) { |
| 2844 | // ----------- S t a t e ------------- |
| 2845 | // -- r0 : value |
| 2846 | // -- r1 : receiver |
| 2847 | // -- r2 : name |
| 2848 | // -- lr : return address |
| 2849 | // ----------------------------------- |
| 2850 | { |
| 2851 | FrameScope scope(masm, StackFrame::INTERNAL); |
| 2852 | |
| 2853 | // Save value register, so we can restore it later. |
| 2854 | __ push(r0); |
| 2855 | |
| 2856 | if (!setter.is_null()) { |
| 2857 | // Call the JavaScript setter with receiver and value on the stack. |
| 2858 | __ Push(r1, r0); |
| 2859 | ParameterCount actual(1); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2860 | ParameterCount expected(setter); |
| 2861 | __ InvokeFunction(setter, expected, actual, |
| 2862 | CALL_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 2863 | } else { |
| 2864 | // If we generate a global code snippet for deoptimization only, remember |
| 2865 | // the place to continue after deoptimization. |
| 2866 | masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); |
| 2867 | } |
| 2868 | |
| 2869 | // We have to return the passed value, not the return value of the setter. |
| 2870 | __ pop(r0); |
| 2871 | |
| 2872 | // Restore context register. |
| 2873 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2874 | } |
| 2875 | __ Ret(); |
| 2876 | } |
| 2877 | |
| 2878 | |
| 2879 | #undef __ |
| 2880 | #define __ ACCESS_MASM(masm()) |
| 2881 | |
| 2882 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2883 | Handle<Code> StoreStubCompiler::CompileStoreInterceptor( |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2884 | Handle<JSObject> object, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2885 | Handle<Name> name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2886 | Label miss; |
| 2887 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2888 | // Check that the map of the object hasn't changed. |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2889 | __ CheckMap(receiver(), scratch1(), Handle<Map>(object->map()), &miss, |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 2890 | DO_SMI_CHECK); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2891 | |
| 2892 | // Perform global security token check if needed. |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2893 | if (object->IsJSGlobalProxy()) { |
| 2894 | __ CheckAccessGlobalProxy(receiver(), scratch1(), &miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2895 | } |
| 2896 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2897 | // Stub is never generated for non-global objects that require access |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2898 | // checks. |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2899 | ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2900 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2901 | __ Push(receiver(), this->name(), value()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2902 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2903 | __ mov(scratch1(), Operand(Smi::FromInt(strict_mode()))); |
| 2904 | __ push(scratch1()); // strict mode |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2905 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 2906 | // Do tail-call to the runtime system. |
| 2907 | ExternalReference store_ic_property = |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 2908 | ExternalReference(IC_Utility(IC::kStoreInterceptorProperty), isolate()); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2909 | __ TailCallExternalReference(store_ic_property, 4, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2910 | |
| 2911 | // Handle store cache miss. |
| 2912 | __ bind(&miss); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2913 | TailCallBuiltin(masm(), MissBuiltin(kind())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2914 | |
| 2915 | // Return the generated code. |
jkummerow@chromium.org | fe74d5d | 2013-09-06 11:12:30 +0000 | [diff] [blame] | 2916 | return GetCode(kind(), Code::INTERCEPTOR, name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2917 | } |
| 2918 | |
| 2919 | |
mstarzinger@chromium.org | e3b8d0f | 2013-02-01 09:06:41 +0000 | [diff] [blame] | 2920 | Handle<Code> LoadStubCompiler::CompileLoadNonexistent( |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2921 | Handle<Object> object, |
mstarzinger@chromium.org | e3b8d0f | 2013-02-01 09:06:41 +0000 | [diff] [blame] | 2922 | Handle<JSObject> last, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2923 | Handle<Name> name, |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2924 | Handle<JSGlobalObject> global) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 2925 | NonexistentHandlerFrontend(object, last, name, global); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 2926 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 2927 | // Return undefined if maps of the full prototype chain are still the |
| 2928 | // same and no global property with this name contains a value. |
| 2929 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 2930 | __ Ret(); |
| 2931 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 2932 | // Return the generated code. |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2933 | return GetCode(kind(), Code::NONEXISTENT, name); |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 2934 | } |
| 2935 | |
| 2936 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2937 | Register* LoadStubCompiler::registers() { |
| 2938 | // receiver, name, scratch1, scratch2, scratch3, scratch4. |
| 2939 | static Register registers[] = { r0, r2, r3, r1, r4, r5 }; |
| 2940 | return registers; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2941 | } |
| 2942 | |
| 2943 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2944 | Register* KeyedLoadStubCompiler::registers() { |
| 2945 | // receiver, name, scratch1, scratch2, scratch3, scratch4. |
| 2946 | static Register registers[] = { r1, r0, r2, r3, r4, r5 }; |
| 2947 | return registers; |
| 2948 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2949 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2950 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2951 | Register* StoreStubCompiler::registers() { |
| 2952 | // receiver, name, value, scratch1, scratch2, scratch3. |
| 2953 | static Register registers[] = { r1, r2, r0, r3, r4, r5 }; |
| 2954 | return registers; |
| 2955 | } |
| 2956 | |
| 2957 | |
| 2958 | Register* KeyedStoreStubCompiler::registers() { |
| 2959 | // receiver, name, value, scratch1, scratch2, scratch3. |
| 2960 | static Register registers[] = { r2, r1, r0, r3, r4, r5 }; |
| 2961 | return registers; |
| 2962 | } |
| 2963 | |
| 2964 | |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 2965 | void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name, |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 2966 | Register name_reg, |
| 2967 | Label* miss) { |
| 2968 | __ cmp(name_reg, Operand(name)); |
| 2969 | __ b(ne, miss); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2970 | } |
| 2971 | |
| 2972 | |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 2973 | void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name, |
| 2974 | Register name_reg, |
| 2975 | Label* miss) { |
| 2976 | __ cmp(name_reg, Operand(name)); |
| 2977 | __ b(ne, miss); |
| 2978 | } |
| 2979 | |
| 2980 | |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 2981 | #undef __ |
| 2982 | #define __ ACCESS_MASM(masm) |
| 2983 | |
| 2984 | |
| 2985 | void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 2986 | Register receiver, |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 2987 | Handle<JSFunction> getter) { |
| 2988 | // ----------- S t a t e ------------- |
| 2989 | // -- r0 : receiver |
| 2990 | // -- r2 : name |
| 2991 | // -- lr : return address |
| 2992 | // ----------------------------------- |
| 2993 | { |
| 2994 | FrameScope scope(masm, StackFrame::INTERNAL); |
| 2995 | |
| 2996 | if (!getter.is_null()) { |
| 2997 | // Call the JavaScript getter with the receiver on the stack. |
mstarzinger@chromium.org | 2efc3e4 | 2013-10-14 08:45:38 +0000 | [diff] [blame] | 2998 | __ push(receiver); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 2999 | ParameterCount actual(0); |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 3000 | ParameterCount expected(getter); |
| 3001 | __ InvokeFunction(getter, expected, actual, |
| 3002 | CALL_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3003 | } else { |
| 3004 | // If we generate a global code snippet for deoptimization only, remember |
| 3005 | // the place to continue after deoptimization. |
| 3006 | masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); |
| 3007 | } |
| 3008 | |
| 3009 | // Restore context register. |
| 3010 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3011 | } |
| 3012 | __ Ret(); |
| 3013 | } |
| 3014 | |
| 3015 | |
| 3016 | #undef __ |
| 3017 | #define __ ACCESS_MASM(masm()) |
| 3018 | |
| 3019 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3020 | Handle<Code> LoadStubCompiler::CompileLoadGlobal( |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3021 | Handle<Object> object, |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 3022 | Handle<GlobalObject> global, |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 3023 | Handle<PropertyCell> cell, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 3024 | Handle<Name> name, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3025 | bool is_dont_delete) { |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3026 | Label miss; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3027 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 3028 | HandlerFrontendHeader(object, receiver(), global, name, &miss); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3029 | |
| 3030 | // Get the value from the cell. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3031 | __ mov(r3, Operand(cell)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 3032 | __ ldr(r4, FieldMemOperand(r3, Cell::kValueOffset)); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3033 | |
| 3034 | // Check for deleted property if property can actually be deleted. |
| 3035 | if (!is_dont_delete) { |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 3036 | __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 3037 | __ cmp(r4, ip); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3038 | __ b(eq, &miss); |
| 3039 | } |
| 3040 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3041 | HandlerFrontendFooter(name, &miss); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 3042 | |
ulan@chromium.org | 32d7dba | 2013-04-24 10:59:06 +0000 | [diff] [blame] | 3043 | Counters* counters = isolate()->counters(); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3044 | __ IncrementCounter(counters->named_load_global_stub(), 1, r1, r3); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 3045 | __ mov(r0, r4); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3046 | __ Ret(); |
| 3047 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3048 | // Return the generated code. |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 3049 | return GetCode(kind(), Code::NORMAL, name); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 3050 | } |
| 3051 | |
| 3052 | |
danno@chromium.org | bee5199 | 2013-07-10 14:57:15 +0000 | [diff] [blame] | 3053 | Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC( |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3054 | MapHandleList* receiver_maps, |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3055 | CodeHandleList* handlers, |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 3056 | Handle<Name> name, |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3057 | Code::StubType type, |
| 3058 | IcCheckType check) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3059 | Label miss; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3060 | |
| 3061 | if (check == PROPERTY) { |
| 3062 | GenerateNameCheck(name, this->name(), &miss); |
| 3063 | } |
| 3064 | |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3065 | Label number_case; |
| 3066 | Label* smi_target = HasHeapNumberMap(receiver_maps) ? &number_case : &miss; |
| 3067 | __ JumpIfSmi(receiver(), smi_target); |
| 3068 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3069 | Register map_reg = scratch1(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3070 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3071 | int receiver_count = receiver_maps->length(); |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3072 | int number_of_handled_maps = 0; |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3073 | __ ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3074 | Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3075 | for (int current = 0; current < receiver_count; ++current) { |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3076 | Handle<Map> map = receiver_maps->at(current); |
| 3077 | if (!map->is_deprecated()) { |
| 3078 | number_of_handled_maps++; |
| 3079 | __ mov(ip, Operand(receiver_maps->at(current))); |
| 3080 | __ cmp(map_reg, ip); |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 3081 | if (map.is_identical_to(heap_number_map)) { |
| 3082 | ASSERT(!number_case.is_unused()); |
| 3083 | __ bind(&number_case); |
| 3084 | } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3085 | __ Jump(handlers->at(current), RelocInfo::CODE_TARGET, eq); |
| 3086 | } |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3087 | } |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3088 | ASSERT(number_of_handled_maps != 0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3089 | |
| 3090 | __ bind(&miss); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3091 | TailCallBuiltin(masm(), MissBuiltin(kind())); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3092 | |
| 3093 | // Return the generated code. |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3094 | InlineCacheState state = |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 3095 | number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 3096 | return GetICCode(kind(), type, name, state); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3100 | Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic( |
| 3101 | MapHandleList* receiver_maps, |
| 3102 | CodeHandleList* handler_stubs, |
| 3103 | MapHandleList* transitioned_maps) { |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3104 | Label miss; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3105 | __ JumpIfSmi(receiver(), &miss); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3106 | |
| 3107 | int receiver_count = receiver_maps->length(); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3108 | __ ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset)); |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 3109 | for (int i = 0; i < receiver_count; ++i) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3110 | __ mov(ip, Operand(receiver_maps->at(i))); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3111 | __ cmp(scratch1(), ip); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3112 | if (transitioned_maps->at(i).is_null()) { |
| 3113 | __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq); |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 3114 | } else { |
| 3115 | Label next_map; |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3116 | __ b(ne, &next_map); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3117 | __ mov(transition_map(), Operand(transitioned_maps->at(i))); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 3118 | __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al); |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 3119 | __ bind(&next_map); |
| 3120 | } |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3121 | } |
| 3122 | |
| 3123 | __ bind(&miss); |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3124 | TailCallBuiltin(masm(), MissBuiltin(kind())); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3125 | |
| 3126 | // Return the generated code. |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3127 | return GetICCode( |
| 3128 | kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3129 | } |
| 3130 | |
| 3131 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 3132 | #undef __ |
| 3133 | #define __ ACCESS_MASM(masm) |
| 3134 | |
| 3135 | |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 3136 | void KeyedLoadStubCompiler::GenerateLoadDictionaryElement( |
| 3137 | MacroAssembler* masm) { |
| 3138 | // ---------- S t a t e -------------- |
| 3139 | // -- lr : return address |
| 3140 | // -- r0 : key |
| 3141 | // -- r1 : receiver |
| 3142 | // ----------------------------------- |
| 3143 | Label slow, miss_force_generic; |
| 3144 | |
| 3145 | Register key = r0; |
| 3146 | Register receiver = r1; |
| 3147 | |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 3148 | __ UntagAndJumpIfNotSmi(r2, key, &miss_force_generic); |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 3149 | __ ldr(r4, FieldMemOperand(receiver, JSObject::kElementsOffset)); |
| 3150 | __ LoadFromNumberDictionary(&slow, r4, key, r0, r2, r3, r5); |
| 3151 | __ Ret(); |
| 3152 | |
| 3153 | __ bind(&slow); |
| 3154 | __ IncrementCounter( |
| 3155 | masm->isolate()->counters()->keyed_load_external_array_slow(), |
| 3156 | 1, r2, r3); |
| 3157 | |
| 3158 | // ---------- S t a t e -------------- |
| 3159 | // -- lr : return address |
| 3160 | // -- r0 : key |
| 3161 | // -- r1 : receiver |
| 3162 | // ----------------------------------- |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3163 | TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow); |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 3164 | |
| 3165 | // Miss case, call the runtime. |
| 3166 | __ bind(&miss_force_generic); |
| 3167 | |
| 3168 | // ---------- S t a t e -------------- |
| 3169 | // -- lr : return address |
| 3170 | // -- r0 : key |
| 3171 | // -- r1 : receiver |
| 3172 | // ----------------------------------- |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 3173 | TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
sgjesse@chromium.org | 6db8871 | 2011-07-11 11:41:22 +0000 | [diff] [blame] | 3174 | } |
| 3175 | |
| 3176 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 3177 | #undef __ |
| 3178 | |
| 3179 | } } // namespace v8::internal |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 3180 | |
| 3181 | #endif // V8_TARGET_ARCH_ARM |