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 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 5 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
6 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 6 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/frames.h" | 10 #include "src/frames.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 void CmpObject(Register reg, Handle<Object> object) { | 297 void CmpObject(Register reg, Handle<Object> object) { |
298 AllowDeferredHandleDereference heap_object_check; | 298 AllowDeferredHandleDereference heap_object_check; |
299 if (object->IsHeapObject()) { | 299 if (object->IsHeapObject()) { |
300 CmpHeapObject(reg, Handle<HeapObject>::cast(object)); | 300 CmpHeapObject(reg, Handle<HeapObject>::cast(object)); |
301 } else { | 301 } else { |
302 cmp(reg, Immediate(object)); | 302 cmp(reg, Immediate(object)); |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 // Compare the given value and the value of weak cell. | |
307 void CmpWeakValue(Register value, Handle<WeakCell> cell, Register scratch); | |
308 | |
309 void GetWeakValue(Register value, Handle<WeakCell> cell); | 306 void GetWeakValue(Register value, Handle<WeakCell> cell); |
310 | 307 |
311 // Load the value of the weak cell in the value register. Branch to the given | 308 // Load the value of the weak cell in the value register. Branch to the given |
312 // miss label if the weak cell was cleared. | 309 // miss label if the weak cell was cleared. |
313 void LoadWeakValue(Register value, Handle<WeakCell> cell, Label* miss); | 310 void LoadWeakValue(Register value, Handle<WeakCell> cell, Label* miss); |
314 | 311 |
315 // --------------------------------------------------------------------------- | 312 // --------------------------------------------------------------------------- |
316 // JavaScript invokes | 313 // JavaScript invokes |
317 | 314 |
318 // Removes current frame and its arguments from the stack preserving | 315 // Removes current frame and its arguments from the stack preserving |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Compare an object's map with the specified map. | 384 // Compare an object's map with the specified map. |
388 void CompareMap(Register obj, Handle<Map> map); | 385 void CompareMap(Register obj, Handle<Map> map); |
389 | 386 |
390 // Check if the map of an object is equal to a specified map and branch to | 387 // Check if the map of an object is equal to a specified map and branch to |
391 // label if not. Skip the smi check if not required (object is known to be a | 388 // label if not. Skip the smi check if not required (object is known to be a |
392 // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match | 389 // heap object). If mode is ALLOW_ELEMENT_TRANSITION_MAPS, then also match |
393 // against maps that are ElementsKind transition maps of the specified map. | 390 // against maps that are ElementsKind transition maps of the specified map. |
394 void CheckMap(Register obj, Handle<Map> map, Label* fail, | 391 void CheckMap(Register obj, Handle<Map> map, Label* fail, |
395 SmiCheckType smi_check_type); | 392 SmiCheckType smi_check_type); |
396 | 393 |
397 // Check if the map of an object is equal to a specified weak map and branch | |
398 // to a specified target if equal. Skip the smi check if not required | |
399 // (object is known to be a heap object) | |
400 void DispatchWeakMap(Register obj, Register scratch1, Register scratch2, | |
401 Handle<WeakCell> cell, Handle<Code> success, | |
402 SmiCheckType smi_check_type); | |
403 | |
404 // Check if the object in register heap_object is a string. Afterwards the | 394 // Check if the object in register heap_object is a string. Afterwards the |
405 // register map contains the object map and the register instance_type | 395 // register map contains the object map and the register instance_type |
406 // contains the instance_type. The registers map and instance_type can be the | 396 // contains the instance_type. The registers map and instance_type can be the |
407 // same in which case it contains the instance type afterwards. Either of the | 397 // same in which case it contains the instance type afterwards. Either of the |
408 // registers map and instance_type can be the same as heap_object. | 398 // registers map and instance_type can be the same as heap_object. |
409 Condition IsObjectStringType(Register heap_object, Register map, | 399 Condition IsObjectStringType(Register heap_object, Register map, |
410 Register instance_type); | 400 Register instance_type); |
411 | 401 |
412 // Check if the object in register heap_object is a name. Afterwards the | |
413 // register map contains the object map and the register instance_type | |
414 // contains the instance_type. The registers map and instance_type can be the | |
415 // same in which case it contains the instance type afterwards. Either of the | |
416 // registers map and instance_type can be the same as heap_object. | |
417 Condition IsObjectNameType(Register heap_object, Register map, | |
418 Register instance_type); | |
419 | |
420 // FCmp is similar to integer cmp, but requires unsigned | 402 // FCmp is similar to integer cmp, but requires unsigned |
421 // jcc instructions (je, ja, jae, jb, jbe, je, and jz). | 403 // jcc instructions (je, ja, jae, jb, jbe, je, and jz). |
422 void FCmp(); | 404 void FCmp(); |
423 | 405 |
424 void ClampUint8(Register reg); | 406 void ClampUint8(Register reg); |
425 | 407 |
426 void ClampDoubleToUint8(XMMRegister input_reg, XMMRegister scratch_reg, | 408 void ClampDoubleToUint8(XMMRegister input_reg, XMMRegister scratch_reg, |
427 Register result_reg); | 409 Register result_reg); |
428 | 410 |
429 void SlowTruncateToI(Register result_reg, Register input_reg, | 411 void SlowTruncateToI(Register result_reg, Register input_reg, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 if (shift < kSmiTagSize) { | 508 if (shift < kSmiTagSize) { |
527 shl(reg, kSmiTagSize - shift); | 509 shl(reg, kSmiTagSize - shift); |
528 } else if (shift > kSmiTagSize) { | 510 } else if (shift > kSmiTagSize) { |
529 sar(reg, shift - kSmiTagSize); | 511 sar(reg, shift - kSmiTagSize); |
530 } | 512 } |
531 and_(reg, Immediate(mask)); | 513 and_(reg, Immediate(mask)); |
532 } | 514 } |
533 | 515 |
534 void LoadPowerOf2(XMMRegister dst, Register scratch, int power); | 516 void LoadPowerOf2(XMMRegister dst, Register scratch, int power); |
535 | 517 |
536 // Abort execution if argument is not a number, enabled via --debug-code. | |
537 void AssertNumber(Register object); | |
538 void AssertNotNumber(Register object); | |
539 | |
540 // Abort execution if argument is not a smi, enabled via --debug-code. | 518 // Abort execution if argument is not a smi, enabled via --debug-code. |
541 void AssertSmi(Register object); | 519 void AssertSmi(Register object); |
542 | 520 |
543 // Abort execution if argument is a smi, enabled via --debug-code. | 521 // Abort execution if argument is a smi, enabled via --debug-code. |
544 void AssertNotSmi(Register object); | 522 void AssertNotSmi(Register object); |
545 | 523 |
546 // Abort execution if argument is not a string, enabled via --debug-code. | |
547 void AssertString(Register object); | |
548 | |
549 // Abort execution if argument is not a name, enabled via --debug-code. | |
550 void AssertName(Register object); | |
551 | |
552 // Abort execution if argument is not a JSFunction, enabled via --debug-code. | 524 // Abort execution if argument is not a JSFunction, enabled via --debug-code. |
553 void AssertFunction(Register object); | 525 void AssertFunction(Register object); |
554 | 526 |
555 // Abort execution if argument is not a JSBoundFunction, | 527 // Abort execution if argument is not a JSBoundFunction, |
556 // enabled via --debug-code. | 528 // enabled via --debug-code. |
557 void AssertBoundFunction(Register object); | 529 void AssertBoundFunction(Register object); |
558 | 530 |
559 // Abort execution if argument is not a JSGeneratorObject, | 531 // Abort execution if argument is not a JSGeneratorObject, |
560 // enabled via --debug-code. | 532 // enabled via --debug-code. |
561 void AssertGeneratorObject(Register object); | 533 void AssertGeneratorObject(Register object); |
562 | 534 |
563 // Abort execution if argument is not a JSReceiver, enabled via --debug-code. | |
564 void AssertReceiver(Register object); | |
565 | |
566 // Abort execution if argument is not undefined or an AllocationSite, enabled | 535 // Abort execution if argument is not undefined or an AllocationSite, enabled |
567 // via --debug-code. | 536 // via --debug-code. |
568 void AssertUndefinedOrAllocationSite(Register object); | 537 void AssertUndefinedOrAllocationSite(Register object); |
569 | 538 |
570 // --------------------------------------------------------------------------- | 539 // --------------------------------------------------------------------------- |
571 // Exception handling | 540 // Exception handling |
572 | 541 |
573 // Push a new stack handler and link it into stack handler chain. | 542 // Push a new stack handler and link it into stack handler chain. |
574 void PushStackHandler(); | 543 void PushStackHandler(); |
575 | 544 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // the end the loop, |current_address| takes the value of |end_address|. | 599 // the end the loop, |current_address| takes the value of |end_address|. |
631 void InitializeFieldsWithFiller(Register current_address, | 600 void InitializeFieldsWithFiller(Register current_address, |
632 Register end_address, Register filler); | 601 Register end_address, Register filler); |
633 | 602 |
634 // --------------------------------------------------------------------------- | 603 // --------------------------------------------------------------------------- |
635 // Support functions. | 604 // Support functions. |
636 | 605 |
637 // Check a boolean-bit of a Smi field. | 606 // Check a boolean-bit of a Smi field. |
638 void BooleanBitTest(Register object, int field_offset, int bit_index); | 607 void BooleanBitTest(Register object, int field_offset, int bit_index); |
639 | 608 |
640 // Check if result is zero and op is negative. | |
641 void NegativeZeroTest(Register result, Register op, Label* then_label); | |
642 | |
643 // Check if result is zero and any of op1 and op2 are negative. | |
644 // Register scratch is destroyed, and it must be different from op2. | |
645 void NegativeZeroTest(Register result, Register op1, Register op2, | |
646 Register scratch, Label* then_label); | |
647 | |
648 // --------------------------------------------------------------------------- | 609 // --------------------------------------------------------------------------- |
649 // Runtime calls | 610 // Runtime calls |
650 | 611 |
651 // Call a code stub. Generate the code if necessary. | 612 // Call a code stub. Generate the code if necessary. |
652 void CallStub(CodeStub* stub, TypeFeedbackId ast_id = TypeFeedbackId::None()); | 613 void CallStub(CodeStub* stub, TypeFeedbackId ast_id = TypeFeedbackId::None()); |
653 | 614 |
654 // Tail call a code stub (jump). Generate the code if necessary. | 615 // Tail call a code stub (jump). Generate the code if necessary. |
655 void TailCallStub(CodeStub* stub); | 616 void TailCallStub(CodeStub* stub); |
656 | 617 |
657 // Return from a code stub after popping its arguments. | |
658 void StubReturn(int argc); | |
659 | |
660 // Call a runtime routine. | 618 // Call a runtime routine. |
661 void CallRuntime(const Runtime::Function* f, int num_arguments, | 619 void CallRuntime(const Runtime::Function* f, int num_arguments, |
662 SaveFPRegsMode save_doubles = kDontSaveFPRegs); | 620 SaveFPRegsMode save_doubles = kDontSaveFPRegs); |
663 void CallRuntimeSaveDoubles(Runtime::FunctionId fid) { | 621 void CallRuntimeSaveDoubles(Runtime::FunctionId fid) { |
664 const Runtime::Function* function = Runtime::FunctionForId(fid); | 622 const Runtime::Function* function = Runtime::FunctionForId(fid); |
665 CallRuntime(function, function->nargs, kSaveFPRegs); | 623 CallRuntime(function, function->nargs, kSaveFPRegs); |
666 } | 624 } |
667 | 625 |
668 // Convenience function: Same as above, but takes the fid instead. | 626 // Convenience function: Same as above, but takes the fid instead. |
669 void CallRuntime(Runtime::FunctionId fid, | 627 void CallRuntime(Runtime::FunctionId fid, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 void IncrementCounter(Condition cc, StatsCounter* counter, int value); | 764 void IncrementCounter(Condition cc, StatsCounter* counter, int value); |
807 void DecrementCounter(Condition cc, StatsCounter* counter, int value); | 765 void DecrementCounter(Condition cc, StatsCounter* counter, int value); |
808 | 766 |
809 // --------------------------------------------------------------------------- | 767 // --------------------------------------------------------------------------- |
810 // Debugging | 768 // Debugging |
811 | 769 |
812 // Calls Abort(msg) if the condition cc is not satisfied. | 770 // Calls Abort(msg) if the condition cc is not satisfied. |
813 // Use --debug_code to enable. | 771 // Use --debug_code to enable. |
814 void Assert(Condition cc, BailoutReason reason); | 772 void Assert(Condition cc, BailoutReason reason); |
815 | 773 |
816 void AssertFastElements(Register elements); | |
817 | |
818 // Like Assert(), but always enabled. | 774 // Like Assert(), but always enabled. |
819 void Check(Condition cc, BailoutReason reason); | 775 void Check(Condition cc, BailoutReason reason); |
820 | 776 |
821 // Print a message to stdout and abort execution. | 777 // Print a message to stdout and abort execution. |
822 void Abort(BailoutReason reason); | 778 void Abort(BailoutReason reason); |
823 | 779 |
824 // Check that the stack is aligned. | 780 // Check that the stack is aligned. |
825 void CheckStackAlignment(); | 781 void CheckStackAlignment(); |
826 | 782 |
827 // Verify restrictions about code generated in stubs. | 783 // Verify restrictions about code generated in stubs. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 inline Operand NativeContextOperand() { | 935 inline Operand NativeContextOperand() { |
980 return ContextOperand(esi, Context::NATIVE_CONTEXT_INDEX); | 936 return ContextOperand(esi, Context::NATIVE_CONTEXT_INDEX); |
981 } | 937 } |
982 | 938 |
983 #define ACCESS_MASM(masm) masm-> | 939 #define ACCESS_MASM(masm) masm-> |
984 | 940 |
985 } // namespace internal | 941 } // namespace internal |
986 } // namespace v8 | 942 } // namespace v8 |
987 | 943 |
988 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 944 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
OLD | NEW |