| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
| (...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 bind(&loop); | 2209 bind(&loop); |
| 2210 JumpIfSmi(result, &done); | 2210 JumpIfSmi(result, &done); |
| 2211 CompareObjectType(result, temp, temp2, MAP_TYPE); | 2211 CompareObjectType(result, temp, temp2, MAP_TYPE); |
| 2212 b(ne, &done); | 2212 b(ne, &done); |
| 2213 ldr(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); | 2213 ldr(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset)); |
| 2214 b(&loop); | 2214 b(&loop); |
| 2215 bind(&done); | 2215 bind(&done); |
| 2216 } | 2216 } |
| 2217 | 2217 |
| 2218 | 2218 |
| 2219 void MacroAssembler::TryGetFunctionPrototype(Register function, | 2219 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result, |
| 2220 Register result, | 2220 Register scratch, Label* miss) { |
| 2221 Register scratch, | |
| 2222 Label* miss, | |
| 2223 bool miss_on_bound_function) { | |
| 2224 Label non_instance; | |
| 2225 if (miss_on_bound_function) { | |
| 2226 // Check that the receiver isn't a smi. | |
| 2227 JumpIfSmi(function, miss); | |
| 2228 | |
| 2229 // Check that the function really is a function. Load map into result reg. | |
| 2230 CompareObjectType(function, result, scratch, JS_FUNCTION_TYPE); | |
| 2231 b(ne, miss); | |
| 2232 | |
| 2233 ldr(scratch, | |
| 2234 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); | |
| 2235 ldr(scratch, | |
| 2236 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); | |
| 2237 tst(scratch, | |
| 2238 Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction))); | |
| 2239 b(ne, miss); | |
| 2240 | |
| 2241 // Make sure that the function has an instance prototype. | |
| 2242 ldrb(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); | |
| 2243 tst(scratch, Operand(1 << Map::kHasNonInstancePrototype)); | |
| 2244 b(ne, &non_instance); | |
| 2245 } | |
| 2246 | |
| 2247 // Get the prototype or initial map from the function. | 2221 // Get the prototype or initial map from the function. |
| 2248 ldr(result, | 2222 ldr(result, |
| 2249 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 2223 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
| 2250 | 2224 |
| 2251 // If the prototype or initial map is the hole, don't return it and | 2225 // If the prototype or initial map is the hole, don't return it and |
| 2252 // simply miss the cache instead. This will allow us to allocate a | 2226 // simply miss the cache instead. This will allow us to allocate a |
| 2253 // prototype object on-demand in the runtime system. | 2227 // prototype object on-demand in the runtime system. |
| 2254 LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 2228 LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 2255 cmp(result, ip); | 2229 cmp(result, ip); |
| 2256 b(eq, miss); | 2230 b(eq, miss); |
| 2257 | 2231 |
| 2258 // If the function does not have an initial map, we're done. | 2232 // If the function does not have an initial map, we're done. |
| 2259 Label done; | 2233 Label done; |
| 2260 CompareObjectType(result, scratch, scratch, MAP_TYPE); | 2234 CompareObjectType(result, scratch, scratch, MAP_TYPE); |
| 2261 b(ne, &done); | 2235 b(ne, &done); |
| 2262 | 2236 |
| 2263 // Get the prototype from the initial map. | 2237 // Get the prototype from the initial map. |
| 2264 ldr(result, FieldMemOperand(result, Map::kPrototypeOffset)); | 2238 ldr(result, FieldMemOperand(result, Map::kPrototypeOffset)); |
| 2265 | 2239 |
| 2266 if (miss_on_bound_function) { | |
| 2267 jmp(&done); | |
| 2268 | |
| 2269 // Non-instance prototype: Fetch prototype from constructor field | |
| 2270 // in initial map. | |
| 2271 bind(&non_instance); | |
| 2272 GetMapConstructor(result, result, scratch, ip); | |
| 2273 } | |
| 2274 | |
| 2275 // All done. | 2240 // All done. |
| 2276 bind(&done); | 2241 bind(&done); |
| 2277 } | 2242 } |
| 2278 | 2243 |
| 2279 | 2244 |
| 2280 void MacroAssembler::CallStub(CodeStub* stub, | 2245 void MacroAssembler::CallStub(CodeStub* stub, |
| 2281 TypeFeedbackId ast_id, | 2246 TypeFeedbackId ast_id, |
| 2282 Condition cond) { | 2247 Condition cond) { |
| 2283 DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. | 2248 DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs. |
| 2284 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); | 2249 Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id, cond); |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 int stack_passed_arguments = CalculateStackPassedWords( | 3344 int stack_passed_arguments = CalculateStackPassedWords( |
| 3380 num_reg_arguments, num_double_arguments); | 3345 num_reg_arguments, num_double_arguments); |
| 3381 if (ActivationFrameAlignment() > kPointerSize) { | 3346 if (ActivationFrameAlignment() > kPointerSize) { |
| 3382 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 3347 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
| 3383 } else { | 3348 } else { |
| 3384 add(sp, sp, Operand(stack_passed_arguments * kPointerSize)); | 3349 add(sp, sp, Operand(stack_passed_arguments * kPointerSize)); |
| 3385 } | 3350 } |
| 3386 } | 3351 } |
| 3387 | 3352 |
| 3388 | 3353 |
| 3389 void MacroAssembler::GetRelocatedValueLocation(Register ldr_location, | |
| 3390 Register result, | |
| 3391 Register scratch) { | |
| 3392 Label small_constant_pool_load, load_result; | |
| 3393 ldr(result, MemOperand(ldr_location)); | |
| 3394 | |
| 3395 if (FLAG_enable_embedded_constant_pool) { | |
| 3396 // Check if this is an extended constant pool load. | |
| 3397 and_(scratch, result, Operand(GetConsantPoolLoadMask())); | |
| 3398 teq(scratch, Operand(GetConsantPoolLoadPattern())); | |
| 3399 b(eq, &small_constant_pool_load); | |
| 3400 if (emit_debug_code()) { | |
| 3401 // Check that the instruction sequence is: | |
| 3402 // movw reg, #offset_low | |
| 3403 // movt reg, #offset_high | |
| 3404 // ldr reg, [pp, reg] | |
| 3405 Instr patterns[] = {GetMovWPattern(), GetMovTPattern(), | |
| 3406 GetLdrPpRegOffsetPattern()}; | |
| 3407 for (int i = 0; i < 3; i++) { | |
| 3408 ldr(result, MemOperand(ldr_location, i * kInstrSize)); | |
| 3409 and_(result, result, Operand(patterns[i])); | |
| 3410 cmp(result, Operand(patterns[i])); | |
| 3411 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); | |
| 3412 } | |
| 3413 // Result was clobbered. Restore it. | |
| 3414 ldr(result, MemOperand(ldr_location)); | |
| 3415 } | |
| 3416 | |
| 3417 // Get the offset into the constant pool. First extract movw immediate into | |
| 3418 // result. | |
| 3419 and_(scratch, result, Operand(0xfff)); | |
| 3420 mov(ip, Operand(result, LSR, 4)); | |
| 3421 and_(ip, ip, Operand(0xf000)); | |
| 3422 orr(result, scratch, Operand(ip)); | |
| 3423 // Then extract movt immediate and or into result. | |
| 3424 ldr(scratch, MemOperand(ldr_location, kInstrSize)); | |
| 3425 and_(ip, scratch, Operand(0xf0000)); | |
| 3426 orr(result, result, Operand(ip, LSL, 12)); | |
| 3427 and_(scratch, scratch, Operand(0xfff)); | |
| 3428 orr(result, result, Operand(scratch, LSL, 16)); | |
| 3429 | |
| 3430 b(&load_result); | |
| 3431 } | |
| 3432 | |
| 3433 bind(&small_constant_pool_load); | |
| 3434 if (emit_debug_code()) { | |
| 3435 // Check that the instruction is a ldr reg, [<pc or pp> + offset] . | |
| 3436 and_(result, result, Operand(GetConsantPoolLoadPattern())); | |
| 3437 cmp(result, Operand(GetConsantPoolLoadPattern())); | |
| 3438 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); | |
| 3439 // Result was clobbered. Restore it. | |
| 3440 ldr(result, MemOperand(ldr_location)); | |
| 3441 } | |
| 3442 | |
| 3443 // Get the offset into the constant pool. | |
| 3444 const uint32_t kLdrOffsetMask = (1 << 12) - 1; | |
| 3445 and_(result, result, Operand(kLdrOffsetMask)); | |
| 3446 | |
| 3447 bind(&load_result); | |
| 3448 // Get the address of the constant. | |
| 3449 if (FLAG_enable_embedded_constant_pool) { | |
| 3450 add(result, pp, Operand(result)); | |
| 3451 } else { | |
| 3452 add(result, ldr_location, Operand(result)); | |
| 3453 add(result, result, Operand(Instruction::kPCReadOffset)); | |
| 3454 } | |
| 3455 } | |
| 3456 | |
| 3457 | |
| 3458 void MacroAssembler::CheckPageFlag( | 3354 void MacroAssembler::CheckPageFlag( |
| 3459 Register object, | 3355 Register object, |
| 3460 Register scratch, | 3356 Register scratch, |
| 3461 int mask, | 3357 int mask, |
| 3462 Condition cc, | 3358 Condition cc, |
| 3463 Label* condition_met) { | 3359 Label* condition_met) { |
| 3464 Bfc(scratch, object, 0, kPageSizeBits); | 3360 Bfc(scratch, object, 0, kPageSizeBits); |
| 3465 ldr(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset)); | 3361 ldr(scratch, MemOperand(scratch, MemoryChunk::kFlagsOffset)); |
| 3466 tst(scratch, Operand(mask)); | 3362 tst(scratch, Operand(mask)); |
| 3467 b(cc, condition_met); | 3363 b(cc, condition_met); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3911 } | 3807 } |
| 3912 } | 3808 } |
| 3913 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 3809 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
| 3914 add(result, result, Operand(dividend, LSR, 31)); | 3810 add(result, result, Operand(dividend, LSR, 31)); |
| 3915 } | 3811 } |
| 3916 | 3812 |
| 3917 } // namespace internal | 3813 } // namespace internal |
| 3918 } // namespace v8 | 3814 } // namespace v8 |
| 3919 | 3815 |
| 3920 #endif // V8_TARGET_ARCH_ARM | 3816 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |