| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // ---------------------------------------------------------------------------- | 38 // ---------------------------------------------------------------------------- |
| 39 // Static IC stub generators. | 39 // Static IC stub generators. |
| 40 // | 40 // |
| 41 | 41 |
| 42 #define __ masm-> | 42 #define __ masm-> |
| 43 | 43 |
| 44 | 44 |
| 45 // Helper function used from LoadIC/CallIC GenerateNormal. | 45 // Helper function used from LoadIC/CallIC GenerateNormal. |
| 46 static void GenerateDictionaryLoad(MacroAssembler* masm, | 46 static void GenerateDictionaryLoad(MacroAssembler* masm, |
| 47 Label* done_label, | 47 Label* miss, |
| 48 Label* miss_label, | |
| 49 Register t0, | 48 Register t0, |
| 50 Register t1) { | 49 Register t1) { |
| 51 // Register use: | 50 // Register use: |
| 52 // | 51 // |
| 53 // t0 - used to hold the property dictionary. | 52 // t0 - used to hold the property dictionary. |
| 54 // | 53 // |
| 55 // t1 - initially the receiver | 54 // t1 - initially the receiver |
| 56 // - used for the index into the property dictionary | 55 // - used for the index into the property dictionary |
| 57 // - holds the result on exit. | 56 // - holds the result on exit. |
| 58 // | 57 // |
| 59 // r3 - used as temporary and to hold the capacity of the property | 58 // r3 - used as temporary and to hold the capacity of the property |
| 60 // dictionary. | 59 // dictionary. |
| 61 // | 60 // |
| 62 // r2 - holds the name of the property and is unchanges. | 61 // r2 - holds the name of the property and is unchanges. |
| 63 | 62 |
| 63 Label done; |
| 64 |
| 64 // Check for the absence of an interceptor. | 65 // Check for the absence of an interceptor. |
| 65 // Load the map into t0. | 66 // Load the map into t0. |
| 66 __ ldr(t0, FieldMemOperand(t1, JSObject::kMapOffset)); | 67 __ ldr(t0, FieldMemOperand(t1, JSObject::kMapOffset)); |
| 67 // Test the has_named_interceptor bit in the map. | 68 // Test the has_named_interceptor bit in the map. |
| 68 __ ldr(t0, FieldMemOperand(t1, Map::kInstanceAttributesOffset)); | 69 __ ldr(t0, FieldMemOperand(t1, Map::kInstanceAttributesOffset)); |
| 69 __ tst(t0, Operand(1 << (Map::kHasNamedInterceptor + (3 * 8)))); | 70 __ tst(t0, Operand(1 << (Map::kHasNamedInterceptor + (3 * 8)))); |
| 70 // Jump to miss if the interceptor bit is set. | 71 // Jump to miss if the interceptor bit is set. |
| 71 __ b(ne, miss_label); | 72 __ b(ne, miss); |
| 72 | 73 |
| 73 | 74 |
| 74 // Check that the properties array is a dictionary. | 75 // Check that the properties array is a dictionary. |
| 75 __ ldr(t0, FieldMemOperand(t1, JSObject::kPropertiesOffset)); | 76 __ ldr(t0, FieldMemOperand(t1, JSObject::kPropertiesOffset)); |
| 76 __ ldr(r3, FieldMemOperand(t0, HeapObject::kMapOffset)); | 77 __ ldr(r3, FieldMemOperand(t0, HeapObject::kMapOffset)); |
| 77 __ cmp(r3, Operand(Factory::hash_table_map())); | 78 __ cmp(r3, Operand(Factory::hash_table_map())); |
| 78 __ b(ne, miss_label); | 79 __ b(ne, miss); |
| 79 | 80 |
| 80 // Compute the capacity mask. | 81 // Compute the capacity mask. |
| 81 const int kCapacityOffset = | 82 const int kCapacityOffset = |
| 82 Array::kHeaderSize + Dictionary::kCapacityIndex * kPointerSize; | 83 Array::kHeaderSize + Dictionary::kCapacityIndex * kPointerSize; |
| 83 __ ldr(r3, FieldMemOperand(t0, kCapacityOffset)); | 84 __ ldr(r3, FieldMemOperand(t0, kCapacityOffset)); |
| 84 __ mov(r3, Operand(r3, ASR, kSmiTagSize)); // convert smi to int | 85 __ mov(r3, Operand(r3, ASR, kSmiTagSize)); // convert smi to int |
| 85 __ sub(r3, r3, Operand(1)); | 86 __ sub(r3, r3, Operand(1)); |
| 86 | 87 |
| 87 const int kElementsStartOffset = | 88 const int kElementsStartOffset = |
| 88 Array::kHeaderSize + Dictionary::kElementsStartIndex * kPointerSize; | 89 Array::kHeaderSize + Dictionary::kElementsStartIndex * kPointerSize; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 100 | 101 |
| 101 // Scale the index by multiplying by the element size. | 102 // Scale the index by multiplying by the element size. |
| 102 ASSERT(Dictionary::kElementSize == 3); | 103 ASSERT(Dictionary::kElementSize == 3); |
| 103 __ add(t1, t1, Operand(t1, LSL, 1)); // t1 = t1 * 3 | 104 __ add(t1, t1, Operand(t1, LSL, 1)); // t1 = t1 * 3 |
| 104 | 105 |
| 105 // Check if the key is identical to the name. | 106 // Check if the key is identical to the name. |
| 106 __ add(t1, t0, Operand(t1, LSL, 2)); | 107 __ add(t1, t0, Operand(t1, LSL, 2)); |
| 107 __ ldr(ip, FieldMemOperand(t1, kElementsStartOffset)); | 108 __ ldr(ip, FieldMemOperand(t1, kElementsStartOffset)); |
| 108 __ cmp(r2, Operand(ip)); | 109 __ cmp(r2, Operand(ip)); |
| 109 if (i != kProbes - 1) { | 110 if (i != kProbes - 1) { |
| 110 __ b(eq, done_label); | 111 __ b(eq, &done); |
| 111 } else { | 112 } else { |
| 112 __ b(ne, miss_label); | 113 __ b(ne, miss); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 // Check that the value is a normal property. | 117 // Check that the value is a normal property. |
| 117 __ bind(done_label); // t1 == t0 + 4*index | 118 __ bind(&done); // t1 == t0 + 4*index |
| 118 __ ldr(r3, FieldMemOperand(t1, kElementsStartOffset + 2 * kPointerSize)); | 119 __ ldr(r3, FieldMemOperand(t1, kElementsStartOffset + 2 * kPointerSize)); |
| 119 __ tst(r3, Operand(PropertyDetails::TypeField::mask() << kSmiTagSize)); | 120 __ tst(r3, Operand(PropertyDetails::TypeField::mask() << kSmiTagSize)); |
| 120 __ b(ne, miss_label); | 121 __ b(ne, miss); |
| 121 | 122 |
| 122 // Get the value at the masked, scaled index and return. | 123 // Get the value at the masked, scaled index and return. |
| 123 __ ldr(t1, FieldMemOperand(t1, kElementsStartOffset + 1 * kPointerSize)); | 124 __ ldr(t1, FieldMemOperand(t1, kElementsStartOffset + 1 * kPointerSize)); |
| 124 } | 125 } |
| 125 | 126 |
| 126 | 127 |
| 127 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { | 128 void LoadIC::GenerateArrayLength(MacroAssembler* masm) { |
| 128 // ----------- S t a t e ------------- | 129 // ----------- S t a t e ------------- |
| 129 // -- r2 : name | 130 // -- r2 : name |
| 130 // -- lr : return address | 131 // -- lr : return address |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 __ ldr(r0, FieldMemOperand(r0, JSArray::kLengthOffset)); | 150 __ ldr(r0, FieldMemOperand(r0, JSArray::kLengthOffset)); |
| 150 __ Ret(); | 151 __ Ret(); |
| 151 | 152 |
| 152 // Cache miss: Jump to runtime. | 153 // Cache miss: Jump to runtime. |
| 153 __ bind(&miss); | 154 __ bind(&miss); |
| 154 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 155 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); |
| 155 __ Jump(ic, RelocInfo::CODE_TARGET); | 156 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 156 } | 157 } |
| 157 | 158 |
| 158 | 159 |
| 159 void LoadIC::GenerateShortStringLength(MacroAssembler* masm) { | 160 // Generate code to check if an object is a string. If the object is |
| 161 // a string, the map's instance type is left in the scratch1 register. |
| 162 static void GenerateStringCheck(MacroAssembler* masm, |
| 163 Register receiver, |
| 164 Register scratch1, |
| 165 Register scratch2, |
| 166 Label* smi, |
| 167 Label* non_string_object) { |
| 168 // Check that the receiver isn't a smi. |
| 169 __ tst(receiver, Operand(kSmiTagMask)); |
| 170 __ b(eq, smi); |
| 171 |
| 172 // Check that the object is a string. |
| 173 __ ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 174 __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
| 175 __ and_(scratch2, scratch1, Operand(kIsNotStringMask)); |
| 176 // The cast is to resolve the overload for the argument of 0x0. |
| 177 __ cmp(scratch2, Operand(static_cast<int32_t>(kStringTag))); |
| 178 __ b(ne, non_string_object); |
| 179 } |
| 180 |
| 181 |
| 182 void LoadIC::GenerateStringLength(MacroAssembler* masm) { |
| 160 // ----------- S t a t e ------------- | 183 // ----------- S t a t e ------------- |
| 161 // -- r2 : name | 184 // -- r2 : name |
| 162 // -- lr : return address | 185 // -- lr : return address |
| 163 // -- [sp] : receiver | 186 // -- [sp] : receiver |
| 164 // ----------------------------------- | 187 // ----------------------------------- |
| 165 | 188 |
| 166 Label miss; | 189 Label miss, load_length, check_wrapper; |
| 167 | 190 |
| 168 __ ldr(r0, MemOperand(sp, 0)); | 191 __ ldr(r0, MemOperand(sp, 0)); |
| 169 | 192 |
| 170 // Check that the receiver isn't a smi. | 193 // Check if the object is a string leaving the instance type in the |
| 171 __ tst(r0, Operand(kSmiTagMask)); | 194 // r1 register. |
| 172 __ b(eq, &miss); | 195 GenerateStringCheck(masm, r0, r1, r3, &miss, &check_wrapper); |
| 173 | |
| 174 // Check that the object is a short string. | |
| 175 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
| 176 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | |
| 177 __ and_(r1, r1, Operand(kIsNotStringMask | kStringSizeMask)); | |
| 178 // The cast is to resolve the overload for the argument of 0x0. | |
| 179 __ cmp(r1, Operand(static_cast<int32_t>(kStringTag | kShortStringTag))); | |
| 180 __ b(ne, &miss); | |
| 181 | 196 |
| 182 // Load length directly from the string. | 197 // Load length directly from the string. |
| 198 __ bind(&load_length); |
| 199 __ and_(r1, r1, Operand(kStringSizeMask)); |
| 200 __ add(r1, r1, Operand(String::kHashShift)); |
| 183 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); | 201 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); |
| 184 __ mov(r0, Operand(r0, LSR, String::kShortLengthShift)); | 202 __ mov(r0, Operand(r0, LSR, r1)); |
| 185 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 203 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |
| 186 __ Ret(); | 204 __ Ret(); |
| 187 | 205 |
| 188 // Cache miss: Jump to runtime. | 206 // Check if the object is a JSValue wrapper. |
| 189 __ bind(&miss); | 207 __ bind(&check_wrapper); |
| 190 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 208 __ cmp(r1, Operand(JS_VALUE_TYPE)); |
| 191 __ Jump(ic, RelocInfo::CODE_TARGET); | |
| 192 } | |
| 193 | |
| 194 | |
| 195 void LoadIC::GenerateMediumStringLength(MacroAssembler* masm) { | |
| 196 // ----------- S t a t e ------------- | |
| 197 // -- r2 : name | |
| 198 // -- lr : return address | |
| 199 // -- [sp] : receiver | |
| 200 // ----------------------------------- | |
| 201 | |
| 202 Label miss; | |
| 203 | |
| 204 __ ldr(r0, MemOperand(sp, 0)); | |
| 205 | |
| 206 // Check that the receiver isn't a smi. | |
| 207 __ tst(r0, Operand(kSmiTagMask)); | |
| 208 __ b(eq, &miss); | |
| 209 | |
| 210 // Check that the object is a medium string. | |
| 211 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
| 212 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | |
| 213 __ and_(r1, r1, Operand(kIsNotStringMask | kStringSizeMask)); | |
| 214 __ cmp(r1, Operand(kStringTag | kMediumStringTag)); | |
| 215 __ b(ne, &miss); | 209 __ b(ne, &miss); |
| 216 | 210 |
| 217 // Load length directly from the string. | 211 // Check if the wrapped value is a string and load the length |
| 218 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); | 212 // directly if it is. |
| 219 __ mov(r0, Operand(r0, LSR, String::kMediumLengthShift)); | 213 __ ldr(r0, FieldMemOperand(r0, JSValue::kValueOffset)); |
| 220 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 214 GenerateStringCheck(masm, r0, r1, r3, &miss, &miss); |
| 221 __ Ret(); | 215 __ b(&load_length); |
| 222 | 216 |
| 223 // Cache miss: Jump to runtime. | 217 // Cache miss: Jump to runtime. |
| 224 __ bind(&miss); | 218 __ bind(&miss); |
| 225 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | |
| 226 __ Jump(ic, RelocInfo::CODE_TARGET); | |
| 227 } | |
| 228 | |
| 229 | |
| 230 void LoadIC::GenerateLongStringLength(MacroAssembler* masm) { | |
| 231 // ----------- S t a t e ------------- | |
| 232 // -- r2 : name | |
| 233 // -- lr : return address | |
| 234 // -- [sp] : receiver | |
| 235 // ----------------------------------- | |
| 236 | |
| 237 Label miss; | |
| 238 | |
| 239 __ ldr(r0, MemOperand(sp, 0)); | |
| 240 // Check that the receiver isn't a smi. | |
| 241 __ tst(r0, Operand(kSmiTagMask)); | |
| 242 __ b(eq, &miss); | |
| 243 | |
| 244 // Check that the object is a long string. | |
| 245 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
| 246 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | |
| 247 __ and_(r1, r1, Operand(kIsNotStringMask | kStringSizeMask)); | |
| 248 __ cmp(r1, Operand(kStringTag | kLongStringTag)); | |
| 249 __ b(ne, &miss); | |
| 250 | |
| 251 // Load length directly from the string. | |
| 252 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); | |
| 253 __ mov(r0, Operand(r0, LSR, String::kLongLengthShift)); | |
| 254 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | |
| 255 __ Ret(); | |
| 256 | |
| 257 // Cache miss: Jump to runtime. | |
| 258 __ bind(&miss); | |
| 259 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 219 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); |
| 260 __ Jump(ic, RelocInfo::CODE_TARGET); | 220 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 261 } | 221 } |
| 262 | 222 |
| 263 | 223 |
| 264 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { | 224 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { |
| 265 // ----------- S t a t e ------------- | 225 // ----------- S t a t e ------------- |
| 266 // -- r2 : name | 226 // -- r2 : name |
| 267 // -- lr : return address | 227 // -- lr : return address |
| 268 // -- [sp] : receiver | 228 // -- [sp] : receiver |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // Probe the stub cache for the value object. | 293 // Probe the stub cache for the value object. |
| 334 __ bind(&probe); | 294 __ bind(&probe); |
| 335 StubCache::GenerateProbe(masm, flags, r1, r2, r3); | 295 StubCache::GenerateProbe(masm, flags, r1, r2, r3); |
| 336 | 296 |
| 337 // Cache miss: Jump to runtime. | 297 // Cache miss: Jump to runtime. |
| 338 __ bind(&miss); | 298 __ bind(&miss); |
| 339 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); | 299 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); |
| 340 } | 300 } |
| 341 | 301 |
| 342 | 302 |
| 303 static void GenerateNormalHelper(MacroAssembler* masm, |
| 304 int argc, |
| 305 bool is_global_object, |
| 306 Label* miss) { |
| 307 // Search dictionary - put result in register r1. |
| 308 GenerateDictionaryLoad(masm, miss, r0, r1); |
| 309 |
| 310 // Check that the value isn't a smi. |
| 311 __ tst(r1, Operand(kSmiTagMask)); |
| 312 __ b(eq, miss); |
| 313 |
| 314 // Check that the value is a JSFunction. |
| 315 __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 316 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
| 317 __ cmp(r0, Operand(JS_FUNCTION_TYPE)); |
| 318 __ b(ne, miss); |
| 319 |
| 320 // Patch the receiver with the global proxy if necessary. |
| 321 if (is_global_object) { |
| 322 __ ldr(r2, MemOperand(sp, argc * kPointerSize)); |
| 323 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); |
| 324 __ str(r2, MemOperand(sp, argc * kPointerSize)); |
| 325 } |
| 326 |
| 327 // Invoke the function. |
| 328 ParameterCount actual(argc); |
| 329 __ InvokeFunction(r1, actual, JUMP_FUNCTION); |
| 330 } |
| 331 |
| 332 |
| 343 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { | 333 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
| 344 // ----------- S t a t e ------------- | 334 // ----------- S t a t e ------------- |
| 345 // -- lr: return address | 335 // -- lr: return address |
| 346 // ----------------------------------- | 336 // ----------------------------------- |
| 347 | 337 |
| 348 Label miss, probe, done, global; | 338 Label miss, global_object, non_global_object; |
| 349 | 339 |
| 350 // Get the receiver of the function from the stack into r1. | 340 // Get the receiver of the function from the stack into r1. |
| 351 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); | 341 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 352 // Get the name of the function from the stack; 1 ~ receiver. | 342 // Get the name of the function from the stack; 1 ~ receiver. |
| 353 __ ldr(r2, MemOperand(sp, (argc + 1) * kPointerSize)); | 343 __ ldr(r2, MemOperand(sp, (argc + 1) * kPointerSize)); |
| 354 | 344 |
| 355 // Check that the receiver isn't a smi. | 345 // Check that the receiver isn't a smi. |
| 356 __ tst(r1, Operand(kSmiTagMask)); | 346 __ tst(r1, Operand(kSmiTagMask)); |
| 357 __ b(eq, &miss); | 347 __ b(eq, &miss); |
| 358 | 348 |
| 359 // Check that the receiver is a valid JS object. | 349 // Check that the receiver is a valid JS object. |
| 360 __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); | 350 __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 361 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | 351 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); |
| 362 __ cmp(r0, Operand(FIRST_JS_OBJECT_TYPE)); | 352 __ cmp(r0, Operand(FIRST_JS_OBJECT_TYPE)); |
| 363 __ b(lt, &miss); | 353 __ b(lt, &miss); |
| 364 | 354 |
| 365 // If this assert fails, we have to check upper bound too. | 355 // If this assert fails, we have to check upper bound too. |
| 366 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 356 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 367 | 357 |
| 368 // Check for access to global proxy. | 358 // Check for access to global object. |
| 359 __ cmp(r0, Operand(JS_GLOBAL_OBJECT_TYPE)); |
| 360 __ b(eq, &global_object); |
| 361 __ cmp(r0, Operand(JS_BUILTINS_OBJECT_TYPE)); |
| 362 __ b(ne, &non_global_object); |
| 363 |
| 364 // Accessing global object: Load and invoke. |
| 365 __ bind(&global_object); |
| 366 GenerateNormalHelper(masm, argc, true, &miss); |
| 367 |
| 368 // Accessing non-global object: Check for access to global proxy. |
| 369 Label global_proxy, invoke; |
| 370 __ bind(&non_global_object); |
| 369 __ cmp(r0, Operand(JS_GLOBAL_PROXY_TYPE)); | 371 __ cmp(r0, Operand(JS_GLOBAL_PROXY_TYPE)); |
| 370 __ b(eq, &global); | 372 __ b(eq, &global_proxy); |
| 371 | 373 __ bind(&invoke); |
| 372 // Search the dictionary placing the result in r1. | 374 GenerateNormalHelper(masm, argc, false, &miss); |
| 373 __ bind(&probe); | |
| 374 GenerateDictionaryLoad(masm, &done, &miss, r0, r1); | |
| 375 | |
| 376 // Check that the value isn't a smi. | |
| 377 __ tst(r1, Operand(kSmiTagMask)); | |
| 378 __ b(eq, &miss); | |
| 379 | |
| 380 // Check that the value is a JSFunction. | |
| 381 __ ldr(r0, FieldMemOperand(r1, HeapObject::kMapOffset)); | |
| 382 __ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset)); | |
| 383 __ cmp(r0, Operand(JS_FUNCTION_TYPE)); | |
| 384 __ b(ne, &miss); | |
| 385 | |
| 386 // TODO(120): Check for access to global object. Needs patching of | |
| 387 // receiver but no security check. | |
| 388 | |
| 389 // Invoke the function. | |
| 390 ParameterCount actual(argc); | |
| 391 __ InvokeFunction(r1, actual, JUMP_FUNCTION); | |
| 392 | 375 |
| 393 // Global object access: Check access rights. | 376 // Global object access: Check access rights. |
| 394 __ bind(&global); | 377 __ bind(&global_proxy); |
| 395 __ CheckAccessGlobalProxy(r1, r0, &miss); | 378 __ CheckAccessGlobalProxy(r1, r0, &miss); |
| 396 __ b(&probe); | 379 __ b(&invoke); |
| 397 | 380 |
| 398 // Cache miss: Jump to runtime. | 381 // Cache miss: Jump to runtime. |
| 399 __ bind(&miss); | 382 __ bind(&miss); |
| 400 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); | 383 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); |
| 401 } | 384 } |
| 402 | 385 |
| 403 | 386 |
| 404 void CallIC::Generate(MacroAssembler* masm, | 387 void CallIC::Generate(MacroAssembler* masm, |
| 405 int argc, | 388 int argc, |
| 406 const ExternalReference& f) { | 389 const ExternalReference& f) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 422 __ mov(r0, Operand(2)); | 405 __ mov(r0, Operand(2)); |
| 423 __ mov(r1, Operand(f)); | 406 __ mov(r1, Operand(f)); |
| 424 | 407 |
| 425 CEntryStub stub; | 408 CEntryStub stub; |
| 426 __ CallStub(&stub); | 409 __ CallStub(&stub); |
| 427 | 410 |
| 428 // Move result to r1 and leave the internal frame. | 411 // Move result to r1 and leave the internal frame. |
| 429 __ mov(r1, Operand(r0)); | 412 __ mov(r1, Operand(r0)); |
| 430 __ LeaveInternalFrame(); | 413 __ LeaveInternalFrame(); |
| 431 | 414 |
| 432 // TODO(120): Check for access to to global object. Needs patching | 415 // Check if the receiver is a global object of some sort. |
| 433 // of receiver but no security check. | 416 Label invoke, global; |
| 417 __ ldr(r2, MemOperand(sp, argc * kPointerSize)); // receiver |
| 418 __ tst(r2, Operand(kSmiTagMask)); |
| 419 __ b(eq, &invoke); |
| 420 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); |
| 421 __ ldrb(r3, FieldMemOperand(r3, Map::kInstanceTypeOffset)); |
| 422 __ cmp(r3, Operand(JS_GLOBAL_OBJECT_TYPE)); |
| 423 __ b(eq, &global); |
| 424 __ cmp(r3, Operand(JS_BUILTINS_OBJECT_TYPE)); |
| 425 __ b(ne, &invoke); |
| 426 |
| 427 // Patch the receiver on the stack. |
| 428 __ bind(&global); |
| 429 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); |
| 430 __ str(r2, MemOperand(sp, argc * kPointerSize)); |
| 434 | 431 |
| 435 // Invoke the function. | 432 // Invoke the function. |
| 436 ParameterCount actual(argc); | 433 ParameterCount actual(argc); |
| 434 __ bind(&invoke); |
| 437 __ InvokeFunction(r1, actual, JUMP_FUNCTION); | 435 __ InvokeFunction(r1, actual, JUMP_FUNCTION); |
| 438 } | 436 } |
| 439 | 437 |
| 440 | 438 |
| 441 // Defined in ic.cc. | 439 // Defined in ic.cc. |
| 442 Object* LoadIC_Miss(Arguments args); | 440 Object* LoadIC_Miss(Arguments args); |
| 443 | 441 |
| 444 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { | 442 void LoadIC::GenerateMegamorphic(MacroAssembler* masm) { |
| 445 // ----------- S t a t e ------------- | 443 // ----------- S t a t e ------------- |
| 446 // -- r2 : name | 444 // -- r2 : name |
| (...skipping 11 matching lines...) Expand all Loading... |
| 458 } | 456 } |
| 459 | 457 |
| 460 | 458 |
| 461 void LoadIC::GenerateNormal(MacroAssembler* masm) { | 459 void LoadIC::GenerateNormal(MacroAssembler* masm) { |
| 462 // ----------- S t a t e ------------- | 460 // ----------- S t a t e ------------- |
| 463 // -- r2 : name | 461 // -- r2 : name |
| 464 // -- lr : return address | 462 // -- lr : return address |
| 465 // -- [sp] : receiver | 463 // -- [sp] : receiver |
| 466 // ----------------------------------- | 464 // ----------------------------------- |
| 467 | 465 |
| 468 Label miss, probe, done, global; | 466 Label miss, probe, global; |
| 469 | 467 |
| 470 __ ldr(r0, MemOperand(sp, 0)); | 468 __ ldr(r0, MemOperand(sp, 0)); |
| 471 // Check that the receiver isn't a smi. | 469 // Check that the receiver isn't a smi. |
| 472 __ tst(r0, Operand(kSmiTagMask)); | 470 __ tst(r0, Operand(kSmiTagMask)); |
| 473 __ b(eq, &miss); | 471 __ b(eq, &miss); |
| 474 | 472 |
| 475 // Check that the receiver is a valid JS object. | 473 // Check that the receiver is a valid JS object. |
| 476 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 474 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 477 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | 475 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); |
| 478 __ cmp(r1, Operand(FIRST_JS_OBJECT_TYPE)); | 476 __ cmp(r1, Operand(FIRST_JS_OBJECT_TYPE)); |
| 479 __ b(lt, &miss); | 477 __ b(lt, &miss); |
| 480 // If this assert fails, we have to check upper bound too. | 478 // If this assert fails, we have to check upper bound too. |
| 481 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 479 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
| 482 | 480 |
| 483 // Check for access to global object (unlikely). | 481 // Check for access to global object (unlikely). |
| 484 __ cmp(r1, Operand(JS_GLOBAL_PROXY_TYPE)); | 482 __ cmp(r1, Operand(JS_GLOBAL_PROXY_TYPE)); |
| 485 __ b(eq, &global); | 483 __ b(eq, &global); |
| 486 | 484 |
| 487 __ bind(&probe); | 485 __ bind(&probe); |
| 488 GenerateDictionaryLoad(masm, &done, &miss, r1, r0); | 486 GenerateDictionaryLoad(masm, &miss, r1, r0); |
| 489 __ Ret(); | 487 __ Ret(); |
| 490 | 488 |
| 491 // Global object access: Check access rights. | 489 // Global object access: Check access rights. |
| 492 __ bind(&global); | 490 __ bind(&global); |
| 493 __ CheckAccessGlobalProxy(r0, r1, &miss); | 491 __ CheckAccessGlobalProxy(r0, r1, &miss); |
| 494 __ b(&probe); | 492 __ b(&probe); |
| 495 | 493 |
| 496 // Cache miss: Restore receiver from stack and jump to runtime. | 494 // Cache miss: Restore receiver from stack and jump to runtime. |
| 497 __ bind(&miss); | 495 __ bind(&miss); |
| 498 Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); | 496 Generate(masm, ExternalReference(IC_Utility(kLoadIC_Miss))); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 587 |
| 590 // Perform tail call to the entry. | 588 // Perform tail call to the entry. |
| 591 __ TailCallRuntime(f, 3); | 589 __ TailCallRuntime(f, 3); |
| 592 } | 590 } |
| 593 | 591 |
| 594 | 592 |
| 595 #undef __ | 593 #undef __ |
| 596 | 594 |
| 597 | 595 |
| 598 } } // namespace v8::internal | 596 } } // namespace v8::internal |
| OLD | NEW |