Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: runtime/vm/assembler_ia32.h

Issue 48743002: Do not directly load smi constants larger than a 16 bit payload on ia32. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_arm.h ('k') | runtime/vm/assembler_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ASSEMBLER_IA32_H_ 5 #ifndef VM_ASSEMBLER_IA32_H_
6 #define VM_ASSEMBLER_IA32_H_ 6 #define VM_ASSEMBLER_IA32_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_ia32.h directly; use assembler.h instead. 9 #error Do not include assembler_ia32.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 #endif 304 #endif
305 }; 305 };
306 306
307 307
308 class Assembler : public ValueObject { 308 class Assembler : public ValueObject {
309 public: 309 public:
310 explicit Assembler(bool use_far_branches = false) 310 explicit Assembler(bool use_far_branches = false)
311 : buffer_(), 311 : buffer_(),
312 object_pool_(GrowableObjectArray::Handle()), 312 object_pool_(GrowableObjectArray::Handle()),
313 prologue_offset_(-1), 313 prologue_offset_(-1),
314 comments_() { 314 comments_(),
315 jit_cookie_(1017109444) {
315 // This mode is only needed and implemented for MIPS and ARM. 316 // This mode is only needed and implemented for MIPS and ARM.
316 ASSERT(!use_far_branches); 317 ASSERT(!use_far_branches);
317 } 318 }
318 ~Assembler() { } 319 ~Assembler() { }
319 320
320 static const bool kNearJump = true; 321 static const bool kNearJump = true;
321 static const bool kFarJump = false; 322 static const bool kFarJump = false;
322 323
323 /* 324 /*
324 * Emit Machine Instructions. 325 * Emit Machine Instructions.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // Issues a move instruction if 'to' is not the same as 'from'. 630 // Issues a move instruction if 'to' is not the same as 'from'.
630 void MoveRegister(Register to, Register from); 631 void MoveRegister(Register to, Register from);
631 void PopRegister(Register r); 632 void PopRegister(Register r);
632 633
633 void AddImmediate(Register reg, const Immediate& imm); 634 void AddImmediate(Register reg, const Immediate& imm);
634 635
635 void Drop(intptr_t stack_elements); 636 void Drop(intptr_t stack_elements);
636 637
637 void LoadObject(Register dst, const Object& object); 638 void LoadObject(Register dst, const Object& object);
638 639
640 // If 'object' is a Smi, xor it with a per-assembler cookie value to
srdjan 2013/10/28 23:06:49 If 'object' is unsafe Smi.
641 // prevent user-controlled immediates from appearing in the code stream.
642 void LoadObjectSafely(Register dst, const Object& object);
643
639 void PushObject(const Object& object); 644 void PushObject(const Object& object);
640 void CompareObject(Register reg, const Object& object); 645 void CompareObject(Register reg, const Object& object);
641 void LoadDoubleConstant(XmmRegister dst, double value); 646 void LoadDoubleConstant(XmmRegister dst, double value);
642 647
643 void StoreIntoObject(Register object, // Object we are storing into. 648 void StoreIntoObject(Register object, // Object we are storing into.
644 const Address& dest, // Where we are storing into. 649 const Address& dest, // Where we are storing into.
645 Register value, // Value we are storing. 650 Register value, // Value we are storing.
646 bool can_value_be_smi = true); 651 bool can_value_be_smi = true);
647 652
648 void StoreIntoObjectNoBarrier(Register object, 653 void StoreIntoObjectNoBarrier(Register object,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 void Unreachable(const char* message); 780 void Unreachable(const char* message);
776 781
777 static void InitializeMemoryWithBreakpoints(uword data, intptr_t length); 782 static void InitializeMemoryWithBreakpoints(uword data, intptr_t length);
778 783
779 void Comment(const char* format, ...) PRINTF_ATTRIBUTE(2, 3); 784 void Comment(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
780 const Code::Comments& GetCodeComments() const; 785 const Code::Comments& GetCodeComments() const;
781 786
782 static const char* RegisterName(Register reg); 787 static const char* RegisterName(Register reg);
783 static const char* FpuRegisterName(FpuRegister reg); 788 static const char* FpuRegisterName(FpuRegister reg);
784 789
790 // Smis that do not fit into 17 bits (16 bits of payload) are unsafe.
791 static bool IsSafe(const Object& object) {
792 return !object.IsSmi() ||
793 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw()));
794 }
795 static bool IsSafeSmi(const Object& object) {
796 return object.IsSmi() &&
797 Utils::IsInt(17, reinterpret_cast<intptr_t>(object.raw()));
798 }
799
785 private: 800 private:
786 AssemblerBuffer buffer_; 801 AssemblerBuffer buffer_;
787 GrowableObjectArray& object_pool_; // Object pool is not used on ia32. 802 GrowableObjectArray& object_pool_; // Object pool is not used on ia32.
788 intptr_t prologue_offset_; 803 intptr_t prologue_offset_;
789 804
790 class CodeComment : public ZoneAllocated { 805 class CodeComment : public ZoneAllocated {
791 public: 806 public:
792 CodeComment(intptr_t pc_offset, const String& comment) 807 CodeComment(intptr_t pc_offset, const String& comment)
793 : pc_offset_(pc_offset), comment_(comment) { } 808 : pc_offset_(pc_offset), comment_(comment) { }
794 809
795 intptr_t pc_offset() const { return pc_offset_; } 810 intptr_t pc_offset() const { return pc_offset_; }
796 const String& comment() const { return comment_; } 811 const String& comment() const { return comment_; }
797 812
798 private: 813 private:
799 intptr_t pc_offset_; 814 intptr_t pc_offset_;
800 const String& comment_; 815 const String& comment_;
801 816
802 DISALLOW_COPY_AND_ASSIGN(CodeComment); 817 DISALLOW_COPY_AND_ASSIGN(CodeComment);
803 }; 818 };
804 819
805 GrowableArray<CodeComment*> comments_; 820 GrowableArray<CodeComment*> comments_;
806 821
822 int32_t jit_cookie_;
823
807 inline void EmitUint8(uint8_t value); 824 inline void EmitUint8(uint8_t value);
808 inline void EmitInt32(int32_t value); 825 inline void EmitInt32(int32_t value);
809 inline void EmitRegisterOperand(int rm, int reg); 826 inline void EmitRegisterOperand(int rm, int reg);
810 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); 827 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg);
811 inline void EmitFixup(AssemblerFixup* fixup); 828 inline void EmitFixup(AssemblerFixup* fixup);
812 inline void EmitOperandSizeOverride(); 829 inline void EmitOperandSizeOverride();
813 830
814 void EmitOperand(int rm, const Operand& operand); 831 void EmitOperand(int rm, const Operand& operand);
815 void EmitImmediate(const Immediate& imm); 832 void EmitImmediate(const Immediate& imm);
816 void EmitComplex(int rm, const Operand& operand, const Immediate& immediate); 833 void EmitComplex(int rm, const Operand& operand, const Immediate& immediate);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 } 876 }
860 877
861 878
862 inline void Assembler::EmitOperandSizeOverride() { 879 inline void Assembler::EmitOperandSizeOverride() {
863 EmitUint8(0x66); 880 EmitUint8(0x66);
864 } 881 }
865 882
866 } // namespace dart 883 } // namespace dart
867 884
868 #endif // VM_ASSEMBLER_IA32_H_ 885 #endif // VM_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm.h ('k') | runtime/vm/assembler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698