| 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 3438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 bind(&loop); | 3449 bind(&loop); |
| 3450 JumpIfSmi(result, &done); | 3450 JumpIfSmi(result, &done); |
| 3451 CmpObjectType(result, MAP_TYPE, temp); | 3451 CmpObjectType(result, MAP_TYPE, temp); |
| 3452 j(not_equal, &done); | 3452 j(not_equal, &done); |
| 3453 movp(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset)); | 3453 movp(result, FieldOperand(result, Map::kConstructorOrBackPointerOffset)); |
| 3454 jmp(&loop); | 3454 jmp(&loop); |
| 3455 bind(&done); | 3455 bind(&done); |
| 3456 } | 3456 } |
| 3457 | 3457 |
| 3458 | 3458 |
| 3459 void MacroAssembler::TryGetFunctionPrototype(Register function, | 3459 void MacroAssembler::TryGetFunctionPrototype(Register function, Register result, |
| 3460 Register result, | 3460 Label* miss) { |
| 3461 Label* miss, | |
| 3462 bool miss_on_bound_function) { | |
| 3463 Label non_instance; | |
| 3464 if (miss_on_bound_function) { | |
| 3465 // Check that the receiver isn't a smi. | |
| 3466 testl(function, Immediate(kSmiTagMask)); | |
| 3467 j(zero, miss); | |
| 3468 | |
| 3469 // Check that the function really is a function. | |
| 3470 CmpObjectType(function, JS_FUNCTION_TYPE, result); | |
| 3471 j(not_equal, miss); | |
| 3472 | |
| 3473 movp(kScratchRegister, | |
| 3474 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | |
| 3475 // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte | |
| 3476 // field). | |
| 3477 TestBitSharedFunctionInfoSpecialField(kScratchRegister, | |
| 3478 SharedFunctionInfo::kCompilerHintsOffset, | |
| 3479 SharedFunctionInfo::kBoundFunction); | |
| 3480 j(not_zero, miss); | |
| 3481 | |
| 3482 // Make sure that the function has an instance prototype. | |
| 3483 testb(FieldOperand(result, Map::kBitFieldOffset), | |
| 3484 Immediate(1 << Map::kHasNonInstancePrototype)); | |
| 3485 j(not_zero, &non_instance, Label::kNear); | |
| 3486 } | |
| 3487 | |
| 3488 // Get the prototype or initial map from the function. | 3461 // Get the prototype or initial map from the function. |
| 3489 movp(result, | 3462 movp(result, |
| 3490 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 3463 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
| 3491 | 3464 |
| 3492 // If the prototype or initial map is the hole, don't return it and | 3465 // If the prototype or initial map is the hole, don't return it and |
| 3493 // simply miss the cache instead. This will allow us to allocate a | 3466 // simply miss the cache instead. This will allow us to allocate a |
| 3494 // prototype object on-demand in the runtime system. | 3467 // prototype object on-demand in the runtime system. |
| 3495 CompareRoot(result, Heap::kTheHoleValueRootIndex); | 3468 CompareRoot(result, Heap::kTheHoleValueRootIndex); |
| 3496 j(equal, miss); | 3469 j(equal, miss); |
| 3497 | 3470 |
| 3498 // If the function does not have an initial map, we're done. | 3471 // If the function does not have an initial map, we're done. |
| 3499 Label done; | 3472 Label done; |
| 3500 CmpObjectType(result, MAP_TYPE, kScratchRegister); | 3473 CmpObjectType(result, MAP_TYPE, kScratchRegister); |
| 3501 j(not_equal, &done, Label::kNear); | 3474 j(not_equal, &done, Label::kNear); |
| 3502 | 3475 |
| 3503 // Get the prototype from the initial map. | 3476 // Get the prototype from the initial map. |
| 3504 movp(result, FieldOperand(result, Map::kPrototypeOffset)); | 3477 movp(result, FieldOperand(result, Map::kPrototypeOffset)); |
| 3505 | 3478 |
| 3506 if (miss_on_bound_function) { | |
| 3507 jmp(&done, Label::kNear); | |
| 3508 | |
| 3509 // Non-instance prototype: Fetch prototype from constructor field | |
| 3510 // in initial map. | |
| 3511 bind(&non_instance); | |
| 3512 GetMapConstructor(result, result, kScratchRegister); | |
| 3513 } | |
| 3514 | |
| 3515 // All done. | 3479 // All done. |
| 3516 bind(&done); | 3480 bind(&done); |
| 3517 } | 3481 } |
| 3518 | 3482 |
| 3519 | 3483 |
| 3520 void MacroAssembler::SetCounter(StatsCounter* counter, int value) { | 3484 void MacroAssembler::SetCounter(StatsCounter* counter, int value) { |
| 3521 if (FLAG_native_code_counters && counter->Enabled()) { | 3485 if (FLAG_native_code_counters && counter->Enabled()) { |
| 3522 Operand counter_operand = ExternalOperand(ExternalReference(counter)); | 3486 Operand counter_operand = ExternalOperand(ExternalReference(counter)); |
| 3523 movl(counter_operand, Immediate(value)); | 3487 movl(counter_operand, Immediate(value)); |
| 3524 } | 3488 } |
| (...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5084 movl(rax, dividend); | 5048 movl(rax, dividend); |
| 5085 shrl(rax, Immediate(31)); | 5049 shrl(rax, Immediate(31)); |
| 5086 addl(rdx, rax); | 5050 addl(rdx, rax); |
| 5087 } | 5051 } |
| 5088 | 5052 |
| 5089 | 5053 |
| 5090 } // namespace internal | 5054 } // namespace internal |
| 5091 } // namespace v8 | 5055 } // namespace v8 |
| 5092 | 5056 |
| 5093 #endif // V8_TARGET_ARCH_X64 | 5057 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |